Removed age_bin function from requirements
It is assumed that the host system is provisioned already with the binary (bootstrap_librem14 takes care of that)
This commit is contained in:
@@ -1,41 +1,59 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# First argument is preprocessed .env file supposed to be in tmp.build.XXXXXXXXXX directory
|
||||
# Let's load it up
|
||||
. $1
|
||||
# If number of arguments not equal to two
|
||||
if [ $# -ne 2 ] ; then
|
||||
echo "invalid argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOT_ENV_FILE="$1"
|
||||
FUNCTION_TO_CALL="$2"
|
||||
|
||||
alpine_source() {
|
||||
find ${CACHE_DIR} -type f -name ${RELEASE_BASENAME}.tar.gz | grep -q ${RELEASE_BASENAME} || \
|
||||
curl -sSL ${ALPINE_MIRROR}/${RELEASE_VERSION}/releases/${ALPINE_ARCH}/${RELEASE_BASENAME}.tar.gz -o ${CACHE_DIR}/${RELEASE_BASENAME}.tar.gz
|
||||
find "$CACHE_DIR" -name "$RELEASE_BASENAME.tar.gz" -type f | grep -q . || \
|
||||
wget "$ALPINE_MIRROR/$RELEASE_VERSION/releases/$ALPINE_ARCH/$RELEASE_BASENAME.tar.gz" -O "$CACHE_DIR/$RELEASE_BASENAME.tar.gz"
|
||||
|
||||
mkdir -p ${CACHE_DIR}/${RELEASE_BASENAME}
|
||||
mkdir -p "$CACHE_DIR/$RELEASE_BASENAME"
|
||||
|
||||
find ${CACHE_DIR}/${RELEASE_BASENAME} -type d -empty -exec tar xfz ${CACHE_DIR}/${RELEASE_BASENAME}.tar.gz -C ${CACHE_DIR}/${RELEASE_BASENAME} \;
|
||||
find "$CACHE_DIR" -name "$RELEASE_BASENAME" -type d -empty -exec \
|
||||
tar --directory "$CACHE_DIR/$RELEASE_BASENAME" --extract --gzip --same-permissions --strip 1 --file="$CACHE_DIR/$RELEASE_BASENAME.tar.gz" \;
|
||||
}
|
||||
|
||||
tailspin_bin() {
|
||||
find ${CACHE_DIR} -type f -name tailspin.tar.gz | grep -q tailspin || \
|
||||
curl -sSL https://github.com/bensadeh/tailspin/releases/download/4.0.0/tailspin-x86_64-unknown-linux-musl.tar.gz -o ${CACHE_DIR}/tailspin.tar.gz
|
||||
find "$CACHE_DIR" -name tailspin.tar.gz -type f | grep -q . || \
|
||||
wget https://github.com/bensadeh/tailspin/releases/download/4.0.0/tailspin-x86_64-unknown-linux-musl.tar.gz -O "$CACHE_DIR/tailspin.tar.gz"
|
||||
|
||||
mkdir -p ${CACHE_DIR}/tailspin
|
||||
mkdir -p "$CACHE_DIR/tailspin"
|
||||
|
||||
find ${CACHE_DIR}/tailspin -type d -empty -exec tar xfz ${CACHE_DIR}/tailspin.tar.gz -C ${CACHE_DIR}/tailspin \;
|
||||
find "$CACHE_DIR/tailspin" -type d -empty -exec tar xz -f "$CACHE_DIR/tailspin.tar.gz" -C "$CACHE_DIR/tailspin" \;
|
||||
}
|
||||
|
||||
age_bin() {
|
||||
find ${CACHE_DIR} -type d -name age-src | grep -q age-src || \
|
||||
git clone https://github.com/wj/age.git ${CACHE_DIR}/age-src
|
||||
# Private function names start with underscore
|
||||
_init() {
|
||||
. "$DOT_ENV_FILE"
|
||||
|
||||
mkdir -p ${CACHE_DIR}/age
|
||||
|
||||
find ${CACHE_DIR}/age -type d -empty -exec docker run --rm -v ${CACHE_DIR}/age:/usr/local/bin -e GOBIN=/usr/local/bin/ -v ${CACHE_DIR}/age-src:/usr/src/age -w /usr/src/age golang:1.22-alpine go install ./cmd/age \;
|
||||
mkdir -p "$CACHE_DIR/aport"
|
||||
mkdir -p "$CACHE_DIR/extras"
|
||||
mkdir -p secrets
|
||||
}
|
||||
|
||||
mkdir -p secrets
|
||||
mkdir -p ${CACHE_DIR}/aport
|
||||
mkdir -p ${CACHE_DIR}/extras
|
||||
# Second argument is supposed to be name of one of the functions declared above
|
||||
# functions starting with underscore are ignored (considered private)
|
||||
FUNCTIONS=$(cat "$0" | awk '/\(\) {/ {print $1}' | rev | cut -c3- | rev | grep "^[^_]")
|
||||
FOUND_FN=0
|
||||
for FN in $FUNCTIONS; do
|
||||
if [ "$FN" = "$FUNCTION_TO_CALL" ]; then
|
||||
FOUND_FN=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Second argument is supposed to be name of the functions decalred above
|
||||
# Let's call it
|
||||
$2
|
||||
if [ $FOUND_FN -eq 1 ]; then
|
||||
_init
|
||||
|
||||
echo "Calling $FUNCTION_TO_CALL"
|
||||
$FUNCTION_TO_CALL
|
||||
else
|
||||
echo "invalid argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user