New package's Makefile is not picked up by build system

I created feeds/package/net/openappid/Makefile and want to test build it. I read this wiki page but I must not have something setup correctly. What am I missing?

% make package/net/openappid/download V=s       
make[2]: Entering directory '/scratch/union/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/scratch/union/scripts/config'
make[1]: Entering directory '/scratch/union'
make[1]: *** No rule to make target 'package/net/openappid/download'.  Stop.
make[1]: Leaving directory '/scratch/union'
make: *** [/scratch/union/include/toplevel.mk:231: package/net/openappid/download] Error 2

Seems like a download rule missing/malformed.
Perhaps share the Makefile?

Ah! That is likely... this is WIP and the first time I am writing one from scratch, any advise is appreciated.

#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=openappid
PKG_VERSION:=26425
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME).tar.gz
PKG_SOURCE_URL:=https://www.snort.org/downloads/openappid/26425
PKG_HASH:=8513877ce2264bb22119d911c2cf11f73735c866e2ca0d061c35eef6740d51f9

PKG_MAINTAINER:=
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=COPYING

define Package/openappid
  SUBMENU:=Firewall
  SECTION:=net
  CATEGORY:=Network
  DEPENDS:=+snort3
  TITLE:=Detection language and processing module for Snort
  URL:=http://www.snort.org/
  MENU:=1
endef

define Package/openappid/description
  OpenAppId is an open, application-focused detection language and processing
  module for Snort that enables users to create, share, and implement
  application and service detection.
endef

define Package/openappid/install
	$(INSTALL_DIR) $(1)/usr/lib/openappid/custom/{libs,lua,port}
	$(CP) \
		$(PKG_INSTALL_DIR)/usr/lib/openappid \
		$(1)/odp/
endef

$(eval $(call BuildPackage,openappid))

To me it looks like you are missing
include $(INCLUDE_DIR)/package.mk

which line should be after you have defined the PKG_xxx variables.
That line actually applies your definitions...

2 Likes

I added that but am still getting errors:

Makefile
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=openappid
PKG_VERSION:=26425
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME).tar.gz
PKG_SOURCE_URL:=https://www.snort.org/downloads/openappid/26425
PKG_HASH:=8513877ce2264bb22119d911c2cf11f73735c866e2ca0d061c35eef6740d51f9

PKG_MAINTAINER:=John Audia <thereadgraysky@proton.me>
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=COPYING

include $(INCLUDE_DIR)/package.mk

define Package/openappid
  SUBMENU:=Firewall
  SECTION:=net
  CATEGORY:=Network
  DEPENDS:=+snort3
  TITLE:=Detection language and processing module for Snort
  URL:=http://www.snort.org/
  MENU:=1
endef

define Package/openappid/description
  OpenAppId is an open, application-focused detection language and processing
  module for Snort that enables users to create, share, and implement
  application and service detection.
endef

define Package/openappid/install
        $(INSTALL_DIR) $(1)/usr/lib/openappid/custom/{libs,lua,port}
        $(CP) \
                $(PKG_INSTALL_DIR)/usr/lib/openappid \
                $(1)/odp/
endef

$(eval $(call BuildPackage,openappid))```
% make package/$i/{clean,prepare} V=s QUILT=1
make[2]: Entering directory '/scratch/union/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/scratch/union/scripts/config'
make[1]: Entering directory '/scratch/union'
make[1]: *** No rule to make target 'package/openappid/clean'.  Stop.
make[1]: Leaving directory '/scratch/union'
make: *** [/scratch/union/include/toplevel.mk:231: package/openappid/clean] Error 2

Note that I just copied the Makefile into the dirtree... is that right?

% mkdir feeds/packages/net/openappid
cp /path/to/Makefile ./feeds/packages/net/openappid

Your Makefile looks mainly ok, but possibly you have not run the feeds update and feeds install commands.
You will also have to enable it in .config via menuconfig. Otherwise it fails latest at the compilation install stage.

 2001  cd /Openwrt/e8450/
 2002  ./scripts/feeds update
 2003  ./scripts/feeds install -a
 2004  make menuconfig
 2005  make package/openappid/download V=s
 2006  make package/openappid/clean V=s

"make clean" succeeds:

perus@ub2210:/Openwrt/e8450$ make package/openappid/clean V=s
make[2]: Entering directory '/Openwrt/e8450/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/Openwrt/e8450/scripts/config'
make[1]: Entering directory '/Openwrt/e8450'
make[2]: Entering directory '/Openwrt/e8450/feeds/packages/net/openappid'
rm -rf /Openwrt/e8450/build_dir/target-aarch64_cortex-a53_musl/openappid-26425
rm -f /Openwrt/e8450/staging_dir/target-aarch64_cortex-a53_musl/stamp/.openappid_installed
rm -f /Openwrt/e8450/staging_dir/target-aarch64_cortex-a53_musl/packages/openappid.list
make[2]: Leaving directory '/Openwrt/e8450/feeds/packages/net/openappid'
time: package/feeds/packages/openappid/clean#0.29#0.02#0.33
make[1]: Leaving directory '/Openwrt/e8450'

But the actually download fails, as you have defined the URL directory wrong.

perus@ub2210:/Openwrt/e8450$ make package/openappid/download V=s
Collecting package info: done
make[2]: Entering directory '/Openwrt/e8450/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/Openwrt/e8450/scripts/config'
make[1]: Entering directory '/Openwrt/e8450'
make[2]: Entering directory '/Openwrt/e8450/feeds/packages/net/openappid'
mkdir -p /Openwrt/e8450/dl
SHELL= flock /Openwrt/e8450/tmp/.openappid.tar.gz.flock -c '  	/Openwrt/e8450/scripts/download.pl "/Openwrt/e8450/dl" "openappid.tar.gz" "8513877ce2264bb22119d911c2cf11f73735c866e2ca0d061c35eef6740d51f9" "" "https://www.snort.org/downloads/openappid/26425"    '
+ wget --tries=5 --timeout=20 --output-document=- https://www.snort.org/downloads/openappid/26425/openappid.tar.gz
--2022-12-07 19:34:28--  https://www.snort.org/downloads/openappid/26425/openappid.tar.gz
Resolving www.snort.org (www.snort.org)... 104.18.138.9, 104.18.139.9, 2606:4700::6812:8b09, ...
Connecting to www.snort.org (www.snort.org)|104.18.138.9|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-12-07 19:34:28 ERROR 404: Not Found.

Download failed.

Apparently "https://www.snort.org/downloads/openappid/26425" is not the source download directory but already the downloaded file's whole URL...

1 Like

This works for download (but is crude as there is no versioning in the final filename):

PKG_NAME:=openappid
PKG_VERSION:=26425
PKG_RELEASE:=1

PKG_SOURCE:=snort-openappid.tar.gz
PKG_SOURCE_URL:=https://www.snort.org/downloads/openappid/
PKG_HASH:=8513877ce2264bb22119d911c2cf11f73735c866e2ca0d061c35eef6740d51f9

Download succeeds:

perus@ub2210:/Openwrt/e8450$ make package/openappid/download V=s
Collecting package info: done
make[2]: Entering directory '/Openwrt/e8450/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/Openwrt/e8450/scripts/config'
make[1]: Entering directory '/Openwrt/e8450'
make[2]: Entering directory '/Openwrt/e8450/feeds/packages/net/openappid'
mkdir -p /Openwrt/e8450/dl
SHELL= flock /Openwrt/e8450/tmp/.snort-openappid.tar.gz.flock -c '  	/Openwrt/e8450/scripts/download.pl "/Openwrt/e8450/dl" "snort-openappid.tar.gz" "8513877ce2264bb22119d911c2cf11f73735c866e2ca0d061c35eef6740d51f9" "" "https://www.snort.org/downloads/openappid/"    '
+ wget --tries=5 --timeout=20 --output-document=- https://www.snort.org/downloads/openappid/snort-openappid.tar.gz
--2022-12-07 20:07:41--  https://www.snort.org/downloads/openappid/snort-openappid.tar.gz
Resolving www.snort.org (www.snort.org)... 104.18.138.9, 104.18.139.9, 2606:4700::6812:8b09, ...
Connecting to www.snort.org...
...
Connecting to snort-org-site.s3.amazonaws.com (snort-org-site.s3.amazonaws.com)|52.216.239.19|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 562175 (549K) [binary/octet-stream]
Saving to: 'STDOUT'

     0K .......... .......... .......... .......... ..........  9%  413K 1s
    50K .......... .......... .......... .......... .......... 18%  406K 1s
...
   500K .......... .......... .......... .......... ........  100%  718K=0.6s

2022-12-07 20:07:43 (940 KB/s) - written to stdout [562175/562175]

make[2]: Leaving directory '/Openwrt/e8450/feeds/packages/net/openappid'
time: package/feeds/packages/openappid/download#0.32#0.05#2.04
make[1]: Leaving directory '/Openwrt/e8450'

perus@ub2210:/Openwrt/e8450$ ls -lt ../dl | head -n 3
total 1468328
-rw-r--r-- 1 perus perus    562175 joulu   7 22:07 snort-openappid.tar.gz
-rw-r--r-- 1 perus perus     43740 joulu   6 13:22 firewall4-2022-11-29-700a925f.tar.xz

I didn't try to compile it.

1 Like

Thanks for showing me the steps, @hnyman as well as proposing the right way to get this thing to download. The software doesn't actually need to be compiled, it is literally a $(CP) operation.

Any tips on adjusting this to simply copy target directory? For one, the tarball simply contains opd/ but the build systems wants to start in openappid-26425

You need to override the compile section, so that there is no compilation.

Example

Like this? Still ends in errors:

...
define Build/Configure
  true
endef

define Build/Compile
  true
endef

define Package/openappid/install
  $(INSTALL_DIR) $(1)/usr/lib/openappid/custom/{libs,lua,port}
  $(CP) $(PKG_INSTALL_DIR)/usr/lib/openappid $(1)/odp
endef

$(eval $(call BuildPackage,openappid))
make[2]: Entering directory '/scratch/union/feeds/packages/net/openappid'
Makefile:52: *** missing separator.  Stop.
make[2]: Leaving directory '/scratch/union/feeds/packages/net/openappid'
time: package/feeds/packages/openappid/compile#0.28#0.03#0.30
    ERROR: package/feeds/packages/openappid failed to build.
make[1]: *** [package/Makefile:116: package/feeds/packages/openappid/compile] Error 1
make[1]: Leaving directory '/scratch/union'
make: *** [/scratch/union/include/toplevel.mk:231: package/openappid/compile] Error 2

I think it is due to the tarball simply contains opd/ but the build systems wants to start in openappid-26425

My $(CP) line is bad...

$(CP) $(PKG_INSTALL_DIR)/usr/lib/openappid $(1)/odp

Anyone have an idea to copy a directory from one level back in the build system?

The source tarball makes /odp and places all of its contents there:

% cd /scratch/union/build_dir/target-aarch64_cortex-a72_musl
% ls odp 
libs  lua  port  AUTHORS  LICENSE  README  appMapping.data  appid.conf  version.conf

But the build system is extracting it to /scratch/union/build_dir/target-aarch64_cortex-a72_musl/odp/ not to /scratch/union/build_dir/target-aarch64_cortex-a72_musl/openappid-26425/ ... that directory is just empty:

% ls openappid-26425

The command unpacking the tarball is in include/unpack.mk, so redefine TAR_CMD in Your recipe or try to redefine PKG_BUILD_DIR=$(BUILD_DIR)/odp (this will use directory name without version which is not good).

Thanks @tmn505! I am still unclear how to implement... we want to untar the source to $(1)/usr/lib/openappid/ thus creating $(1)/usr/lib/openappid/odp

Would that go inside the define Package/openappid/install? Can you suggest the syntax to try?

#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=openappid
PKG_VERSION:=26425
PKG_RELEASE:=1

PKG_SOURCE:=snort-$(PKG_NAME).tar.gz
PKG_SOURCE_URL:=https://www.snort.org/downloads/openappid/
PKG_HASH:=8513877ce2264bb22119d911c2cf11f73735c866e2ca0d061c35eef6740d51f9

PKG_MAINTAINER:=John Audia <thereadgraysky@proton.me>
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=COPYING

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/unpack.mk

define Package/openappid
  SUBMENU:=Firewall
  SECTION:=net
  CATEGORY:=Network
  DEPENDS:=+snort3
  TITLE:=Detection language and processing module for Snort
  URL:=http://www.snort.org/
  MENU:=1
endef

define Package/openappid/description
  OpenAppId is an open, application-focused detection language and processing
  module for Snort that enables users to create, share, and implement
  application and service detection.
endef

define Build/Configure
  true
endef

define Build/Compile
  true
endef

define Package/openappid/install
        $(INSTALL_DIR) $(1)/usr/lib/openappid/custom/{libs,lua,port}
        $(TAR_CMD) 
endef

$(eval $(call BuildPackage,openappid))

That's a lot of hand-holding. Anyway, unpack.mk is included by default no need to specify it, also variables must be defined outside rules like define Build/... and others, and lastly, commands inside rules need to be indented with TAB.
For Your recipe You can directly untar downloaded archive inside Package/.../install just disable Build/Prepare rule and Package/openappid/install rule would look like this:

	$(INSTALL_DIR) $(1)/usr/lib/openappid/custom
	$(HOST_TAR) -x -C $(1)/usr/lib/openappid/custom --strip-components=1 -f $(DL_DIR)/$(PKG_SOURCE)
2 Likes

Thanks, that did it.

% tree usr
[  60]  usr
└── [  60]  lib
    └── [  60]  openappid
        └── [ 220]  custom
            ├── [ 482]  AUTHORS
            ├── [ 21K]  LICENSE
            ├── [1.2K]  README
            ├── [124K]  appMapping.data
            ├── [1.1K]  appid.conf
            ├── [  60]  libs
            │   └── [ 11K]  DetectorCommon.lua
            ├── [ 11K]  lua
            │   ├── [4.7K]  client_100Bao.lua
            │   ├── [2.2K]  client_5by5_Radio.lua
...
            │   ├── [ 12K]  ssl_host_group_zappa.lua
            │   └── [3.0K]  ssl_host_group_zztop.lua
            ├── [  40]  port
            └── [  12]  version.conf

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.