-define PAK
- # Bringing the files to their right place.
- @rm -rf $(DIR_TMP_PAK) && mkdir -p $(DIR_TMP_PAK)
- if [ -e "/usr/src/src/paks/$(PROG)" ]; then \
- cp -f /usr/src/src/paks/$(PROG)/{,un}install.sh /usr/src/src/paks/$(PROG)/update.sh \
- $(DIR_TMP_PAK); \
- else \
- cp -f /usr/src/src/paks/default/{,un}install.sh /usr/src/src/paks/default/update.sh \
- $(DIR_TMP_PAK); \
- fi
- for i in $(DIR_SRC)/config/rootfiles/packages/{$(BUILD_ARCH),}/$(PROG); do \
- if [ -e "$${i}" ]; then \
- cp -v $${i} $(DIR_TMP_PAK)/ROOTFILES; \
- break; \
- fi; \
- done
+ARCHIVE_DIR = /tmp/archive
+ARCHIVE_TMP = $(ARCHIVE_DIR)/.tmp
+
+# The filename of the package file
+PACKAGE_FILENAME = $(PROG)-$(VER)-$(PAK_VER).ipfire
+
+# The filename of the meta file
+META_FILENAME = meta-$(PROG)
+
+# Takes one rootfile or a directory and will return a list of all included files
+COLLECT_FILES = \
+ BUILD_ARCH="$(BUILD_ARCH)" \
+ BUILDTARGET="$(BUILDTARGET)" \
+ KVER="$(KVER)" \
+ $(DIR_SRC)/src/scripts/archive.files $(BUILD_ARCH) $(1) $(2) | tee $(3)
+
+# Takes a filelist from standard input and streams a tarball with all files
+__FILES_IN = \
+ tar \
+ --create \
+ $(TAR_OPTIONS) \
+ --directory=/ \
+ --exclude="dev/pts/*" \
+ --exclude="proc/*" \
+ --exclude="tmp/*" \
+ --exclude="__pycache__" \
+ $(if $(1),--exclude-from=$(1)) \
+ --files-from=-
+
+# Takes a tarball and extracts it in the target directory
+__FILES_OUT = \
+ tar \
+ --extract \
+ $(TAR_OPTIONS) \
+ --directory=$(1)
+
+# Copies all files on a rootfile into the given directory
+define COPY_FILES
+ # Copy all files from $(1) to $(2) ($(3))
+ # $4 = rootfile to write out
+ # $5 = exclude
+ $(call COLLECT_FILES,$(1),$(3),$(4)) | \
+ $(call __FILES_IN,$(5)) | \
+ $(call __FILES_OUT,$(2))
+
+ # Strip everything, except a few things
+ $(DIR_SRC)/src/stripper $(2) \
+ --exclude=/lib/firmware \
+ --exclude=/usr/lib/go \
+ --exclude=/usr/lib/vdr \
+ --exclude=/usr/sbin/vdr
+endef