OpenWrt Forum Archive

Topic: Packaging a single file

The content of this topic has been archived on 1 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I want to package a single file, a special startup script that will eventually wind up in /etc/init.d so that when I build an image it will always be included. I don't want to create a tarball of the file or any extra Makefiles. Right now my package Makefile looks like this:

include $(TOPDIR)/rules.mk

PKG_NAME:=dummy
PKG_VERSION:=2
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define Package/dummy/install
    $(INSTALL_DIR) $(1)/etc/init.d
    $(INSTALL_BIN) ./files/dummy $(1)/etc/init.d/
endef

$(eval $(call BuildPackage,dummy))

Trying to build this either by itself "make package/dummy/install"  or linked in to the packages along with a full build fails. I get am getting

ERROR: please fix package/dummy/Makefile

This is caused by the last line calling BuildPackage.

I'm aware of the wiki package page:

http://wiki.openwrt.org/doc/howto/creatingpackages

but it doesn't help in this case. I can't find any example packages either. They all have some sort of tarball associated with them that gets downloaded.

Is there any way to create a package without doing a build and only including files?

Gus

I had to add the following sections to a similar package of mine:


define Build/Compile
endef

define Build/Configure
endef


One question - are you building your own firmware?  If so there's a simple way to include files without making a package.  You only need to build a package if you want to install the file on an existing system.

That doesn't work. I still get the same error.

I am building my own firmware. How do I go about adding extra files easily?

This is a Makefile format that works here :

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=zzz-dummy
PKG_RELEASE:=2
PKG_VERSION:=1

include $(INCLUDE_DIR)/package.mk

define Package/zzz-dummy
  SECTION:=net
  CATEGORY:=Base system
  TITLE:=Custom Startup Script
# DEPENDS:=@LINUX_2_6 +ip +ntpclient +tc +hostapd-utils +iw +wpa-supplicant
endef

define Package/zzz-dummy/description
The description of what your single package does
endef

define Build/Compile
    rm -rf $(PKG_INSTALL_DIR)
    mkdir -p $(PKG_INSTALL_DIR)
endef

define Package/zzz-dummy/install
    $(INSTALL_DIR) $(1)/etc/init.d
    $(INSTALL_BIN) ./files/dummy $(1)/etc/init.d
endef

$(eval $(call BuildPackage,zzz-dummy))

That's great! Both methods work. One caveat for anyone doing a cut and paste is that the lines in the Build/Compile and the Package/zzz-dummy/install section need to start with TABS and not spaces because these eventually wind up as Makefile commands.

This looks like it should be moved to  the HOWTO section.

The discussion might have continued from here.