mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
Shellcheck fixes 3 (#2054)
* lib/general.sh: Lint via shellcheck * lib/compilation-prepare.sh: Lint via shellcheck
This commit is contained in:
365
lib/general.sh
365
lib/general.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
|
||||
@@ -38,50 +40,50 @@ cleaning()
|
||||
{
|
||||
case $1 in
|
||||
debs) # delete ${DEB_STORAGE} for current branch and family
|
||||
if [[ -d ${DEB_STORAGE} ]]; then
|
||||
if [[ -d "${DEB_STORAGE}" ]]; then
|
||||
display_alert "Cleaning ${DEB_STORAGE} for" "$BOARD $BRANCH" "info"
|
||||
# easier than dealing with variable expansion and escaping dashes in file names
|
||||
find ${DEB_STORAGE} -name "${CHOSEN_UBOOT}_*.deb" -delete
|
||||
find ${DEB_STORAGE} \( -name "${CHOSEN_KERNEL}_*.deb" -o \
|
||||
find "${DEB_STORAGE}" -name "${CHOSEN_UBOOT}_*.deb" -delete
|
||||
find "${DEB_STORAGE}" \( -name "${CHOSEN_KERNEL}_*.deb" -o \
|
||||
-name "armbian-*.deb" -o \
|
||||
-name "${CHOSEN_KERNEL/image/dtb}_*.deb" -o \
|
||||
-name "${CHOSEN_KERNEL/image/headers}_*.deb" -o \
|
||||
-name "${CHOSEN_KERNEL/image/source}_*.deb" -o \
|
||||
-name "${CHOSEN_KERNEL/image/firmware-image}_*.deb" \) -delete
|
||||
[[ -n $RELEASE ]] && rm -f ${DEB_STORAGE}/$RELEASE/${CHOSEN_ROOTFS}_*.deb
|
||||
[[ -n $RELEASE ]] && rm -f ${DEB_STORAGE}/$RELEASE/armbian-desktop-${RELEASE}_*.deb
|
||||
[[ -n $RELEASE ]] && rm -f "${DEB_STORAGE}/${RELEASE}/${CHOSEN_ROOTFS}"_*.deb
|
||||
[[ -n $RELEASE ]] && rm -f "${DEB_STORAGE}/${RELEASE}/armbian-desktop-${RELEASE}"_*.deb
|
||||
fi
|
||||
;;
|
||||
|
||||
extras) # delete ${DEB_STORAGE}/extra/$RELEASE for all architectures
|
||||
if [[ -n $RELEASE && -d ${DEB_STORAGE}/extra/$RELEASE ]]; then
|
||||
display_alert "Cleaning ${DEB_STORAGE}/extra for" "$RELEASE" "info"
|
||||
rm -rf ${DEB_STORAGE}/extra/$RELEASE
|
||||
rm -rf "${DEB_STORAGE}/extra/${RELEASE}"
|
||||
fi
|
||||
;;
|
||||
|
||||
alldebs) # delete output/debs
|
||||
[[ -d ${DEB_STORAGE} ]] && display_alert "Cleaning" "${DEB_STORAGE}" "info" && rm -rf ${DEB_STORAGE}/*
|
||||
[[ -d "${DEB_STORAGE}" ]] && display_alert "Cleaning" "${DEB_STORAGE}" "info" && rm -rf "${DEB_STORAGE}"/*
|
||||
;;
|
||||
|
||||
cache) # delete output/cache
|
||||
[[ -d $SRC/cache/rootfs ]] && display_alert "Cleaning" "rootfs cache (all)" "info" && find $SRC/cache/rootfs -type f -delete
|
||||
[[ -d "${SRC}"/cache/rootfs ]] && display_alert "Cleaning" "rootfs cache (all)" "info" && find "${SRC}"/cache/rootfs -type f -delete
|
||||
;;
|
||||
|
||||
images) # delete output/images
|
||||
[[ -d $DEST/images ]] && display_alert "Cleaning" "output/images" "info" && rm -rf $DEST/images/*
|
||||
[[ -d "${DEST}"/images ]] && display_alert "Cleaning" "output/images" "info" && rm -rf "${DEST}"/images/*
|
||||
;;
|
||||
|
||||
sources) # delete output/sources and output/buildpkg
|
||||
[[ -d $SRC/cache/sources ]] && display_alert "Cleaning" "sources" "info" && rm -rf $SRC/cache/sources/* $DEST/buildpkg/*
|
||||
[[ -d "${SRC}"/cache/sources ]] && display_alert "Cleaning" "sources" "info" && rm -rf "${SRC}"/cache/sources/* "${DEST}"/buildpkg/*
|
||||
;;
|
||||
|
||||
oldcache) # remove old `cache/rootfs` except for the newest 8 files
|
||||
if [[ -d $SRC/cache/rootfs && $(ls -1 $SRC/cache/rootfs/*.lz4 2> /dev/null | wc -l) -gt ${ROOTFS_CACHE_MAX} ]]; then
|
||||
if [[ -d "${SRC}"/cache/rootfs && $(ls -1 "${SRC}"/cache/rootfs/*.lz4 2> /dev/null | wc -l) -gt "${ROOTFS_CACHE_MAX}" ]]; then
|
||||
display_alert "Cleaning" "rootfs cache (old)" "info"
|
||||
(cd $SRC/cache/rootfs; ls -t *.lz4 | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f)
|
||||
(cd "${SRC}"/cache/rootfs; ls -t *.lz4 | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f)
|
||||
# Remove signatures if they are present. We use them for internal purpose
|
||||
(cd $SRC/cache/rootfs; ls -t *.asc | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f)
|
||||
(cd "${SRC}"/cache/rootfs; ls -t *.asc | sed -e "1,${ROOTFS_CACHE_MAX}d" | xargs -d '\n' rm -f)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -95,11 +97,12 @@ cleaning()
|
||||
|
||||
exit_with_error()
|
||||
{
|
||||
local _file=$(basename ${BASH_SOURCE[1]})
|
||||
local _file
|
||||
local _line=${BASH_LINENO[0]}
|
||||
local _function=${FUNCNAME[1]}
|
||||
local _description=$1
|
||||
local _highlight=$2
|
||||
_file=$(basename "${BASH_SOURCE[1]}")
|
||||
|
||||
display_alert "ERROR in function $_function" "$_file:$_line" "err"
|
||||
display_alert "$_description" "$_highlight" "err"
|
||||
@@ -108,9 +111,9 @@ exit_with_error()
|
||||
overlayfs_wrapper "cleanup"
|
||||
# unlock loop device access in case of starvation
|
||||
exec {FD}>/var/lock/armbian-debootstrap-losetup
|
||||
flock -u $FD
|
||||
flock -u "${FD}"
|
||||
|
||||
exit -1
|
||||
exit 255
|
||||
}
|
||||
|
||||
# get_package_list_hash
|
||||
@@ -119,7 +122,7 @@ exit_with_error()
|
||||
|
||||
get_package_list_hash()
|
||||
{
|
||||
( printf '%s\n' $PACKAGE_LIST | sort -u; printf '%s\n' $PACKAGE_LIST_EXCLUDE | sort -u; echo "$1" ) \
|
||||
( printf '%s\n' "${PACKAGE_LIST}" | sort -u; printf '%s\n' "${PACKAGE_LIST_EXCLUDE}" | sort -u; echo "${1}" ) \
|
||||
| md5sum | cut -d' ' -f 1
|
||||
}
|
||||
|
||||
@@ -136,7 +139,7 @@ create_sources_list()
|
||||
|
||||
case $release in
|
||||
stretch|buster|bullseye)
|
||||
cat <<-EOF > $basedir/etc/apt/sources.list
|
||||
cat <<-EOF > "${basedir}"/etc/apt/sources.list
|
||||
deb http://${DEBIAN_MIRROR} $release main contrib non-free
|
||||
#deb-src http://${DEBIAN_MIRROR} $release main contrib non-free
|
||||
|
||||
@@ -152,7 +155,7 @@ create_sources_list()
|
||||
;;
|
||||
|
||||
xenial|bionic|eoan|focal)
|
||||
cat <<-EOF > $basedir/etc/apt/sources.list
|
||||
cat <<-EOF > "${basedir}"/etc/apt/sources.list
|
||||
deb http://${UBUNTU_MIRROR} $release main restricted universe multiverse
|
||||
#deb-src http://${UBUNTU_MIRROR} $release main restricted universe multiverse
|
||||
|
||||
@@ -171,7 +174,7 @@ create_sources_list()
|
||||
# workaround for Chromium by downloading it from Debian
|
||||
if [[ $release == focal || $release == eoan ]]; then
|
||||
|
||||
cat <<-EOF > $basedir/etc/apt/preferences.d/chromium.pref
|
||||
cat <<-EOF > "${basedir}"/etc/apt/preferences.d/chromium.pref
|
||||
# Note: 2 blank lines are required between entries
|
||||
Package: *
|
||||
Pin: release a=${release}
|
||||
@@ -188,7 +191,7 @@ create_sources_list()
|
||||
Pin-Priority: 700
|
||||
EOF
|
||||
|
||||
cat <<-EOF > $basedir/etc/apt/sources.list.d/debian.list
|
||||
cat <<-EOF > "${basedir}"/etc/apt/sources.list.d/debian.list
|
||||
deb http://${DEBIAN_MIRROR} stable main
|
||||
deb http://${DEBIAN_MIRROR} stable-updates main
|
||||
deb http://${DEBIAN_MIRROR}-security stable/updates main
|
||||
@@ -200,18 +203,18 @@ create_sources_list()
|
||||
|
||||
# stage: add armbian repository and install key
|
||||
if [[ $DOWNLOAD_MIRROR == "china" ]]; then
|
||||
echo "deb http://mirrors.tuna.tsinghua.edu.cn/armbian $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > $SDCARD/etc/apt/sources.list.d/armbian.list
|
||||
echo "deb http://mirrors.tuna.tsinghua.edu.cn/armbian $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${SDCARD}"/etc/apt/sources.list.d/armbian.list
|
||||
else
|
||||
echo "deb http://apt.armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > $SDCARD/etc/apt/sources.list.d/armbian.list
|
||||
echo "deb http://apt.armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" > "${SDCARD}"/etc/apt/sources.list.d/armbian.list
|
||||
fi
|
||||
|
||||
# add local package server if defined. Suitable for development
|
||||
[[ -n $LOCAL_MIRROR ]] && echo "deb http://$LOCAL_MIRROR $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" >> $SDCARD/etc/apt/sources.list.d/armbian.list
|
||||
[[ -n $LOCAL_MIRROR ]] && echo "deb http://$LOCAL_MIRROR $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" >> "${SDCARD}"/etc/apt/sources.list.d/armbian.list
|
||||
|
||||
display_alert "Adding Armbian repository and authentication key" "/etc/apt/sources.list.d/armbian.list" "info"
|
||||
cp $SRC/config/armbian.key $SDCARD
|
||||
chroot $SDCARD /bin/bash -c "cat armbian.key | apt-key add - > /dev/null 2>&1"
|
||||
rm $SDCARD/armbian.key
|
||||
cp "${SRC}"/config/armbian.key "${SDCARD}"
|
||||
chroot "${SDCARD}" /bin/bash -c "cat armbian.key | apt-key add - > /dev/null 2>&1"
|
||||
rm "${SDCARD}"/armbian.key
|
||||
}
|
||||
|
||||
# fetch_from_repo <url> <directory> <ref> <ref_subdir>
|
||||
@@ -261,10 +264,10 @@ fetch_from_repo()
|
||||
local workdir=$dir
|
||||
fi
|
||||
|
||||
mkdir -p $SRC/cache/sources/$workdir 2>/dev/null || \
|
||||
exit_with_error "No path or no write permission" "$SRC/cache/sources/$workdir"
|
||||
mkdir -p "${SRC}/cache/sources/${workdir}" 2>/dev/null || \
|
||||
exit_with_error "No path or no write permission" "${SRC}/cache/sources/${workdir}"
|
||||
|
||||
cd $SRC/cache/sources/$workdir
|
||||
cd "${SRC}/cache/sources/${workdir}" || exit
|
||||
|
||||
# check if existing remote URL for the repo or branch does not match current one
|
||||
# may not be supported by older git versions
|
||||
@@ -274,13 +277,13 @@ fetch_from_repo()
|
||||
if [[ "$(git rev-parse --git-dir 2>/dev/null)" == ".git" && \
|
||||
"$url" != "$(git remote get-url origin 2>/dev/null)" ]]; then
|
||||
display_alert "Remote URL does not match, removing existing local copy"
|
||||
rm -rf .git *
|
||||
rm -rf .git ./*
|
||||
fi
|
||||
|
||||
if [[ "$(git rev-parse --git-dir 2>/dev/null)" != ".git" ]]; then
|
||||
display_alert "Creating local copy"
|
||||
git init -q .
|
||||
git remote add origin $url
|
||||
git remote add origin "${url}"
|
||||
# Here you need to upload from a new address
|
||||
offline=false
|
||||
fi
|
||||
@@ -289,26 +292,30 @@ fetch_from_repo()
|
||||
|
||||
# when we work offline we simply return the sources to their original state
|
||||
if ! $offline; then
|
||||
local local_hash=$(git rev-parse @ 2>/dev/null)
|
||||
local local_hash
|
||||
local_hash=$(git rev-parse @ 2>/dev/null)
|
||||
|
||||
case $ref_type in
|
||||
branch)
|
||||
# TODO: grep refs/heads/$name
|
||||
local remote_hash=$(git ls-remote -h $url "$ref_name" | head -1 | cut -f1)
|
||||
[[ -z $local_hash || $local_hash != $remote_hash ]] && changed=true
|
||||
local remote_hash
|
||||
remote_hash=$(git ls-remote -h "${url}" "$ref_name" | head -1 | cut -f1)
|
||||
[[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
|
||||
;;
|
||||
|
||||
tag)
|
||||
local remote_hash=$(git ls-remote -t $url "$ref_name" | cut -f1)
|
||||
if [[ -z $local_hash || $local_hash != $remote_hash ]]; then
|
||||
remote_hash=$(git ls-remote -t $url "$ref_name^{}" | cut -f1)
|
||||
[[ -z $remote_hash || $local_hash != $remote_hash ]] && changed=true
|
||||
local remote_hash
|
||||
remote_hash=$(git ls-remote -t "${url}" "$ref_name" | cut -f1)
|
||||
if [[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]]; then
|
||||
remote_hash=$(git ls-remote -t "${url}" "$ref_name^{}" | cut -f1)
|
||||
[[ -z $remote_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
|
||||
fi
|
||||
;;
|
||||
|
||||
head)
|
||||
local remote_hash=$(git ls-remote $url HEAD | cut -f1)
|
||||
[[ -z $local_hash || $local_hash != $remote_hash ]] && changed=true
|
||||
local remote_hash
|
||||
remote_hash=$(git ls-remote "${url}" HEAD | cut -f1)
|
||||
[[ -z $local_hash || "${local_hash}" != "${remote_hash}" ]] && changed=true
|
||||
;;
|
||||
|
||||
commit)
|
||||
@@ -323,22 +330,22 @@ fetch_from_repo()
|
||||
# remote was updated, fetch and check out updates
|
||||
display_alert "Fetching updates"
|
||||
case $ref_type in
|
||||
branch) git fetch --depth 1 origin $ref_name ;;
|
||||
tag) git fetch --depth 1 origin tags/$ref_name ;;
|
||||
branch) git fetch --depth 1 origin "${ref_name}" ;;
|
||||
tag) git fetch --depth 1 origin tags/"${ref_name}" ;;
|
||||
head) git fetch --depth 1 origin HEAD ;;
|
||||
esac
|
||||
|
||||
# commit type needs support for older git servers that doesn't support fetching id directly
|
||||
if [[ $ref_type == commit ]]; then
|
||||
|
||||
git fetch --depth 1 origin $ref_name
|
||||
git fetch --depth 1 origin "${ref_name}"
|
||||
|
||||
# cover old type
|
||||
if [[ $? -ne 0 ]]; then
|
||||
|
||||
display_alert "Commit checkout not supported on this repository. Doing full clone." "" "wrn"
|
||||
git pull
|
||||
git checkout -fq $ref_name
|
||||
git checkout -fq "${ref_name}"
|
||||
display_alert "Checkout out to" "$(git --no-pager log -2 --pretty=format:"$ad%s [%an]" | head -1)" "info"
|
||||
|
||||
else
|
||||
@@ -374,9 +381,10 @@ fetch_from_repo()
|
||||
display_alert "Updating submodules" "" "ext"
|
||||
# FML: http://stackoverflow.com/a/17692710
|
||||
for i in $(git config -f .gitmodules --get-regexp path | awk '{ print $2 }'); do
|
||||
cd $SRC/cache/sources/$workdir
|
||||
local surl=$(git config -f .gitmodules --get "submodule.$i.url")
|
||||
local sref=$(git config -f .gitmodules --get "submodule.$i.branch")
|
||||
cd "${SRC}/cache/sources/${workdir}" || exit
|
||||
local surl sref
|
||||
surl=$(git config -f .gitmodules --get "submodule.$i.url")
|
||||
sref=$(git config -f .gitmodules --get "submodule.$i.branch")
|
||||
if [[ -n $sref ]]; then
|
||||
sref="branch:$sref"
|
||||
else
|
||||
@@ -393,7 +401,7 @@ fetch_from_repo()
|
||||
display_alert()
|
||||
{
|
||||
# log function parameters to install.log
|
||||
[[ -n $DEST ]] && echo "Displaying message: $@" >> $DEST/debug/output.log
|
||||
[[ -n "${DEST}" ]] && echo "Displaying message: $@" >> "${DEST}"/debug/output.log
|
||||
|
||||
local tmp=""
|
||||
[[ -n $2 ]] && tmp="[\e[0;33m $2 \x1B[0m]"
|
||||
@@ -428,7 +436,7 @@ display_alert()
|
||||
fingerprint_image()
|
||||
{
|
||||
display_alert "Fingerprinting"
|
||||
cat <<-EOF > $1
|
||||
cat <<-EOF > "${1}"
|
||||
--------------------------------------------------------------------------------
|
||||
Title: Armbian $REVISION ${BOARD^} $DISTRIBUTION $RELEASE $BRANCH
|
||||
Kernel: Linux $VER
|
||||
@@ -442,7 +450,7 @@ fingerprint_image()
|
||||
EOF
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
cat <<-EOF >> $1
|
||||
cat <<-EOF >> "${1}"
|
||||
--------------------------------------------------------------------------------
|
||||
Partitioning configuration:
|
||||
Root partition type: $ROOTFS_TYPE
|
||||
@@ -465,9 +473,9 @@ fingerprint_image()
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat <<-EOF >> $1
|
||||
cat <<-EOF >> "${1}"
|
||||
--------------------------------------------------------------------------------
|
||||
$(cat $SRC/LICENSE)
|
||||
$(cat "${SRC}"/LICENSE)
|
||||
--------------------------------------------------------------------------------
|
||||
EOF
|
||||
}
|
||||
@@ -482,7 +490,7 @@ function distro_menu ()
|
||||
|
||||
for i in "${!distro_name[@]}"
|
||||
do
|
||||
if [[ $i == $1 ]]; then
|
||||
if [[ "${i}" == "${1}" ]]; then
|
||||
if [[ "${distro_support[$i]}" != "supported" && $EXPERT != "yes" ]]; then
|
||||
:
|
||||
else
|
||||
@@ -505,16 +513,17 @@ adding_packages()
|
||||
# add deb files to repository if they are not already there
|
||||
|
||||
display_alert "Checking and adding to repository $release" "$3" "ext"
|
||||
for f in ${DEB_STORAGE}$2/*.deb
|
||||
for f in "${DEB_STORAGE}${2}"/*.deb
|
||||
do
|
||||
local name=$(dpkg-deb -I $f | grep Package | awk '{print $2}')
|
||||
local version=$(dpkg-deb -I $f | grep Version | awk '{print $2}')
|
||||
local arch=$(dpkg-deb -I $f | grep Architecture | awk '{print $2}')
|
||||
local name version arch
|
||||
name=$(dpkg-deb -I "${f}" | grep Package | awk '{print $2}')
|
||||
version=$(dpkg-deb -I "${f}" | grep Version | awk '{print $2}')
|
||||
arch=$(dpkg-deb -I "${f}" | grep Architecture | awk '{print $2}')
|
||||
# add if not already there
|
||||
aptly repo search -architectures=$arch -config=${SCRIPTPATH}config/${REPO_CONFIG} $1 'Name (% '$name'), $Version (='$version'), $Architecture (='$arch')' &>/dev/null
|
||||
aptly repo search -architectures="${arch}" -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${1}" 'Name (% '${name}'), $Version (='${version}'), $Architecture (='${arch}')' &>/dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_alert "Adding" "$name" "info"
|
||||
aptly repo add -force-replace=true -config=${SCRIPTPATH}config/${REPO_CONFIG} $1 ${f} &>/dev/null
|
||||
aptly repo add -force-replace=true -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${1}" "${f}" &>/dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -538,74 +547,75 @@ addtorepo()
|
||||
local forceoverwrite=""
|
||||
|
||||
# let's drop from publish if exits
|
||||
if [[ -n $(aptly publish list -config=${SCRIPTPATH}config/${REPO_CONFIG} -raw | awk '{print $(NF)}' | grep $release) ]]; then
|
||||
aptly publish drop -config=${SCRIPTPATH}config/${REPO_CONFIG} $release > /dev/null 2>&1
|
||||
if [[ -n $(aptly publish list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "${release}") ]]; then
|
||||
aptly publish drop -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" > /dev/null 2>&1
|
||||
fi
|
||||
|
||||
# create local repository if not exist
|
||||
if [[ -z $(aptly repo list -config=${SCRIPTPATH}config/${REPO_CONFIG} -raw | awk '{print $(NF)}' | grep $release) ]]; then
|
||||
if [[ -z $(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "${release}") ]]; then
|
||||
display_alert "Creating section" "$release" "info"
|
||||
aptly repo create -config=${SCRIPTPATH}config/${REPO_CONFIG} -distribution=$release -component="main" \
|
||||
-comment="Armbian main repository" ${release} >/dev/null
|
||||
aptly repo create -config="${SCRIPTPATH}config/${REPO_CONFIG}" -distribution="${release}" -component="main" \
|
||||
-comment="Armbian main repository" "${release}" >/dev/null
|
||||
fi
|
||||
if [[ -z $(aptly repo list -config=${SCRIPTPATH}config/${REPO_CONFIG} -raw | awk '{print $(NF)}' | grep "^utils") ]]; then
|
||||
aptly repo create -config=${SCRIPTPATH}config/${REPO_CONFIG} -distribution=$release -component="utils" \
|
||||
if [[ -z $(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "^utils") ]]; then
|
||||
aptly repo create -config="${SCRIPTPATH}config/${REPO_CONFIG}" -distribution="${release}" -component="utils" \
|
||||
-comment="Armbian utilities (backwards compatibility)" utils >/dev/null
|
||||
fi
|
||||
if [[ -z $(aptly repo list -config=${SCRIPTPATH}config/${REPO_CONFIG} -raw | awk '{print $(NF)}' | grep "${release}-utils") ]]; then
|
||||
aptly repo create -config=${SCRIPTPATH}config/${REPO_CONFIG} -distribution=$release -component="${release}-utils" \
|
||||
-comment="Armbian ${release} utilities" ${release}-utils >/dev/null
|
||||
if [[ -z $(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "${release}-utils") ]]; then
|
||||
aptly repo create -config="${SCRIPTPATH}config/${REPO_CONFIG}" -distribution="${release}" -component="${release}-utils" \
|
||||
-comment="Armbian ${release} utilities" "${release}-utils" >/dev/null
|
||||
fi
|
||||
if [[ -z $(aptly repo list -config=${SCRIPTPATH}config/${REPO_CONFIG} -raw | awk '{print $(NF)}' | grep "${release}-desktop") ]]; then
|
||||
aptly repo create -config=${SCRIPTPATH}config/${REPO_CONFIG} -distribution=$release -component="${release}-desktop" \
|
||||
-comment="Armbian ${release} desktop" ${release}-desktop >/dev/null
|
||||
if [[ -z $(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}" -raw | awk '{print $(NF)}' | grep "${release}-desktop") ]]; then
|
||||
aptly repo create -config="${SCRIPTPATH}config/${REPO_CONFIG}" -distribution="${release}" -component="${release}-desktop" \
|
||||
-comment="Armbian ${release} desktop" "${release}-desktop" >/dev/null
|
||||
fi
|
||||
|
||||
|
||||
# adding main
|
||||
if find ${DEB_STORAGE}/ -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
|
||||
if find "${DEB_STORAGE}"/ -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
|
||||
adding_packages "$release" "" "main"
|
||||
else
|
||||
aptly repo add -config=${SCRIPTPATH}config/${REPO_CONFIG} $release ${SCRIPTPATH}config/templates/example.deb >/dev/null
|
||||
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "${SCRIPTPATH}config/templates/example.deb" >/dev/null
|
||||
fi
|
||||
|
||||
local COMPONENTS="main"
|
||||
|
||||
# adding main distribution packages
|
||||
if find ${DEB_STORAGE}/${release} -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
|
||||
if find "${DEB_STORAGE}/${release}" -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
|
||||
adding_packages "$release" "/${release}" "release"
|
||||
else
|
||||
# workaround - add dummy package to not trigger error
|
||||
aptly repo add -config=${SCRIPTPATH}config/${REPO_CONFIG} $release ${SCRIPTPATH}config/templates/example.deb >/dev/null
|
||||
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "${SCRIPTPATH}config/templates/example.deb" >/dev/null
|
||||
fi
|
||||
|
||||
# adding release-specific utils
|
||||
if find ${DEB_STORAGE}/extra/${release}-utils -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
|
||||
if find "${DEB_STORAGE}/extra/${release}-utils" -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
|
||||
adding_packages "${release}-utils" "/extra/${release}-utils" "release utils"
|
||||
else
|
||||
aptly repo add -config=${SCRIPTPATH}config/${REPO_CONFIG} "${release}-utils" ${SCRIPTPATH}config/templates/example.deb >/dev/null
|
||||
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-utils" "${SCRIPTPATH}config/templates/example.deb" >/dev/null
|
||||
fi
|
||||
COMPONENTS="${COMPONENTS} ${release}-utils"
|
||||
|
||||
# adding desktop
|
||||
if find ${DEB_STORAGE}/extra/${release}-desktop -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
|
||||
if find "${DEB_STORAGE}/extra/${release}-desktop" -maxdepth 1 -type f -name "*.deb" 2>/dev/null | grep -q .; then
|
||||
adding_packages "${release}-desktop" "/extra/${release}-desktop" "desktop"
|
||||
else
|
||||
# workaround - add dummy package to not trigger error
|
||||
aptly repo add -config=${SCRIPTPATH}config/${REPO_CONFIG} "${release}-desktop" ${SCRIPTPATH}config/templates/example.deb >/dev/null
|
||||
aptly repo add -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" "${SCRIPTPATH}config/templates/example.deb" >/dev/null
|
||||
fi
|
||||
COMPONENTS="${COMPONENTS} ${release}-desktop"
|
||||
|
||||
local mainnum=$(aptly repo show -with-packages -config=${SCRIPTPATH}config/${REPO_CONFIG} $release | grep "Number of packages" | awk '{print $NF}')
|
||||
local utilnum=$(aptly repo show -with-packages -config=${SCRIPTPATH}config/${REPO_CONFIG} ${release}-desktop | grep "Number of packages" | awk '{print $NF}')
|
||||
local desknum=$(aptly repo show -with-packages -config=${SCRIPTPATH}config/${REPO_CONFIG} ${release}-utils | grep "Number of packages" | awk '{print $NF}')
|
||||
local mainnum utilnum desknum
|
||||
mainnum=$(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" | grep "Number of packages" | awk '{print $NF}')
|
||||
utilnum=$(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" | grep "Number of packages" | awk '{print $NF}')
|
||||
desknum=$(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-utils" | grep "Number of packages" | awk '{print $NF}')
|
||||
|
||||
if [ $mainnum -gt 0 ] && [ $utilnum -gt 0 ] && [ $desknum -gt 0 ]; then
|
||||
# publish
|
||||
aptly publish -force-overwrite -passphrase=$GPG_PASS -origin=Armbian -label=Armbian -config=${SCRIPTPATH}config/${REPO_CONFIG} -component=${COMPONENTS// /,} \
|
||||
--distribution=$release repo $release ${COMPONENTS//main/} >/dev/null
|
||||
aptly publish -force-overwrite -passphrase="${GPG_PASS}" -origin=Armbian -label=Armbian -config="${SCRIPTPATH}config/${REPO_CONFIG}" -component="${COMPONENTS// /,}" \
|
||||
--distribution="${release}" repo "${release}" "${COMPONENTS//main/}" >/dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
display_alert "Publishing failed" "$release" "err"
|
||||
display_alert "Publishing failed" "${release}" "err"
|
||||
errors=$((errors+1))
|
||||
exit 0
|
||||
fi
|
||||
@@ -618,18 +628,18 @@ addtorepo()
|
||||
|
||||
# cleanup
|
||||
display_alert "Cleaning repository" "${DEB_STORAGE}" "info"
|
||||
aptly db cleanup -config=${SCRIPTPATH}config/${REPO_CONFIG}
|
||||
aptly db cleanup -config="${SCRIPTPATH}config/${REPO_CONFIG}"
|
||||
|
||||
# display what we have
|
||||
echo ""
|
||||
display_alert "List of local repos" "local" "info"
|
||||
(aptly repo list -config=${SCRIPTPATH}config/${REPO_CONFIG}) | egrep packages
|
||||
(aptly repo list -config="${SCRIPTPATH}config/${REPO_CONFIG}") | grep -E packages
|
||||
|
||||
# remove debs if no errors found
|
||||
if [[ $errors -eq 0 ]]; then
|
||||
if [[ "$2" == "delete" ]]; then
|
||||
display_alert "Purging incoming debs" "all" "ext"
|
||||
find ${DEB_STORAGE} -name "*.deb" -type f -delete
|
||||
find "${DEB_STORAGE}" -name "*.deb" -type f -delete
|
||||
fi
|
||||
else
|
||||
display_alert "There were some problems $err_txt" "leaving incoming directory intact" "err"
|
||||
@@ -646,18 +656,18 @@ repo-manipulate() {
|
||||
serve)
|
||||
# display repository content
|
||||
display_alert "Serving content" "common utils" "ext"
|
||||
aptly serve -listen=$(ip -f inet addr | grep -Po 'inet \K[\d.]+' | grep -v 127.0.0.1 | head -1):8080 -config="${SCRIPTPATH}"config/${REPO_CONFIG}
|
||||
aptly serve -listen=$(ip -f inet addr | grep -Po 'inet \K[\d.]+' | grep -v 127.0.0.1 | head -1):8080 -config="${SCRIPTPATH}config/${REPO_CONFIG}"
|
||||
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/${REPO_CONFIG} "${release}" | tail -n +7
|
||||
aptly repo show -with-packages -config="${SCRIPTPATH}"config/${REPO_CONFIG} "${release}-desktop" | tail -n +7
|
||||
aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" | tail -n +7
|
||||
aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" | tail -n +7
|
||||
done
|
||||
display_alert "Displaying repository contents for" "common utils" "ext"
|
||||
aptly repo show -with-packages -config="${SCRIPTPATH}"config/${REPO_CONFIG} utils | tail -n +7
|
||||
aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" utils | tail -n +7
|
||||
echo "done."
|
||||
exit 0
|
||||
;;
|
||||
@@ -667,10 +677,10 @@ repo-manipulate() {
|
||||
while true; do
|
||||
LIST=()
|
||||
for release in "${DISTROS[@]}"; do
|
||||
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}"config/${REPO_CONFIG} "${release}" | tail -n +7) )
|
||||
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}"config/${REPO_CONFIG} "${release}-desktop" | tail -n +7) )
|
||||
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" | tail -n +7) )
|
||||
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" | tail -n +7) )
|
||||
done
|
||||
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}"config/${REPO_CONFIG} utils | tail -n +7) )
|
||||
LIST+=( $(aptly repo show -with-packages -config="${SCRIPTPATH}config/${REPO_CONFIG}" utils | tail -n +7) )
|
||||
LIST=( $(echo "${LIST[@]}" | tr ' ' '\n' | sort -u))
|
||||
new_list=()
|
||||
# create a human readable menu
|
||||
@@ -687,10 +697,10 @@ repo-manipulate() {
|
||||
exec 3>&-
|
||||
if [[ $exitstatus -eq 0 ]]; then
|
||||
for release in "${DISTROS[@]}"; do
|
||||
aptly repo remove -config="${SCRIPTPATH}"config/${REPO_CONFIG} "${release}" "$TARGET_VERSION"
|
||||
aptly repo remove -config="${SCRIPTPATH}"config/${REPO_CONFIG} "${release}-desktop" "$TARGET_VERSION"
|
||||
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" "$TARGET_VERSION"
|
||||
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}-desktop" "$TARGET_VERSION"
|
||||
done
|
||||
aptly repo remove -config="${SCRIPTPATH}"config/${REPO_CONFIG} "utils" "$TARGET_VERSION"
|
||||
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "utils" "$TARGET_VERSION"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
@@ -709,16 +719,16 @@ repo-manipulate() {
|
||||
repo-remove-old-packages "$release" "armhf" "5"
|
||||
repo-remove-old-packages "$release" "arm64" "5"
|
||||
repo-remove-old-packages "$release" "all" "5"
|
||||
aptly -config="${SCRIPTPATH}"config/${REPO_CONFIG} -passphrase="${GPG_PASS}" publish update "${release}" > /dev/null 2>&1
|
||||
aptly -config="${SCRIPTPATH}config/${REPO_CONFIG}" -passphrase="${GPG_PASS}" publish update "${release}" > /dev/null 2>&1
|
||||
done
|
||||
exit 0
|
||||
;;
|
||||
purgesource)
|
||||
for release in "${DISTROS[@]}"; do
|
||||
aptly repo remove -config=${SCRIPTPATH}config/${REPO_CONFIG} ${release} 'Name (% *-source*)'
|
||||
aptly -config="${SCRIPTPATH}"config/${REPO_CONFIG} -passphrase="${GPG_PASS}" publish update "${release}" > /dev/null 2>&1
|
||||
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${release}" 'Name (% *-source*)'
|
||||
aptly -config="${SCRIPTPATH}config/${REPO_CONFIG}" -passphrase="${GPG_PASS}" publish update "${release}" > /dev/null 2>&1
|
||||
done
|
||||
aptly db cleanup -config=${SCRIPTPATH}config/${REPO_CONFIG} > /dev/null 2>&1
|
||||
aptly db cleanup -config="${SCRIPTPATH}config/${REPO_CONFIG}" > /dev/null 2>&1
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
@@ -745,7 +755,7 @@ repo-remove-old-packages() {
|
||||
local arch=$2
|
||||
local keep=$3
|
||||
|
||||
for pkg in $(aptly repo search -config="${SCRIPTPATH}"config/${REPO_CONFIG} "${repo}" "Architecture ($arch)" | grep -v "ERROR: no results" | sort -rV); do
|
||||
for pkg in $(aptly repo search -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${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
|
||||
@@ -757,7 +767,7 @@ repo-remove-old-packages() {
|
||||
((count+=1))
|
||||
if [[ $count -gt $keep ]]; then
|
||||
pkg_version=$(echo "${pkg}" | cut -d_ -f2)
|
||||
aptly repo remove -config="${SCRIPTPATH}"config/${REPO_CONFIG} "${repo}" "Name ($pkg_name), Version (<= $pkg_version)"
|
||||
aptly repo remove -config="${SCRIPTPATH}config/${REPO_CONFIG}" "${repo}" "Name ($pkg_name), Version (<= $pkg_version)"
|
||||
deleted='yes'
|
||||
fi
|
||||
done
|
||||
@@ -921,9 +931,9 @@ prepare_host()
|
||||
# distribution packages are buggy, download from author
|
||||
if [[ ! -f /etc/apt/sources.list.d/aptly.list ]]; then
|
||||
display_alert "Updating from external repository" "aptly" "info"
|
||||
if [ x"" != x$http_proxy ]; then
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options http-proxy=$http_proxy --recv-keys ED75B5A4483DA07C >/dev/null 2>&1
|
||||
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --keyserver-options http-proxy=$http_proxy --recv-keys ED75B5A4483DA07C >/dev/null 2>&1
|
||||
if [ x"" != x"${http_proxy}" ]; then
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options http-proxy="${http_proxy}" --recv-keys ED75B5A4483DA07C >/dev/null 2>&1
|
||||
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --keyserver-options http-proxy="${http_proxy}" --recv-keys ED75B5A4483DA07C >/dev/null 2>&1
|
||||
else
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys ED75B5A4483DA07C >/dev/null 2>&1
|
||||
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys ED75B5A4483DA07C >/dev/null 2>&1
|
||||
@@ -937,14 +947,14 @@ prepare_host()
|
||||
display_alert "Installing build dependencies"
|
||||
apt-get -q update
|
||||
apt-get -y upgrade
|
||||
apt-get -q -y --no-install-recommends install -o Dpkg::Options::='--force-confold' "${deps[@]}" | tee -a $DEST/debug/hostdeps.log
|
||||
apt-get -q -y --no-install-recommends install -o Dpkg::Options::='--force-confold' "${deps[@]}" | tee -a "${DEST}"/debug/hostdeps.log
|
||||
update-ccache-symlinks
|
||||
fi
|
||||
|
||||
# sync clock
|
||||
if [[ $SYNC_CLOCK != no ]]; then
|
||||
display_alert "Syncing clock" "host" "info"
|
||||
ntpdate -s ${NTP_SERVER:- pool.ntp.org}
|
||||
ntpdate -s "${NTP_SERVER:- pool.ntp.org}"
|
||||
fi
|
||||
|
||||
if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' 'zlib1g:i386' 2>/dev/null) != *ii* ]]; then
|
||||
@@ -952,16 +962,16 @@ prepare_host()
|
||||
fi
|
||||
|
||||
# create directory structure
|
||||
mkdir -p $SRC/{cache,output} $USERPATCHES_PATH
|
||||
mkdir -p "${SRC}"/{cache,output} "${USERPATCHES_PATH}"
|
||||
if [[ -n $SUDO_USER ]]; then
|
||||
chgrp --quiet sudo cache output $USERPATCHES_PATH
|
||||
chgrp --quiet sudo cache output "${USERPATCHES_PATH}"
|
||||
# SGID bit on cache/sources breaks kernel dpkg packaging
|
||||
chmod --quiet g+w,g+s output $USERPATCHES_PATH
|
||||
chmod --quiet g+w,g+s output "${USERPATCHES_PATH}"
|
||||
# fix existing permissions
|
||||
find $SRC/output $USERPATCHES_PATH -type d ! -group sudo -exec chgrp --quiet sudo {} \;
|
||||
find $SRC/output $USERPATCHES_PATH -type d ! -perm -g+w,g+s -exec chmod --quiet g+w,g+s {} \;
|
||||
find "${SRC}"/output "${USERPATCHES_PATH}" -type d ! -group sudo -exec chgrp --quiet sudo {} \;
|
||||
find "${SRC}"/output "${USERPATCHES_PATH}" -type d ! -perm -g+w,g+s -exec chmod --quiet g+w,g+s {} \;
|
||||
fi
|
||||
mkdir -p $DEST/debs-beta/extra $DEST/debs/extra $DEST/{config,debug,patch} $USERPATCHES_PATH/overlay $SRC/cache/{sources,hash,toolchains,utility,rootfs} $SRC/.tmp
|
||||
mkdir -p "${DEST}"/debs-beta/extra "${DEST}"/debs/extra "${DEST}"/{config,debug,patch} "${USERPATCHES_PATH}"/overlay "${SRC}"/cache/{sources,hash,toolchains,utility,rootfs} "${SRC}"/.tmp
|
||||
|
||||
display_alert "Checking for external GCC compilers" "" "info"
|
||||
# download external Linaro compiler and missing special dependencies since they are needed for certain sources
|
||||
@@ -990,8 +1000,8 @@ prepare_host()
|
||||
download_and_verify "_toolchains" "${toolchain##*/}"
|
||||
done
|
||||
|
||||
rm -rf $SRC/cache/toolchains/*.tar.xz*
|
||||
local existing_dirs=( $(ls -1 $SRC/cache/toolchains) )
|
||||
rm -rf "${SRC}"/cache/toolchains/*.tar.xz*
|
||||
local existing_dirs=( $(ls -1 "${SRC}"/cache/toolchains) )
|
||||
for dir in ${existing_dirs[@]}; do
|
||||
local found=no
|
||||
for toolchain in ${toolchains[@]}; do
|
||||
@@ -1001,7 +1011,7 @@ prepare_host()
|
||||
done
|
||||
if [[ $found == no ]]; then
|
||||
display_alert "Removing obsolete toolchain" "$dir"
|
||||
rm -rf $SRC/cache/toolchains/$dir
|
||||
rm -rf "${SRC}/cache/toolchains/${dir}"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1015,19 +1025,19 @@ prepare_host()
|
||||
test -e /proc/sys/fs/binfmt_misc/qemu-aarch64 || update-binfmts --enable qemu-aarch64
|
||||
fi
|
||||
|
||||
[[ ! -f $USERPATCHES_PATH/customize-image.sh ]] && cp $SRC/config/templates/customize-image.sh.template $USERPATCHES_PATH/customize-image.sh
|
||||
[[ ! -f "${USERPATCHES_PATH}"/customize-image.sh ]] && cp "${SRC}"/config/templates/customize-image.sh.template "${USERPATCHES_PATH}"/customize-image.sh
|
||||
|
||||
if [[ ! -f $USERPATCHES_PATH/README ]]; then
|
||||
rm -f $USERPATCHES_PATH/readme.txt
|
||||
echo 'Please read documentation about customizing build configuration' > $USERPATCHES_PATH/README
|
||||
echo 'http://www.armbian.com/using-armbian-tools/' >> $USERPATCHES_PATH/README
|
||||
if [[ ! -f "${USERPATCHES_PATH}"/README ]]; then
|
||||
rm -f "${USERPATCHES_PATH}"/readme.txt
|
||||
echo 'Please read documentation about customizing build configuration' > "${USERPATCHES_PATH}"/README
|
||||
echo 'http://www.armbian.com/using-armbian-tools/' >> "${USERPATCHES_PATH}"/README
|
||||
|
||||
# create patches directory structure under USERPATCHES_PATH
|
||||
find $SRC/patch -maxdepth 2 -type d ! -name . | sed "s%/.*patch%/$USERPATCHES_PATH%" | xargs mkdir -p
|
||||
find "${SRC}"/patch -maxdepth 2 -type d ! -name . | sed "s%/.*patch%/$USERPATCHES_PATH%" | xargs mkdir -p
|
||||
fi
|
||||
|
||||
# check free space (basic)
|
||||
local freespace=$(findmnt --target $SRC -n -o AVAIL -b 2>/dev/null) # in bytes
|
||||
local freespace=$(findmnt --target "${SRC}" -n -o AVAIL -b 2>/dev/null) # in bytes
|
||||
if [[ -n $freespace && $(( $freespace / 1073741824 )) -lt 10 ]]; then
|
||||
display_alert "Low free space left" "$(( $freespace / 1073741824 )) GiB" "wrn"
|
||||
# pause here since dialog-based menu will hide this message otherwise
|
||||
@@ -1063,12 +1073,12 @@ WEBSEED=(
|
||||
fi
|
||||
for toolchain in ${WEBSEED[@]}; do
|
||||
# use only live
|
||||
if [[ `wget -S --spider $toolchain$1 2>&1 >/dev/null | grep 'HTTP/1.1 200 OK'` ]]; then
|
||||
text=$text" "$toolchain$1
|
||||
if [[ $(wget -S --spider "${toolchain}${1}" 2>&1 >/dev/null | grep 'HTTP/1.1 200 OK') ]]; then
|
||||
text="${text} ${toolchain}${1}"
|
||||
fi
|
||||
done
|
||||
text="${text:1}"
|
||||
echo $text
|
||||
echo "${text}"
|
||||
}
|
||||
|
||||
|
||||
@@ -1079,7 +1089,7 @@ download_and_verify()
|
||||
|
||||
local remotedir=$1
|
||||
local filename=$2
|
||||
local localdir=$SRC/cache/${remotedir//_}
|
||||
local localdir="${SRC}"/cache/${remotedir//_}
|
||||
local dirname=${filename//.tar.xz}
|
||||
|
||||
if [[ $DOWNLOAD_MIRROR == china ]]; then
|
||||
@@ -1092,19 +1102,19 @@ download_and_verify()
|
||||
return
|
||||
fi
|
||||
|
||||
cd ${localdir}
|
||||
cd "${localdir}" || exit
|
||||
|
||||
# use local control file
|
||||
if [[ -f $SRC/config/torrents/${filename}.asc ]]; then
|
||||
local torrent=$SRC/config/torrents/${filename}.torrent
|
||||
ln -s $SRC/config/torrents/${filename}.asc ${localdir}/${filename}.asc
|
||||
elif [[ ! `wget -S --spider ${server}${remotedir}/${filename}.asc 2>&1 >/dev/null | grep 'HTTP/1.1 200 OK'` ]]; then
|
||||
if [[ -f "${SRC}"/config/torrents/${filename}.asc ]]; then
|
||||
local torrent="${SRC}"/config/torrents/${filename}.torrent
|
||||
ln -s "${SRC}/config/torrents/${filename}.asc" "${localdir}/${filename}.asc"
|
||||
elif [[ ! $(wget -S --spider "${server}${remotedir}/${filename}.asc" 2>&1 >/dev/null | grep 'HTTP/1.1 200 OK') ]]; then
|
||||
return
|
||||
else
|
||||
# download control file
|
||||
local torrent=${server}torrent/${filename}.torrent
|
||||
aria2c --download-result=hide --disable-ipv6=true --summary-interval=0 --console-log-level=error --auto-file-renaming=false \
|
||||
--continue=false --allow-overwrite=true --dir=${localdir} $(webseed "$remotedir/${filename}.asc") -o "${filename}.asc"
|
||||
--continue=false --allow-overwrite=true --dir="${localdir}" "$(webseed "$remotedir/${filename}.asc")" -o "${filename}.asc"
|
||||
[[ $? -ne 0 ]] && display_alert "Failed to download control file" "" "wrn"
|
||||
fi
|
||||
|
||||
@@ -1115,75 +1125,75 @@ download_and_verify()
|
||||
local ariatorrent="--summary-interval=0 --auto-save-interval=0 --seed-time=0 --bt-stop-timeout=15 --console-log-level=error \
|
||||
--allow-overwrite=true --download-result=hide --rpc-save-upload-metadata=false --auto-file-renaming=false \
|
||||
--file-allocation=trunc --continue=true ${torrent} \
|
||||
--dht-file-path=$SRC/cache/.aria2/dht.dat --disable-ipv6=true --stderr --follow-torrent=mem --dir=${localdir}"
|
||||
--dht-file-path=${SRC}/cache/.aria2/dht.dat --disable-ipv6=true --stderr --follow-torrent=mem --dir=${localdir}"
|
||||
|
||||
# exception. It throws error if dht.dat file does not exists. Error suppress needed only at first download.
|
||||
if [[ -f $SRC/cache/.aria2/dht.dat ]]; then
|
||||
aria2c ${ariatorrent}
|
||||
if [[ -f "${SRC}"/cache/.aria2/dht.dat ]]; then
|
||||
aria2c "${ariatorrent}"
|
||||
else
|
||||
aria2c ${ariatorrent} &> $DEST/debug/torrent.log
|
||||
aria2c "${ariatorrent}" &> "${DEST}"/debug/torrent.log
|
||||
fi
|
||||
# mark complete
|
||||
[[ $? -eq 0 ]] && touch ${localdir}/${filename}.complete
|
||||
[[ $? -eq 0 ]] && touch "${localdir}/${filename}.complete"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
# direct download if torrent fails
|
||||
if [[ ! -f ${localdir}/${filename}.complete ]]; then
|
||||
if [[ `wget -S --spider ${server}${remotedir}/${filename} 2>&1 >/dev/null \
|
||||
| grep 'HTTP/1.1 200 OK'` ]]; then
|
||||
if [[ ! -f "${localdir}/${filename}.complete" ]]; then
|
||||
if [[ $(wget -S --spider "${server}${remotedir}/${filename}" 2>&1 >/dev/null \
|
||||
| grep 'HTTP/1.1 200 OK') ]]; then
|
||||
display_alert "downloading using http(s) network" "$filename"
|
||||
aria2c --download-result=hide --rpc-save-upload-metadata=false --console-log-level=error \
|
||||
--dht-file-path=$SRC/cache/.aria2/dht.dat --disable-ipv6=true --summary-interval=0 --auto-file-renaming=false --dir=${localdir} $(webseed "$remotedir/$filename") -o ${filename}
|
||||
--dht-file-path="${SRC}"/cache/.aria2/dht.dat --disable-ipv6=true --summary-interval=0 --auto-file-renaming=false --dir="${localdir}" "$(webseed "${remotedir}/${filename}")" -o "${filename}"
|
||||
# mark complete
|
||||
[[ $? -eq 0 ]] && touch ${localdir}/${filename}.complete && echo ""
|
||||
[[ $? -eq 0 ]] && touch "${localdir}/${filename}.complete" && echo ""
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f ${localdir}/${filename}.asc ]]; then
|
||||
|
||||
if grep -q 'BEGIN PGP SIGNATURE' ${localdir}/${filename}.asc; then
|
||||
if grep -q 'BEGIN PGP SIGNATURE' "${localdir}/${filename}.asc"; then
|
||||
|
||||
if [[ ! -d $SRC/cache/.gpg ]]; then
|
||||
mkdir -p $SRC/cache/.gpg
|
||||
chmod 700 $SRC/cache/.gpg
|
||||
touch $SRC/cache/.gpg/gpg.conf
|
||||
chmod 600 $SRC/cache/.gpg/gpg.conf
|
||||
if [[ ! -d "${SRC}"/cache/.gpg ]]; then
|
||||
mkdir -p "${SRC}"/cache/.gpg
|
||||
chmod 700 "${SRC}"/cache/.gpg
|
||||
touch "${SRC}"/cache/.gpg/gpg.conf
|
||||
chmod 600 "${SRC}"/cache/.gpg/gpg.conf
|
||||
fi
|
||||
|
||||
# Verify archives with Linaro and Armbian GPG keys
|
||||
|
||||
if [ x"" != x$http_proxy ]; then
|
||||
(gpg --homedir $SRC/cache/.gpg --no-permission-warning --list-keys 8F427EAF >> $DEST/debug/output.log 2>&1\
|
||||
|| gpg --homedir $SRC/cache/.gpg --no-permission-warning \
|
||||
--keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options http-proxy=$http_proxy \
|
||||
--recv-keys 8F427EAF >> $DEST/debug/output.log 2>&1)
|
||||
if [ x"" != x"${http_proxy}" ]; then
|
||||
(gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning --list-keys 8F427EAF >> "${DEST}"/debug/output.log 2>&1\
|
||||
|| gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning \
|
||||
--keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options http-proxy="${http_proxy}" \
|
||||
--recv-keys 8F427EAF >> "${DEST}"/debug/output.log 2>&1)
|
||||
|
||||
(gpg --homedir $SRC/cache/.gpg --no-permission-warning --list-keys 9F0E78D5 >> $DEST/debug/output.log 2>&1\
|
||||
|| gpg --homedir $SRC/cache/.gpg --no-permission-warning \
|
||||
--keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options http-proxy=$http_proxy \
|
||||
--recv-keys 9F0E78D5 >> $DEST/debug/output.log 2>&1)
|
||||
(gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning --list-keys 9F0E78D5 >> "${DEST}"/debug/output.log 2>&1\
|
||||
|| gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning \
|
||||
--keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options http-proxy="${http_proxy}" \
|
||||
--recv-keys 9F0E78D5 >> "${DEST}"/debug/output.log 2>&1)
|
||||
else
|
||||
(gpg --homedir $SRC/cache/.gpg --no-permission-warning --list-keys 8F427EAF >> $DEST/debug/output.log 2>&1\
|
||||
|| gpg --homedir $SRC/cache/.gpg --no-permission-warning \
|
||||
(gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning --list-keys 8F427EAF >> "${DEST}"/debug/output.log 2>&1\
|
||||
|| gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning \
|
||||
--keyserver hkp://keyserver.ubuntu.com:80 \
|
||||
--recv-keys 8F427EAF >> $DEST/debug/output.log 2>&1)
|
||||
--recv-keys 8F427EAF >> "${DEST}"/debug/output.log 2>&1)
|
||||
|
||||
(gpg --homedir $SRC/cache/.gpg --no-permission-warning --list-keys 9F0E78D5 >> $DEST/debug/output.log 2>&1\
|
||||
|| gpg --homedir $SRC/cache/.gpg --no-permission-warning \
|
||||
(gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning --list-keys 9F0E78D5 >> "${DEST}"/debug/output.log 2>&1\
|
||||
|| gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning \
|
||||
--keyserver hkp://keyserver.ubuntu.com:80 \
|
||||
--recv-keys 9F0E78D5 >> $DEST/debug/output.log 2>&1)
|
||||
--recv-keys 9F0E78D5 >> "${DEST}"/debug/output.log 2>&1)
|
||||
fi
|
||||
|
||||
gpg --homedir $SRC/cache/.gpg --no-permission-warning --verify \
|
||||
--trust-model always -q ${localdir}/${filename}.asc >> $DEST/debug/output.log 2>&1
|
||||
gpg --homedir "${SRC}"/cache/.gpg --no-permission-warning --verify \
|
||||
--trust-model always -q "${localdir}/${filename}.asc" >> "${DEST}"/debug/output.log 2>&1
|
||||
[[ ${PIPESTATUS[0]} -eq 0 ]] && verified=true && display_alert "Verified" "PGP" "info"
|
||||
|
||||
else
|
||||
|
||||
md5sum -c --status ${localdir}/${filename}.asc && verified=true && display_alert "Verified" "MD5" "info"
|
||||
md5sum -c --status "${localdir}/${filename}.asc" && verified=true && display_alert "Verified" "MD5" "info"
|
||||
|
||||
fi
|
||||
|
||||
@@ -1191,8 +1201,8 @@ download_and_verify()
|
||||
if [[ "${filename:(-6)}" == "tar.xz" ]]; then
|
||||
|
||||
display_alert "decompressing"
|
||||
pv -p -b -r -c -N "[ .... ] ${filename}" $filename | xz -dc | tar xp --xattrs --no-same-owner --overwrite
|
||||
[[ $? -eq 0 ]] && touch ${localdir}/$dirname/.download-complete
|
||||
pv -p -b -r -c -N "[ .... ] ${filename}" "${filename}" | xz -dc | tar xp --xattrs --no-same-owner --overwrite
|
||||
[[ $? -eq 0 ]] && touch "${localdir}/${dirname}/.download-complete"
|
||||
fi
|
||||
else
|
||||
exit_with_error "verification failed"
|
||||
@@ -1206,8 +1216,9 @@ download_and_verify()
|
||||
|
||||
show_developer_warning()
|
||||
{
|
||||
local temp_rc=$(mktemp)
|
||||
cat <<-'EOF' > $temp_rc
|
||||
local temp_rc
|
||||
temp_rc=$(mktemp)
|
||||
cat <<-'EOF' > "${temp_rc}"
|
||||
screen_color = (WHITE,RED,ON)
|
||||
EOF
|
||||
local warn_text="You are switching to the \Z1EXPERT MODE\Zn
|
||||
@@ -1222,8 +1233,8 @@ show_developer_warning()
|
||||
- Forum posts related to dev kernel, CSC, WIP and EOS boards
|
||||
should be created in the \Z2\"Community forums\"\Zn section
|
||||
"
|
||||
DIALOGRC=$temp_rc dialog --title "Expert mode warning" --backtitle "$backtitle" --colors --defaultno --no-label "I do not agree" \
|
||||
--yes-label "I understand and agree" --yesno "$warn_text" $TTY_Y $TTY_X
|
||||
DIALOGRC=$temp_rc dialog --title "Expert mode warning" --backtitle "${backtitle}" --colors --defaultno --no-label "I do not agree" \
|
||||
--yes-label "I understand and agree" --yesno "$warn_text" "${TTY_Y}" "${TTY_X}"
|
||||
[[ $? -ne 0 ]] && exit_with_error "Error switching to the expert mode"
|
||||
SHOW_WARNING=no
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user