Commit 06d3a7fb authored by Natanael Copa's avatar Natanael Copa

scripts/mkimage.sh: generate yaml

parent 4f0364e6
#!/bin/sh
progname=$(basename $0)
usage() {
echo "usage: $progname --checksums <checksums> --arch <arch> FILE..."
}
checksums="sha256 sha512"
while [ $# -gt 0 ]; do
opt="$1"
shift
case "$opt" in
--checksums) checksums="$1"; shift ;;
--arch) arch="$1"; shift ;;
--branch) branch="$1"; shift;;
--release) release="$1"; shift;;
--flavor) flavor="$1"; shift;;
--) break ;;
-*) usage; exit 1;;
esac
done
set -- $opt "$@"
releasedir="$branch/releases/$arch"
if [ -z "$branch" ]; then
git_branch="$(git rev-parse --abbrev-ref HEAD)"
case "$git_branch" in
*-stable) branch=${git_branch%-stable};;
*) branch=edge;;
esac
fi
[ -n "$arch" ] || arch=$(apk --print-arch)
if [ -z "$release" ]; then
release=$(git describe --always)
if git describe --exact-match >/dev/null 2>&1; then
release=${release#v}
fi
fi
for image; do
filepath="$releasedir/${image##*/}"
datetime="$(stat -c "%y" $image)"
size="$(stat -c "%s" $image)"
date=${datetime%% *}
time=${datetime#* }
file=${filepath##*/}
flavor=${file%-${release}-${arch}.*}
cat <<-EOF
-
branch: $branch
arch: $arch
version: $release
flavor: $flavor
file: $file
iso: $file
date: $date
time: $time
size: $size
EOF
# generate checksums if missing
for hash in ${checksums}; do
if ! [ -f "$image.$hash" ]; then
${hash}sum $image > $image.$hash
fi
echo " $hash: $(cut -d' ' -f1 $image.$hash)"
done
done
......@@ -53,6 +53,7 @@ usage() {
$0 [--tag RELEASE] [--outdir OUTDIR] [--workdir WORKDIR]
[--arch ARCH] [--profile PROFILE] [--hostkeys] [--simulate]
[--yaml FILE]
$0 --help
options:
......@@ -64,6 +65,7 @@ options:
--simulate Don't execute commands
--tag Build images for tag RELEASE
--workdir Specify temporary working directory (cache)
--yaml
known profiles: $(echo $all_profiles | sort -u)
......@@ -172,6 +174,11 @@ build_profile() {
${_c}sum "$output_file" > "${output_file}.${_c}"
done
fi
if [ -n "$_yaml_out" ]; then
$mkimage_yaml --release $RELEASE \
"$output_file" >> "$_yaml_out"
fi
fi
}
......@@ -179,6 +186,8 @@ build_profile() {
load_plugins "$(dirname $0)"
[ -z "$HOME" ] || load_plugins "$HOME/.mkimage"
mkimage_yaml="$(dirname $0)"/mkimage-yaml.sh
# parse parameters
while [ $# -gt 0 ]; do
opt="$1"
......@@ -193,6 +202,7 @@ while [ $# -gt 0 ]; do
--hostkeys) _hostkeys="--hostkeys";;
--simulate) _simulate="yes";;
--checksum) _checksum="yes";;
--yaml) _yaml="yes";;
--) break ;;
-*) usage; exit 1;;
esac
......@@ -233,6 +243,10 @@ for ARCH in $req_arch; do
fi
abuild-apk update --root "$APKROOT"
if [ "$_yaml" = "yes" ]; then
_yaml_out=${OUTDIR:-.}/latest-release.yaml
echo "---" > "$_yaml_out"
fi
for PROFILE in $req_profiles; do
(build_profile) || exit 1
done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment