diff --git a/lib/chroot-buildpackages.sh b/lib/chroot-buildpackages.sh index 65f161941..413c6614d 100644 --- a/lib/chroot-buildpackages.sh +++ b/lib/chroot-buildpackages.sh @@ -47,36 +47,36 @@ create_chroot() else local mirror_addr="http://${apt_mirror[$release]}" fi - debootstrap --variant=buildd --components=${components[${release}]} --arch="${arch}" --foreign --include="${includes}" "${release}" "${target_dir}" "${mirror_addr}" - [[ $? -ne 0 || ! -f "${target_dir}"/debootstrap/debootstrap ]] && exit_with_error "Create chroot first stage failed" - cp "/usr/bin/${qemu_binary[$arch]}" "${target_dir}"/usr/bin/ - [[ ! -f "${target_dir}"/usr/share/keyrings/debian-archive-keyring.gpg ]] && \ - mkdir -p "${target_dir}"/usr/share/keyrings/ && \ - cp /usr/share/keyrings/debian-archive-keyring.gpg "${target_dir}"/usr/share/keyrings/ - chroot "${target_dir}" /bin/bash -c "/debootstrap/debootstrap --second-stage" - [[ $? -ne 0 || ! -f "${target_dir}"/bin/bash ]] && exit_with_error "Create chroot second stage failed" - create_sources_list "${release}" "${target_dir}" + debootstrap --variant=buildd --components=${components[$release]} --arch=$arch --foreign --include="$includes" $release $target_dir $mirror_addr + [[ $? -ne 0 || ! -f $target_dir/debootstrap/debootstrap ]] && exit_with_error "Create chroot first stage failed" + cp /usr/bin/${qemu_binary[$arch]} $target_dir/usr/bin/ + [[ ! -f $target_dir/usr/share/keyrings/debian-archive-keyring.gpg ]] && \ + mkdir -p $target_dir/usr/share/keyrings/ && \ + cp /usr/share/keyrings/debian-archive-keyring.gpg $target_dir/usr/share/keyrings/ + chroot $target_dir /bin/bash -c "/debootstrap/debootstrap --second-stage" + [[ $? -ne 0 || ! -f $target_dir/bin/bash ]] && exit_with_error "Create chroot second stage failed" + create_sources_list "$release" "$target_dir" [[ $NO_APT_CACHER != yes ]] && \ - echo 'Acquire::http { Proxy "http://localhost:3142"; };' > "${target_dir}"/etc/apt/apt.conf.d/02proxy - cat <<-EOF > "${target_dir}"/etc/apt/apt.conf.d/71-no-recommends + echo 'Acquire::http { Proxy "http://localhost:3142"; };' > $target_dir/etc/apt/apt.conf.d/02proxy + cat <<-EOF > $target_dir/etc/apt/apt.conf.d/71-no-recommends APT::Install-Recommends "0"; APT::Install-Suggests "0"; EOF - [[ -f "${target_dir}"/etc/locale.gen ]] && sed -i "s/^# en_US.UTF-8/en_US.UTF-8/" "${target_dir}"/etc/locale.gen - chroot "${target_dir}" /bin/bash -c "locale-gen; update-locale LANG=en_US:en LC_ALL=en_US.UTF-8" - printf '#!/bin/sh\nexit 101' > "${target_dir}"/usr/sbin/policy-rc.d - chmod 755 "${target_dir}"/usr/sbin/policy-rc.d - rm "${target_dir}"/etc/resolv.conf 2>/dev/null - echo "nameserver $NAMESERVER" > "${target_dir}"/etc/resolv.conf - rm "${target_dir}"/etc/hosts 2>/dev/null - echo "127.0.0.1 localhost" > "${target_dir}"/etc/hosts - mkdir -p "${target_dir}"/root/{build,overlay,sources} "${target_dir}"/selinux - if [[ -L "${target_dir}"/var/lock ]]; then - rm -rf "${target_dir}"/var/lock 2>/dev/null - mkdir -p "${target_dir}"/var/lock + [[ -f $target_dir/etc/locale.gen ]] && sed -i "s/^# en_US.UTF-8/en_US.UTF-8/" $target_dir/etc/locale.gen + chroot $target_dir /bin/bash -c "locale-gen; update-locale LANG=en_US:en LC_ALL=en_US.UTF-8" + printf '#!/bin/sh\nexit 101' > $target_dir/usr/sbin/policy-rc.d + chmod 755 $target_dir/usr/sbin/policy-rc.d + rm $target_dir/etc/resolv.conf 2>/dev/null + echo "nameserver $NAMESERVER" > $target_dir/etc/resolv.conf + rm $target_dir/etc/hosts 2>/dev/null + echo "127.0.0.1 localhost" > $target_dir/etc/hosts + mkdir -p $target_dir/root/{build,overlay,sources} $target_dir/selinux + if [[ -L $target_dir/var/lock ]]; then + rm -rf $target_dir/var/lock 2>/dev/null + mkdir -p $target_dir/var/lock fi - chroot "${target_dir}" /bin/bash -c "/usr/sbin/update-ccache-symlinks" - touch "${target_dir}"/root/.debootstrap-complete + chroot $target_dir /bin/bash -c "/usr/sbin/update-ccache-symlinks" + touch $target_dir/root/.debootstrap-complete display_alert "Debootstrap complete" "$release/$arch" "info" } ############################################################################# @@ -97,20 +97,21 @@ chroot_prepare_distccd() gcc_version['disco']='8.3' gcc_type['armhf']='arm-linux-gnueabihf-' gcc_type['arm64']='aarch64-linux-gnu-' - rm -f "${dest}"/cmdlist - mkdir -p "${dest}" + rm -f $dest/cmdlist + mkdir -p $dest local toolchain_path=$(find_toolchain "${gcc_type[$arch]}" "== ${gcc_version[$release]}") - ln -sf "${toolchain_path}/${gcc_type[$arch]}gcc" "${dest}"/cc - echo "${dest}/cc" >> "${dest}"/cmdlist + ln -sf ${toolchain_path}/${gcc_type[$arch]}gcc $dest/cc + echo "$dest/cc" >> $dest/cmdlist for compiler in gcc cpp g++ c++; do - echo "${dest}/$compiler" >> "${dest}/cmdlist" - echo "${dest}/${gcc_type[$arch]}${compiler}" >> "${dest}/cmdlist" - ln -sf "${toolchain_path}/${gcc_type[$arch]}${compiler}" "${dest}/${compiler}" - ln -sf "${toolchain_path}/${gcc_type[$arch]}${compiler}" "${dest}/${gcc_type[$arch]}${compiler}" + echo "$dest/$compiler" >> $dest/cmdlist + echo "$dest/${gcc_type[$arch]}${compiler}" >> $dest/cmdlist + ln -sf ${toolchain_path}/${gcc_type[$arch]}${compiler} $dest/$compiler + ln -sf ${toolchain_path}/${gcc_type[$arch]}${compiler} $dest/${gcc_type[$arch]}${compiler} done mkdir -p /var/run/distcc/ - touch "/var/run/distcc/${release}-${arch}.pid" - chown -R distccd /var/run/distcc/ /tmp/distcc + touch /var/run/distcc/${release}-${arch}.pid + chown -R distccd /var/run/distcc/ + chown -R distccd /tmp/distcc } # chroot_build_packages @@ -134,33 +135,32 @@ chroot_build_packages() for arch in $target_arch; do display_alert "Starting package building process" "$release/$arch" "info" - local target_dir="${SRC}/cache/buildpkg/${release}-${arch}-v${CHROOT_CACHE_VERSION}" + local target_dir=$SRC/cache/buildpkg/${release}-${arch}-v${CHROOT_CACHE_VERSION} local distcc_bindaddr="127.0.0.2" - [[ ! -f "${target_dir}"/root/.debootstrap-complete ]] && create_chroot "${target_dir}" "${release}" "${arch}" - [[ ! -f "${target_dir}"/root/.debootstrap-complete ]] && exit_with_error "Creating chroot failed" "$release/$arch" + [[ ! -f $target_dir/root/.debootstrap-complete ]] && create_chroot "$target_dir" "$release" "$arch" + [[ ! -f $target_dir/root/.debootstrap-complete ]] && exit_with_error "Creating chroot failed" "$release/$arch" - [[ -f /var/run/distcc/${release}-${arch}.pid ]] && kill "$( /dev/null 2>&1 + [[ -f /var/run/distcc/${release}-${arch}.pid ]] && kill $( /dev/null 2>&1 - chroot_prepare_distccd "${release}" "${arch}" + chroot_prepare_distccd $release $arch # DISTCC_TCP_DEFER_ACCEPT=0 DISTCC_CMDLIST=/tmp/distcc/${release}-${arch}/cmdlist TMPDIR=/tmp/distcc distccd --daemon \ - --pid-file "/var/run/distcc/${release}-${arch}.pid" --listen "$distcc_bindaddr" --allow 127.0.0.0/24 \ - --log-file "/tmp/distcc/${release}-${arch}.log" --user distccd + --pid-file /var/run/distcc/${release}-${arch}.pid --listen $distcc_bindaddr --allow 127.0.0.0/24 \ + --log-file /tmp/distcc/${release}-${arch}.log --user distccd - local t="${target_dir}"/root/.update-timestamp - if [[ ! -f $t || $(( ($(date +%s) - $(<"$t")) / 86400 )) -gt 7 ]]; then + local t=$target_dir/root/.update-timestamp + if [[ ! -f $t || $(( ($(date +%s) - $(<$t)) / 86400 )) -gt 7 ]]; then display_alert "Upgrading packages" "$release/$arch" "info" - systemd-nspawn -a -q -D "${target_dir}" /bin/bash -c "apt-get -q update; apt-get -q -y upgrade; apt-get clean" - date +%s > "$t" + systemd-nspawn -a -q -D $target_dir /bin/bash -c "apt-get -q update; apt-get -q -y upgrade; apt-get clean" + date +%s > $t fi - for plugin in "${SRC}"/packages/extras-buildpkgs/*.conf; do + for plugin in $SRC/packages/extras-buildpkgs/*.conf; do unset package_name package_repo package_ref package_builddeps package_install_chroot package_install_target \ - package_upstream_version needs_building plugin_target_dir package_component "package_builddeps_${release}" - # shellcheck source=/dev/null - source "${plugin}" + package_upstream_version needs_building plugin_target_dir package_component package_builddeps_${release} + source $plugin # check build condition if [[ $(type -t package_checkbuild) == function ]] && ! package_checkbuild; then @@ -169,13 +169,13 @@ chroot_build_packages() fi local plugin_target_dir=$DEST/debs/extra/$package_component/ - mkdir -p "${plugin_target_dir}" + mkdir -p $plugin_target_dir # check if needs building local needs_building=no if [[ -n $package_install_target ]]; then for f in $package_install_target; do - if [[ -z $(find "${plugin_target_dir}" -name "${f}_*$REVISION*_$arch.deb") ]]; then + if [[ -z $(find $plugin_target_dir -name "${f}_*$REVISION*_$arch.deb") ]]; then needs_building=yes break fi @@ -192,7 +192,7 @@ chroot_build_packages() [[ -v $dist_builddeps_name ]] && package_builddeps="$package_builddeps ${!dist_builddeps_name}" # create build script - cat <<-EOF > "${target_dir}"/root/build.sh + cat <<-EOF > $target_dir/root/build.sh #!/bin/bash export PATH="/usr/lib/ccache:\$PATH" export HOME="/root" @@ -251,22 +251,22 @@ chroot_build_packages() fi EOF - chmod +x "${target_dir}"/root/build.sh + chmod +x $target_dir/root/build.sh fetch_from_repo "$package_repo" "extra/$package_name" "$package_ref" - eval systemd-nspawn -a -q --capability=CAP_MKNOD -D "${target_dir}" --tmpfs=/root/build --tmpfs=/tmp:mode=777 --bind-ro "${SRC}"/packages/extras-buildpkgs/:/root/overlay \ - --bind-ro "${SRC}"/cache/sources/extra/:/root/sources /bin/bash -c "/root/build.sh" 2>&1 \ + eval systemd-nspawn -a -q --capability=CAP_MKNOD -D $target_dir --tmpfs=/root/build --tmpfs=/tmp:mode=777 --bind-ro $SRC/packages/extras-buildpkgs/:/root/overlay \ + --bind-ro $SRC/cache/sources/extra/:/root/sources /bin/bash -c "/root/build.sh" 2>&1 \ ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/buildpkg.log'} if [[ ${PIPESTATUS[0]} -eq 2 ]]; then failed+=("$package_name:$release/$arch") else built_ok+=("$package_name:$release/$arch") fi - mv "${target_dir}"/root/*.deb "${plugin_target_dir}" 2>/dev/null + mv $target_dir/root/*.deb $plugin_target_dir 2>/dev/null done # cleanup for distcc - kill $( "${SDCARD}"/etc/apt/preferences.d/90-armbian-temp.pref + cp $SRC/packages/extras-buildpkgs/buildpkg.key $SDCARD/tmp/buildpkg.key + cat <<-'EOF' > $SDCARD/etc/apt/preferences.d/90-armbian-temp.pref Package: * Pin: origin "localhost" Pin-Priority: 550 @@ -309,7 +309,7 @@ chroot_installpackages_local() deb http://localhost:8189/ $RELEASE temp EOF chroot_installpackages - kill "${aptly_pid}" + kill $aptly_pid } ############################################################################# # chroot_installpackages @@ -320,7 +320,6 @@ chroot_installpackages() local install_list="" display_alert "Installing additional packages" "EXTERNAL_NEW" for plugin in "${SRC}"/packages/extras-buildpkgs/*.conf; do - # shellcheck source=/dev/null source "$plugin" if [[ $(type -t package_checkinstall) == function ]] && package_checkinstall; then install_list="$install_list $package_install_target" diff --git a/lib/compilation-prepare.sh b/lib/compilation-prepare.sh index 6f92ca8cd..94511c5fc 100644 --- a/lib/compilation-prepare.sh +++ b/lib/compilation-prepare.sh @@ -1,5 +1,3 @@ -#!/bin/bash -# # Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com # # This file is licensed under the terms of the GNU General Public @@ -19,7 +17,7 @@ compilation_prepare() # # Older versions have AUFS support with a patch - if linux-version compare "${version}" ge 5.1 && linux-version compare "${version}" le 5.2 && [ "$AUFS" == yes ]; then + if linux-version compare $version ge 5.1 && linux-version compare $version le 5.2 && [ "$AUFS" == yes ]; then # attach to specifics tag or branch local aufsver="branch:aufs5.1" @@ -27,13 +25,13 @@ compilation_prepare() display_alert "Adding" "AUFS 5.1" "info" fetch_from_repo "https://github.com/sfjro/aufs5-standalone" "aufs5" "branch:${aufsver}" "yes" - cd "${SRC}/cache/sources/${LINUXSOURCEDIR}" || exit + cd ${SRC}/cache/sources/${LINUXSOURCEDIR} process_patch_file "${SRC}/cache/sources/aufs5/${aufsver#*:}/aufs5-kbuild.patch" "applying" process_patch_file "${SRC}/cache/sources/aufs5/${aufsver#*:}/aufs5-base.patch" "applying" process_patch_file "${SRC}/cache/sources/aufs5/${aufsver#*:}/aufs5-mmap.patch" "applying" process_patch_file "${SRC}/cache/sources/aufs5/${aufsver#*:}/aufs5-standalone.patch" "applying" - cp -R "${SRC}/cache/sources/aufs5/${aufsver#*:}/{Documentation,fs}" . - cp "${SRC}/cache/sources/aufs5/${aufsver#*:}/include/uapi/linux/aufs_type.h" include/uapi/linux/ + cp -R ${SRC}/cache/sources/aufs5/${aufsver#*:}/{Documentation,fs} . + cp ${SRC}/cache/sources/aufs5/${aufsver#*:}/include/uapi/linux/aufs_type.h include/uapi/linux/ fi @@ -42,7 +40,7 @@ compilation_prepare() # WireGuard - fast, modern, secure VPN tunnel - if linux-version compare "${version}" ge 3.14 && [ "${WIREGUARD}" == yes ]; then + if linux-version compare $version ge 3.14 && [ "${WIREGUARD}" == yes ]; then # attach to specifics tag or branch #local wirever="branch:master" @@ -51,23 +49,23 @@ compilation_prepare() display_alert "Adding" "WireGuard ${wirever} " "info" fetch_from_repo "https://git.zx2c4.com/WireGuard" "wireguard" "${wirever}" "yes" - cd "${SRC}/cache/sources/${LINUXSOURCEDIR}" || exit - rm -rf "${SRC}/cache/sources/${LINUXSOURCEDIR}/net/wireguard" - cp -R "${SRC}/cache/sources/wireguard/${wirever#*:}/src/" "${SRC}/cache/sources/${LINUXSOURCEDIR}/net/wireguard" + cd ${SRC}/cache/sources/${LINUXSOURCEDIR} + rm -rf ${SRC}/cache/sources/${LINUXSOURCEDIR}/net/wireguard + cp -R ${SRC}/cache/sources/wireguard/${wirever#*:}/src/ ${SRC}/cache/sources/${LINUXSOURCEDIR}/net/wireguard sed -i "/^obj-\\\$(CONFIG_NETFILTER).*+=/a obj-\$(CONFIG_WIREGUARD) += wireguard/" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Makefile" + ${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Makefile sed -i "/^if INET\$/a source \"net/wireguard/Kconfig\"" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Kconfig" + ${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Kconfig # remove duplicates - [[ $(grep -c wireguard "${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Makefile") -gt 1 ]] && \ - sed -i '0,/wireguard/{/wireguard/d;}' "${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Makefile" - [[ $(grep -c wireguard "${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Kconfig") -gt 1 ]] && \ - sed -i '0,/wireguard/{/wireguard/d;}' "${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Kconfig" + [[ $(cat ${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Makefile | grep wireguard | wc -l) -gt 1 ]] && \ + sed -i '0,/wireguard/{/wireguard/d;}' ${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Makefile + [[ $(cat ${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Kconfig | grep wireguard | wc -l) -gt 1 ]] && \ + sed -i '0,/wireguard/{/wireguard/d;}' ${SRC}/cache/sources/${LINUXSOURCEDIR}/net/Kconfig # headers workaround display_alert "Patching WireGuard" "Applying workaround for headers compilation" "info" sed -i '/mkdir -p "$destdir"/a mkdir -p "$destdir"/net/wireguard; \ touch "$destdir"/net/wireguard/{Kconfig,Makefile} # workaround for Wireguard' \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/scripts/package/builddeb" + ${SRC}/cache/sources/${LINUXSOURCEDIR}/scripts/package/builddeb fi @@ -76,7 +74,7 @@ compilation_prepare() # Wireless drivers for Realtek 8811, 8812, 8814 and 8821 chipsets - if linux-version compare "${version}" ge 3.14 && [ "$EXTRAWIFI" == yes ]; then + if linux-version compare $version ge 3.14 && [ "$EXTRAWIFI" == yes ]; then # attach to specifics tag or branch local rtl8812auver="branch:v5.2.20" @@ -84,28 +82,28 @@ compilation_prepare() display_alert "Adding" "Wireless drivers for Realtek 8811, 8812, 8814 and 8821 chipsets ${rtl8812auver}" "info" fetch_from_repo "https://github.com/aircrack-ng/rtl8812au" "rtl8812au" "${rtl8812auver}" "yes" - cd "${SRC}/cache/sources/${LINUXSOURCEDIR}" || exit - rm -rf "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au" - mkdir -p "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/" - cp -R "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/{core,hal,include,os_dep,platform}" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au" + cd ${SRC}/cache/sources/${LINUXSOURCEDIR} + rm -rf ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au + mkdir -p ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/ + cp -R ${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/{core,hal,include,os_dep,platform} \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au # Makefile - cp "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/Makefile" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/Makefile" - cp "${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/Kconfig" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/Kconfig" + cp ${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/Makefile \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/Makefile + cp ${SRC}/cache/sources/rtl8812au/${rtl8812auver#*:}/Kconfig \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/Kconfig # Adjust path sed -i 's/include $(src)\/hal\/phydm\/phydm.mk/include $(TopDIR)\/drivers\/net\/wireless\/rtl8812au\/hal\/phydm\/phydm.mk/' \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/Makefile" + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/Makefile sed -i 's/include $(TopDIR)\/hal\/phydm\/phydm.mk/include $(TopDIR)\/drivers\/net\/wireless\/rtl8812au\/hal\/phydm\/phydm.mk/' \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/Makefile" + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8812au/Makefile # Add to section Makefile - echo "obj-\$(CONFIG_RTL8812AU) += rtl8812au/" >> "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Makefile" + echo "obj-\$(CONFIG_RTL8812AU) += rtl8812au/" >> $SRC/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Makefile sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8812au\/Kconfig"' \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Kconfig" + $SRC/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Kconfig fi @@ -114,7 +112,7 @@ compilation_prepare() # Wireless drivers for Realtek 8188EU 8188EUS and 8188ETV chipsets - if linux-version compare "${version}" ge 3.14 && [ "$EXTRAWIFI" == yes ]; then + if linux-version compare $version ge 3.14 && [ "$EXTRAWIFI" == yes ]; then # attach to specifics tag or branch local rtl8811euver="branch:v5.3.9" @@ -122,22 +120,22 @@ compilation_prepare() display_alert "Adding" "Wireless drivers for Realtek 8188EU 8188EUS and 8188ETV chipsets ${rtl8811euver}" "info" fetch_from_repo "https://github.com/aircrack-ng/rtl8188eus" "rtl8188eu" "${rtl8811euver}" "yes" - cd "${SRC}/cache/sources/${LINUXSOURCEDIR}" || exit - rm -rf "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu" - mkdir -p "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu/" - cp -R "${SRC}/cache/sources/rtl8188eu/${rtl8811euver#*:}/{core,hal,include,os_dep,platform}" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu" + cd ${SRC}/cache/sources/${LINUXSOURCEDIR} + rm -rf ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu + mkdir -p ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu/ + cp -R ${SRC}/cache/sources/rtl8188eu/${rtl8811euver#*:}/{core,hal,include,os_dep,platform} \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu # Makefile - cp "${SRC}/cache/sources/rtl8188eu/${rtl8811euver#*:}/Makefile" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu/Makefile" - cp "${SRC}/cache/sources/rtl8188eu/${rtl8811euver#*:}/Kconfig" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu/Kconfig" + cp ${SRC}/cache/sources/rtl8188eu/${rtl8811euver#*:}/Makefile \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu/Makefile + cp ${SRC}/cache/sources/rtl8188eu/${rtl8811euver#*:}/Kconfig \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl8188eu/Kconfig # Add to section Makefile - echo "obj-\$(CONFIG_RTL8188EU) += rtl8188eu/" >> "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Makefile" + echo "obj-\$(CONFIG_RTL8188EU) += rtl8188eu/" >> $SRC/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Makefile sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl8188eu\/Kconfig"' \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Kconfig" + $SRC/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Kconfig fi @@ -146,7 +144,7 @@ compilation_prepare() # Wireless drivers for Realtek 88x2bu chipsets - if linux-version compare "${version}" ge 3.14 && [ "$EXTRAWIFI" == yes ]; then + if linux-version compare $version ge 3.14 && [ "$EXTRAWIFI" == yes ]; then # attach to specifics tag or branch local rtl88x2buver="branch:master" @@ -154,26 +152,26 @@ compilation_prepare() display_alert "Adding" "Wireless drivers for Realtek 88x2bu chipsets ${rtl88x2buver}" "info" fetch_from_repo "https://github.com/cilynx/rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959" "rtl88x2bu" "${rtl88x2buver}" "yes" - cd "${SRC}/cache/sources/${LINUXSOURCEDIR}" || exit - rm -rf "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu" - mkdir -p "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu/" - cp -R "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/{core,hal,include,os_dep,platform,rtl8822b.mk}" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu" + cd ${SRC}/cache/sources/${LINUXSOURCEDIR} + rm -rf ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu + mkdir -p ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu/ + cp -R ${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/{core,hal,include,os_dep,platform,rtl8822b.mk} \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu # Makefile - cp "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Makefile" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu/Makefile" - cp "${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Kconfig" \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu/Kconfig" + cp ${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Makefile \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu/Makefile + cp ${SRC}/cache/sources/rtl88x2bu/${rtl88x2buver#*:}/Kconfig \ + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu/Kconfig # Adjust path sed -i 's/include $(src)\/rtl8822b.mk /include $(TopDIR)\/drivers\/net\/wireless\/rtl88x2bu\/rtl8822b.mk/' \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu/Makefile" + ${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/rtl88x2bu/Makefile # Add to section Makefile - echo "obj-\$(CONFIG_RTL8822BU) += rtl88x2bu/" >> "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Makefile" + echo "obj-\$(CONFIG_RTL8822BU) += rtl88x2bu/" >> $SRC/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Makefile sed -i '/source "drivers\/net\/wireless\/ti\/Kconfig"/a source "drivers\/net\/wireless\/rtl88x2bu\/Kconfig"' \ - "${SRC}/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Kconfig" + $SRC/cache/sources/${LINUXSOURCEDIR}/drivers/net/wireless/Kconfig fi diff --git a/lib/compilation.sh b/lib/compilation.sh index fc0bf1de7..0b207a2ff 100644 --- a/lib/compilation.sh +++ b/lib/compilation.sh @@ -1,5 +1,3 @@ -#!/bin/bash -# # Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com # # This file is licensed under the terms of the GNU General Public @@ -26,48 +24,45 @@ compile_atf() { if [[ $CLEAN_LEVEL == *make* ]]; then display_alert "Cleaning" "$ATFSOURCEDIR" "info" - (cd "${SRC}/cache/sources/${ATFSOURCEDIR}" || exit; make clean > /dev/null 2>&1) + (cd $SRC/cache/sources/$ATFSOURCEDIR; make clean > /dev/null 2>&1) fi - local atfdir + if [[ $USE_OVERLAYFS == yes ]]; then - atfdir=$(overlayfs_wrapper "wrap" "$SRC/cache/sources/$ATFSOURCEDIR" "atf_${LINUXFAMILY}_${BRANCH}") + local atfdir=$(overlayfs_wrapper "wrap" "$SRC/cache/sources/$ATFSOURCEDIR" "atf_${LINUXFAMILY}_${BRANCH}") else - atfdir="$SRC/cache/sources/$ATFSOURCEDIR" + local atfdir="$SRC/cache/sources/$ATFSOURCEDIR" fi - cd "$atfdir" || exit + cd "$atfdir" display_alert "Compiling ATF" "" "info" - local toolchain - toolchain=$(find_toolchain "$ATF_COMPILER" "$ATF_USE_GCC") + local toolchain=$(find_toolchain "$ATF_COMPILER" "$ATF_USE_GCC") [[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${ATF_COMPILER}gcc $ATF_USE_GCC" if [[ -n $ATF_TOOLCHAIN2 ]]; then - local toolchain2_type toolchain2_ver toolchain2 - toolchain2_type=$(cut -d':' -f1 <<< "${ATF_TOOLCHAIN2}") - toolchain2_ver=$(cut -d':' -f2 <<< "${ATF_TOOLCHAIN2}") - toolchain2=$(find_toolchain "$toolchain2_type" "$toolchain2_ver") + local toolchain2_type=$(cut -d':' -f1 <<< $ATF_TOOLCHAIN2) + local toolchain2_ver=$(cut -d':' -f2 <<< $ATF_TOOLCHAIN2) + local toolchain2=$(find_toolchain "$toolchain2_type" "$toolchain2_ver") [[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver" fi - display_alert "Compiler version" "${ATF_COMPILER}gcc $(eval env PATH="${toolchain}:${PATH}" "${ATF_COMPILER}gcc" -dumpversion)" "info" + display_alert "Compiler version" "${ATF_COMPILER}gcc $(eval env PATH=$toolchain:$PATH ${ATF_COMPILER}gcc -dumpversion)" "info" - local target_make target_patchdir target_files - target_make=$(cut -d';' -f1 <<< "${ATF_TARGET_MAP}") - target_patchdir=$(cut -d';' -f2 <<< "${ATF_TARGET_MAP}") - target_files=$(cut -d';' -f3 <<< "${ATF_TARGET_MAP}") + local target_make=$(cut -d';' -f1 <<< $ATF_TARGET_MAP) + local target_patchdir=$(cut -d';' -f2 <<< $ATF_TARGET_MAP) + local target_files=$(cut -d';' -f3 <<< $ATF_TARGET_MAP) advanced_patch "atf" "atf-${LINUXFAMILY}" "$BOARD" "$target_patchdir" "$BRANCH" "${LINUXFAMILY}-${BOARD}-${BRANCH}" # create patch for manual source changes [[ $CREATE_PATCHES == yes ]] && userpatch_create "atf" - echo -e "\n\t== atf ==\n" >>"${DEST}"/debug/compilation.log + echo -e "\n\t== atf ==\n" >>$DEST/debug/compilation.log # ENABLE_BACKTRACE="0" has been added to workaround a regression in ATF. # Check: https://github.com/armbian/build/issues/1157 eval CCACHE_BASEDIR="$(pwd)" env PATH=$toolchain:$toolchain2:$PATH \ 'make ENABLE_BACKTRACE="0" $target_make $CTHREADS \ - CROSS_COMPILE="$CCACHE $ATF_COMPILER"' 2>>"${DEST}"/debug/compilation.log \ + CROSS_COMPILE="$CCACHE $ATF_COMPILER"' 2>>$DEST/debug/compilation.log \ ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \ ${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling ATF..." $TTY_Y $TTY_X'} \ ${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} @@ -77,7 +72,7 @@ compile_atf() [[ $(type -t atf_custom_postprocess) == function ]] && atf_custom_postprocess local atftempdir=$SRC/.tmp/atf-${LINUXFAMILY}-${BOARD}-${BRANCH} - mkdir -p "${atftempdir}" + mkdir -p $atftempdir # copy files to temp directory for f in $target_files; do @@ -88,11 +83,11 @@ compile_atf() local f_dst=$(basename $f_src) fi [[ ! -f $f_src ]] && exit_with_error "ATF file not found" "$(basename $f_src)" - cp "${f_src}" "${atftempdir}/${f_dst}" + cp $f_src $atftempdir/$f_dst done # copy license file to pack it to u-boot package later - [[ -f license.md ]] && cp license.md "${atftempdir}"/ + [[ -f license.md ]] && cp license.md $atftempdir/ } compile_uboot() @@ -100,13 +95,13 @@ compile_uboot() # not optimal, but extra cleaning before overlayfs_wrapper should keep sources directory clean if [[ $CLEAN_LEVEL == *make* ]]; then display_alert "Cleaning" "$BOOTSOURCEDIR" "info" - (cd "${SRC}/cache/sources/${BOOTSOURCEDIR}" || exit; make clean > /dev/null 2>&1) + (cd $SRC/cache/sources/$BOOTSOURCEDIR; make clean > /dev/null 2>&1) fi if [[ $USE_OVERLAYFS == yes ]]; then - local ubootdir=$(overlayfs_wrapper "wrap" "${SRC}/cache/sources/$BOOTSOURCEDIR" "u-boot_${LINUXFAMILY}_${BRANCH}") + local ubootdir=$(overlayfs_wrapper "wrap" "$SRC/cache/sources/$BOOTSOURCEDIR" "u-boot_${LINUXFAMILY}_${BRANCH}") else - local ubootdir=""${SRC}"/cache/sources/$BOOTSOURCEDIR" + local ubootdir="$SRC/cache/sources/$BOOTSOURCEDIR" fi cd "$ubootdir" @@ -131,8 +126,8 @@ compile_uboot() # create directory structure for the .deb package local uboot_name=${CHOSEN_UBOOT}_${REVISION}_${ARCH} - rm -rf "${SRC}"/.tmp/$uboot_name - mkdir -p "${SRC}/.tmp/$uboot_name/usr/lib/{u-boot,$uboot_name}" "${SRC}/.tmp/$uboot_name/DEBIAN" + rm -rf $SRC/.tmp/$uboot_name + mkdir -p $SRC/.tmp/$uboot_name/usr/lib/{u-boot,$uboot_name} $SRC/.tmp/$uboot_name/DEBIAN # process compilation for one or multiple targets while read -r target; do @@ -145,7 +140,7 @@ compile_uboot() if [[ $CLEAN_LEVEL == *make* ]]; then display_alert "Cleaning" "$BOOTSOURCEDIR" "info" - (cd "${SRC}"/cache/sources/$BOOTSOURCEDIR; make clean > /dev/null 2>&1) + (cd $SRC/cache/sources/$BOOTSOURCEDIR; make clean > /dev/null 2>&1) fi advanced_patch "u-boot" "$BOOTPATCHDIR" "$BOARD" "$target_patchdir" "$BRANCH" "${LINUXFAMILY}-${BOARD}-${BRANCH}" @@ -154,14 +149,14 @@ compile_uboot() [[ $CREATE_PATCHES == yes ]] && userpatch_create "u-boot" if [[ -n $ATFSOURCE ]]; then - local atftempdir="${SRC}"/.tmp/atf-${LINUXFAMILY}-${BOARD}-${BRANCH} + local atftempdir=$SRC/.tmp/atf-${LINUXFAMILY}-${BOARD}-${BRANCH} cp -Rv $atftempdir/*.bin . fi - echo -e "\n\t== u-boot ==\n" >>"${DEST}"/debug/compilation.log + echo -e "\n\t== u-boot ==\n" >>$DEST/debug/compilation.log eval CCACHE_BASEDIR="$(pwd)" env PATH=$toolchain:$toolchain2:$PATH \ 'make $CTHREADS $BOOTCONFIG \ - CROSS_COMPILE="$CCACHE $UBOOT_COMPILER"' 2>>"${DEST}"/debug/compilation.log \ + CROSS_COMPILE="$CCACHE $UBOOT_COMPILER"' 2>>$DEST/debug/compilation.log \ ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \ ${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} @@ -177,7 +172,7 @@ compile_uboot() [[ -f .config ]] && echo 'CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto"' >> .config [[ -f .config ]] && echo 'CONFIG_ENV_EXT4_FILE="/boot/boot.env"' >> .config fi - [[ -f tools/logos/udoo.bmp ]] && cp "${SRC}"/packages/blobs/splash/udoo.bmp tools/logos/udoo.bmp + [[ -f tools/logos/udoo.bmp ]] && cp $SRC/packages/blobs/splash/udoo.bmp tools/logos/udoo.bmp touch .scmversion # $BOOTDELAY can be set in board family config, ensure autoboot can be stopped even if set to 0 @@ -190,7 +185,7 @@ compile_uboot() eval CCACHE_BASEDIR="$(pwd)" env PATH=$toolchain:$toolchain2:$PATH \ 'make $target_make $CTHREADS \ - "${cross_compile}"' 2>>"${DEST}"/debug/compilation.log \ + "${cross_compile}"' 2>>$DEST/debug/compilation.log \ ${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \ ${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling u-boot..." $TTY_Y $TTY_X'} \ ${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} @@ -208,12 +203,12 @@ compile_uboot() local f_dst=$(basename $f_src) fi [[ ! -f $f_src ]] && exit_with_error "U-boot file not found" "$(basename $f_src)" - cp "${f_src}" "${SRC}/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst" + cp $f_src $SRC/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst done done <<< "$UBOOT_TARGET_MAP" # declare -f on non-defined function does not do anything - cat <<-EOF > "${SRC}"/.tmp/$uboot_name/usr/lib/u-boot/platform_install.sh + cat <<-EOF > $SRC/.tmp/$uboot_name/usr/lib/u-boot/platform_install.sh DIR=/usr/lib/$uboot_name $(declare -f write_uboot_platform) $(declare -f write_uboot_platform_mtd) @@ -221,7 +216,7 @@ compile_uboot() EOF # set up control file - cat <<-EOF > "${SRC}"/.tmp/$uboot_name/DEBIAN/control + cat <<-EOF > $SRC/.tmp/$uboot_name/DEBIAN/control Package: linux-u-boot-${BOARD}-${BRANCH} Version: $REVISION Architecture: $ARCH @@ -237,41 +232,41 @@ compile_uboot() # copy config file to the package # useful for FEL boot with overlayfs_wrapper - [[ -f .config && -n $BOOTCONFIG ]] && cp .config "${SRC}/.tmp/$uboot_name/usr/lib/u-boot/$BOOTCONFIG" + [[ -f .config && -n $BOOTCONFIG ]] && cp .config $SRC/.tmp/$uboot_name/usr/lib/u-boot/$BOOTCONFIG # copy license files from typical locations - [[ -f COPYING ]] && cp COPYING "${SRC}/.tmp/$uboot_name/usr/lib/u-boot/LICENSE" - [[ -f Licenses/README ]] && cp Licenses/README "${SRC}/.tmp/$uboot_name/usr/lib/u-boot/LICENSE" - [[ -n $atftempdir && -f $atftempdir/license.md ]] && cp "${atftempdir}/license.md" "${SRC}/.tmp/$uboot_name/usr/lib/u-boot/LICENSE.atf" + [[ -f COPYING ]] && cp COPYING $SRC/.tmp/$uboot_name/usr/lib/u-boot/LICENSE + [[ -f Licenses/README ]] && cp Licenses/README $SRC/.tmp/$uboot_name/usr/lib/u-boot/LICENSE + [[ -n $atftempdir && -f $atftempdir/license.md ]] && cp $atftempdir/license.md $SRC/.tmp/$uboot_name/usr/lib/u-boot/LICENSE.atf display_alert "Building deb" "${uboot_name}.deb" "info" - fakeroot dpkg-deb -b "${SRC}"/.tmp/$uboot_name "${SRC}"/.tmp/${uboot_name}.deb >> "${DEST}"/debug/output.log 2>&1 - rm -rf "${SRC}"/.tmp/$uboot_name + fakeroot dpkg-deb -b $SRC/.tmp/$uboot_name $SRC/.tmp/${uboot_name}.deb >> $DEST/debug/output.log 2>&1 + rm -rf $SRC/.tmp/$uboot_name [[ -n $$atftempdir ]] && rm -rf $atftempdir - [[ ! -f "${SRC}"/.tmp/${uboot_name}.deb ]] && exit_with_error "Building u-boot package failed" + [[ ! -f $SRC/.tmp/${uboot_name}.deb ]] && exit_with_error "Building u-boot package failed" - mv "${SRC}"/.tmp/${uboot_name}.deb "${DEST}"/debs/ + mv $SRC/.tmp/${uboot_name}.deb $DEST/debs/ } compile_kernel() { if [[ $CLEAN_LEVEL == *make* ]]; then display_alert "Cleaning" "$LINUXSOURCEDIR" "info" - (cd "${SRC}"/cache/sources/$LINUXSOURCEDIR; make ARCH=$ARCHITECTURE clean >/dev/null 2>&1) + (cd $SRC/cache/sources/$LINUXSOURCEDIR; make ARCH=$ARCHITECTURE clean >/dev/null 2>&1) fi if [[ $USE_OVERLAYFS == yes ]]; then - local kerneldir=$(overlayfs_wrapper "wrap" "${SRC}/cache/sources/$LINUXSOURCEDIR" "kernel_${LINUXFAMILY}_${BRANCH}") + local kerneldir=$(overlayfs_wrapper "wrap" "$SRC/cache/sources/$LINUXSOURCEDIR" "kernel_${LINUXFAMILY}_${BRANCH}") else - local kerneldir=""${SRC}"/cache/sources/$LINUXSOURCEDIR" + local kerneldir="$SRC/cache/sources/$LINUXSOURCEDIR" fi cd "$kerneldir" # this is a patch that Ubuntu Trusty compiler works # TODO: Check if still required - if [[ $(patch --dry-run -t -p1 < "${SRC}"/patch/kernel/compiler.patch | grep Reversed) != "" ]]; then + if [[ $(patch --dry-run -t -p1 < $SRC/patch/kernel/compiler.patch | grep Reversed) != "" ]]; then display_alert "Patching kernel for compiler support" - patch --batch --silent -t -p1 < "${SRC}"/patch/kernel/compiler.patch >> "${DEST}"/debug/output.log 2>&1 + patch --batch --silent -t -p1 < $SRC/patch/kernel/compiler.patch >> $DEST/debug/output.log 2>&1 fi advanced_patch "kernel" "$KERNELPATCHDIR" "$BOARD" "" "$BRANCH" "$LINUXFAMILY-$BRANCH" @@ -288,7 +283,7 @@ compile_kernel() compilation_prepare # create linux-source package - with already patched sources - local sources_pkg_dir="${SRC}"/.tmp/${CHOSEN_KSRC}_${REVISION}_all + local sources_pkg_dir=$SRC/.tmp/${CHOSEN_KSRC}_${REVISION}_all rm -rf ${sources_pkg_dir} mkdir -p $sources_pkg_dir/usr/src/ $sources_pkg_dir/usr/share/doc/linux-source-${version}-${LINUXFAMILY} $sources_pkg_dir/DEBIAN @@ -311,27 +306,27 @@ compile_kernel() display_alert "Compiler version" "${KERNEL_COMPILER}gcc $(eval env PATH=$toolchain:$PATH ${KERNEL_COMPILER}gcc -dumpversion)" "info" # copy kernel config - if [[ $KERNEL_KEEP_CONFIG == yes && -f "${DEST}"/config/$LINUXCONFIG.config ]]; then + if [[ $KERNEL_KEEP_CONFIG == yes && -f $DEST/config/$LINUXCONFIG.config ]]; then display_alert "Using previous kernel config" "$DEST/config/$LINUXCONFIG.config" "info" - cp "${DEST}"/config/$LINUXCONFIG.config .config + cp $DEST/config/$LINUXCONFIG.config .config else - if [[ -f "${SRC}"/userpatches/$LINUXCONFIG.config ]]; then + if [[ -f $SRC/userpatches/$LINUXCONFIG.config ]]; then display_alert "Using kernel config provided by user" "userpatches/$LINUXCONFIG.config" "info" - cp "${SRC}"/userpatches/$LINUXCONFIG.config .config + cp $SRC/userpatches/$LINUXCONFIG.config .config else display_alert "Using kernel config file" "config/kernel/$LINUXCONFIG.config" "info" - cp "${SRC}"/config/kernel/$LINUXCONFIG.config .config + cp $SRC/config/kernel/$LINUXCONFIG.config .config fi fi # hack for OdroidXU4. Copy firmare files if [[ $BOARD == odroidxu4 ]]; then - mkdir -p "${SRC}"/cache/sources/$LINUXSOURCEDIR/firmware/edid - cp "${SRC}"/packages/blobs/odroidxu4/*.bin "${SRC}"/cache/sources/$LINUXSOURCEDIR/firmware/edid + mkdir -p $SRC/cache/sources/$LINUXSOURCEDIR/firmware/edid + cp $SRC/packages/blobs/odroidxu4/*.bin $SRC/cache/sources/$LINUXSOURCEDIR/firmware/edid fi # hack for deb builder. To pack what's missing in headers pack. - cp "${SRC}"/patch/misc/headers-debian-byteshift.patch /tmp + cp $SRC/patch/misc/headers-debian-byteshift.patch /tmp if [[ $KERNEL_CONFIGURE != yes ]]; then if [[ $BRANCH == default ]]; then @@ -349,18 +344,18 @@ compile_kernel() 'make $CTHREADS ARCH=$ARCHITECTURE CROSS_COMPILE="$CCACHE $KERNEL_COMPILER" ${KERNEL_MENUCONFIG:-menuconfig}' # store kernel config in easily reachable place display_alert "Exporting new kernel config" "$DEST/config/$LINUXCONFIG.config" "info" - cp .config "${DEST}"/config/$LINUXCONFIG.config + cp .config $DEST/config/$LINUXCONFIG.config # export defconfig too if requested if [[ $KERNEL_EXPORT_DEFCONFIG == yes ]]; then eval CCACHE_BASEDIR="$(pwd)" env PATH=$toolchain:$PATH \ 'make ARCH=$ARCHITECTURE CROSS_COMPILE="$CCACHE $KERNEL_COMPILER" savedefconfig' - [[ -f defconfig ]] && cp defconfig "${DEST}"/config/$LINUXCONFIG.defconfig + [[ -f defconfig ]] && cp defconfig $DEST/config/$LINUXCONFIG.defconfig fi fi xz < .config > $sources_pkg_dir/usr/src/${LINUXCONFIG}_${version}_${REVISION}_config.xz - echo -e "\n\t== kernel ==\n" >>"${DEST}"/debug/compilation.log + echo -e "\n\t== kernel ==\n" >>$DEST/debug/compilation.log eval CCACHE_BASEDIR="$(pwd)" env PATH=$toolchain:$PATH \ 'make $CTHREADS ARCH=$ARCHITECTURE \ CROSS_COMPILE="$CCACHE $KERNEL_COMPILER" \ @@ -386,7 +381,7 @@ compile_kernel() display_alert "Creating packages" # produce deb packages: image, headers, firmware, dtb - echo -e "\n\t== deb packages: image, headers, firmware, dtb ==\n" >>"${DEST}"/debug/compilation.log + echo -e "\n\t== deb packages: image, headers, firmware, dtb ==\n" >>$DEST/debug/compilation.log eval CCACHE_BASEDIR="$(pwd)" env PATH=$toolchain:$PATH \ 'make -j1 $kernel_packing \ KDEB_PKGVERSION=$REVISION \ @@ -400,7 +395,7 @@ compile_kernel() ${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Creating kernel packages..." $TTY_Y $TTY_X'} \ ${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'} - cat <<-EOF > "${sources_pkg_dir}"/DEBIAN/control + cat <<-EOF > $sources_pkg_dir/DEBIAN/control Package: linux-source-${version}-${BRANCH}-${LINUXFAMILY} Version: ${version}-${BRANCH}-${LINUXFAMILY}+${REVISION} Architecture: all @@ -414,21 +409,21 @@ compile_kernel() EOF if [[ $BUILD_KSRC != no ]]; then - fakeroot dpkg-deb -z0 -b "${sources_pkg_dir}" "${sources_pkg_dir}.deb" - mv ${sources_pkg_dir}.deb "${DEST}"/debs/ + fakeroot dpkg-deb -z0 -b $sources_pkg_dir ${sources_pkg_dir}.deb + mv ${sources_pkg_dir}.deb $DEST/debs/ fi - rm -rf "${sources_pkg_dir}" + rm -rf $sources_pkg_dir cd .. # remove firmare image packages here - easier than patching ~40 packaging scripts at once rm -f linux-firmware-image-*.deb - mv *.deb "${DEST}"/debs/ || exit_with_error "Failed moving kernel DEBs" + mv *.deb $DEST/debs/ || exit_with_error "Failed moving kernel DEBs" } compile_sunxi_tools() { # Compile and install only if git commit hash changed - cd "${SRC}"/cache/sources/sunxi-tools + cd $SRC/cache/sources/sunxi-tools # need to check if /usr/local/bin/sunxi-fexc to detect new Docker containers with old cached sources if [[ ! -f .commit_id || $(git rev-parse @ 2>/dev/null) != $(<.commit_id) || ! -f /usr/local/bin/sunxi-fexc ]]; then display_alert "Compiling" "sunxi-tools" "info" @@ -443,7 +438,7 @@ compile_sunxi_tools() install_rkbin_tools() { # install only if git commit hash changed - cd "${SRC}"/cache/sources/rkbin-tools + cd $SRC/cache/sources/rkbin-tools # need to check if /usr/local/bin/sunxi-fexc to detect new Docker containers with old cached sources if [[ ! -f .commit_id || $(git rev-parse @ 2>/dev/null) != $(<.commit_id) || ! -f /usr/local/bin/loaderimage ]]; then display_alert "Installing" "rkbin-tools" "info" @@ -476,7 +471,7 @@ find_toolchain() local toolchain="" # extract target major.minor version from expression local target_ver=$(grep -oE "[[:digit:]]+\.[[:digit:]]" <<< "$expression") - for dir in "${SRC}"/cache/toolchains/*/; do + for dir in $SRC/cache/toolchains/*/; do # check if is a toolchain for current $ARCH [[ ! -f ${dir}bin/${compiler}gcc ]] && continue # get toolchain major.minor version @@ -552,7 +547,7 @@ advanced_patch() # get patch file names for dir in "${dirs[@]}"; do for patch in ${dir%%:*}/*.patch; do - names+=($(basename "${patch}")) + names+=($(basename $patch)) done done # remove duplicates @@ -584,18 +579,18 @@ process_patch_file() local status=$2 # detect and remove files which patch will create - lsdiff -s --strip=1 "${patch}" | grep '^+' | awk '{print $2}' | xargs -I % sh -c 'rm -f %' + lsdiff -s --strip=1 $patch | grep '^+' | awk '{print $2}' | xargs -I % sh -c 'rm -f %' - echo "Processing file $patch" >> "${DEST}"/debug/patching.log - patch --batch --silent -p1 -N < "${patch}" >> "${DEST}"/debug/patching.log 2>&1 + echo "Processing file $patch" >> $DEST/debug/patching.log + patch --batch --silent -p1 -N < $patch >> $DEST/debug/patching.log 2>&1 if [[ $? -ne 0 ]]; then - display_alert "* $status $(basename "${patch}")" "failed" "wrn" + display_alert "* $status $(basename $patch)" "failed" "wrn" [[ $EXIT_PATCHING_ERROR == yes ]] && exit_with_error "Aborting due to" "EXIT_PATCHING_ERROR" else - display_alert "* $status $(basename "${patch}")" "" "info" + display_alert "* $status $(basename $patch)" "" "info" fi - echo >> "${DEST}"/debug/patching.log + echo >> $DEST/debug/patching.log } userpatch_create() @@ -607,17 +602,17 @@ userpatch_create() local patch="$DEST/patch/$1-$LINUXFAMILY-$BRANCH.patch" # apply previous user debug mode created patches - [[ -f $patch ]] && display_alert "Applying existing $1 patch" "$patch" "wrn" && patch --batch --silent -p1 -N < "${patch}" + [[ -f $patch ]] && display_alert "Applying existing $1 patch" "$patch" "wrn" && patch --batch --silent -p1 -N < $patch # prompt to alter source display_alert "Make your changes in this directory:" "$(pwd)" "wrn" display_alert "Press after you are done" "waiting" "wrn" - read -r "${patch}" + git diff --staged > $patch display_alert "You will find your patch here:" "$patch" "info" else display_alert "No changes found, skipping patch creation" "" "wrn" @@ -647,10 +642,9 @@ overlayfs_wrapper() local srcdir="$2" local description="$3" mkdir -p /tmp/overlay_components/ /tmp/armbian_build/ - local tempdir workdir mergeddir - tempdir=$(mktemp -d --tmpdir="/tmp/overlay_components/") - workdir=$(mktemp -d --tmpdir="/tmp/overlay_components/") - mergeddir=$(mktemp -d --suffix="_$description" --tmpdir="/tmp/armbian_build/") + local tempdir=$(mktemp -d --tmpdir="/tmp/overlay_components/") + local workdir=$(mktemp -d --tmpdir="/tmp/overlay_components/") + local mergeddir=$(mktemp -d --suffix="_$description" --tmpdir="/tmp/armbian_build/") mount -t overlay overlay -o lowerdir="$srcdir",upperdir="$tempdir",workdir="$workdir" "$mergeddir" # this is executed in a subshell, so use temp files to pass extra data outside echo "$tempdir" >> /tmp/.overlayfs_wrapper_cleanup diff --git a/lib/image-helpers.sh b/lib/image-helpers.sh index 32f6bfe66..fc5405fd3 100644 --- a/lib/image-helpers.sh +++ b/lib/image-helpers.sh @@ -82,7 +82,6 @@ install_external_applications() display_alert "Installing extra applications and drivers" "" "info" for plugin in "${SRC}"/packages/extras/*.sh; do - # shellcheck source=/dev/null source "${plugin}" done } ############################################################################# @@ -99,7 +98,8 @@ write_uboot() display_alert "Writing U-boot bootloader" "$loop" "info" mkdir -p /tmp/u-boot/ dpkg -x "${DEST}/debs/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb" /tmp/u-boot/ - write_uboot_platform "/tmp/u-boot/usr/lib/${CHOSEN_UBOOT}_${REVISION}_${ARCH}" "$loop" || exit_with_error "U-boot bootloader failed to install" "@host" + write_uboot_platform "/tmp/u-boot/usr/lib/${CHOSEN_UBOOT}_${REVISION}_${ARCH}" "$loop" + [[ $? -ne 0 ]] && exit_with_error "U-boot bootloader failed to install" "@host" rm -r /tmp/u-boot/ sync } ############################################################################# @@ -107,7 +107,6 @@ write_uboot() customize_image() { # for users that need to prepare files at host - # shellcheck source=/dev/null [[ -f $SRC/userpatches/customize-image-host.sh ]] && source "${SRC}"/userpatches/customize-image-host.sh cp "${SRC}"/userpatches/customize-image.sh "${SDCARD}"/tmp/customize-image.sh chmod +x "${SDCARD}"/tmp/customize-image.sh