mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
lib/*.sh: Apply further shellcheck recommendations
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
@@ -30,17 +32,17 @@ pack_upload ()
|
||||
local filename=$DESTIMG/${version}.7z
|
||||
|
||||
# stage: generate sha256sum.sha
|
||||
cd $DESTIMG
|
||||
sha256sum -b ${version}.img > sha256sum.sha
|
||||
cd "${DESTIMG}" || exit
|
||||
sha256sum -b "${version}.img" > sha256sum.sha
|
||||
|
||||
# stage: sign with PGP
|
||||
if [[ -n $GPG_PASS ]]; then
|
||||
echo $GPG_PASS | gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes ${version}.img
|
||||
echo "${GPG_PASS}" | gpg --passphrase-fd 0 --armor --detach-sign --pinentry-mode loopback --batch --yes "${version}.img"
|
||||
fi
|
||||
|
||||
if [[ -n "${SEND_TO_SERVER}" ]]; then
|
||||
# create remote directory structure
|
||||
ssh ${SEND_TO_SERVER} "mkdir -p /var/www/dl.armbian.com/${BOARD}/{archive,nightly};";
|
||||
ssh "${SEND_TO_SERVER}" "mkdir -p /var/www/dl.armbian.com/${BOARD}/{archive,nightly};";
|
||||
|
||||
# pack and move file to server under new process
|
||||
nice -n 19 bash -c "\
|
||||
@@ -60,7 +62,8 @@ pack_upload ()
|
||||
build_main ()
|
||||
{
|
||||
touch "/run/armbian/Armbian_${BOARD^}_${BRANCH}_${RELEASE}_${BUILD_DESKTOP}.pid";
|
||||
source $SRC/lib/main.sh;
|
||||
# shellcheck source=main.sh
|
||||
source "${SRC}"/lib/main.sh;
|
||||
[[ $KERNEL_ONLY != yes ]] && pack_upload
|
||||
rm "/run/armbian/Armbian_${BOARD^}_${BRANCH}_${RELEASE}_${BUILD_DESKTOP}.pid"
|
||||
}
|
||||
@@ -143,12 +146,12 @@ create_images_list()
|
||||
if [[ -n $REBUILD_IMAGES ]]; then naming=$naming" $SRC/config/boards/*.csc"; REBUILD_IMAGES=$REBUILD_IMAGES","; fi
|
||||
|
||||
for board in $naming; do
|
||||
BOARD=$(basename $board | cut -d'.' -f1)
|
||||
BOARD=$(basename "${board}" | cut -d'.' -f1)
|
||||
local file="${SRC}/config/boards/${BOARD}"
|
||||
if [[ -f $file".conf" ]]; then source $file".conf"; fi
|
||||
if [[ -f $file".wip" ]]; then source $file".wip"; fi
|
||||
if [[ -f $file".csc" ]]; then source $file".csc"; fi
|
||||
if [[ -f $file".tvb" ]]; then source $file".tvb"; fi
|
||||
if [[ -f $file".conf" ]]; then source "${file}.conf"; fi
|
||||
if [[ -f $file".wip" ]]; then source "${file}.wip"; fi
|
||||
if [[ -f $file".csc" ]]; then source "${file}.csc"; fi
|
||||
if [[ -f $file".tvb" ]]; then source "${file}.tvb"; fi
|
||||
|
||||
# beta targets are the same as stable. To build the same set beta set as future stable.
|
||||
if [[ "$MERGETARGETS" == "yes" ]]; then
|
||||
@@ -173,10 +176,10 @@ create_kernels_list()
|
||||
for board in $naming; do
|
||||
BOARD=$(basename $board | cut -d'.' -f1)
|
||||
local file="${SRC}/config/boards/${BOARD}"
|
||||
if [[ -f $file".conf" ]]; then source $file".conf"; fi
|
||||
if [[ -f $file".wip" ]]; then source $file".wip"; fi
|
||||
if [[ -f $file".csc" ]]; then source $file".csc"; fi
|
||||
if [[ -f $file".tvb" ]]; then source $file".tvb"; fi
|
||||
if [[ -f $file".conf" ]]; then source "${file}.conf"; fi
|
||||
if [[ -f $file".wip" ]]; then source "${file}.wip"; fi
|
||||
if [[ -f $file".csc" ]]; then source "${file}.csc"; fi
|
||||
if [[ -f $file".tvb" ]]; then source "${file}.tvb"; fi
|
||||
|
||||
if [[ -n $KERNEL_TARGET ]]; then
|
||||
for kernel in $(tr ',' ' ' <<< $KERNEL_TARGET); do
|
||||
@@ -211,14 +214,15 @@ fi
|
||||
|
||||
n=0
|
||||
for line in "${buildlist[@]}"; do
|
||||
n=$[$n+1]
|
||||
printf "%-3s %-20s %-10s %-10s %-10s\n" $n $line
|
||||
((n+=1))
|
||||
read -r BOARD BRANCH RELEASE BUILD_DESKTOP <<< "${line}"
|
||||
printf "%-3s %-20s %-10s %-10s %-10s\n" "$n" "$BOARD" "$BRANCH" "$RELEASE" "$BUILD_DESKTOP"
|
||||
done
|
||||
echo -e "\n${#buildlist[@]} total\n"
|
||||
|
||||
[[ $BUILD_ALL == demo ]] && exit 0
|
||||
|
||||
buildall_start=`date +%s`
|
||||
buildall_start=$(date +%s)
|
||||
n=0
|
||||
for line in "${buildlist[@]}"; do
|
||||
unset LINUXFAMILY LINUXCONFIG KERNELDIR KERNELSOURCE KERNELBRANCH BOOTDIR BOOTSOURCE BOOTBRANCH ARCH UBOOT_USE_GCC KERNEL_USE_GCC DEFAULT_OVERLAYS \
|
||||
@@ -231,12 +235,12 @@ for line in "${buildlist[@]}"; do
|
||||
CRYPTROOT_ENABLE CRYPTROOT_PASSPHRASE CRYPTROOT_SSH_UNLOCK CRYPTROOT_SSH_UNLOCK_PORT CRYPTROOT_SSH_UNLOCK_KEY_NAME ROOT_MAPPER \
|
||||
NETWORK HDMI USB WIRELESS ARMBIANMONITOR DEFAULT_CONSOLE FORCE_BOOTSCRIPT_UPDATE SERIALCON UBOOT_TOOLCHAIN2 toolchain2
|
||||
|
||||
read BOARD BRANCH RELEASE BUILD_DESKTOP <<< $line
|
||||
n=$[$n+1]
|
||||
read -r BOARD BRANCH RELEASE BUILD_DESKTOP <<< "${line}"
|
||||
((n+=1))
|
||||
[[ -z $RELEASE ]] && RELEASE=$FORCEDRELEASE;
|
||||
if [[ $from -le $n ]]; then
|
||||
[[ -z $BUILD_DESKTOP ]] && BUILD_DESKTOP="no"
|
||||
jobs=$(ls /run/armbian | wc -l)
|
||||
jobs=$(find /run/armbian | wc -l)
|
||||
if [[ $jobs -lt $MULTITHREAD ]]; then
|
||||
display_alert "Building in the back $n / ${#buildlist[@]}" "Board: $BOARD Kernel:$BRANCH${RELEASE:+ Release: $RELEASE}${BUILD_DESKTOP:+ Desktop: $BUILD_DESKTOP}" "ext"
|
||||
(build_main) &
|
||||
@@ -247,7 +251,8 @@ for line in "${buildlist[@]}"; do
|
||||
# include testing report if exist
|
||||
if [[ -f $SRC/cache/sources/testing-reports/${BOARD}-${BRANCH}.report ]]; then
|
||||
display_alert "Loading board report" "${BOARD}-${BRANCH}.report" "info"
|
||||
source $SRC/cache/sources/testing-reports/${BOARD}-${BRANCH}.report
|
||||
# shellcheck source=/dev/null
|
||||
source "${SRC}/cache/sources/testing-reports/${BOARD}-${BRANCH}.report"
|
||||
fi
|
||||
if [[ $KERNEL_ONLY == yes ]]; then
|
||||
REPORT=$REPORT"\n|$n|$BOARD|$BRANCH|$UBOOT_VER|$VER|$NETWORK|$WIRELESS|$HDMI|$USB|$ARMBIANMONITOR|"
|
||||
@@ -261,16 +266,16 @@ for line in "${buildlist[@]}"; do
|
||||
done
|
||||
|
||||
display_alert "Build report" "$DEST/debug/report.md" "info"
|
||||
buildall_end=`date +%s`
|
||||
buildall_end=$(date +%s)
|
||||
buildall_runtime=$(((buildall_end - buildall_start) / 60))
|
||||
display_alert "Runtime in total" "$buildall_runtime min" "info"
|
||||
|
||||
if [[ $KERNEL_ONLY == yes ]]; then
|
||||
|
||||
echo -e $REPORT > $DEST/debug/report.md
|
||||
echo -e "${REPORT}" > "${DEST}"/debug/report.md
|
||||
|
||||
echo -e "\nSummary:\n\n|Armbian version | Built date| Built time in total\n|--|--:|--:|" >> $DEST/debug/report.md
|
||||
echo -e "|$REVISION|$(date -d "@$buildall_end")|$buildall_runtime|" >> $DEST/debug/report.md
|
||||
echo -e "$REPORTHTML<tr><td colspan=10>Current version: $REVISION - Refreshed at: $(date -d "@$buildall_end")</td></tr></table>" > $DEST/debug/report.html
|
||||
echo -e "\nSummary:\n\n|Armbian version | Built date| Built time in total\n|--|--:|--:|" >> "${DEST}"/debug/report.md
|
||||
echo -e "|$REVISION|$(date -d "@$buildall_end")|$buildall_runtime|" >> "${DEST}"/debug/report.md
|
||||
echo -e "$REPORTHTML<tr><td colspan=10>Current version: $REVISION - Refreshed at: $(date -d "@$buildall_end")</td></tr></table>" > "${DEST}"/debug/report.html
|
||||
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
@@ -293,7 +295,7 @@ chroot_installpackages_local()
|
||||
Pin: origin "localhost"
|
||||
Pin-Priority: 550
|
||||
EOF
|
||||
cat <<-EOF > $SDCARD/etc/apt/sources.list.d/armbian-temp.list
|
||||
cat <<-EOF > "${SDCARD}"/etc/apt/sources.list.d/armbian-temp.list
|
||||
deb http://localhost:8189/ $RELEASE temp
|
||||
EOF
|
||||
chroot_installpackages
|
||||
@@ -307,15 +309,15 @@ chroot_installpackages()
|
||||
local remote_only=$1
|
||||
local install_list=""
|
||||
display_alert "Installing additional packages" "EXTERNAL_NEW"
|
||||
for plugin in $SRC/packages/extras-buildpkgs/*.conf; do
|
||||
source $plugin
|
||||
for plugin in "${SRC}"/packages/extras-buildpkgs/*.conf; do
|
||||
source "$plugin"
|
||||
if [[ $(type -t package_checkinstall) == function ]] && package_checkinstall; then
|
||||
install_list="$install_list $package_install_target"
|
||||
fi
|
||||
unset package_install_target package_checkinstall
|
||||
done
|
||||
[[ $NO_APT_CACHER != yes ]] && local apt_extra="-o Acquire::http::Proxy=\"http://${APT_PROXY_ADDR:-localhost:3142}\" -o Acquire::http::Proxy::localhost=\"DIRECT\""
|
||||
cat <<-EOF > $SDCARD/tmp/install.sh
|
||||
cat <<-EOF > "${SDCARD}"/tmp/install.sh
|
||||
#!/bin/bash
|
||||
[[ "$remote_only" != yes ]] && apt-key add /tmp/buildpkg.key
|
||||
apt-get $apt_extra -q update
|
||||
@@ -335,6 +337,6 @@ chroot_installpackages()
|
||||
rm /tmp/buildpkg.key 2>/dev/null
|
||||
rm -- "\$0"
|
||||
EOF
|
||||
chmod +x $SDCARD/tmp/install.sh
|
||||
chroot $SDCARD /bin/bash -c "/tmp/install.sh"
|
||||
chmod +x "${SDCARD}"/tmp/install.sh
|
||||
chroot "${SDCARD}" /bin/bash -c "/tmp/install.sh"
|
||||
} #############################################################################
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
@@ -14,7 +16,7 @@ REVISION="5.88$SUBREVISION" # all boards have same revision
|
||||
ROOTPWD="1234" # Must be changed @first login
|
||||
[[ -z $MAINTAINER ]] && MAINTAINER="Igor Pecovnik" # deb signature
|
||||
[[ -z $MAINTAINERMAIL ]] && MAINTAINERMAIL="igor.pecovnik@****l.com" # deb signature
|
||||
TZDATA=`cat /etc/timezone` # Timezone for target is taken from host or defined here.
|
||||
TZDATA=$(cat /etc/timezone) # Timezone for target is taken from host or defined here.
|
||||
USEALLCORES=yes # Use all CPU cores for compiling
|
||||
EXIT_PATCHING_ERROR="" # exit patching if failed
|
||||
HOST="$(echo "$BOARD" | cut -f1 -d-)" # set hostname to the board
|
||||
@@ -73,18 +75,18 @@ CAN_BUILD_STRETCH=yes
|
||||
#BOOTFS_TYPE=''
|
||||
|
||||
# set unique mounting directory
|
||||
SDCARD="$SRC/.tmp/rootfs-${BRANCH}-${BOARD}-${RELEASE}-${BUILD_DESKTOP}"
|
||||
MOUNT="$SRC/.tmp/mount-${BRANCH}-${BOARD}-${RELEASE}-${BUILD_DESKTOP}"
|
||||
DESTIMG="$SRC/.tmp/image-${BRANCH}-${BOARD}-${RELEASE}-${BUILD_DESKTOP}"
|
||||
SDCARD="${SRC}/.tmp/rootfs-${BRANCH}-${BOARD}-${RELEASE}-${BUILD_DESKTOP}"
|
||||
MOUNT="${SRC}/.tmp/mount-${BRANCH}-${BOARD}-${RELEASE}-${BUILD_DESKTOP}"
|
||||
DESTIMG="${SRC}/.tmp/image-${BRANCH}-${BOARD}-${RELEASE}-${BUILD_DESKTOP}"
|
||||
|
||||
[[ ! -f $SRC/config/sources/$LINUXFAMILY.conf ]] && \
|
||||
[[ ! -f ${SRC}/config/sources/$LINUXFAMILY.conf ]] && \
|
||||
exit_with_error "Sources configuration not found" "$LINUXFAMILY"
|
||||
|
||||
source $SRC/config/sources/$LINUXFAMILY.conf
|
||||
source "${SRC}/config/sources/${LINUXFAMILY}.conf"
|
||||
|
||||
if [[ -f $SRC/userpatches/sources/$LINUXFAMILY.conf ]]; then
|
||||
if [[ -f ${SRC}/userpatches/sources/$LINUXFAMILY.conf ]]; then
|
||||
display_alert "Adding user provided $LINUXFAMILY overrides"
|
||||
source $SRC/userpatches/sources/$LINUXFAMILY.conf
|
||||
source "${SRC}/userpatches/sources/${LINUXFAMILY}.conf"
|
||||
fi
|
||||
|
||||
# dropbear needs to be configured differently
|
||||
@@ -233,9 +235,9 @@ if [[ $DOWNLOAD_MIRROR == china ]] ; then
|
||||
fi
|
||||
|
||||
# For user override
|
||||
if [[ -f $SRC/userpatches/lib.config ]]; then
|
||||
if [[ -f ${SRC}/userpatches/lib.config ]]; then
|
||||
display_alert "Using user configuration override" "userpatches/lib.config" "info"
|
||||
source $SRC/userpatches/lib.config
|
||||
source "${SRC}"/userpatches/lib.config
|
||||
fi
|
||||
|
||||
# apt-cacher-ng mirror configurarion
|
||||
@@ -257,18 +259,18 @@ PACKAGE_LIST="$PACKAGE_LIST $PACKAGE_LIST_RELEASE $PACKAGE_LIST_ADDITIONAL"
|
||||
|
||||
# remove any packages defined in PACKAGE_LIST_RM in lib.config
|
||||
if [[ -n $PACKAGE_LIST_RM ]]; then
|
||||
PACKAGE_LIST=$(sed -r "s/\b($(tr ' ' '|' <<< $PACKAGE_LIST_RM))\b//g" <<< $PACKAGE_LIST)
|
||||
PACKAGE_LIST=$(sed -r "s/\b($(tr ' ' '|' <<< ${PACKAGE_LIST_RM}))\b//g" <<< "${PACKAGE_LIST}")
|
||||
fi
|
||||
|
||||
# Give the option to configure DNS server used in the chroot during the build process
|
||||
[[ -z $NAMESERVER ]] && NAMESERVER="1.0.0.1" # default is cloudflare alternate
|
||||
|
||||
# debug
|
||||
cat <<-EOF >> $DEST/debug/output.log
|
||||
cat <<-EOF >> "${DEST}"/debug/output.log
|
||||
|
||||
## BUILD SCRIPT ENVIRONMENT
|
||||
|
||||
Repository: $(git remote get-url $(git remote 2>/dev/null) 2>/dev/null)
|
||||
Repository: $(git remote get-url "$(git remote 2>/dev/null)" 2>/dev/null)
|
||||
Version: $(git describe --match=d_e_a_d_b_e_e_f --always --dirty 2>/dev/null)
|
||||
|
||||
Host OS: $(lsb_release -sc)
|
||||
@@ -278,13 +280,13 @@ Virtualization type: $(systemd-detect-virt)
|
||||
|
||||
## Build script directories
|
||||
Build directory is located on:
|
||||
$(findmnt -o TARGET,SOURCE,FSTYPE,AVAIL -T $SRC)
|
||||
$(findmnt -o TARGET,SOURCE,FSTYPE,AVAIL -T "${SRC}")
|
||||
|
||||
Build directory permissions:
|
||||
$(getfacl -p $SRC)
|
||||
$(getfacl -p "${SRC}")
|
||||
|
||||
Temp directory permissions:
|
||||
$(getfacl -p $SRC/.tmp)
|
||||
$(getfacl -p "${SRC}"/.tmp)
|
||||
|
||||
## BUILD CONFIGURATION
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
@@ -19,128 +21,128 @@ install_common()
|
||||
# install rootfs encryption related packages separate to not break packages cache
|
||||
if [[ $CRYPTROOT_ENABLE == yes ]]; then
|
||||
display_alert "Installing rootfs encryption related packages" "cryptsetup" "info"
|
||||
chroot $SDCARD /bin/bash -c "apt -y -qq --no-install-recommends install cryptsetup" >> $DEST/debug/install.log 2>&1
|
||||
chroot "${SDCARD}" /bin/bash -c "apt -y -qq --no-install-recommends install cryptsetup" >> "${DEST}"/debug/install.log 2>&1
|
||||
if [[ $CRYPTROOT_SSH_UNLOCK == yes ]]; then
|
||||
display_alert "Installing rootfs encryption related packages" "dropbear-initramfs" "info"
|
||||
chroot $SDCARD /bin/bash -c "apt -y -qq --no-install-recommends install dropbear-initramfs " >> $DEST/debug/install.log 2>&1
|
||||
chroot "${SDCARD}" /bin/bash -c "apt -y -qq --no-install-recommends install dropbear-initramfs " >> "${DEST}"/debug/install.log 2>&1
|
||||
fi
|
||||
|
||||
fi
|
||||
# define ARCH within global environment variables
|
||||
[[ -f $SDCARD/etc/environment ]] && echo -e "ARCH=${ARCH//hf}\nLC_ALL=\"C\"" >> $SDCARD/etc/environment
|
||||
[[ -f $SDCARD/etc/environment ]] && echo -e "ARCH=${ARCH//hf}\nLC_ALL=\"C\"" >> "${SDCARD}"/etc/environment
|
||||
|
||||
# add dummy fstab entry to make mkinitramfs happy
|
||||
echo "/dev/mmcblk0p1 / $ROOTFS_TYPE defaults 0 1" >> $SDCARD/etc/fstab
|
||||
echo "/dev/mmcblk0p1 / $ROOTFS_TYPE defaults 0 1" >> "${SDCARD}"/etc/fstab
|
||||
# required for initramfs-tools-core on Stretch since it ignores the / fstab entry
|
||||
echo "/dev/mmcblk0p2 /usr $ROOTFS_TYPE defaults 0 2" >> $SDCARD/etc/fstab
|
||||
echo "/dev/mmcblk0p2 /usr $ROOTFS_TYPE defaults 0 2" >> "${SDCARD}"/etc/fstab
|
||||
|
||||
# adjust initramfs dropbear configuration
|
||||
# needs to be done before kernel installation, else it won't be in the initrd image
|
||||
if [[ $CRYPTROOT_ENABLE == yes && $CRYPTROOT_SSH_UNLOCK == yes ]]; then
|
||||
# Set the port of the dropbear ssh deamon in the initramfs to a different one if configured
|
||||
# this avoids the typical 'host key changed warning' - `WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!`
|
||||
[[ -f $SDCARD/etc/dropbear-initramfs/config ]] && sed -i 's/^#DROPBEAR_OPTIONS=/DROPBEAR_OPTIONS="-p '$CRYPTROOT_SSH_UNLOCK_PORT'"/' $SDCARD/etc/dropbear-initramfs/config
|
||||
[[ -f $SDCARD/etc/dropbear-initramfs/config ]] && sed -i 's/^#DROPBEAR_OPTIONS=/DROPBEAR_OPTIONS="-p '"${CRYPTROOT_SSH_UNLOCK_PORT}"'"/' "${SDCARD}"/etc/dropbear-initramfs/config
|
||||
|
||||
# setup dropbear authorized_keys, either provided by userpatches or generated
|
||||
if [[ -f $SRC/userpatches/dropbear_authorized_keys ]]; then
|
||||
cp $SRC/userpatches/dropbear_authorized_keys $SDCARD/etc/dropbear-initramfs/authorized_keys
|
||||
cp "${SRC}"/userpatches/dropbear_authorized_keys "${SDCARD}"/etc/dropbear-initramfs/authorized_keys
|
||||
else
|
||||
# generate a default ssh key for login on dropbear in initramfs
|
||||
# this key should be changed by the user on first login
|
||||
display_alert "Generating a new SSH key pair for dropbear (initramfs)" "" ""
|
||||
ssh-keygen -t ecdsa -f $SDCARD/etc/dropbear-initramfs/id_ecdsa -N '' -O force-command=cryptroot-unlock -C 'AUTOGENERATED_BY_ARMBIAN_BUILD' >> $DEST/debug/install.log 2>&1
|
||||
ssh-keygen -t ecdsa -f "${SDCARD}"/etc/dropbear-initramfs/id_ecdsa -N '' -O force-command=cryptroot-unlock -C 'AUTOGENERATED_BY_ARMBIAN_BUILD' >> "${DEST}"/debug/install.log 2>&1
|
||||
|
||||
# /usr/share/initramfs-tools/hooks/dropbear will automatically add 'id_ecdsa.pub' to authorized_keys file
|
||||
# during mkinitramfs of update-initramfs
|
||||
#cat $SDCARD/etc/dropbear-initramfs/id_ecdsa.pub > $SDCARD/etc/dropbear-initramfs/authorized_keys
|
||||
CRYPTROOT_SSH_UNLOCK_KEY_NAME="Armbian_${REVISION}_${BOARD^}_${DISTRIBUTION}_${RELEASE}_${BRANCH}_${VER/-$LINUXFAMILY/}".key
|
||||
# copy dropbear ssh key to image output dir for convenience
|
||||
cp $SDCARD/etc/dropbear-initramfs/id_ecdsa $DEST/images/$CRYPTROOT_SSH_UNLOCK_KEY_NAME
|
||||
cp "${SDCARD}"/etc/dropbear-initramfs/id_ecdsa "${DEST}/images/${CRYPTROOT_SSH_UNLOCK_KEY_NAME}"
|
||||
display_alert "SSH private key for dropbear (initramfs) has been copied to:" "$DEST/images/$CRYPTROOT_SSH_UNLOCK_KEY_NAME" "info"
|
||||
fi
|
||||
fi
|
||||
|
||||
# create modules file
|
||||
if [[ $BRANCH == dev && -n $MODULES_DEV ]]; then
|
||||
tr ' ' '\n' <<< "$MODULES_DEV" > $SDCARD/etc/modules
|
||||
tr ' ' '\n' <<< "$MODULES_DEV" > "${SDCARD}"/etc/modules
|
||||
elif [[ $BRANCH == next || $BRANCH == dev ]]; then
|
||||
tr ' ' '\n' <<< "$MODULES_NEXT" > $SDCARD/etc/modules
|
||||
tr ' ' '\n' <<< "$MODULES_NEXT" > "${SDCARD}"/etc/modules
|
||||
else
|
||||
tr ' ' '\n' <<< "$MODULES" > $SDCARD/etc/modules
|
||||
tr ' ' '\n' <<< "$MODULES" > "${SDCARD}"/etc/modules
|
||||
fi
|
||||
|
||||
# create blacklist files
|
||||
if [[ $BRANCH == dev && -n $MODULES_BLACKLIST_DEV ]]; then
|
||||
tr ' ' '\n' <<< "$MODULES_BLACKLIST_DEV" | sed -e 's/^/blacklist /' > $SDCARD/etc/modprobe.d/blacklist-${BOARD}.conf
|
||||
tr ' ' '\n' <<< "$MODULES_BLACKLIST_DEV" | sed -e 's/^/blacklist /' > "${SDCARD}/etc/modprobe.d/blacklist-${BOARD}.conf"
|
||||
elif [[ ($BRANCH == next || $BRANCH == dev) && -n $MODULES_BLACKLIST_NEXT ]]; then
|
||||
tr ' ' '\n' <<< "$MODULES_BLACKLIST_NEXT" | sed -e 's/^/blacklist /' > $SDCARD/etc/modprobe.d/blacklist-${BOARD}.conf
|
||||
tr ' ' '\n' <<< "$MODULES_BLACKLIST_NEXT" | sed -e 's/^/blacklist /' > "${SDCARD}/etc/modprobe.d/blacklist-${BOARD}.conf"
|
||||
elif [[ $BRANCH == default && -n $MODULES_BLACKLIST ]]; then
|
||||
tr ' ' '\n' <<< "$MODULES_BLACKLIST" | sed -e 's/^/blacklist /' > $SDCARD/etc/modprobe.d/blacklist-${BOARD}.conf
|
||||
tr ' ' '\n' <<< "$MODULES_BLACKLIST" | sed -e 's/^/blacklist /' > "${SDCARD}/etc/modprobe.d/blacklist-${BOARD}.conf"
|
||||
fi
|
||||
|
||||
# remove default interfaces file if present
|
||||
# before installing board support package
|
||||
rm -f $SDCARD/etc/network/interfaces
|
||||
rm -f "${SDCARD}"/etc/network/interfaces
|
||||
|
||||
mkdir -p $SDCARD/selinux
|
||||
mkdir -p "${SDCARD}"/selinux
|
||||
|
||||
# remove Ubuntu's legal text
|
||||
[[ -f $SDCARD/etc/legal ]] && rm $SDCARD/etc/legal
|
||||
[[ -f $SDCARD/etc/legal ]] && rm "${SDCARD}"/etc/legal
|
||||
|
||||
# Prevent loading paralel printer port drivers which we don't need here.Suppress boot error if kernel modules are absent
|
||||
if [[ -f $SDCARD/etc/modules-load.d/cups-filters.conf ]]; then
|
||||
sed "s/^lp/#lp/" -i $SDCARD/etc/modules-load.d/cups-filters.conf
|
||||
sed "s/^ppdev/#ppdev/" -i $SDCARD/etc/modules-load.d/cups-filters.conf
|
||||
sed "s/^parport_pc/#parport_pc/" -i $SDCARD/etc/modules-load.d/cups-filters.conf
|
||||
sed "s/^lp/#lp/" -i "${SDCARD}"/etc/modules-load.d/cups-filters.conf
|
||||
sed "s/^ppdev/#ppdev/" -i "${SDCARD}"/etc/modules-load.d/cups-filters.conf
|
||||
sed "s/^parport_pc/#parport_pc/" -i "${SDCARD}"/etc/modules-load.d/cups-filters.conf
|
||||
fi
|
||||
|
||||
# console fix due to Debian bug
|
||||
sed -e 's/CHARMAP=".*"/CHARMAP="'$CONSOLE_CHAR'"/g' -i $SDCARD/etc/default/console-setup
|
||||
sed -e 's/CHARMAP=".*"/CHARMAP="'$CONSOLE_CHAR'"/g' -i "${SDCARD}"/etc/default/console-setup
|
||||
|
||||
# change time zone data
|
||||
echo $TZDATA > $SDCARD/etc/timezone
|
||||
chroot $SDCARD /bin/bash -c "dpkg-reconfigure -f noninteractive tzdata >/dev/null 2>&1"
|
||||
echo "${TZDATA}" > "${SDCARD}"/etc/timezone
|
||||
chroot "${SDCARD}" /bin/bash -c "dpkg-reconfigure -f noninteractive tzdata >/dev/null 2>&1"
|
||||
|
||||
# set root password
|
||||
chroot $SDCARD /bin/bash -c "(echo $ROOTPWD;echo $ROOTPWD;) | passwd root >/dev/null 2>&1"
|
||||
chroot "${SDCARD}" /bin/bash -c "(echo $ROOTPWD;echo $ROOTPWD;) | passwd root >/dev/null 2>&1"
|
||||
# force change root password at first login
|
||||
chroot $SDCARD /bin/bash -c "chage -d 0 root"
|
||||
chroot "${SDCARD}" /bin/bash -c "chage -d 0 root"
|
||||
|
||||
# display welcome message at first root login
|
||||
touch $SDCARD/root/.not_logged_in_yet
|
||||
touch "${SDCARD}"/root/.not_logged_in_yet
|
||||
|
||||
# NOTE: this needs to be executed before family_tweaks
|
||||
local bootscript_src=${BOOTSCRIPT%%:*}
|
||||
local bootscript_dst=${BOOTSCRIPT##*:}
|
||||
cp $SRC/config/bootscripts/$bootscript_src $SDCARD/boot/$bootscript_dst
|
||||
cp "${SRC}/config/bootscripts/${bootscript_src}" "${SDCARD}/boot/${bootscript_dst}"
|
||||
|
||||
[[ -n $BOOTENV_FILE && -f $SRC/config/bootenv/$BOOTENV_FILE ]] && \
|
||||
cp $SRC/config/bootenv/$BOOTENV_FILE $SDCARD/boot/armbianEnv.txt
|
||||
cp "${SRC}/config/bootenv/${BOOTENV_FILE}" "${SDCARD}"/boot/armbianEnv.txt
|
||||
|
||||
# TODO: modify $bootscript_dst or armbianEnv.txt to make NFS boot universal
|
||||
# instead of copying sunxi-specific template
|
||||
if [[ $ROOTFS_TYPE == nfs ]]; then
|
||||
display_alert "Copying NFS boot script template"
|
||||
if [[ -f $SRC/userpatches/nfs-boot.cmd ]]; then
|
||||
cp $SRC/userpatches/nfs-boot.cmd $SDCARD/boot/boot.cmd
|
||||
cp "${SRC}"/userpatches/nfs-boot.cmd "${SDCARD}"/boot/boot.cmd
|
||||
else
|
||||
cp $SRC/config/templates/nfs-boot.cmd.template $SDCARD/boot/boot.cmd
|
||||
cp "${SRC}"/config/templates/nfs-boot.cmd.template "${SDCARD}"/boot/boot.cmd
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ -n $OVERLAY_PREFIX && -f $SDCARD/boot/armbianEnv.txt ]] && \
|
||||
echo "overlay_prefix=$OVERLAY_PREFIX" >> $SDCARD/boot/armbianEnv.txt
|
||||
echo "overlay_prefix=$OVERLAY_PREFIX" >> "${SDCARD}"/boot/armbianEnv.txt
|
||||
|
||||
[[ -n $DEFAULT_OVERLAYS && -f $SDCARD/boot/armbianEnv.txt ]] && \
|
||||
echo "overlays=${DEFAULT_OVERLAYS//,/ }" >> $SDCARD/boot/armbianEnv.txt
|
||||
echo "overlays=${DEFAULT_OVERLAYS//,/ }" >> "${SDCARD}"/boot/armbianEnv.txt
|
||||
|
||||
# initial date for fake-hwclock
|
||||
date -u '+%Y-%m-%d %H:%M:%S' > $SDCARD/etc/fake-hwclock.data
|
||||
date -u '+%Y-%m-%d %H:%M:%S' > "${SDCARD}"/etc/fake-hwclock.data
|
||||
|
||||
echo $HOST > $SDCARD/etc/hostname
|
||||
echo "${HOST}" > "${SDCARD}"/etc/hostname
|
||||
|
||||
# set hostname in hosts file
|
||||
cat <<-EOF > $SDCARD/etc/hosts
|
||||
cat <<-EOF > "${SDCARD}"/etc/hosts
|
||||
127.0.0.1 localhost $HOST
|
||||
::1 localhost $HOST ip6-localhost ip6-loopback
|
||||
fe00::0 ip6-localnet
|
||||
@@ -182,60 +184,60 @@ install_common()
|
||||
# freeze armbian packages
|
||||
if [[ $BSPFREEZE == yes ]]; then
|
||||
display_alert "Freezing Armbian packages" "$BOARD" "info"
|
||||
chroot $SDCARD /bin/bash -c "apt-mark hold ${CHOSEN_KERNEL} ${CHOSEN_KERNEL/image/headers} \
|
||||
linux-u-boot-${BOARD}-${BRANCH} ${CHOSEN_KERNEL/image/dtb}" >> $DEST/debug/install.log 2>&1
|
||||
chroot "${SDCARD}" /bin/bash -c "apt-mark hold ${CHOSEN_KERNEL} ${CHOSEN_KERNEL/image/headers} \
|
||||
linux-u-boot-${BOARD}-${BRANCH} ${CHOSEN_KERNEL/image/dtb}" >> "${DEST}"/debug/install.log 2>&1
|
||||
fi
|
||||
|
||||
# copy boot splash images
|
||||
cp $SRC/packages/blobs/splash/armbian-u-boot.bmp $SDCARD/boot/boot.bmp
|
||||
cp $SRC/packages/blobs/splash/armbian-desktop.png $SDCARD/boot/boot-desktop.png
|
||||
cp "${SRC}"/packages/blobs/splash/armbian-u-boot.bmp "${SDCARD}"/boot/boot.bmp
|
||||
cp "${SRC}"/packages/blobs/splash/armbian-desktop.png "${SDCARD}"/boot/boot-desktop.png
|
||||
|
||||
# execute $LINUXFAMILY-specific tweaks
|
||||
[[ $(type -t family_tweaks) == function ]] && family_tweaks
|
||||
|
||||
# enable additional services
|
||||
chroot $SDCARD /bin/bash -c "systemctl --no-reload enable armbian-firstrun.service armbian-firstrun-config.service armbian-zram-config.service armbian-hardware-optimize.service armbian-ramlog.service armbian-resize-filesystem.service armbian-hardware-monitor.service >/dev/null 2>&1"
|
||||
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload enable armbian-firstrun.service armbian-firstrun-config.service armbian-zram-config.service armbian-hardware-optimize.service armbian-ramlog.service armbian-resize-filesystem.service armbian-hardware-monitor.service >/dev/null 2>&1"
|
||||
|
||||
# copy "first run automated config, optional user configured"
|
||||
cp $SRC/packages/bsp/armbian_first_run.txt.template $SDCARD/boot/armbian_first_run.txt.template
|
||||
cp "${SRC}"/packages/bsp/armbian_first_run.txt.template "${SDCARD}"/boot/armbian_first_run.txt.template
|
||||
|
||||
# switch to beta repository at this stage if building nightly images
|
||||
[[ $IMAGE_TYPE == nightly ]] && echo "deb http://beta.armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > $SDCARD/etc/apt/sources.list.d/armbian.list
|
||||
[[ $IMAGE_TYPE == nightly ]] && echo "deb http://beta.armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${SDCARD}"/etc/apt/sources.list.d/armbian.list
|
||||
|
||||
# Cosmetic fix [FAILED] Failed to start Set console font and keymap at first boot
|
||||
[[ -f $SDCARD/etc/console-setup/cached_setup_font.sh ]] && sed -i "s/^printf '.*/printf '\\\033\%\%G'/g" $SDCARD/etc/console-setup/cached_setup_font.sh
|
||||
[[ -f $SDCARD/etc/console-setup/cached_setup_terminal.sh ]] && sed -i "s/^printf '.*/printf '\\\033\%\%G'/g" $SDCARD/etc/console-setup/cached_setup_terminal.sh
|
||||
[[ -f $SDCARD/etc/console-setup/cached_setup_keyboard.sh ]] && sed -i "s/-u/-x'/g" $SDCARD/etc/console-setup/cached_setup_keyboard.sh
|
||||
[[ -f $SDCARD/etc/console-setup/cached_setup_font.sh ]] && sed -i "s/^printf '.*/printf '\\\033\%\%G'/g" "${SDCARD}"/etc/console-setup/cached_setup_font.sh
|
||||
[[ -f $SDCARD/etc/console-setup/cached_setup_terminal.sh ]] && sed -i "s/^printf '.*/printf '\\\033\%\%G'/g" "${SDCARD}"/etc/console-setup/cached_setup_terminal.sh
|
||||
[[ -f $SDCARD/etc/console-setup/cached_setup_keyboard.sh ]] && sed -i "s/-u/-x'/g" "${SDCARD}"/etc/console-setup/cached_setup_keyboard.sh
|
||||
|
||||
# disable low-level kernel messages for non betas
|
||||
# TODO: enable only for desktop builds?
|
||||
if [[ -z $BETA ]]; then
|
||||
sed -i "s/^#kernel.printk*/kernel.printk/" $SDCARD/etc/sysctl.conf
|
||||
sed -i "s/^#kernel.printk*/kernel.printk/" "${SDCARD}"/etc/sysctl.conf
|
||||
fi
|
||||
|
||||
# disable repeated messages due to xconsole not being installed.
|
||||
[[ -f $SDCARD/etc/rsyslog.d/50-default.conf ]] && sed '/daemon\.\*\;mail.*/,/xconsole/ s/.*/#&/' -i $SDCARD/etc/rsyslog.d/50-default.conf
|
||||
[[ -f $SDCARD/etc/rsyslog.d/50-default.conf ]] && sed '/daemon\.\*\;mail.*/,/xconsole/ s/.*/#&/' -i "${SDCARD}"/etc/rsyslog.d/50-default.conf
|
||||
# disable deprecated parameter
|
||||
sed '/.*$KLogPermitNonKernelFacility.*/,// s/.*/#&/' -i $SDCARD/etc/rsyslog.conf
|
||||
sed '/.*$KLogPermitNonKernelFacility.*/,// s/.*/#&/' -i "${SDCARD}"/etc/rsyslog.conf
|
||||
|
||||
# enable getty on multiple serial consoles and adjust the speed if it is defined and different than 115200, example: ttyS0:15000000,ttyGS1
|
||||
ifs=$IFS
|
||||
for i in $(echo ${SERIALCON} | sed "s/,/ /g")
|
||||
do
|
||||
# add serial console to secure tty list
|
||||
[ -z "$(grep -w '^$i' $SDCARD/etc/securetty 2> /dev/null)" ] && echo "$i" >> $SDCARD/etc/securetty
|
||||
[ -z "$(grep -w '^$i' "${SDCARD}"/etc/securetty 2> /dev/null)" ] && echo "$i" >> "${SDCARD}"/etc/securetty
|
||||
IFS=':' read -r -a array <<< "$i"
|
||||
if [[ ${array[1]} != "115200" && -n ${array[1]} ]]; then
|
||||
# make a copy, fix speed and enable
|
||||
cp $SDCARD/lib/systemd/system/serial-getty@.service $SDCARD/lib/systemd/system/serial-getty@${array[0]}.service
|
||||
sed -i "s/--keep-baud 115200/--keep-baud ${array[1]},115200/" $SDCARD/lib/systemd/system/serial-getty@${array[0]}.service
|
||||
cp "${SDCARD}"/lib/systemd/system/serial-getty@.service "${SDCARD}"/lib/systemd/system/serial-getty@${array[0]}.service
|
||||
sed -i "s/--keep-baud 115200/--keep-baud ${array[1]},115200/" "${SDCARD}"/lib/systemd/system/serial-getty@${array[0]}.service
|
||||
fi
|
||||
display_alert "Enabling serial console" "${array[0]}" "info"
|
||||
chroot $SDCARD /bin/bash -c "systemctl daemon-reload" >> $DEST/debug/install.log 2>&1
|
||||
chroot $SDCARD /bin/bash -c "systemctl --no-reload enable serial-getty@${array[0]}.service" >> $DEST/debug/install.log 2>&1
|
||||
chroot "${SDCARD}" /bin/bash -c "systemctl daemon-reload" >> "${DEST}"/debug/install.log 2>&1
|
||||
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload enable serial-getty@${array[0]}.service" >> "${DEST}"/debug/install.log 2>&1
|
||||
if [[ ${array[0]} == "ttyGS0" && $LINUXFAMILY == sun8i && $BRANCH == default ]]; then
|
||||
mkdir -p $SDCARD/etc/systemd/system/serial-getty@ttyGS0.service.d
|
||||
cat <<-EOF > $SDCARD/etc/systemd/system/serial-getty@ttyGS0.service.d/10-switch-role.conf
|
||||
mkdir -p "${SDCARD}"/etc/systemd/system/serial-getty@ttyGS0.service.d
|
||||
cat <<-EOF > "${SDCARD}"/etc/systemd/system/serial-getty@ttyGS0.service.d/10-switch-role.conf
|
||||
[Service]
|
||||
ExecStartPre=-/bin/sh -c "echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role"
|
||||
EOF
|
||||
@@ -243,46 +245,46 @@ install_common()
|
||||
done
|
||||
IFS=$ifs
|
||||
|
||||
[[ $LINUXFAMILY == sun*i ]] && mkdir -p $SDCARD/boot/overlay-user
|
||||
[[ $LINUXFAMILY == sun*i ]] && mkdir -p "${SDCARD}"/boot/overlay-user
|
||||
|
||||
# to prevent creating swap file on NFS (needs specific kernel options)
|
||||
# and f2fs/btrfs (not recommended or needs specific kernel options)
|
||||
[[ $ROOTFS_TYPE != ext4 ]] && touch $SDCARD/var/swap
|
||||
[[ $ROOTFS_TYPE != ext4 ]] && touch "${SDCARD}"/var/swap
|
||||
|
||||
# install initial asound.state if defined
|
||||
mkdir -p $SDCARD/var/lib/alsa/
|
||||
[[ -n $ASOUND_STATE ]] && cp $SRC/packages/blobs/asound.state/$ASOUND_STATE $SDCARD/var/lib/alsa/asound.state
|
||||
mkdir -p "${SDCARD}"/var/lib/alsa/
|
||||
[[ -n $ASOUND_STATE ]] && cp "${SRC}/packages/blobs/asound.state/${ASOUND_STATE}" "${SDCARD}"/var/lib/alsa/asound.state
|
||||
|
||||
# save initial armbian-release state
|
||||
cp $SDCARD/etc/armbian-release $SDCARD/etc/armbian-image-release
|
||||
cp "${SDCARD}"/etc/armbian-release "${SDCARD}"/etc/armbian-image-release
|
||||
|
||||
# DNS fix. package resolvconf is not available everywhere
|
||||
if [ -d /etc/resolvconf/resolv.conf.d ]; then
|
||||
echo "nameserver $NAMESERVER" > $SDCARD/etc/resolvconf/resolv.conf.d/head
|
||||
echo "nameserver $NAMESERVER" > "${SDCARD}"/etc/resolvconf/resolv.conf.d/head
|
||||
fi
|
||||
|
||||
# premit root login via SSH for the first boot
|
||||
sed -i 's/#\?PermitRootLogin .*/PermitRootLogin yes/' $SDCARD/etc/ssh/sshd_config
|
||||
sed -i 's/#\?PermitRootLogin .*/PermitRootLogin yes/' "${SDCARD}"/etc/ssh/sshd_config
|
||||
|
||||
# enable PubkeyAuthentication. Enabled by default everywhere except on Jessie
|
||||
sed -i 's/#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' $SDCARD/etc/ssh/sshd_config
|
||||
sed -i 's/#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' "${SDCARD}"/etc/ssh/sshd_config
|
||||
|
||||
# configure network manager
|
||||
sed "s/managed=\(.*\)/managed=true/g" -i $SDCARD/etc/NetworkManager/NetworkManager.conf
|
||||
sed "s/managed=\(.*\)/managed=true/g" -i "${SDCARD}"/etc/NetworkManager/NetworkManager.conf
|
||||
|
||||
# Just regular DNS and maintain /etc/resolv.conf as a file
|
||||
sed "/dns/d" -i $SDCARD/etc/NetworkManager/NetworkManager.conf
|
||||
sed "s/\[main\]/\[main\]\ndns=default\nrc-manager=file/g" -i $SDCARD/etc/NetworkManager/NetworkManager.conf
|
||||
sed "/dns/d" -i "${SDCARD}"/etc/NetworkManager/NetworkManager.conf
|
||||
sed "s/\[main\]/\[main\]\ndns=default\nrc-manager=file/g" -i "${SDCARD}"/etc/NetworkManager/NetworkManager.conf
|
||||
if [[ -n $NM_IGNORE_DEVICES ]]; then
|
||||
mkdir -p $SDCARD/etc/NetworkManager/conf.d/
|
||||
cat <<-EOF > $SDCARD/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
|
||||
mkdir -p "${SDCARD}"/etc/NetworkManager/conf.d/
|
||||
cat <<-EOF > "${SDCARD}"/etc/NetworkManager/conf.d/10-ignore-interfaces.conf
|
||||
[keyfile]
|
||||
unmanaged-devices=$NM_IGNORE_DEVICES
|
||||
EOF
|
||||
fi
|
||||
|
||||
# nsswitch settings for sane DNS behavior: remove resolve, assure libnss-myhostname support
|
||||
sed "s/hosts\:.*/hosts: files mymachines dns myhostname/g" -i $SDCARD/etc/nsswitch.conf
|
||||
sed "s/hosts\:.*/hosts: files mymachines dns myhostname/g" -i "${SDCARD}"/etc/nsswitch.conf
|
||||
}
|
||||
|
||||
install_distribution_specific()
|
||||
@@ -291,28 +293,28 @@ install_distribution_specific()
|
||||
case $RELEASE in
|
||||
jessie)
|
||||
if [[ -z $NM_IGNORE_DEVICES ]]; then
|
||||
echo "# Network Manager under Jessie doesn't work properly. Workaround" >> $SDCARD/etc/network/interfaces.d/eth0.conf
|
||||
echo "auto eth0" >> $SDCARD/etc/network/interfaces.d/eth0.conf
|
||||
echo "iface eth0 inet dhcp" >> $SDCARD/etc/network/interfaces.d/eth0.conf
|
||||
echo "[keyfile]" >> $SDCARD/etc/NetworkManager/NetworkManager.conf
|
||||
echo "unmanaged-devices=interface-name:eth0" >> $SDCARD/etc/NetworkManager/NetworkManager.conf
|
||||
echo "# Network Manager under Jessie doesn't work properly. Workaround" >> "${SDCARD}"/etc/network/interfaces.d/eth0.conf
|
||||
echo "auto eth0" >> "${SDCARD}"/etc/network/interfaces.d/eth0.conf
|
||||
echo "iface eth0 inet dhcp" >> "${SDCARD}"/etc/network/interfaces.d/eth0.conf
|
||||
echo "[keyfile]" >> "${SDCARD}"/etc/NetworkManager/NetworkManager.conf
|
||||
echo "unmanaged-devices=interface-name:eth0" >> "${SDCARD}"/etc/NetworkManager/NetworkManager.conf
|
||||
fi
|
||||
;;
|
||||
|
||||
xenial)
|
||||
# remove legal info from Ubuntu
|
||||
[[ -f $SDCARD/etc/legal ]] && rm $SDCARD/etc/legal
|
||||
[[ -f $SDCARD/etc/legal ]] && rm "${SDCARD}"/etc/legal
|
||||
|
||||
# disable not working or unneeded services
|
||||
# ureadahead needs kernel tracing options that AFAIK are present only in mainline
|
||||
chroot $SDCARD /bin/bash -c "systemctl --no-reload mask ondemand.service ureadahead.service setserial.service etc-setserial.service >/dev/null 2>&1"
|
||||
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload mask ondemand.service ureadahead.service setserial.service etc-setserial.service >/dev/null 2>&1"
|
||||
;;
|
||||
|
||||
stretch)
|
||||
# remove doubled uname from motd
|
||||
[[ -f $SDCARD/etc/update-motd.d/10-uname ]] && rm $SDCARD/etc/update-motd.d/10-uname
|
||||
[[ -f $SDCARD/etc/update-motd.d/10-uname ]] && rm "${SDCARD}"/etc/update-motd.d/10-uname
|
||||
# rc.local is not existing in stretch but we might need it
|
||||
cat <<-EOF > $SDCARD/etc/rc.local
|
||||
cat <<-EOF > "${SDCARD}"/etc/rc.local
|
||||
#!/bin/sh -e
|
||||
#
|
||||
# rc.local
|
||||
@@ -328,15 +330,15 @@ install_distribution_specific()
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x $SDCARD/etc/rc.local
|
||||
chmod +x "${SDCARD}"/etc/rc.local
|
||||
;;
|
||||
bionic)
|
||||
# remove doubled uname from motd
|
||||
[[ -f $SDCARD/etc/update-motd.d/10-uname ]] && rm $SDCARD/etc/update-motd.d/10-uname
|
||||
[[ -f $SDCARD/etc/update-motd.d/10-uname ]] && rm "${SDCARD}"/etc/update-motd.d/10-uname
|
||||
# remove motd news from motd.ubuntu.com
|
||||
[[ -f $SDCARD/etc/default/motd-news ]] && sed -i "s/^ENABLED=.*/ENABLED=0/" $SDCARD/etc/default/motd-news
|
||||
[[ -f $SDCARD/etc/default/motd-news ]] && sed -i "s/^ENABLED=.*/ENABLED=0/" "${SDCARD}"/etc/default/motd-news
|
||||
# rc.local is not existing in bionic but we might need it
|
||||
cat <<-EOF > $SDCARD/etc/rc.local
|
||||
cat <<-EOF > "${SDCARD}"/etc/rc.local
|
||||
#!/bin/sh -e
|
||||
#
|
||||
# rc.local
|
||||
@@ -352,28 +354,28 @@ install_distribution_specific()
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x $SDCARD/etc/rc.local
|
||||
chmod +x "${SDCARD}"/etc/rc.local
|
||||
# Basic Netplan config. Let NetworkManager manage all devices on this system
|
||||
cat <<-EOF > $SDCARD/etc/netplan/armbian-default.yaml
|
||||
cat <<-EOF > "${SDCARD}"/etc/netplan/armbian-default.yaml
|
||||
network:
|
||||
version: 2
|
||||
renderer: NetworkManager
|
||||
EOF
|
||||
# DNS fix
|
||||
sed -i "s/#DNS=.*/DNS=$NAMESERVER/g" $SDCARD/etc/systemd/resolved.conf
|
||||
sed -i "s/#DNS=.*/DNS=$NAMESERVER/g" "${SDCARD}"/etc/systemd/resolved.conf
|
||||
# Journal service adjustements
|
||||
sed -i "s/#Storage=.*/Storage=volatile/g" $SDCARD/etc/systemd/journald.conf
|
||||
sed -i "s/#Compress=.*/Compress=yes/g" $SDCARD/etc/systemd/journald.conf
|
||||
sed -i "s/#RateLimitIntervalSec=.*/RateLimitIntervalSec=30s/g" $SDCARD/etc/systemd/journald.conf
|
||||
sed -i "s/#RateLimitBurst=.*/RateLimitBurst=10000/g" $SDCARD/etc/systemd/journald.conf
|
||||
sed -i "s/#Storage=.*/Storage=volatile/g" "${SDCARD}"/etc/systemd/journald.conf
|
||||
sed -i "s/#Compress=.*/Compress=yes/g" "${SDCARD}"/etc/systemd/journald.conf
|
||||
sed -i "s/#RateLimitIntervalSec=.*/RateLimitIntervalSec=30s/g" "${SDCARD}"/etc/systemd/journald.conf
|
||||
sed -i "s/#RateLimitBurst=.*/RateLimitBurst=10000/g" "${SDCARD}"/etc/systemd/journald.conf
|
||||
# disable conflicting services
|
||||
chroot $SDCARD /bin/bash -c "systemctl --no-reload mask ondemand.service >/dev/null 2>&1"
|
||||
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload mask ondemand.service >/dev/null 2>&1"
|
||||
;;
|
||||
buster)
|
||||
# remove doubled uname from motd
|
||||
[[ -f $SDCARD/etc/update-motd.d/10-uname ]] && rm $SDCARD/etc/update-motd.d/10-uname
|
||||
[[ -f $SDCARD/etc/update-motd.d/10-uname ]] && rm "${SDCARD}"/etc/update-motd.d/10-uname
|
||||
# rc.local is not existing in stretch but we might need it
|
||||
cat <<-EOF > $SDCARD/etc/rc.local
|
||||
cat <<-EOF > "${SDCARD}"/etc/rc.local
|
||||
#!/bin/sh -e
|
||||
#
|
||||
# rc.local
|
||||
@@ -389,13 +391,13 @@ install_distribution_specific()
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x $SDCARD/etc/rc.local
|
||||
chmod +x "${SDCARD}"/etc/rc.local
|
||||
;;
|
||||
disco)
|
||||
# remove motd news from motd.ubuntu.com
|
||||
[[ -f $SDCARD/etc/default/motd-news ]] && sed -i "s/^ENABLED=.*/ENABLED=0/" $SDCARD/etc/default/motd-news
|
||||
[[ -f $SDCARD/etc/default/motd-news ]] && sed -i "s/^ENABLED=.*/ENABLED=0/" "${SDCARD}"/etc/default/motd-news
|
||||
# rc.local is not existing in disco but we might need it
|
||||
cat <<-EOF > $SDCARD/etc/rc.local
|
||||
cat <<-EOF > "${SDCARD}"/etc/rc.local
|
||||
#!/bin/sh -e
|
||||
#
|
||||
# rc.local
|
||||
@@ -411,22 +413,22 @@ install_distribution_specific()
|
||||
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x $SDCARD/etc/rc.local
|
||||
chmod +x "${SDCARD}"/etc/rc.local
|
||||
# Basic Netplan config. Let NetworkManager manage all devices on this system
|
||||
cat <<-EOF > $SDCARD/etc/netplan/armbian-default.yaml
|
||||
cat <<-EOF > "${SDCARD}"/etc/netplan/armbian-default.yaml
|
||||
network:
|
||||
version: 2
|
||||
renderer: NetworkManager
|
||||
EOF
|
||||
# DNS fix
|
||||
sed -i "s/#DNS=.*/DNS=$NAMESERVER/g" $SDCARD/etc/systemd/resolved.conf
|
||||
sed -i "s/#DNS=.*/DNS=$NAMESERVER/g" "${SDCARD}"/etc/systemd/resolved.conf
|
||||
# Journal service adjustements
|
||||
sed -i "s/#Storage=.*/Storage=volatile/g" $SDCARD/etc/systemd/journald.conf
|
||||
sed -i "s/#Compress=.*/Compress=yes/g" $SDCARD/etc/systemd/journald.conf
|
||||
sed -i "s/#RateLimitIntervalSec=.*/RateLimitIntervalSec=30s/g" $SDCARD/etc/systemd/journald.conf
|
||||
sed -i "s/#RateLimitBurst=.*/RateLimitBurst=10000/g" $SDCARD/etc/systemd/journald.conf
|
||||
sed -i "s/#Storage=.*/Storage=volatile/g" "${SDCARD}"/etc/systemd/journald.conf
|
||||
sed -i "s/#Compress=.*/Compress=yes/g" "${SDCARD}"/etc/systemd/journald.conf
|
||||
sed -i "s/#RateLimitIntervalSec=.*/RateLimitIntervalSec=30s/g" "${SDCARD}"/etc/systemd/journald.conf
|
||||
sed -i "s/#RateLimitBurst=.*/RateLimitBurst=10000/g" "${SDCARD}"/etc/systemd/journald.conf
|
||||
# disable conflicting services
|
||||
chroot $SDCARD /bin/bash -c "systemctl --no-reload mask ondemand.service >/dev/null 2>&1"
|
||||
chroot "${SDCARD}" /bin/bash -c "systemctl --no-reload mask ondemand.service >/dev/null 2>&1"
|
||||
;;
|
||||
|
||||
esac
|
||||
@@ -435,11 +437,11 @@ install_distribution_specific()
|
||||
post_debootstrap_tweaks()
|
||||
{
|
||||
# remove service start blockers and QEMU binary
|
||||
rm -f $SDCARD/sbin/initctl $SDCARD/sbin/start-stop-daemon
|
||||
chroot $SDCARD /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/initctl"
|
||||
chroot $SDCARD /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/start-stop-daemon"
|
||||
rm -f "${SDCARD}"/sbin/initctl "${SDCARD}"/sbin/start-stop-daemon
|
||||
chroot "${SDCARD}" /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/initctl"
|
||||
chroot "${SDCARD}" /bin/bash -c "dpkg-divert --quiet --local --rename --remove /sbin/start-stop-daemon"
|
||||
|
||||
|
||||
rm -f $SDCARD/usr/sbin/policy-rc.d $SDCARD/usr/bin/$QEMU_BINARY
|
||||
rm -f "${SDCARD}"/usr/sbin/policy-rc.d "${SDCARD}/usr/bin/${QEMU_BINARY}"
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
@@ -24,54 +26,56 @@ fel_prepare_target()
|
||||
{
|
||||
if [[ -f $SRC/userpatches/fel-boot.cmd ]]; then
|
||||
display_alert "Using custom boot script" "userpatches/fel-boot.cmd" "info"
|
||||
cp $SRC/userpatches/fel-boot.cmd $FEL_ROOTFS/boot/boot.cmd
|
||||
cp "${SRC}"/userpatches/fel-boot.cmd "${FEL_ROOTFS}"/boot/boot.cmd
|
||||
else
|
||||
cp $SRC/config/templates/fel-boot.cmd.template $FEL_ROOTFS/boot/boot.cmd
|
||||
cp "${SRC}"/config/templates/fel-boot.cmd.template "${FEL_ROOTFS}"/boot/boot.cmd
|
||||
fi
|
||||
if [[ -z $FEL_LOCAL_IP ]]; then
|
||||
FEL_LOCAL_IP=$(ifconfig $FEL_NET_IFNAME | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
|
||||
FEL_LOCAL_IP=$(ifconfig "${FEL_NET_IFNAME}" | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
|
||||
fi
|
||||
sed -i "s#BRANCH#$BRANCH#" $FEL_ROOTFS/boot/boot.cmd
|
||||
sed -i "s#FEL_LOCAL_IP#$FEL_LOCAL_IP#" $FEL_ROOTFS/boot/boot.cmd
|
||||
sed -i "s#FEL_ROOTFS#$FEL_ROOTFS#" $FEL_ROOTFS/boot/boot.cmd
|
||||
mkimage -C none -A arm -T script -d $FEL_ROOTFS/boot/boot.cmd $FEL_ROOTFS/boot/boot.scr > /dev/null
|
||||
sed -i "s#BRANCH#$BRANCH#" "${FEL_ROOTFS}"/boot/boot.cmd
|
||||
sed -i "s#FEL_LOCAL_IP#$FEL_LOCAL_IP#" "${FEL_ROOTFS}"/boot/boot.cmd
|
||||
sed -i "s#FEL_ROOTFS#$FEL_ROOTFS#" "${FEL_ROOTFS}"/boot/boot.cmd
|
||||
mkimage -C none -A arm -T script -d "${FEL_ROOTFS}"/boot/boot.cmd "${FEL_ROOTFS}"/boot/boot.scr > /dev/null
|
||||
|
||||
# kill /etc/fstab on target
|
||||
echo > $FEL_ROOTFS/etc/fstab
|
||||
echo "/dev/nfs / nfs defaults 0 0" >> $FEL_ROOTFS/etc/fstab
|
||||
echo "tmpfs /tmp tmpfs defaults,nosuid 0 0" >> $FEL_ROOTFS/etc/fstab
|
||||
echo > "${FEL_ROOTFS}"/etc/fstab
|
||||
echo "/dev/nfs / nfs defaults 0 0" >> "${FEL_ROOTFS}"/etc/fstab
|
||||
echo "tmpfs /tmp tmpfs defaults,nosuid 0 0" >> "${FEL_ROOTFS}"/etc/fstab
|
||||
}
|
||||
|
||||
fel_load()
|
||||
{
|
||||
# update each time in case boot/script.bin link was changed in multi-board images
|
||||
local dtb_file
|
||||
if [[ -n $FEL_DTB_FILE ]]; then
|
||||
local dtb_file=$FEL_DTB_FILE
|
||||
dtb_file=$FEL_DTB_FILE
|
||||
else
|
||||
if [[ $BRANCH == default ]]; then
|
||||
# script.bin is either regular file or absolute symlink
|
||||
if [[ -L $FEL_ROOTFS/boot/script.bin ]]; then
|
||||
local dtb_file=boot/bin/$(basename $(readlink $FEL_ROOTFS/boot/script.bin))
|
||||
dtb_file=boot/bin/$(basename "$(readlink "${FEL_ROOTFS}"/boot/script.bin)")
|
||||
else
|
||||
local dtb_file=boot/script.bin
|
||||
dtb_file=boot/script.bin
|
||||
fi
|
||||
else
|
||||
local dtb_file=boot/dtb/$(grep CONFIG_DEFAULT_DEVICE_TREE $FEL_ROOTFS/usr/lib/u-boot/$BOOTCONFIG | cut -d '"' -f2).dtb
|
||||
dtb_file=boot/dtb/$(grep CONFIG_DEFAULT_DEVICE_TREE "${FEL_ROOTFS}/usr/lib/u-boot/${BOOTCONFIG}" | cut -d '"' -f2).dtb
|
||||
fi
|
||||
fi
|
||||
[[ $(type -t fel_pre_load) == function ]] && fel_pre_load
|
||||
|
||||
display_alert "Loading files via" "FEL USB" "info"
|
||||
sunxi-fel $FEL_EXTRA_ARGS -p uboot $FEL_ROOTFS/usr/lib/${CHOSEN_UBOOT}_${REVISION}_armhf/u-boot-sunxi-with-spl.bin \
|
||||
write 0x42000000 $FEL_ROOTFS/boot/zImage \
|
||||
write 0x43000000 $FEL_ROOTFS/$dtb_file \
|
||||
write 0x43300000 $FEL_ROOTFS/boot/uInitrd \
|
||||
write 0x43100000 $FEL_ROOTFS/boot/boot.scr
|
||||
sunxi-fel "${FEL_EXTRA_ARGS}" -p uboot "${FEL_ROOTFS}/usr/lib/${CHOSEN_UBOOT}_${REVISION}_armhf/u-boot-sunxi-with-spl.bin" \
|
||||
write 0x42000000 "${FEL_ROOTFS}"/boot/zImage \
|
||||
write 0x43000000 "${FEL_ROOTFS}/${dtb_file}" \
|
||||
write 0x43300000 "${FEL_ROOTFS}"/boot/uInitrd \
|
||||
write 0x43100000 "${FEL_ROOTFS}"/boot/boot.scr
|
||||
}
|
||||
|
||||
if [[ -f $SRC/userpatches/fel-hooks.sh ]]; then
|
||||
display_alert "Using additional FEL hooks in" "userpatches/fel-hooks.sh" "info"
|
||||
source $SRC/userpatches/fel-hooks.sh
|
||||
# shellcheck source=/dev/null
|
||||
source "${SRC}"/userpatches/fel-hooks.sh
|
||||
fi
|
||||
|
||||
# basic sanity check
|
||||
@@ -83,11 +87,11 @@ if [[ -n $FEL_ROOTFS ]]; then
|
||||
while [[ $RES != q ]]; do
|
||||
if [[ $FEL_AUTO != yes ]]; then
|
||||
display_alert "Connect device in FEL mode and press" "<Enter>" "info"
|
||||
read
|
||||
read -r
|
||||
fi
|
||||
fel_load
|
||||
display_alert "Press any key to boot again, <q> to finish" "FEL" "info"
|
||||
read -n 1 RES
|
||||
read -r -n 1 RES
|
||||
echo
|
||||
done
|
||||
service nfs-kernel-server restart
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
@@ -25,10 +27,10 @@
|
||||
mount_chroot()
|
||||
{
|
||||
local target=$1
|
||||
mount -t proc chproc $target/proc
|
||||
mount -t sysfs chsys $target/sys
|
||||
mount -t devtmpfs chdev $target/dev || mount --bind /dev $target/dev
|
||||
mount -t devpts chpts $target/dev/pts
|
||||
mount -t proc chproc "${target}"/proc
|
||||
mount -t sysfs chsys "${target}"/sys
|
||||
mount -t devtmpfs chdev "${target}"/dev || mount --bind /dev "${target}"/dev
|
||||
mount -t devpts chpts "${target}"/dev/pts
|
||||
} #############################################################################
|
||||
|
||||
# umount_chroot <target>
|
||||
@@ -38,10 +40,10 @@ mount_chroot()
|
||||
umount_chroot()
|
||||
{
|
||||
local target=$1
|
||||
umount -l $target/dev/pts >/dev/null 2>&1
|
||||
umount -l $target/dev >/dev/null 2>&1
|
||||
umount -l $target/proc >/dev/null 2>&1
|
||||
umount -l $target/sys >/dev/null 2>&1
|
||||
umount -l "${target}"/dev/pts >/dev/null 2>&1
|
||||
umount -l "${target}"/dev >/dev/null 2>&1
|
||||
umount -l "${target}"/proc >/dev/null 2>&1
|
||||
umount -l "${target}"/sys >/dev/null 2>&1
|
||||
} #############################################################################
|
||||
|
||||
# unmount_on_exit
|
||||
@@ -49,14 +51,14 @@ umount_chroot()
|
||||
unmount_on_exit()
|
||||
{
|
||||
trap - INT TERM EXIT
|
||||
umount_chroot "$SDCARD/"
|
||||
umount -l $SDCARD/tmp >/dev/null 2>&1
|
||||
umount -l $SDCARD >/dev/null 2>&1
|
||||
umount -l $MOUNT/boot >/dev/null 2>&1
|
||||
umount -l $MOUNT >/dev/null 2>&1
|
||||
[[ $CRYPTROOT_ENABLE == yes ]] && cryptsetup luksClose $ROOT_MAPPER
|
||||
losetup -d $LOOP >/dev/null 2>&1
|
||||
rm -rf --one-file-system $SDCARD
|
||||
umount_chroot "${SDCARD}/"
|
||||
umount -l "${SDCARD}"/tmp >/dev/null 2>&1
|
||||
umount -l "${SDCARD}" >/dev/null 2>&1
|
||||
umount -l "${MOUNT}"/boot >/dev/null 2>&1
|
||||
umount -l "${MOUNT}" >/dev/null 2>&1
|
||||
[[ $CRYPTROOT_ENABLE == yes ]] && cryptsetup luksClose "${ROOT_MAPPER}"
|
||||
losetup -d "${LOOP}" >/dev/null 2>&1
|
||||
rm -rf --one-file-system "${SDCARD}"
|
||||
exit_with_error "debootstrap-ng was interrupted"
|
||||
} #############################################################################
|
||||
|
||||
@@ -68,7 +70,7 @@ check_loop_device()
|
||||
if [[ ! -b $device ]]; then
|
||||
if [[ $CONTAINER_COMPAT == yes && -b /tmp/$device ]]; then
|
||||
display_alert "Creating device node" "$device"
|
||||
mknod -m0660 $device b 0x$(stat -c '%t' "/tmp/$device") 0x$(stat -c '%T' "/tmp/$device")
|
||||
mknod -m0660 "${device}" b "0x$(stat -c '%t' "/tmp/$device")" "0x$(stat -c '%T' "/tmp/$device")"
|
||||
else
|
||||
exit_with_error "Device node $device does not exist"
|
||||
fi
|
||||
@@ -79,8 +81,8 @@ install_external_applications()
|
||||
{
|
||||
display_alert "Installing extra applications and drivers" "" "info"
|
||||
|
||||
for plugin in $SRC/packages/extras/*.sh; do
|
||||
source $plugin
|
||||
for plugin in "${SRC}"/packages/extras/*.sh; do
|
||||
source "${plugin}"
|
||||
done
|
||||
} #############################################################################
|
||||
|
||||
@@ -95,7 +97,7 @@ write_uboot()
|
||||
local loop=$1
|
||||
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/
|
||||
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"
|
||||
[[ $? -ne 0 ]] && exit_with_error "U-boot bootloader failed to install" "@host"
|
||||
rm -r /tmp/u-boot/
|
||||
@@ -105,17 +107,17 @@ write_uboot()
|
||||
customize_image()
|
||||
{
|
||||
# for users that need to prepare files at host
|
||||
[[ -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
|
||||
mkdir -p $SDCARD/tmp/overlay
|
||||
[[ -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
|
||||
mkdir -p "${SDCARD}"/tmp/overlay
|
||||
# util-linux >= 2.27 required
|
||||
mount -o bind,ro $SRC/userpatches/overlay $SDCARD/tmp/overlay
|
||||
mount -o bind,ro "${SRC}"/userpatches/overlay "${SDCARD}"/tmp/overlay
|
||||
display_alert "Calling image customization script" "customize-image.sh" "info"
|
||||
chroot $SDCARD /bin/bash -c "/tmp/customize-image.sh $RELEASE $LINUXFAMILY $BOARD $BUILD_DESKTOP"
|
||||
chroot "${SDCARD}" /bin/bash -c "/tmp/customize-image.sh $RELEASE $LINUXFAMILY $BOARD $BUILD_DESKTOP"
|
||||
CUSTOMIZE_IMAGE_RC=$?
|
||||
umount $SDCARD/tmp/overlay
|
||||
mountpoint -q $SDCARD/tmp/overlay || rm -r $SDCARD/tmp/overlay
|
||||
umount "${SDCARD}"/tmp/overlay
|
||||
mountpoint -q "${SDCARD}"/tmp/overlay || rm -r "${SDCARD}"/tmp/overlay
|
||||
if [[ $CUSTOMIZE_IMAGE_RC != 0 ]]; then
|
||||
exit_with_error "customize-image.sh exited with error (rc: $CUSTOMIZE_IMAGE_RC)"
|
||||
fi
|
||||
@@ -124,9 +126,10 @@ customize_image()
|
||||
install_deb_chroot()
|
||||
{
|
||||
local package=$1
|
||||
local name=$(basename $package)
|
||||
cp $package $SDCARD/root/$name
|
||||
local name
|
||||
name=$(basename "${package}")
|
||||
cp "${package}" "${SDCARD}/root/${name}"
|
||||
display_alert "Installing" "$name"
|
||||
chroot $SDCARD /bin/bash -c "dpkg -i /root/$name" >> $DEST/debug/install.log 2>&1
|
||||
rm -f $SDCARD/root/$name
|
||||
chroot "${SDCARD}" /bin/bash -c "dpkg -i /root/$name" >> "${DEST}"/debug/install.log 2>&1
|
||||
rm -f "${SDCARD}/root/${name}"
|
||||
}
|
||||
|
||||
@@ -15,13 +15,15 @@ SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||
SCRIPTPATH=${SCRIPTPATH//lib}
|
||||
|
||||
# load user config
|
||||
# shellcheck source=/dev/null
|
||||
[[ -f "${SCRIPTPATH}userpatches/lib.config" ]] && source "${SCRIPTPATH}/userpatches/lib.config"
|
||||
|
||||
# define debs path
|
||||
POT="${SCRIPTPATH}/output/debs/"
|
||||
|
||||
# load functions
|
||||
source ${SCRIPTPATH}lib/general.sh
|
||||
# shellcheck source=general.sh
|
||||
source "${SCRIPTPATH}"lib/general.sh
|
||||
|
||||
DISTROS=("jessie" "xenial" "stretch" "bionic" "buster" "disco")
|
||||
|
||||
@@ -30,18 +32,18 @@ ParseOptions() {
|
||||
serve)
|
||||
# display repository content
|
||||
display_alert "Serving content" "common utils" "ext"
|
||||
aptly serve -listen=:8080 -config=${SCRIPTPATH}config/aptly.conf
|
||||
aptly serve -listen=:8080 -config="${SCRIPTPATH}"config/aptly.conf
|
||||
exit 0
|
||||
;;
|
||||
show)
|
||||
# display repository content
|
||||
for release in "${DISTROS[@]}"; do
|
||||
display_alert "Displaying repository contents for" "$release" "ext"
|
||||
aptly repo show -with-packages -config=${SCRIPTPATH}config/aptly.conf $release | tail -n +7
|
||||
aptly repo show -with-packages -config=${SCRIPTPATH}config/aptly.conf ${release}-desktop | tail -n +7
|
||||
aptly repo show -with-packages -config="${SCRIPTPATH}"config/aptly.conf "${release}" | tail -n +7
|
||||
aptly repo show -with-packages -config="${SCRIPTPATH}"config/aptly.conf "${release}-desktop" | tail -n +7
|
||||
done
|
||||
display_alert "Displaying repository contents for" "common utils" "ext"
|
||||
aptly repo show -with-packages -config=${SCRIPTPATH}config/aptly.conf utils | tail -n +7
|
||||
aptly repo show -with-packages -config="${SCRIPTPATH}"config/aptly.conf utils | tail -n +7
|
||||
echo "done."
|
||||
exit 0
|
||||
;;
|
||||
@@ -50,7 +52,7 @@ ParseOptions() {
|
||||
# run repository update
|
||||
addtorepo "$@" ""
|
||||
# add a key to repo
|
||||
cp ${SCRIPTPATH}config/armbian.key ${SCRIPTPATH}output/repository/public
|
||||
cp "${SCRIPTPATH}"config/armbian.key "${SCRIPTPATH}"output/repository/public
|
||||
exit 0
|
||||
;;
|
||||
purge)
|
||||
@@ -58,7 +60,7 @@ ParseOptions() {
|
||||
repo-remove-old-packages "$release" "armhf" "3"
|
||||
repo-remove-old-packages "$release" "arm64" "3"
|
||||
repo-remove-old-packages "$release" "all" "3"
|
||||
aptly -config=${SCRIPTPATH}config/aptly.conf -passphrase=$GPG_PASS publish update $release
|
||||
aptly -config="${SCRIPTPATH}"config/aptly.conf -passphrase="${GPG_PASS}" publish update "${release}"
|
||||
# example to remove all packages from bionic that contain source in the name
|
||||
# aptly repo remove -config=${SCRIPTPATH}config/aptly.conf bionic 'Name (% *-source*)'
|
||||
done
|
||||
@@ -81,18 +83,19 @@ repo-remove-old-packages() {
|
||||
local arch=$2
|
||||
local keep=$3
|
||||
|
||||
for pkg in $(aptly repo search -config=${SCRIPTPATH}config/aptly.conf $repo "Architecture ($arch)" | grep -v "ERROR: no results" | sort -rV); do
|
||||
local pkg_name=$(echo $pkg | cut -d_ -f1)
|
||||
for pkg in $(aptly repo search -config="${SCRIPTPATH}"config/aptly.conf "${repo}" "Architecture ($arch)" | grep -v "ERROR: no results" | sort -rV); do
|
||||
local pkg_name
|
||||
pkg_name=$(echo "${pkg}" | cut -d_ -f1)
|
||||
if [ "$pkg_name" != "$cur_pkg" ]; then
|
||||
local count=0
|
||||
local deleted=""
|
||||
local cur_pkg="$pkg_name"
|
||||
fi
|
||||
test -n "$deleted" && continue
|
||||
let count+=1
|
||||
if [ $count -gt $keep ]; then
|
||||
pkg_version=$(echo $pkg | cut -d_ -f2)
|
||||
aptly repo remove -config=${SCRIPTPATH}config/aptly.conf $repo "Name ($pkg_name), Version (<= $pkg_version)"
|
||||
((count+=1))
|
||||
if [[ $count -gt $keep ]]; then
|
||||
pkg_version=$(echo "${pkg}" | cut -d_ -f2)
|
||||
aptly repo remove -config="${SCRIPTPATH}"config/aptly.conf "${repo}" "Name ($pkg_name), Version (<= $pkg_version)"
|
||||
deleted='yes'
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user