1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-24 03:35:38 +03:00
aports/scripts/mkimage-yaml.sh
Natanael Copa 86da5a1047 scripts/mkimage: fix generation of version string
use git tag if we are at a given tag. use timestamp otherwise
2016-11-14 20:10:40 +00:00

69 lines
1.3 KiB
Bash
Executable file

#!/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)
for image; do
filepath="$releasedir/${image##*/}"
datetime="$(stat -c "%y" $image)"
size="$(stat -c "%s" $image)"
date=${datetime%% *}
time=${datetime#* }
time=${time%.*}
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