From b600f16806d94f8d9ef7597dca58213b85e7c510 Mon Sep 17 00:00:00 2001 From: chainsx Date: Sun, 24 Sep 2023 13:09:02 +0800 Subject: [PATCH] fix OPENSBI_USE_GCC unset error. --- lib/compilation.sh | 35 +- lib/configuration.sh | 2 +- lib/general.sh | 2 +- packages/armbian/builddeb | 9 - patch/kernel/thead-current/000-builddeb.patch | 4 +- patch/misc/general-packaging-5.10.y.patch | 367 ++++++++++++++++++ 6 files changed, 376 insertions(+), 43 deletions(-) create mode 100644 patch/misc/general-packaging-5.10.y.patch diff --git a/lib/compilation.sh b/lib/compilation.sh index 58c9438..c2f973a 100644 --- a/lib/compilation.sh +++ b/lib/compilation.sh @@ -16,7 +16,6 @@ # compile_kernel # compile_firmware # compile_armbian-config -# compile_xilinx_bootgen # grab_version # find_toolchain # advanced_patch @@ -163,11 +162,11 @@ compile_uboot() # create patch for manual source changes [[ $CREATE_PATCHES == yes ]] && userpatch_create "u-boot" - if [[ -n $OPENSBISOURCE ]]; then - cp -Rv "${opensbitempdir}"/*.bin . - cp -Rv "${opensbitempdir}"/*.elf . - rm -rf "${opensbitempdir}" - fi + #if [[ -n $OPENSBISOURCE ]]; then + # cp -Rv "${opensbitempdir}"/*.bin . + # cp -Rv "${opensbitempdir}"/*.elf . + # rm -rf "${opensbitempdir}" + #fi echo -e "\n\t== u-boot make $BOOTCONFIG ==\n" >> "${DEST}"/${LOG_SUBPATH}/compilation.log eval CCACHE_BASEDIR="$(pwd)" env PATH="${toolchain}:${toolchain2}:${PATH}" \ @@ -432,9 +431,6 @@ Before any olddefconfig any Kconfig make is called. A good place to customize the .config directly. CUSTOM_KERNEL_CONFIG - # hack for deb builder. To pack what's missing in headers pack. - cp "${SRC}"/patch/misc/headers-debian-byteshift.patch /tmp - if [[ $KERNEL_CONFIGURE != yes ]]; then if [[ $BRANCH == default ]]; then eval CCACHE_BASEDIR="$(pwd)" env PATH="${toolchain}:${PATH}" \ @@ -731,27 +727,6 @@ compile_armbian-config() rm -rf "${tmp_dir}" } -compile_xilinx_bootgen() -{ - # Source code checkout - (fetch_from_repo "$GITHUB_SOURCE/Xilinx/bootgen.git" "xilinx-bootgen" "branch:master") - - pushd "${SRC}"/cache/sources/xilinx-bootgen || exit - - # Compile and install only if git commit hash changed - # need to check if /usr/local/bin/bootgen to detect new Docker containers with old cached sources - if [[ ! -f .commit_id || $(improved_git rev-parse @ 2>/dev/null) != $(<.commit_id) || ! -f /usr/local/bin/bootgen ]]; then - display_alert "Compiling" "xilinx-bootgen" "info" - make -s clean >/dev/null - make -s -j$(nproc) bootgen >/dev/null - mkdir -p /usr/local/bin/ - install bootgen /usr/local/bin >/dev/null 2>&1 - improved_git rev-parse @ 2>/dev/null > .commit_id - fi - - popd -} - grab_version() { local ver=() diff --git a/lib/configuration.sh b/lib/configuration.sh index 4d4c4c9..6b66cd8 100644 --- a/lib/configuration.sh +++ b/lib/configuration.sh @@ -412,7 +412,7 @@ SDCARD="${SRC}/.tmp/rootfs-${MOUNT_UUID}" MOUNT="${SRC}/.tmp/mount-${MOUNT_UUID}" DESTIMG="${SRC}/.tmp/image-${MOUNT_UUID}" -[[ -n $OPENSBISOURCE && -z $ATF_USE_GCC ]] && exit_with_error "Error in configuration: ATF_USE_GCC is unset" +[[ -n $OPENSBISOURCE && -z $OPENSBI_USE_GCC ]] && exit_with_error "Error in configuration: OPENSBI_USE_GCC is unset" [[ -z $UBOOT_USE_GCC ]] && exit_with_error "Error in configuration: UBOOT_USE_GCC is unset" [[ -z $KERNEL_USE_GCC ]] && exit_with_error "Error in configuration: KERNEL_USE_GCC is unset" diff --git a/lib/general.sh b/lib/general.sh index 8eeab90..8cfd1b6 100644 --- a/lib/general.sh +++ b/lib/general.sh @@ -1531,7 +1531,7 @@ prepare_host() display_alert "Checking for external GCC compilers" "" "info" # download external Linaro compiler and missing special dependencies since they are needed for certain sources - local toolchain="https://github.com/chainsx/armbian-d1-build/releases/download/toolchain/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz" + local toolchain="${GITHUB_SOURCE}/chainsx/armbian-d1-build/releases/download/toolchain/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1-20220906.tar.gz" if [[ ! -d ${SRC}/cache/toolchain/gcc-toolchain/ ]]; then wget ${toolchain} -O "${SRC}/cache/toolchain/toolchain.tar.gz" tar -zxf "${SRC}/cache/toolchain/toolchain.tar.gz" -C ${SRC}/cache/toolchain/ diff --git a/packages/armbian/builddeb b/packages/armbian/builddeb index a8efbb4..fd22f1e 100755 --- a/packages/armbian/builddeb +++ b/packages/armbian/builddeb @@ -147,15 +147,6 @@ deploy_kernel_headers() { fi } > debian/hdrobjfiles - if is_native; then - echo "info: Build native: Skip headers-debian-byteshift.patch" >&2 - elif is_build_on_amd64; then - ( - cd $destdir - patch -p1 < /tmp/headers-debian-byteshift.patch - ) - fi - tar -c -f - -C $srctree -T debian/hdrsrcfiles | tar -xf - -C $destdir tar -c -f - -T debian/hdrobjfiles | tar -xf - -C $destdir rm -f debian/hdrsrcfiles debian/hdrobjfiles diff --git a/patch/kernel/thead-current/000-builddeb.patch b/patch/kernel/thead-current/000-builddeb.patch index 2f9d2db..3d8ca50 100644 --- a/patch/kernel/thead-current/000-builddeb.patch +++ b/patch/kernel/thead-current/000-builddeb.patch @@ -1,5 +1,5 @@ ---- builddeb 2023-08-30 23:34:33.515646129 +0800 -+++ builddeb.2 2023-08-30 23:35:59.386906141 +0800 +--- a/scripts/package/builddeb ++++ b/scripts/package/builddeb @@ -126,7 +126,7 @@ installed_image_path="usr/bin/linux-$version" ;; diff --git a/patch/misc/general-packaging-5.10.y.patch b/patch/misc/general-packaging-5.10.y.patch new file mode 100644 index 0000000..67f8d35 --- /dev/null +++ b/patch/misc/general-packaging-5.10.y.patch @@ -0,0 +1,367 @@ +diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile +index 5858d6e44..e81b8a6fc 100644 +--- a/arch/arm64/Makefile ++++ b/arch/arm64/Makefile +@@ -142,7 +142,7 @@ core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a + + # Default target when executing plain make + boot := arch/arm64/boot +-KBUILD_IMAGE := $(boot)/Image.gz ++KBUILD_IMAGE := $(boot)/Image + + all: Image.gz + +diff --git a/scripts/package/builddeb b/scripts/package/builddeb +index 1b11f8993..c21d931ea 100755 +--- a/scripts/package/builddeb ++++ b/scripts/package/builddeb +@@ -26,31 +26,62 @@ + + create_package() { + local pname="$1" pdir="$2" +- local dpkg_deb_opts + + mkdir -m 755 -p "$pdir/DEBIAN" + mkdir -p "$pdir/usr/share/doc/$pname" + cp debian/copyright "$pdir/usr/share/doc/$pname/" + cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian" +- gzip -n -9 "$pdir/usr/share/doc/$pname/changelog.Debian" ++ gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian" + sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ + | xargs -r0 md5sum > DEBIAN/md5sums" + + # Fix ownership and permissions +- if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then +- dpkg_deb_opts="--root-owner-group" +- else +- chown -R root:root "$pdir" +- fi ++ chown -R root:root "$pdir" + chmod -R go-w "$pdir" + # in case we are in a restrictive umask environment like 0077 + chmod -R a+rX "$pdir" +- # in case we build in a setuid/setgid directory +- chmod -R ug-s "$pdir" ++ ++ # Create preinstall and post install script to remove dtb ++ if [ "$3" = "dtb" ]; then ++ ++ cat >> $pdir/DEBIAN/preinst <> $pdir/DEBIAN/postinst < /dev/null || mv dtb-$version dtb ++exit 0 ++EOT ++ ++ chmod 775 $pdir/DEBIAN/preinst ; chmod 775 $pdir/DEBIAN/postinst ++ fi ++ ++ # Create postinst prerm scripts for headers ++ if [ "$3" = "headers" ]; then ++ ++cat >> $pdir/DEBIAN/postinst << EOT ++cd /usr/src/linux-headers-$version ++echo "Compiling headers - please wait ..." ++find -type f -exec touch {} + ++yes "" | make oldconfig >/dev/null ++make -j\$(grep -c 'processor' /proc/cpuinfo) -s scripts >/dev/null ++make -j\$(grep -c 'processor' /proc/cpuinfo) -s M=scripts/mod/ >/dev/null ++exit 0 ++EOT ++ ++cat >> $pdir/DEBIAN/prerm << EOT ++cd /usr/src/linux-headers-$version ++rm -rf scripts .config.old ++EOT ++ ++ chmod 775 $pdir/DEBIAN/postinst ; chmod 775 $pdir/DEBIAN/prerm ++ fi + + # Create the package + dpkg-gencontrol -p$pname -P"$pdir" +- dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. ++ dpkg-deb ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. + } + + deploy_kernel_headers () { +@@ -62,7 +92,7 @@ + cd $srctree + find . arch/$SRCARCH -maxdepth 1 -name Makefile\* + find include scripts -type f -o -type l +- find arch/$SRCARCH -name Kbuild.platforms -o -name Platform ++ find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform + find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f + ) > debian/hdrsrcfiles + +@@ -107,9 +137,15 @@ + } + + version=$KERNELRELEASE +-tmpdir=debian/linux-image +-dbg_dir=debian/linux-image-dbg +-packagename=linux-image-$version ++tmpdir="$objtree/debian/tmp" ++kernel_headers_dir="$objtree/debian/hdrtmp" ++libc_headers_dir="$objtree/debian/headertmp" ++dbg_dir="$objtree/debian/dbgtmp" ++dtb_dir="$objtree/debian/dtbtmp" ++packagename=linux-image-"$BRANCH$LOCALVERSION" ++kernel_headers_packagename=linux-headers-"$BRANCH$LOCALVERSION" ++dtb_packagename=linux-dtb-"$BRANCH$LOCALVERSION" ++libc_headers_packagename=linux-libc-dev-"$BRANCH$LOCALVERSION" + dbg_packagename=$packagename-dbg + + if [ "$ARCH" = "um" ] ; then +@@ -120,6 +156,15 @@ + # XXX: have each arch Makefile export a variable of the canonical image install + # path instead + case $ARCH in ++aarch64|arm64) ++ image_name=Image ++ installed_image_path="boot/vmlinuz-$version" ++ ++ ;; ++arm*) ++ image_name=zImage ++ installed_image_path="boot/vmlinuz-$version" ++ ;; + um) + installed_image_path="usr/bin/linux-$version" + ;; +@@ -133,13 +178,17 @@ + BUILD_DEBUG=$(if_enabled_echo CONFIG_DEBUG_INFO Yes) + + # Setup the directory structure +-rm -rf "$tmpdir" "$dbg_dir" debian/files ++rm -rf "$tmpdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" "$dtb_dir" $objtree/debian/files ++mkdir -m 755 -p "$dtb_dir/DEBIAN" ++mkdir -p "$dtb_dir/boot/dtb-$version" "$dtb_dir/usr/share/doc/$dtb_packagename" + mkdir -m 755 -p "$tmpdir/DEBIAN" + mkdir -p "$tmpdir/lib" "$tmpdir/boot" ++mkdir -p "$kernel_headers_dir/lib/modules/$version/" + +-# Install the kernel ++# Build and install the kernel + if [ "$ARCH" = "um" ] ; then + mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdir/usr/share/doc/$packagename" ++ $MAKE linux + cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" + cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" + gzip "$tmpdir/usr/share/doc/$packagename/config" +@@ -183,6 +232,21 @@ + fi + fi + ++if grep -q '^CONFIG_OF=y' $KCONFIG_CONFIG ; then ++ #mkdir -p "$tmpdir/boot/dtb" ++ INSTALL_DTBS_PATH="$dtb_dir/boot/dtb-$version" $MAKE KBUILD_SRC= dtbs_install ++fi ++ ++if [ "$ARCH" != "um" ]; then ++ $MAKE -f $srctree/Makefile headers ++ $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr" ++ # move asm headers to /usr/include//asm to match the structure ++ # used by Debian-based distros (to support multi-arch) ++ host_arch=$(dpkg-architecture -a$(cat debian/arch) -qDEB_HOST_MULTIARCH) ++ mkdir $libc_headers_dir/usr/include/$host_arch ++ mv $libc_headers_dir/usr/include/asm $libc_headers_dir/usr/include/$host_arch/ ++fi ++ + # Install the maintainer scripts + # Note: hook scripts under /etc/kernel are also executed by official Debian + # kernel packages, as well as kernel packages built using make-kpkg. +@@ -192,7 +256,7 @@ + for script in postinst postrm preinst prerm ; do + mkdir -p "$tmpdir$debhookdir/$script.d" + cat < "$tmpdir/DEBIAN/$script" +-#!/bin/sh ++#!/bin/bash + + set -e + +@@ -208,14 +272,73 @@ + chmod 755 "$tmpdir/DEBIAN/$script" + done + +-if [ "$ARCH" != "um" ]; then +- if is_enabled CONFIG_MODULES; then +- deploy_kernel_headers debian/linux-headers +- create_package linux-headers-$version debian/linux-headers ++## ++## Create sym link to kernel image ++## ++sed -e "s/exit 0//g" -i $tmpdir/DEBIAN/postinst ++cat >> $tmpdir/DEBIAN/postinst < /dev/null || cp /$installed_image_path /boot/$image_name ++touch /boot/.next ++exit 0 ++EOT ++ ++## ++## FAT install workaround ++## ++sed -e "s/exit 0//g" -i $tmpdir/DEBIAN/preinst ++cat >> $tmpdir/DEBIAN/preinst <> $tmpdir/DEBIAN/preinst ++ ++# Build kernel header package ++(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" ++(cd $srctree; find arch/*/include include scripts -type f -o -type l) >> "$objtree/debian/hdrsrcfiles" ++(cd $srctree; find security/*/include -type f) >> "$objtree/debian/hdrsrcfiles" ++(cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" ++(cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" ++ldstemp=$(mktemp);cp scripts/module.lds $ldstemp ++(cd $objtree; make M=scripts clean;) ++if is_enabled CONFIG_STACK_VALIDATION; then ++ (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" ++fi ++(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" ++if is_enabled CONFIG_GCC_PLUGINS; then ++ (cd $objtree; find scripts/gcc-plugins -name \*.so -o -name gcc-common.h) >> "$objtree/debian/hdrobjfiles" ++fi ++destdir=$kernel_headers_dir/usr/src/linux-headers-$version ++mkdir -p "$destdir" ++(cd $destdir; patch -p1 < /tmp/headers-debian-byteshift.patch) ++(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) ++(cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -) ++(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be ++mv ${ldstemp} $destdir/scripts/module.lds ++ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" ++rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" + +- deploy_libc_headers debian/linux-libc-dev +- create_package linux-libc-dev debian/linux-libc-dev ++if [ "$ARCH" != "um" ]; then ++ create_package "$kernel_headers_packagename" "$kernel_headers_dir" "headers" ++ create_package "$dtb_packagename" "$dtb_dir" "dtb" + fi + + create_package "$packagename" "$tmpdir" +diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian +index 60a2a63a5..7c6197efa 100755 +--- a/scripts/package/mkdebian ++++ b/scripts/package/mkdebian +@@ -94,16 +94,18 @@ else + packageversion=$version-$revision + fi + sourcename=$KDEB_SOURCENAME ++packagename=linux-image-$BRANCH$LOCALVERSION ++kernel_headers_packagename=linux-headers-$BRANCH$LOCALVERSION ++dtb_packagename=linux-dtb-$BRANCH$LOCALVERSION ++dbg_packagename=$packagename-dbg ++debarch= ++image_name= ++set_debarch + + if [ "$ARCH" = "um" ] ; then +- packagename=user-mode-linux +-else +- packagename=linux-image ++ packagename=user-mode-linux-$version + fi + +-debarch= +-set_debarch +- + email=${DEBEMAIL-$EMAIL} + + # use email string directly if it contains +@@ -174,16 +176,28 @@ Source: $sourcename + Section: kernel + Priority: optional + Maintainer: $maintainer +-Rules-Requires-Root: no + Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends + Homepage: https://www.kernel.org/ + +-Package: $packagename-$version ++Package: $packagename + Architecture: $debarch + Description: Linux kernel, version $version + This package contains the Linux kernel, modules and corresponding other + files, version: $version. + ++Package: $dtb_packagename ++Architecture: $debarch ++Description: Linux DTB, version $version ++ This package contains device blobs from the Linux kernel, version $version ++ ++Package: $kernel_headers_packagename ++Architecture: $debarch ++Depends: make, gcc, libc6-dev, bison, flex, libssl-dev ++Description: Linux kernel headers for $version on $debarch ++ This package provides kernel header files for $version on $debarch ++ . ++ This is useful for people who need to build external modules ++ + Package: linux-libc-dev + Section: devel + Provides: linux-kernel-headers +@@ -194,22 +208,10 @@ Description: Linux support headers for userspace development + Multi-Arch: same + EOF + +-if is_enabled CONFIG_MODULES; then +-cat <> debian/control +- +-Package: linux-headers-$version +-Architecture: $debarch +-Description: Linux kernel headers for $version on $debarch +- This package provides kernel header files for $version on $debarch +- . +- This is useful for people who need to build external modules +-EOF +-fi +- + if is_enabled CONFIG_DEBUG_INFO; then + cat <> debian/control + +-Package: linux-image-$version-dbg ++Package: $dbg_packagename + Section: debug + Architecture: $debarch + Description: Linux kernel debugging symbols for $version +@@ -223,15 +225,11 @@ cat < debian/rules + + srctree ?= . + +-build-indep: +-build-arch: ++build: + \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ + KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile + +-build: build-arch +- +-binary-indep: +-binary-arch: build-arch ++binary-arch: + \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ + KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg +