aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mkimage-yaml.sh
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2016-11-11 06:45:15 -0800
committerNatanael Copa <ncopa@alpinelinux.org>2016-11-14 20:10:39 +0000
commit06d3a7fb5aa1527ba397127759f0cce358f82eb0 (patch)
treec343588abb596b5cf4256b4f391a9b6e7b79dd18 /scripts/mkimage-yaml.sh
parent4f0364e66ce5361cf43bd4002c3fe3d4ab6986bd (diff)
downloadaports-06d3a7fb5aa1527ba397127759f0cce358f82eb0.tar.bz2
aports-06d3a7fb5aa1527ba397127759f0cce358f82eb0.tar.xz
scripts/mkimage.sh: generate yaml
Diffstat (limited to 'scripts/mkimage-yaml.sh')
-rwxr-xr-xscripts/mkimage-yaml.sh74
1 files changed, 74 insertions, 0 deletions
diff --git a/scripts/mkimage-yaml.sh b/scripts/mkimage-yaml.sh
new file mode 100755
index 0000000000..b3e49626a0
--- /dev/null
+++ b/scripts/mkimage-yaml.sh
@@ -0,0 +1,74 @@
+#!/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