Cleaned up error handling in dist scripting
This commit is contained in:
parent
ae8c37e951
commit
8b3d4ee651
1
dist/tools/clean.sh
vendored
1
dist/tools/clean.sh
vendored
@ -21,6 +21,7 @@ if [[ ! -d "$PWD/dist/tools/" ]]; then echo "This script may only be executed vi
|
||||
if [[ ! -f ./dist/tools/common.sh ]]; then echo "Common script is missing. Ensure the source tree is intact."; exit 2; fi
|
||||
|
||||
source ./dist/tools/common.sh
|
||||
ACTION_NOUN="Housekeeping"
|
||||
|
||||
DIST_BIN="$PWD/dist/bin"
|
||||
DIST_RUNTIME="$PWD/dist/runtime"
|
||||
|
13
dist/tools/common.sh
vendored
13
dist/tools/common.sh
vendored
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/bash -e
|
||||
#
|
||||
# pacwrap - common.sh
|
||||
#
|
||||
@ -19,6 +19,11 @@
|
||||
|
||||
[[ ! -z $COMMON_SCRIPT ]] && return
|
||||
|
||||
set -e
|
||||
trap 'LAST_CMD=$BASH_COMMAND' DEBUG
|
||||
trap 'handle_failure "$ACTION_NOUN" $?' ERR TERM INT
|
||||
|
||||
ACTION_NOUN="Common script"
|
||||
DIST_BIN="$PWD/dist/bin"
|
||||
DIST_SRC="$PWD/dist/src"
|
||||
|
||||
@ -27,7 +32,11 @@ if [[ -t 2 ]] && [[ ! -z $COLORTERM ]] && [[ $TERM != "dummy" ]]; then
|
||||
RED="[1;31m"
|
||||
GREEN="[1;32m"
|
||||
RESET="[0m"
|
||||
fi
|
||||
fi
|
||||
|
||||
handle_failure() {
|
||||
error_fatal "$1 failure: $LAST_CMD exited with exit code $?."
|
||||
}
|
||||
|
||||
error_fatal() {
|
||||
echo $BOLD$RED"error:$RESET $@";
|
||||
|
7
dist/tools/package.sh
vendored
7
dist/tools/package.sh
vendored
@ -23,10 +23,11 @@ if [[ ! -d "$PWD/dist/tools/" ]]; then echo "This script may only be executed vi
|
||||
if [[ ! -f ./dist/tools/common.sh ]]; then echo "Common script is missing. Ensure the source tree is intact."; exit 2; fi
|
||||
|
||||
source ./dist/tools/common.sh
|
||||
ACTION_NOUN="Packaging"
|
||||
|
||||
DIST_MAN="$PWD/dist/man"
|
||||
|
||||
validate_args $1
|
||||
package $DIST_MAN/pacwrap.1 $DIST_BIN/pacwrap.1 $1; if [[ $? != 0 ]]; then error_fatal "Packaging of pacwrap.1 manpage failed."; fi
|
||||
package $DIST_MAN/pacwrap.yml.2 $DIST_BIN/pacwrap.yml.2 $1; if [[ $? != 0 ]]; then error_fatal "Packaging of pacwrap.yml.2 manpage failed."; fi
|
||||
./dist/tools/runtime.sh $1; if [[ $? != 0 ]]; then error_fatal "Build of container runtime failed."; fi
|
||||
package $DIST_MAN/pacwrap.1 $DIST_BIN/pacwrap.1 $1
|
||||
package $DIST_MAN/pacwrap.yml.2 $DIST_BIN/pacwrap.yml.2 $1
|
||||
./dist/tools/runtime.sh $1
|
||||
|
11
dist/tools/prepare.sh
vendored
11
dist/tools/prepare.sh
vendored
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/bin/bash -e
|
||||
#
|
||||
# pacwrap - prepare.sh
|
||||
#
|
||||
@ -23,8 +23,9 @@ if [[ ! -d "$PWD/dist/tools/" ]]; then echo "This script may only be executed vi
|
||||
if [[ ! -f ./dist/tools/common.sh ]]; then echo "Common script is missing. Ensure the source tree is intact."; exit 2; fi
|
||||
|
||||
source ./dist/tools/common.sh
|
||||
ACTION_NOUN="Preparation"
|
||||
|
||||
validate_args $1; if [[ $? != 0 ]]; then error_fatal "Argument validation failed."; fi
|
||||
layout_dir; if [[ $? != 0 ]]; then error_fatal "Directory initialization failed."; fi
|
||||
package $DIST_SRC/pacwrap-key $DIST_BIN/pacwrap-key $1 0; if [[ $? != 0 ]]; then error_fatal "Packaging of pacwrap-key failed."; fi
|
||||
./dist/tools/schema.sh $1; if [[ $? != 0 ]]; then error_fatal "Build of container schema failed."; fi
|
||||
validate_args $1
|
||||
layout_dir
|
||||
package $DIST_SRC/pacwrap-key $DIST_BIN/pacwrap-key $1 0
|
||||
./dist/tools/schema.sh $1
|
||||
|
21
dist/tools/runtime.sh
vendored
21
dist/tools/runtime.sh
vendored
@ -24,6 +24,7 @@ if [[ ! -d "$PWD/dist/tools/" ]]; then echo "This script may only be executed vi
|
||||
if [[ ! -f ./dist/tools/common.sh ]]; then echo "Common script is missing. Ensure the source tree is intact."; exit 2; fi
|
||||
|
||||
source ./dist/tools/common.sh
|
||||
ACTION_NOUN="Runtime generation"
|
||||
|
||||
#
|
||||
# Environment variables
|
||||
@ -118,8 +119,8 @@ populate_lib() {
|
||||
ln -s .$FAKEROOT$FAKECHROOT/libfakechroot.so $DEST_DIR$LIB_DIR/libfakechroot.so
|
||||
|
||||
# Remove debuglink section, to ensure the Arch Build System doesn't complain
|
||||
for lib in $(find $DEST_DIR$LIB_DIR -maxdepth 3 -printf "%p "); do
|
||||
objcopy --remove-section=.gnu_debuglink $lib 2>/dev/null
|
||||
for lib in $(find $DEST_DIR$LIB_DIR -maxdepth 3 -type f -printf "%p "); do
|
||||
objcopy --remove-section=.gnu_debuglink $lib
|
||||
done
|
||||
}
|
||||
|
||||
@ -148,8 +149,14 @@ populate_etc() {
|
||||
# Populate busybox links
|
||||
#
|
||||
busybox_links() {
|
||||
for applet in $(busybox --list); do
|
||||
ln -s busybox ./dist/runtime/bin/$applet 2>/dev/null
|
||||
for applet in $(busybox --list); do
|
||||
if [[ "${COREUTILS[@]}" == *$applet* ]] ||
|
||||
[[ "${BIN_UTILS[@]}" == *$applet* ]] ||
|
||||
[[ $applet == "busybox" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
ln -s busybox ./dist/runtime/bin/$applet
|
||||
done
|
||||
}
|
||||
|
||||
@ -173,8 +180,12 @@ copy_bins() {
|
||||
for bin in ${@}; do
|
||||
cp $(type -P $bin) $DEST_DIR$BIN_DIR/$bin
|
||||
|
||||
if [[ $bin == "fakeroot" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Remove debuglink section, to ensure the Arch Build System doesn't complain
|
||||
objcopy --remove-section=.gnu_debuglink $DEST_DIR$BIN_DIR/$bin 2>/dev/null
|
||||
objcopy --remove-section=.gnu_debuglink $DEST_DIR$BIN_DIR/$bin
|
||||
done
|
||||
}
|
||||
|
||||
|
3
dist/tools/schema.sh
vendored
3
dist/tools/schema.sh
vendored
@ -25,6 +25,7 @@ if [[ ! -d "$PWD/dist/tools/" ]]; then echo "This script may only be executed vi
|
||||
if [[ ! -f ./dist/tools/common.sh ]]; then echo "Common script is missing. Ensure the source tree is intact."; exit 2; fi
|
||||
|
||||
source ./dist/tools/common.sh
|
||||
ACTION_NOUN="Schema generation"
|
||||
|
||||
#
|
||||
# Environment variables
|
||||
@ -75,7 +76,7 @@ clean() {
|
||||
# Populate container skeleton archive
|
||||
#
|
||||
create_archive() {
|
||||
cd $DEST_DIR
|
||||
cd $DEST_DIR
|
||||
tar acf ../bin/filesystem.tar.zst *
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user