X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=lfs%2FConfig;h=3c552f3f07d39c43c83d231cef7470564fe95682;hb=HEAD;hp=1209c1603a876084cc5005d34531c2f6918044b4;hpb=8a448186198418977db1be15d707d7b584285bfb;p=ipfire-2.x.git diff --git a/lfs/Config b/lfs/Config index 1209c1603a..9fabe790c3 100644 --- a/lfs/Config +++ b/lfs/Config @@ -13,7 +13,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2021 IPFire Team # +# Copyright (C) 2007-2023 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -31,8 +31,19 @@ ############################################################################### # Cleanup environment from any variables -unexport BUILD_ARCH BUILD_PLATFORM BUILDTARGET CROSSTARGET TOOLCHAIN TOOLS_DIR +unexport BUILD_ARCH BUILD_PLATFORM BUILDTARGET CROSSTARGET TOOLCHAIN +unexport NAME SNAME VERSION CORE SLOGAN SYSTEM_RELEASE PAKFIRE_TREE CONFIG_ROOT +unexport KVER KVER_SUFFIX +unexport SYSTEM_PROCESSOR SYSTEM_MEMORY +unexport DEFAULT_PARALLELISM +unexport LFS_BASEDIR +unexport BUILD_DIR +unexport IMAGES_DIR +unexport LOG_DIR +unexport PACKAGES_DIR +unexport TOOLS_DIR unexport XZ_OPT +unexport ZSTD_OPT # Basic Variables EMPTY := @@ -58,53 +69,23 @@ PARALLELISM = $(shell echo $$( \ MAKETUNING = -j$(PARALLELISM) -ifeq "$(BUILD_ARCH)" "aarch64" - IS_64BIT = 1 -endif - -ifeq "$(BUILD_ARCH)" "armv7hl" - IS_32BIT = 1 -endif - -ifeq "$(BUILD_ARCH)" "armv6l" - IS_32BIT = 1 -endif - -ifeq "$(BUILD_ARCH)" "x86_64" - IS_64BIT = 1 -endif - -ifeq "$(BUILD_ARCH)" "riscv64" - IS_64BIT = 1 -endif - ifeq "$(TOOLCHAIN)" "1" PREFIX = $(TOOLS_DIR) else PREFIX = /usr endif -# Permit building with 32 bit time_t on 32 bit architectures -ifeq "$(IS_32BIT)" "1" - export TIME_T_32_BIT_OK = yes -endif - TAR_OPTIONS = \ --format=pax \ --acls \ - --xattrs --xattrs-include='*' - -ZSTD_OPTIONS = \ - -T$(PARALLELISM) \ - -19 \ - --long + --xattrs \ + --xattrs-include='*' \ + --sparse # URLs that are common sources of downloads. If you're having trouble with # a site you should change its URL to that of a suitable mirror site. # URL_IPFIRE = https://source.ipfire.org/source-2.x -URL_TOOLCHAIN = https://source.ipfire.org/toolchains -URL_SOURCE = git.ipfire.org:/pub/sources/source-2.x # Don't change this; it will be overridden by other makefiles where necessary. # @@ -123,20 +104,26 @@ DIR_SRC = $(ROOT)/usr/src DIR_DL = $(LFS_BASEDIR)/cache DIR_CHK = $(LFS_BASEDIR)/cache/check DIR_CONF = $(LFS_BASEDIR)/config -DIR_INFO = $(LFS_BASEDIR)/log +DIR_INFO = $(LOG_DIR) DIR_TMP = /tmp DIR_TMP_PAK = $(DIR_TMP)/package-$(PROG) # Add the compiler location and version and specs to the ccache hash CCACHE_COMPILERCHECK += $(shell gcc -dumpspecs 2>/dev/null | md5sum | cut -d ' ' -f1) -# We support EFI on x86_64 and aarch64 +# We support EFI on x86_64 riscv64 and aarch64 ifeq "$(BUILD_ARCH)" "x86_64" EFI = 1 EFI_ARCH = x64 GRUB_ARCH = $(BUILD_ARCH) endif +ifeq "$(BUILD_ARCH)" "riscv64" + EFI = 1 + EFI_ARCH = $(BUILD_ARCH) + GRUB_ARCH = $(BUILD_ARCH) +endif + ifeq "$(BUILD_ARCH)" "aarch64" EFI = 1 EFI_ARCH = aa64 @@ -157,14 +144,14 @@ ifeq "$(BUILD_ARCH)" "aarch64" endif # Rust -RUST_ARCH = $(BUILD_ARCH) - -ifeq "$(BUILD_ARCH)" "armv6l" - RUST_PLATFORM = arm-unknown-linux-gnueabi +ifeq "$(BUILD_ARCH)" "riscv64" + RUST_ARCH = riscv64gc else - RUST_PLATFORM = $(RUST_ARCH)-unknown-linux-gnu + RUST_ARCH = $(BUILD_ARCH) endif +RUST_PLATFORM = $(RUST_ARCH)-unknown-linux-gnu + CARGO_PATH = $(DIR_APP)/.cargo CARGO_REGISTRY = /usr/share/cargo/registry @@ -205,9 +192,15 @@ CARGO = \ --offline CARGO_OPTIONS = \ - $(MAKETUNING) \ -Z avoid-dev-deps +# Cargo dealocks on riscv64 when building on multiple cores at the same time +ifeq "$(BUILD_ARCH)" "riscv64" + CARGO_OPTIONS += -j1 +else + CARGO_OPTIONS += $(MAKETUNING) +endif + define CARGO_PREPARE mkdir -p $(CARGO_PATH) && \ echo "$${CARGO_CONFIG}" > $(CARGO_PATH)/config && \ @@ -244,7 +237,7 @@ endef # Common Macro Definitions ############################################################################### -# For each package we create a list of files that it installed under +# For each package we create a list of files that it installed under # log/ name. Modified files are not identified # define FIND_FILES @@ -261,12 +254,6 @@ define PREBUILD echo "====================================== Installing $(THISAPP) ..." @echo "Install started; saving file list to $(DIR_SRC)/lsalr ..." @if [ ! -f $(DIR_SRC)/lsalr ]; then $(FIND_FILES) > $(DIR_SRC)/lsalr; fi - # Fix installation on partial rebuild, so modules install where they should - # and not everytime on the last compiled kernel - if [ -f $(DIR_SRC)/linux-$(KVER) ]; then \ - cd $(DIR_SRC)/linux-$(KVER) && \ - sed -i -e 's+^EXTRAVERSION.*$$+EXTRAVERSION\ =\ $(word 4,$(subst ., .,$(KVER)))-ipfire$(KCFG)+' Makefile; \ - fi endef else define PREBUILD @@ -284,9 +271,8 @@ define POSTBUILD @rm -rf $(GOPATH) /root/.cargo @$(FIND_FILES) > $(DIR_SRC)/lsalrnew @diff $(DIR_SRC)/lsalr $(DIR_SRC)/lsalrnew | grep '^> ' | sed 's/^> //' > $(TARGET)_diff - @cp -f $(DIR_SRC)/lsalrnew $(DIR_SRC)/lsalr - @rm -f $(DIR_SRC)/lsalrnew - sed -i -e 's+.\/++' $(TARGET)_diff + @mv -f $(DIR_SRC)/lsalrnew $(DIR_SRC)/lsalr + @sed -i -e 's+.\/++' $(TARGET)_diff # compare roofile ( same name as lfs script) with the list of installed files # special cases # - if the corresponding rootfile is not found, touch $(TARGET)_missing_rootfile @@ -295,8 +281,8 @@ define POSTBUILD # ROOTFILE : reference of include/exclude files # $(TARGET)_rootfile : ROOTFILE with KVER replacement # $(TARGET) : log result with {commented|include|added} files - if [ -s "$(TARGET)_diff" ]; then \ - LFS_SCRIPT=$(firstword $(MAKEFILE_LIST))$(KCFG); \ + @if [ -s "$(TARGET)_diff" ]; then \ + LFS_SCRIPT=$(firstword $(MAKEFILE_LIST)); \ echo $(LFS_SCRIPT); \ ROOTFILE=$$(find -L $(DIR_SRC)/config/rootfiles/{common,packages}/{$(BUILD_ARCH),} -maxdepth 1 -type f -name $$LFS_SCRIPT 2>/dev/null | head -1); \ if [ "$$ROOTFILE" = "" ]; then \ @@ -305,13 +291,13 @@ define POSTBUILD echo "error $$LFS_SCRIPT not found in config/rootfiles"; \ fi; \ sed -e "s/BUILDTARGET/$(BUILDTARGET)/g" -e "s/KVER/$(KVER)/g" -e "s/xxxMACHINExxx/$(BUILD_ARCH)/g" $$ROOTFILE > $(TARGET)_rootfile; \ - for line in `cat $(TARGET)_diff`; do \ + while read -r line; do \ if grep -qG "^#$$line$$" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \ elif grep -qG "^$$line$$" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \ else echo "+$$line" >> $(TARGET); \ fi; \ - done; \ - for line in `grep -v "^#" $(TARGET)_rootfile`; do \ + done < $(TARGET)_diff; \ + grep -v "^#" $(TARGET)_rootfile | while read -r line; do \ if ! grep -qG "^$$line$$" $(TARGET)_diff ; then echo "-$$line" >> $(TARGET); \ fi; \ done; \ @@ -337,82 +323,157 @@ endef define LOAD @echo -e "$(MESSAGE)Download: $($(notdir $@))" wget -T 60 -t 1 -nv -U "IPFireSourceGrabber/2.x" $($(notdir $@)) -O $(DIR_TMP)/$(notdir $@) - [ "$($(notdir $@)_MD5)" = `md5sum $(DIR_TMP)/$(notdir $@) | awk '{ print $$1 }'` ] # detect page not found answer + [ "$($(notdir $@)_BLAKE2)" = "$$(b2sum $(DIR_TMP)/$(notdir $@) | awk '{ print $$1 }')" ] # detect page not found answer mv $(DIR_TMP)/$(notdir $@) $(DIR_DL) endef -define MD5 +define B2SUM # error mean file signature don't match the one in lfs script - [ "$($@_MD5)" = `md5sum $(DIR_DL)/$@ | awk '{ print $$1 }'` ] - echo "$@ checksum OK" + [ "$($@_BLAKE2)" = "$$(b2sum $(DIR_DL)/$@ | awk '{ print $$1 }')" ] && echo "$@ checksum OK" endef -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 - # Replace variables in rootfiles - sed -i $(DIR_TMP_PAK)/ROOTFILES \ - -e 's/BUILDTARGET/$(BUILDTARGET)/g' \ - -e 's/KVER/$(KVER)/g' \ - -e 's/xxxMACHINExxx/$(BUILD_ARCH)/g' +# Called to compress a file that will be distributed +__COMPRESS = \ + tar \ + --create \ + --verbose --verbose \ + --use-compress-program="$(3)" \ + $(TAR_OPTIONS) \ + --directory=$(1) \ + --file=$(2) \ + --show-transform \ + --transform="s@^\./@@" \ + . + +COMPRESS_XZ = $(call __COMPRESS,$(1),$(2),xz $(XZ_OPT)) +COMPRESS_ZSTD = $(call __COMPRESS,$(1),$(2),zstd $(ZSTD_OPT)) + +# Command to create a Pakfire package +define CREATE_PACKAGE + # Compress the package + tar \ + --create \ + --format=pax \ + --no-acls \ + --no-xattrs \ + --directory=$(1) \ + --file=$(2) \ + --transform="s@^\./@@" \ + . +endef - # Replace variables in scripts - sed -i $(DIR_TMP_PAK)/install.sh \ - -e 's/xxxKVERxxx/$(KVER)/g' +# Creates the meta file for a Pakfire package +define CREATE_META + # Clear/create the file + : > $(2) + + # Write payload + echo "Name: $(PROG)" >> $(2) + echo "Summary: $(SUMMARY)" >> $(2) + echo "ProgVersion: $(VER)" >> $(2) + echo "Release: $(PAK_VER)" >> $(2) + echo "Size: $(shell stat --format=%s $(1))" >> $(2) + echo "Dependencies: $(DEPS)" >> $(2) + echo "File: $(PROG)-$(VER)-$(PAK_VER).ipfire" >> $(2) + echo "Services: $(SERVICES)" >> $(2) +endef - # Make scripts executable - chmod 754 $(DIR_TMP_PAK)/{{,un}install,update}.sh +# Helper function to make sure that we have all sorts of mountpoints in the images +CREATE_MOUNTPOINTS = mkdir -pv $(1)/dev $(1)/proc $(1)/sys - # Collect all files - rm -rf $(DIR_TMP_PAK)/root && mkdir -p $(DIR_TMP_PAK)/root - tar -c --exclude='#*' --exclude='proc/*' --exclude='dev/pts/*' --exclude='tmp/*' \ - --exclude='__pycache__' \ - -C / --files-from=$(DIR_TMP_PAK)/ROOTFILES | tar -x -C $(DIR_TMP_PAK)/root; \ - exit $${PIPESTATUS[0]} +define PAK + # Bringing the files to their right place + @rm -rf $(ARCHIVE_DIR) && mkdir -p $(ARCHIVE_DIR) $(ARCHIVE_TMP) + + # Install scripts + cd $(DIR_SRC) && if [ -e "src/paks/$(PROG)" ]; then \ + install -v -m 744 src/paks/$(PROG)/{install,uninstall,update}.sh $(ARCHIVE_DIR); \ + else \ + install -v -m 744 src/paks/default/{install,uninstall,update}.sh $(ARCHIVE_DIR); \ + fi + + # Copy all files + $(call COPY_FILES,$(DIR_SRC)/config/rootfiles/packages,$(ARCHIVE_TMP),$(PROG),$(ARCHIVE_DIR)/ROOTFILES) # Compress tarball - cd $(DIR_TMP_PAK)/root && tar cf - * | xz $(XZ_OPT) > $(DIR_TMP_PAK)/files.tar.xz + $(call COMPRESS_XZ,$(ARCHIVE_TMP),$(ARCHIVE_DIR)/files.tar.xz) # Cleanup temporary files - rm -rf $(DIR_TMP_PAK)/root + rm -rf $(ARCHIVE_TMP) - # Remove any commented lines - sed -i $(DIR_TMP_PAK)/ROOTFILES -e "/^#/d" + # Create the package + $(call CREATE_PACKAGE,$(ARCHIVE_DIR),$(PACKAGES_DIR)/$(PACKAGE_FILENAME)) - # Make package - cd $(DIR_TMP_PAK) && tar cf /install/packages/$(PROG)-$(VER)-$(PAK_VER).ipfire * + # Write the meta file + $(call CREATE_META,$(PACKAGES_DIR)/$(PACKAGE_FILENAME),$(PACKAGES_DIR)/$(META_FILENAME)) # Cleanup - rm -rf $(DIR_TMP_PAK) - - # Create meta file - sed \ - -e "s/NAME/$(PROG)/g" \ - -e "s/VER/$(VER)/g" \ - -e "s/RELEASE/$(PAK_VER)/g" \ - -e "s/DEPS/$(DEPS)/g" \ - -e "s/SIZE/$$(stat --format=%s /install/packages/$(PROG)-$(VER)-$(PAK_VER).ipfire)/g" \ - < /usr/src/src/pakfire/meta > /install/packages/meta-$(PROG) + rm -rf $(ARCHIVE_DIR) endef define INSTALL_INITSCRIPT install -m 754 -v $(DIR_SRC)/src/initscripts/packages/$(1) /etc/rc.d/init.d/$(1) endef +define INSTALL_INITSCRIPTS + for initscript in $(1); do \ + $(call INSTALL_INITSCRIPT,$$initscript) || exit 1; \ + done +endef + ifeq "$(BUILD_ARCH)" "$(filter $(BUILD_ARCH),aarch64 riscv64)" define UPDATE_AUTOMAKE for i in $$(find $(DIR_APP) -name config.guess -o -name config.sub); do \ @@ -421,6 +482,3 @@ define UPDATE_AUTOMAKE done endef endif - -test: - $(call INSTALL_INITSCRIPT,hostapd)