189 lines
6.0 KiB
Bash
Executable File
189 lines
6.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
set -x
|
|
|
|
##
|
|
## PARAMS
|
|
##
|
|
|
|
RELEASE_VERSION=${RELEASE_VERSION:-2.1.0.0}
|
|
SKAWARE_VERSION="2.0.0"
|
|
SKAWARE_SOURCE=${SKAWARE_SOURCE:-https://github.com/just-containers/skaware/releases/download/v$SKAWARE_VERSION}
|
|
|
|
ENVDIR_VERSION="1.0.0"
|
|
ENVDIR_SOURCE=${ENVDIR_SOURCE:-https://github.com/just-containers/justc-envdir/releases/download/v$ENVDIR_VERSION}
|
|
|
|
PREINIT_VERSION="1.0.2"
|
|
PREINIT_SOURCE=${PREINIT_SOURCE:-https://github.com/just-containers/s6-overlay-preinit/releases/download/v$PREINIT_VERSION}
|
|
|
|
PWD=$(pwd)
|
|
TMP=${PWD}/tmp
|
|
DIST=${PWD}/dist
|
|
OVERLAY_SRC_PATH=${OVERLAY_SRC_PATH:-$PWD/overlay-rootfs}
|
|
OVERLAY_DST_PATH=${OVERLAY_DST_PATH:-$PWD/overlay-rootfs}
|
|
|
|
mkdir -p ${TMP}
|
|
mkdir -p ${DIST}
|
|
|
|
targets=( 'amd64' 'arm' 'armhf' 'x86' 'aarch64' 'ppc64le' )
|
|
editions=( '' 'nobin' )
|
|
|
|
generate_release() {
|
|
printf "Binary releases include the following skaware packages:\n\n" > ${DIST}/release.md
|
|
printf "| Software | Version |\n" >> ${DIST}/release.md
|
|
printf "| -------- |:-------:|\n" >> ${DIST}/release.md
|
|
|
|
while read -r line
|
|
do
|
|
package=`echo "${line}" | cut -d"=" -f1`
|
|
version=`echo "${line}" | cut -d"=" -f2`
|
|
if [ -n "${version}" ] ; then
|
|
printf "| %s | %s |\n" "${package}" "${version}" >> ${DIST}/release.md
|
|
fi
|
|
done < ${DIST}/manifest.txt
|
|
printf "\n" >> $DIST/release.md
|
|
|
|
printf "Additionally, justc-envdir version %s\n" "${ENVDIR_VERSION}" >> ${DIST}/release.md
|
|
}
|
|
|
|
get_packages_with_versions_from_manifest() {
|
|
# manifest
|
|
manifest=$1
|
|
|
|
# skaware versions manifest
|
|
curl -R -L -o ${TMP}/manifest.txt ${SKAWARE_SOURCE}/$manifest
|
|
|
|
# parse manifest into s6 associative array
|
|
versions=()
|
|
while read -r line
|
|
do
|
|
key=`echo "${line}" | cut -d"=" -f1`
|
|
value=`echo "${line}" | cut -d"=" -f2`
|
|
if [[ ! -z "${key}" && ! -z "${value}" ]]; then
|
|
versions+=("${key}-${value}")
|
|
fi
|
|
done < ${TMP}/manifest.txt
|
|
|
|
mv ${TMP}/manifest.txt ${DIST}/manifest.txt
|
|
|
|
# output manifest as an array
|
|
echo ${versions[@]}
|
|
}
|
|
|
|
##
|
|
## DOWNLOAD PACKAGES
|
|
##
|
|
|
|
# destination folder
|
|
cd ${TMP}
|
|
|
|
for target in "${targets[@]}"; do
|
|
curl -R -L -O ${ENVDIR_SOURCE}/justc-envdir-${ENVDIR_VERSION}-linux-${target}.tar.gz
|
|
curl -R -L -O ${PREINIT_SOURCE}/s6-overlay-preinit-${PREINIT_VERSION}-linux-${target}.tar.gz
|
|
done
|
|
|
|
packages=($(get_packages_with_versions_from_manifest "manifest-linux.txt"))
|
|
for package in "${packages[@]}"; do
|
|
for target in "${targets[@]}"; do
|
|
file=${package}-linux-${target}-bin.tar.gz
|
|
curl -R -L -O ${SKAWARE_SOURCE}/$file
|
|
done
|
|
done
|
|
|
|
generate_release
|
|
|
|
##
|
|
## OVERLAYS
|
|
##
|
|
|
|
for edition in "${editions[@]}"; do
|
|
for target in "${targets[@]}"; do
|
|
# overlay path and dist file
|
|
if [ "${edition}" == "nobin" ]; then
|
|
overlaydstpath="$OVERLAY_DST_PATH-nobin"
|
|
overlaytarpath="${DIST}/s6-overlay-nobin.tar.gz"
|
|
else
|
|
overlaydstpath="$OVERLAY_DST_PATH-raw"
|
|
overlaytarpath="${DIST}/s6-overlay-$target.tar.gz"
|
|
fi
|
|
|
|
rm -rf $overlaydstpath
|
|
rm -f $overlaytarpath
|
|
|
|
# create overlay folder
|
|
mkdir -p $overlaydstpath
|
|
mkdir -p ${DIST}
|
|
|
|
# copy overlay files
|
|
cp -a $OVERLAY_SRC_PATH/. $overlaydstpath/
|
|
|
|
if [ "${edition}" != "nobin" ]; then
|
|
# skarnet versions manifest
|
|
packages=($(get_packages_with_versions_from_manifest "manifest-linux.txt"))
|
|
|
|
# install required binaries for this concrete output
|
|
for package in "${packages[@]}"; do
|
|
tar xvfz ${TMP}/$package-linux-$target-bin.tar.gz -C $overlaydstpath
|
|
done
|
|
tar xvfz ${TMP}/justc-envdir-${ENVDIR_VERSION}-linux-$target.tar.gz -C $overlaydstpath
|
|
tar xvfz ${TMP}/s6-overlay-preinit-${PREINIT_VERSION}-linux-$target.tar.gz -C $overlaydstpath
|
|
fi
|
|
|
|
# create must exist directories
|
|
mkdir -p $overlaydstpath/etc/s6/init/env-stage2
|
|
mkdir -p $overlaydstpath/etc/{cont-init.d,cont-finish.d,fix-attrs.d,services.d}
|
|
|
|
# fix perms for utilities
|
|
chmod 0755 $overlaydstpath/usr/bin/fix-attrs
|
|
chmod 0755 $overlaydstpath/usr/bin/logutil-{newfifo,service,service-main}
|
|
chmod 0755 $overlaydstpath/usr/bin/printcontenv
|
|
chmod 0755 $overlaydstpath/usr/bin/with-{contenv,retries,contenv-legacy}
|
|
|
|
# fix init perms
|
|
chmod 0755 $overlaydstpath/init
|
|
chmod 0755 $overlaydstpath/etc/s6/init/init-*
|
|
chmod 0755 $overlaydstpath/etc/s6/init-catchall/init-*
|
|
chmod 0755 $overlaydstpath/etc/s6/init-no-catchall/init-*
|
|
chmod 0755 $overlaydstpath/etc/s6/services/.s6-svscan/{crash,finish}
|
|
chmod 0755 $overlaydstpath/etc/s6/services/s6-fdholderd/run
|
|
chmod 0755 $overlaydstpath/etc/s6/services/s6-svscan-log/run
|
|
|
|
# fix misc perms
|
|
chmod 0755 $overlaydstpath/etc
|
|
chmod 0755 $overlaydstpath/etc/{cont-init.d,cont-finish.d,fix-attrs.d,services.d}
|
|
chmod 0755 $overlaydstpath/etc/s6
|
|
chmod 0755 $overlaydstpath/etc/s6/{services,init-catchall,init-no-catchall,init}
|
|
chmod 0755 $overlaydstpath/etc/s6/{init-catchall,init-no-catchall,init,services}
|
|
chmod 0755 $overlaydstpath/etc/s6/init/{env,env-stage2}
|
|
chmod 0755 $overlaydstpath/etc/s6/services/{.s6-svscan,s6-fdholderd,s6-svscan-log}
|
|
chmod 0755 $overlaydstpath/etc/s6/services/s6-fdholderd/rules
|
|
chmod 0755 $overlaydstpath/etc/s6/services/s6-fdholderd/rules/uid
|
|
chmod 0755 $overlaydstpath/etc/s6/services/s6-fdholderd/rules/uid/{0,default}
|
|
chmod 0755 $overlaydstpath/etc/s6/services/s6-fdholderd/rules/uid/0/env
|
|
chmod 0755 $overlaydstpath/etc/s6/services/s6-fdholderd/rules/uid/default/env
|
|
chmod 0755 $overlaydstpath/usr/bin
|
|
|
|
if [ "${edition}" != "nobin" ]; then
|
|
chmod 0755 $overlaydstpath/bin
|
|
chmod 0755 $overlaydstpath/libexec
|
|
|
|
# setuid for preinit
|
|
chmod 4755 $overlaydstpath/bin/s6-overlay-preinit
|
|
fi
|
|
|
|
chmod 0644 $overlaydstpath/etc/leapsecs.dat
|
|
chmod 0644 $overlaydstpath/etc/s6/services/s6-fdholderd/notification-fd
|
|
chmod 0644 $overlaydstpath/etc/s6/init/env/*
|
|
chmod 0644 $overlaydstpath/etc/s6/init/init-stage2-fixattrs.txt
|
|
|
|
# dist!
|
|
tar --owner=root --group=root \
|
|
-zcvf \
|
|
$overlaytarpath \
|
|
-C $overlaydstpath \
|
|
./
|
|
done
|
|
done
|
|
|
|
exit 0
|