summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLyndon Brown <jnqnfe@gmail.com>2020-02-20 06:58:11 +0000
committerLyndon Brown <jnqnfe@gmail.com>2020-03-16 22:10:03 +0000
commitc55eb8a0c3ca5b8ed1081e7eb8a423563288fb58 (patch)
tree6ea61f7291b27ce9e22b40c5593c6ab6f54555d2
parentaf040d78035b88aaf2f99f38bf5f0db176c92d0a (diff)
downloadvyos-live-build-c55eb8a0c3ca5b8ed1081e7eb8a423563288fb58.tar.gz
vyos-live-build-c55eb8a0c3ca5b8ed1081e7eb8a423563288fb58.zip
use local scope for private function vars
all vars affected have been carefully checked to be quite certain that they are definitely local where variable is assigned the return value of a function/command, the local "declaration" is deliberately done on a separate line, since `local FOO` is actually treated itself as a command rather than a declaration; will thus always cause $? to be zero, and thus if done on the same line as such an assignment can not only clobber $? but in doing so unintentionally blocks failure of a command from triggering the expected exit from having `set -e`. also, from testing, i have found that when assigning "${@}" this must be done on a separate line confusingly as otherwise an error occurs. Gbp-Dch: Short
-rwxr-xr-xfunctions/aliases.sh2
-rwxr-xr-xfunctions/architectures.sh8
-rwxr-xr-xfunctions/arguments.sh1
-rwxr-xr-xfunctions/bootloaders.sh5
-rwxr-xr-xfunctions/breakpoints.sh2
-rwxr-xr-xfunctions/cache.sh5
-rwxr-xr-xfunctions/chroot.sh12
-rwxr-xr-xfunctions/chroot_bind_path.sh6
-rwxr-xr-xfunctions/conffile.sh4
-rwxr-xr-xfunctions/configuration.sh23
-rwxr-xr-xfunctions/defaults.sh2
-rwxr-xr-xfunctions/echo.sh13
-rwxr-xr-xfunctions/firmwarelists.sh1
-rwxr-xr-xfunctions/losetup.sh30
-rwxr-xr-xfunctions/packagelists.sh24
-rwxr-xr-xfunctions/packages.sh13
-rwxr-xr-xfunctions/stagefile.sh8
-rwxr-xr-xfunctions/wrapper.sh2
-rwxr-xr-xscripts/build/binary_grub-legacy21
-rwxr-xr-xscripts/build/binary_hdd2
-rwxr-xr-xscripts/build/binary_loopback_cfg10
-rwxr-xr-xscripts/build/config4
-rwxr-xr-xscripts/build/installer_debian-installer27
23 files changed, 141 insertions, 84 deletions
diff --git a/functions/aliases.sh b/functions/aliases.sh
index c4fb634e2..bf77e4284 100755
--- a/functions/aliases.sh
+++ b/functions/aliases.sh
@@ -19,6 +19,7 @@ In_list ()
local NEEDLE="${1}"
shift
+ local ITEM
for ITEM in ${@}
do
if [ "${NEEDLE}" = "${ITEM}" ]
@@ -32,6 +33,7 @@ In_list ()
Truncate ()
{
+ local FILE
for FILE in ${@}
do
if [ ! -L ${FILE} ]
diff --git a/functions/architectures.sh b/functions/architectures.sh
index 01d2b1f74..3f9ccc527 100755
--- a/functions/architectures.sh
+++ b/functions/architectures.sh
@@ -11,9 +11,11 @@
Check_architectures ()
{
- ARCHITECTURES="${@}"
- VALID=false
+ local ARCHITECTURES
+ ARCHITECTURES="${@}" #must be on separate line to 'local' declaration to avoid error
+ local VALID=false
+ local ARCHITECTURE
for ARCHITECTURE in ${ARCHITECTURES}
do
if [ "$(echo ${LB_ARCHITECTURES} | grep ${ARCHITECTURE})" ]
@@ -50,6 +52,7 @@ Check_architectures ()
Check_crossarchitectures ()
{
+ local HOST
if [ $(which dpkg) ]
then
HOST="$(dpkg --print-architecture)"
@@ -57,6 +60,7 @@ Check_crossarchitectures ()
HOST="$(uname -m)"
fi
+ local CROSS
case "${HOST}" in
amd64|i386|x86_64)
CROSS="amd64 i386"
diff --git a/functions/arguments.sh b/functions/arguments.sh
index 5d406f4b5..f87593204 100755
--- a/functions/arguments.sh
+++ b/functions/arguments.sh
@@ -11,6 +11,7 @@
Arguments ()
{
+ local ARGUMENTS
local ERR=0
ARGUMENTS="$(getopt --longoptions breakpoints,color,no-color,conffile:,debug,force,help,quiet,usage,verbose,version --name=${PROGRAM} --options c:huv --shell sh -- "${@}")" || ERR=$?
diff --git a/functions/bootloaders.sh b/functions/bootloaders.sh
index 36e132fb5..14e50ac4c 100755
--- a/functions/bootloaders.sh
+++ b/functions/bootloaders.sh
@@ -10,8 +10,9 @@
Is_Requested_Bootloader ()
{
- OLDIFS="$IFS"
- IFS=","
+ local OLDIFS="$IFS"
+ local IFS=","
+ local BOOTLOADER
for BOOTLOADER in ${LB_BOOTLOADERS}; do
if [ "${BOOTLOADER}" = "${1}" ]; then
IFS="$OLDIFS"
diff --git a/functions/breakpoints.sh b/functions/breakpoints.sh
index 6896c0521..e1eff1966 100755
--- a/functions/breakpoints.sh
+++ b/functions/breakpoints.sh
@@ -11,7 +11,7 @@
Breakpoint ()
{
- NAME="${1}"
+ local NAME="${1}"
if [ "${_BREAKPOINTS}" = "true" ]
then
diff --git a/functions/cache.sh b/functions/cache.sh
index 4e4c4b884..3e5c7ef70 100755
--- a/functions/cache.sh
+++ b/functions/cache.sh
@@ -11,7 +11,7 @@
Restore_package_cache ()
{
- DIRECTORY="cache/packages.${1}"
+ local DIRECTORY="cache/packages.${1}"
if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ]
then
@@ -32,7 +32,7 @@ Restore_package_cache ()
Save_package_cache ()
{
- DIRECTORY="cache/packages.${1}"
+ local DIRECTORY="cache/packages.${1}"
if [ "${LB_CACHE}" = "true" ] && [ "${LB_CACHE_PACKAGES}" = "true" ]
then
@@ -47,6 +47,7 @@ Save_package_cache ()
mkdir -p "${DIRECTORY}"
# Saving new cache
+ local PACKAGE
for PACKAGE in chroot/var/cache/apt/archives/*.deb
do
if [ -e "${DIRECTORY}"/"$(basename ${PACKAGE})" ]
diff --git a/functions/chroot.sh b/functions/chroot.sh
index 374cefd89..5658807e3 100755
--- a/functions/chroot.sh
+++ b/functions/chroot.sh
@@ -11,14 +11,16 @@
Chroot ()
{
- CHROOT="${1}"; shift
- COMMANDS="${@}"
+ local CHROOT="${1}"; shift
+ local COMMANDS
+ COMMANDS="${@}" #must be on separate line to 'local' declaration to avoid error
# Executing commands in chroot
Echo_debug "Executing: %s" "${COMMANDS}"
ENV=""
+ local _FILE
for _FILE in config/environment config/environment.chroot
do
if [ -e "${_FILE}" ]
@@ -39,8 +41,8 @@ Chroot ()
}
Chroot_has_package() {
- PACKAGE="${1}"; shift
- CHROOT="${2:-chroot}"; shift
+ local PACKAGE="${1}"; shift
+ local CHROOT="${2:-chroot}"; shift
if dpkg-query --admindir=${CHROOT}/var/lib/dpkg -s ${PACKAGE} >/dev/null 2>&1 | grep -q "^Status: install"
then
@@ -50,7 +52,7 @@ Chroot_has_package() {
}
Chroot_package_list() {
- CHROOT="${1:-chroot}"; shift
+ local CHROOT="${1:-chroot}"; shift
dpkg-query --admindir=${CHROOT}/var/lib/dpkg -W -f'${Package}\n'
}
diff --git a/functions/chroot_bind_path.sh b/functions/chroot_bind_path.sh
index e6695dd2f..94a033e85 100755
--- a/functions/chroot_bind_path.sh
+++ b/functions/chroot_bind_path.sh
@@ -11,6 +11,9 @@
Chroot_bind_path ()
{
+ local CHROOT
+ local BIND_SRC
+ local BIND_DEST
CHROOT="$(readlink -f ${1})"
BIND_SRC="$(readlink -f ${2})"
@@ -27,6 +30,9 @@ Chroot_bind_path ()
Chroot_unbind_path ()
{
+ local CHROOT
+ local BIND_SRC
+ local BIND_DEST
CHROOT="$(readlink -f ${1})"
BIND_SRC="$(readlink -f ${2})"
diff --git a/functions/conffile.sh b/functions/conffile.sh
index 15f16c93f..ceb11ea06 100755
--- a/functions/conffile.sh
+++ b/functions/conffile.sh
@@ -11,10 +11,12 @@
Get_conffiles ()
{
+ local FILES
if [ -n "${LB_CONFIG}" ]
then
FILES="${LB_CONFIG}"
else
+ local FILE
for FILE in ${@}
do
FILES="${FILES} ${FILE} ${FILE}.${LB_ARCHITECTURES} ${FILE}.${DISTRIBUTION}"
@@ -29,6 +31,7 @@ Get_conffiles ()
Read_conffiles ()
{
+ local CONFFILE
for CONFFILE in $(Get_conffiles "${@}")
do
if [ -f "${CONFFILE}" ]
@@ -46,6 +49,7 @@ Read_conffiles ()
Print_conffiles ()
{
+ local CONFFILE
for CONFFILE in $(Get_conffiles "${@}")
do
if [ -f "${CONFFILE}" ]
diff --git a/functions/configuration.sh b/functions/configuration.sh
index 0fb84a962..70faa62a1 100755
--- a/functions/configuration.sh
+++ b/functions/configuration.sh
@@ -11,29 +11,30 @@
Get_configuration ()
{
- _CONFIGURATION_FILE="${1}"
- _FIELD_NAME="${2}"
+ local CONFIGURATION_FILE="${1}"
+ local FIELD_NAME="${2}"
+ local FIELD_BODY
- if [ -e "${_CONFIGURATION_FILE}" ]
+ if [ -e "${CONFIGURATION_FILE}" ]
then
- _FIELD_BODY="$(grep ^${_FIELD_NAME}: ${_CONFIGURATION_FILE} | awk '{ $1=""; print $0 }' | sed -e 's|^ ||')"
+ FIELD_BODY="$(grep ^${FIELD_NAME}: ${CONFIGURATION_FILE} | awk '{ $1=""; print $0 }' | sed -e 's|^ ||')"
fi
- echo ${_FIELD_BODY}
+ echo ${FIELD_BODY}
}
Set_configuration ()
{
- _CONFIGURATION_FILE="${1}"
- _FIELD_NAME="${2}"
- _FIELD_BODY="${3}"
+ local CONFIGURATION_FILE="${1}"
+ local FIELD_NAME="${2}"
+ local FIELD_BODY="${3}"
- if grep -qs "^${_FIELD_NAME}:" "${_CONFIGURATION_FILE}"
+ if grep -qs "^${FIELD_NAME}:" "${CONFIGURATION_FILE}"
then
# Update configuration
- sed -i -e "s|^${_FIELD_NAME}:.*$|${_FIELD_NAME}: ${_FIELD_BODY}|" "${_CONFIGURATION_FILE}"
+ sed -i -e "s|^${FIELD_NAME}:.*$|${FIELD_NAME}: ${FIELD_BODY}|" "${CONFIGURATION_FILE}"
else
# Append configuration
- echo "${_FIELD_NAME}: ${_FIELD_BODY}" >> "${_CONFIGURATION_FILE}"
+ echo "${FIELD_NAME}: ${FIELD_BODY}" >> "${CONFIGURATION_FILE}"
fi
}
diff --git a/functions/defaults.sh b/functions/defaults.sh
index 786a9dc4c..14ec0efea 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -96,6 +96,7 @@ Set_config_defaults ()
# Setting mode (currently: debian, progress-linux)
if [ $(which lsb_release) ]
then
+ local _DISTRIBUTOR
_DISTRIBUTOR="$(lsb_release -is | tr "[A-Z]" "[a-z]")"
case "${_DISTRIBUTOR}" in
@@ -624,6 +625,7 @@ Set_config_defaults ()
;;
esac
+ local _LB_BOOTAPPEND_PRESEED
if [ -n "${LB_DEBIAN_INSTALLER_PRESEEDFILE}" ]
then
case "${LIVE_IMAGE_TYPE}" in
diff --git a/functions/echo.sh b/functions/echo.sh
index e019d8ed7..48cf3cf8e 100755
--- a/functions/echo.sh
+++ b/functions/echo.sh
@@ -12,7 +12,7 @@ exec 3>&1
Echo ()
{
- STRING="${1}"
+ local STRING="${1}"
shift
printf "${STRING}\n" "${@}" >&3
@@ -21,7 +21,7 @@ Echo ()
Echo_debug ()
{
if [ "${_DEBUG}" = "true" ]; then
- STRING="${1}"
+ local STRING="${1}"
shift
printf "D: ${STRING}\n" "${@}" >&3
@@ -30,7 +30,7 @@ Echo_debug ()
Echo_error ()
{
- STRING="${1}"
+ local STRING="${1}"
shift
local PREFIX="${RED}E${NO_COLOR}"
@@ -45,7 +45,7 @@ Echo_message ()
{
if [ "${_QUIET}" != "true" ]
then
- STRING="${1}"
+ local STRING="${1}"
shift
local PREFIX="${PURPLE}P${NO_COLOR}"
@@ -60,7 +60,7 @@ Echo_message ()
Echo_verbose ()
{
if [ "${_VERBOSE}" = "true" ]; then
- STRING="${1}"
+ local STRING="${1}"
shift
printf "I: ${STRING}\n" "${@}" >&3
@@ -69,7 +69,7 @@ Echo_verbose ()
Echo_warning ()
{
- STRING="${1}"
+ local STRING="${1}"
shift
local PREFIX="${YELLOW}W${NO_COLOR}"
@@ -82,6 +82,7 @@ Echo_warning ()
Echo_file ()
{
+ local LINE
while read -r LINE
do
echo "${1}: ${LINE}" >&3
diff --git a/functions/firmwarelists.sh b/functions/firmwarelists.sh
index a31860622..345752de4 100755
--- a/functions/firmwarelists.sh
+++ b/functions/firmwarelists.sh
@@ -19,6 +19,7 @@ Firmware_List_From_Contents () {
local DISTRO_CHROOT="${2}"
local ARCHIVE_AREAS="${3}"
+ local _ARCHIVE_AREA
for _ARCHIVE_AREA in ${ARCHIVE_AREAS}
do
local CONTENTS_URL="${MIRROR_CHROOT}/dists/${DISTRO_CHROOT}/${_ARCHIVE_AREA}/Contents-${LB_ARCHITECTURES}.gz"
diff --git a/functions/losetup.sh b/functions/losetup.sh
index c3dd59641..c91852f26 100755
--- a/functions/losetup.sh
+++ b/functions/losetup.sh
@@ -10,8 +10,8 @@
Lodetach ()
{
- DEVICE="${1}"
- ATTEMPT="${2:-1}"
+ local DEVICE="${1}"
+ local ATTEMPT="${2:-1}"
if [ "${ATTEMPT}" -gt 3 ]
then
@@ -37,10 +37,12 @@ Lodetach ()
Losetup ()
{
- DEVICE="${1}"
- FILE="${2}"
- PARTITION="${3:-1}"
+ local DEVICE="${1}"
+ local FILE="${2}"
+ local PARTITION="${3:-1}"
+ local FDISK_OUT
+ local LOOPDEVICE
losetup --read-only --partscan "${DEVICE}" "${FILE}"
FDISK_OUT="$(fdisk -l -u ${DEVICE} 2>&1)"
Lodetach "${DEVICE}"
@@ -53,6 +55,8 @@ Losetup ()
losetup --partscan "${DEVICE}" "${FILE}"
else
+ local SECTORS
+ local OFFSET
SECTORS="$(echo "$FDISK_OUT" | sed -ne "s|^$LOOPDEVICE[ *]*\([0-9]*\).*|\1|p")"
OFFSET="$(expr ${SECTORS} '*' 512)"
@@ -65,7 +69,7 @@ Losetup ()
# adapted from lib/ext2fs/mkjournal.c, default block size is 4096 bytes (/etc/mke2fs.conf).
ext2fs_default_journal_size()
{
- SIZE="$1"
+ local SIZE="$1"
if [ "${SIZE}" -lt "8" ]; then # 2048*4096
echo 0
elif [ "${SIZE}" -lt "128" ]; then # 32768*4096
@@ -83,9 +87,10 @@ ext2fs_default_journal_size()
Calculate_partition_size_without_journal ()
{
- WITHOUT_JOURNAL_ORIGINAL_SIZE="${1}"
- WITHOUT_JOURNAL_FILESYSTEM="${2}"
+ local WITHOUT_JOURNAL_ORIGINAL_SIZE="${1}"
+ local WITHOUT_JOURNAL_FILESYSTEM="${2}"
+ local PERCENT
case "${WITHOUT_JOURNAL_FILESYSTEM}" in
ext2|ext3|ext4)
PERCENT="6"
@@ -100,11 +105,16 @@ Calculate_partition_size_without_journal ()
Calculate_partition_size ()
{
- ORIGINAL_SIZE="${1}"
- FILESYSTEM="${2}"
+ local ORIGINAL_SIZE="${1}"
+ local FILESYSTEM="${2}"
case "${FILESYSTEM}" in
ext3|ext4)
+ local NON_JOURNAL_SIZE
+ local PROJECTED_JOURNAL_SIZE
+ local PROJECTED_PARTITION_SIZE
+ local PRE_FINAL_PARTITION_SIZE
+ local JOURNAL_SIZE
NON_JOURNAL_SIZE=$(Calculate_partition_size_without_journal ${ORIGINAL_SIZE} ${FILESYSTEM})
PROJECTED_JOURNAL_SIZE=$(ext2fs_default_journal_size ${NON_JOURNAL_SIZE})
PROJECTED_PARTITION_SIZE=$(expr ${ORIGINAL_SIZE} + ${PROJECTED_JOURNAL_SIZE})
diff --git a/functions/packagelists.sh b/functions/packagelists.sh
index 4701c3c70..ad31f4909 100755
--- a/functions/packagelists.sh
+++ b/functions/packagelists.sh
@@ -11,17 +11,20 @@
Expand_packagelist ()
{
+ local _LB_EXPAND_QUEUE
_LB_EXPAND_QUEUE="$(basename "${1}")"
shift
while [ -n "${_LB_EXPAND_QUEUE}" ]
do
+ local _LB_LIST_NAME
+ local _LB_EXPAND_QUEUE
_LB_LIST_NAME="$(echo ${_LB_EXPAND_QUEUE} | cut -d" " -f1)"
_LB_EXPAND_QUEUE="$(echo ${_LB_EXPAND_QUEUE} | cut -s -d" " -f2-)"
- _LB_LIST_LOCATION=""
- _LB_NESTED=0
- _LB_ENABLED=1
+ local _LB_LIST_LOCATION=""
+ local _LB_NESTED=0
+ local _LB_ENABLED=1
for _LB_SEARCH_PATH in ${@}
do
@@ -42,6 +45,7 @@ Expand_packagelist ()
do
case "${_LB_LINE}" in
\!*)
+ local _EXEC
_EXEC="$(echo ${_LB_LINE} | sed -e 's|^!||')"
case "${LB_BUILD_WITH_CHROOT}" in
@@ -63,6 +67,10 @@ Expand_packagelist ()
fi
_LB_NESTED=1
+ local _LB_NEEDLE
+ local _LB_HAYSTACK
+ local _LB_NEEDLE_PART
+ local _LB_HAYSTACK_PART
_LB_NEEDLE="$(echo "${_LB_LINE}" | cut -d' ' -f3-)"
_LB_HAYSTACK="$(eval "echo \$LB_$(echo "${_LB_LINE}" | cut -d' ' -f2)")"
@@ -87,6 +95,10 @@ Expand_packagelist ()
fi
_LB_NESTED=1
+ local _LB_NEEDLE
+ local _LB_HAYSTACK
+ local _LB_NEEDLE_PART
+ local _LB_HAYSTACK_PART
_LB_NEEDLE="$(echo "${_LB_LINE}" | cut -d' ' -f3-)"
_LB_HAYSTACK="$(eval "echo \$LB_$(echo "${_LB_LINE}" | cut -d' ' -f2)")"
@@ -126,13 +138,15 @@ Expand_packagelist ()
Discover_package_architectures ()
{
- _LB_EXPANDED_PKG_LIST="${1}"
- _LB_DISCOVERED_ARCHITECTURES=""
+ local _LB_EXPANDED_PKG_LIST="${1}"
+ local _LB_DISCOVERED_ARCHITECTURES=""
shift
if [ -e "${_LB_EXPANDED_PKG_LIST}" ] && [ -s "${_LB_EXPANDED_PKG_LIST}" ]
then
+ local _LB_PACKAGE_LINE
+ local _LB_PACKAGE_LINE_PART
while read _LB_PACKAGE_LINE
do
# Lines from the expanded package list may have multiple, space-separated packages
diff --git a/functions/packages.sh b/functions/packages.sh
index f07bed35f..fa16b1161 100755
--- a/functions/packages.sh
+++ b/functions/packages.sh
@@ -9,11 +9,12 @@
## under certain conditions; see COPYING for details.
+# Note, updates _LB_PACKAGES
Check_package ()
{
- CHROOT="${1}"
- FILE="${2}"
- PACKAGE="${3}"
+ local CHROOT="${1}"
+ local FILE="${2}"
+ local PACKAGE="${3}"
Check_installed "${CHROOT}" "${FILE}" "${PACKAGE}"
@@ -68,9 +69,9 @@ Remove_package ()
# 2 if package isn't installed and we aren't in an apt managed system
Check_installed ()
{
- CHROOT="${1}"
- FILE="${2}"
- PACKAGE="${3}"
+ local CHROOT="${1}"
+ local FILE="${2}"
+ local PACKAGE="${3}"
if [ "${LB_BUILD_WITH_CHROOT}" = "true" ] && [ "${CHROOT}" = "chroot" ]
then
diff --git a/functions/stagefile.sh b/functions/stagefile.sh
index 09168f5f4..9ef4789c9 100755
--- a/functions/stagefile.sh
+++ b/functions/stagefile.sh
@@ -44,11 +44,15 @@ Create_stagefile ()
Require_stagefile ()
{
+ local NAME
+ local FILES
+ local NUMBER
NAME="$(basename ${0})"
- FILES="${@}"
+ FILES="${@}" #must be on separate line to 'local' declaration to avoid error
NUMBER="$(echo ${@} | wc -w)"
- CONTINUE=false
+ local FILE
+ local CONTINUE=false
for FILE in ${FILES}
do
# Find at least one of the required stages
diff --git a/functions/wrapper.sh b/functions/wrapper.sh
index 002de785e..e96e1ac4e 100755
--- a/functions/wrapper.sh
+++ b/functions/wrapper.sh
@@ -11,7 +11,7 @@
Apt ()
{
- CHROOT="${1}"
+ local CHROOT="${1}"
shift
case "${LB_APT}" in
diff --git a/scripts/build/binary_grub-legacy b/scripts/build/binary_grub-legacy
index 442b70326..fd54e7f64 100755
--- a/scripts/build/binary_grub-legacy
+++ b/scripts/build/binary_grub-legacy
@@ -50,10 +50,10 @@ Install_package
# Local functions
Grub_live_entry ()
{
- LABEL="${1}"
- KERNEL="${2}"
- INITRD="${3}"
- APPEND="${4}"
+ local LABEL="${1}"
+ local KERNEL="${2}"
+ local INITRD="${3}"
+ local APPEND="${4}"
LINUX_LIVE="${LINUX_LIVE}\ntitle\t\tDebian GNU/Linux - ${LABEL}"
LINUX_LIVE="${LINUX_LIVE}\nkernel\t\t/${KERNEL} ${INITFS:+boot=${INITFS} }config LB_BOOTAPPEND_LIVE ${APPEND}"
@@ -62,15 +62,14 @@ Grub_live_entry ()
Grub_install_entry ()
{
- LABEL="${1}"
- KERNEL="${2}"
- INITRD="${3}"
- APPEND="${4}"
+ local LABEL="${1}"
+ local KERNEL="${2}"
+ local INITRD="${3}"
+ local APPEND="${4}"
- APPEND="${APPEND} LB_BOOTAPPEND_INSTALL"
+ local APPEND="${APPEND} LB_BOOTAPPEND_INSTALL"
- if [ "${LABEL}" != "expert" ] && [ "${LABEL}" != "expertgui" ]
- then
+ if [ "${LABEL}" != "expert" ] && [ "${LABEL}" != "expertgui" ]; then
APPEND="${APPEND} --- quiet"
fi
diff --git a/scripts/build/binary_hdd b/scripts/build/binary_hdd
index a4d907fdd..bc9c61672 100755
--- a/scripts/build/binary_hdd
+++ b/scripts/build/binary_hdd
@@ -287,6 +287,8 @@ find /live/vmlinuz
EOM
EOF
+ local rootpartition
+ local hdddev
rootpartition="$(Chroot chroot 'sh grub.sh' 2>/dev/null | grep -A 1 'find /live/vmlinuz' | grep -v 'find /live/vmlinuz')"
hdddev="$(echo $rootpartition | sed -e 's|,[[:digit:]]||')"
echo "Root partition is $rootpartition, device is: $hdddev"
diff --git a/scripts/build/binary_loopback_cfg b/scripts/build/binary_loopback_cfg
index 0b8af76a4..62681603a 100755
--- a/scripts/build/binary_loopback_cfg
+++ b/scripts/build/binary_loopback_cfg
@@ -66,11 +66,11 @@ Grub_live_entry ()
Grub_install_entry ()
{
- LABEL="${1}"
- TYPE="${2}"
- KERNEL="${3}"
- INITRD="${4}"
- APPEND="${5}"
+ local LABEL="${1}"
+ local TYPE="${2}"
+ local KERNEL="${3}"
+ local INITRD="${4}"
+ local APPEND="${5}"
# Drop "quiet" kernel parameter for expert entries
case $TYPE in
diff --git a/scripts/build/config b/scripts/build/config
index 1d0c150ff..2b9ff701c 100755
--- a/scripts/build/config
+++ b/scripts/build/config
@@ -137,6 +137,7 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
Local_arguments ()
{
+ local LONG_OPTIONS
LONG_OPTIONS="apt:,apt-ftp-proxy:,apt-http-proxy:,apt-options:,aptitude-options:,debootstrap-options:,debootstrap-script:,
apt-pipeline:,apt-recommends:,apt-secure:,apt-source-archives:,cache:,cache-indices:,cache-packages:,
cache-stages:,debconf-frontend:,debconf-priority:,dump,
@@ -165,6 +166,7 @@ Local_arguments ()
# Remove spaces added by indentation
LONG_OPTIONS="$(echo ${LONG_OPTIONS} | tr -d ' ')"
+ local ARGUMENTS
local ERR=0
ARGUMENTS="$(getopt --longoptions ${LONG_OPTIONS} --name="${PROGRAM}" --options a:d:m:k:b:s:c:huv --shell sh -- "${@}")" || ERR=$?
@@ -183,6 +185,7 @@ Local_arguments ()
case "${1}" in
--dump)
# Dump version
+ local VERSION_DPKG
if [ $(which dpkg-query) ]
then
VERSION_DPKG="$(dpkg-query -f='${Version}' --show live-build)"
@@ -194,6 +197,7 @@ Local_arguments ()
Print_conffiles $(Common_config_files)
# Dump contents of directories that contain text files
+ local DIRECTORY
for DIRECTORY in config/package-lists config/apt config/preseed config/rootfs
do
if Find_files "${DIRECTORY}"
diff --git a/scripts/build/installer_debian-installer b/scripts/build/installer_debian-installer
index 343c678ee..5eb935fe6 100755
--- a/scripts/build/installer_debian-installer
+++ b/scripts/build/installer_debian-installer
@@ -151,8 +151,7 @@ case "${LB_ARCHITECTURES}" in
esac
Install_file() {
- local FILE
- FILE="${1}"
+ local FILE="${1}"
Echo_debug "Installing file %s" "${FILE}"
@@ -166,9 +165,9 @@ Install_file() {
ARCHIVE_AREA="main"
fi
- local TARGET
- TARGET="${2}/${ARCHIVE_AREA}"
+ local TARGET="${2}/${ARCHIVE_AREA}"
+ local SOURCE
SOURCE="$(dpkg -f ${FILE} Source | awk '{ print $1 }')"
if [ -z "${SOURCE}" ]
@@ -176,6 +175,7 @@ Install_file() {
SOURCE="$(basename ${FILE} | awk -F_ '{ print $1 }')"
fi
+ local LETTER
case "${SOURCE}" in
lib?*)
LETTER="$(echo ${SOURCE} | sed 's|\(....\).*|\1|')"
@@ -198,14 +198,12 @@ Install_file() {
_LB_CACHE_DIR="$(pwd)/cache/installer_debian-installer"
Download_file () {
- local _LB_TARGET
- _LB_TARGET="${1}"
-
- local _LB_URL
- _LB_URL="${2}"
+ local _LB_TARGET="${1}"
+ local _LB_URL="${2}"
Echo_debug "Downloading file \`%s\` from \`%s\`" "${_LB_TARGET}" "${_LB_URL}"
+ local _LB_CACHE_FILE
_LB_CACHE_FILE="${_LB_CACHE_DIR}/$(echo "${_LB_URL}" | sed 's|/|_|g')"
if [ ! -f "${_LB_CACHE_FILE}" ]
@@ -795,11 +793,9 @@ fi
Repack_initrd()
{
- local TARGET_INITRD
- local INCLUDE_PATH
- TARGET_INITRD="${1}"
- INCLUDE_PATH="${2}"
- REPACK_TMPDIR="unpacked-initrd"
+ local TARGET_INITRD="${1}"
+ local INCLUDE_PATH="${2}"
+ local REPACK_TMPDIR="unpacked-initrd"
Echo_debug "Repacking initrd \`%s\`" "${TARGET_INITRD}"
@@ -816,6 +812,7 @@ Repack_initrd()
if [ ! -d "${INCLUDE_PATH}" ]
then
# Invoked the old way, just copy the preseeds
+ local _FILE
for _FILE in ../config/preseed/*.cfg ../config/preseed/*.cfg.installer
do
if [ -e "${_FILE}" ]
@@ -825,7 +822,7 @@ Repack_initrd()
done
else
# New way, include target directory content in the initrd
- REPACK_TMPDIR_ABS="${PWD}"
+ local REPACK_TMPDIR_ABS="${PWD}"
cd "${INCLUDE_PATH}"
find -print0 | cpio -pumd0 --no-preserve-owner "${REPACK_TMPDIR_ABS}/"
cd "${OLDPWD}"