Skip to content

Commit

Permalink
restamp: new command to bump timestamp
Browse files Browse the repository at this point in the history
Split out the `--timestamp-only` functionality from the `prune` command
since it feels awkward there, and put it in a new dedicated `restamp`
command instead.
  • Loading branch information
jlebon committed Dec 5, 2018
1 parent b89a40a commit 8d03d0f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion coreos-assembler
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [ -e /sys/fs/selinux/status ]; then
fi

cmd=${1:-}
build_commands="init fetch build buildextend-ec2 buildextend-openstack tag run prune clean"
build_commands="init fetch build buildextend-ec2 buildextend-openstack tag restamp run prune clean"
other_commands="shell"
utility_commands="gf-oemid virt-install oscontainer"
if [ -z "${cmd}" ]; then
Expand Down
16 changes: 2 additions & 14 deletions src/cmd-prune
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@ dn=$(dirname "$0")
print_help() {
cat 1>&2 <<'EOF'
Usage: coreos-assembler prune --help
coreos-assembler prune [--keep=N] [--timestamp-only]
coreos-assembler prune [--keep=N]
Delete older build artifacts. By default, only the last 3 builds are kept.
This can be overridden with the `--keep` option.
The `--timestamp-only` option will just update the `timestamp` key of
`builds.json`
EOF
}

# Parse options
KEEP_LAST_N="3"
TIMESTAMP=0
rc=0
options=$(getopt --options h --longoptions help,keep:,timestamp-only -- "$@") || rc=$?
options=$(getopt --options h --longoptions help,keep: -- "$@") || rc=$?
[ $rc -eq 0 ] || {
print_help
exit 1
Expand All @@ -41,9 +37,6 @@ while true; do
shift
KEEP_LAST_N="$1"
;;
--timestamp-only)
TIMESTAMP=1
;;
--)
shift
break
Expand All @@ -64,9 +57,4 @@ fi

prepare_build

if [ "${TIMESTAMP}" == 1 ]; then
"${dn}"/prune_builds --timestamp-only --workdir "${workdir:?}"
exit 0
fi

"${dn}"/prune_builds --keep-last-n "${KEEP_LAST_N}" --workdir "${workdir:?}"
24 changes: 24 additions & 0 deletions src/cmd-restamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail

dn=$(dirname "$0")
# shellcheck source=src/cmdlib.sh
. "${dn}"/cmdlib.sh

print_help() {
cat 1>&2 <<'EOF'
Usage: coreos-assembler restamp
Update the `timestamp` key of `builds.json`.
EOF
}

if [ $# -ne 0 ]; then
print_help
fatal "ERROR: Too many arguments"
exit 1
fi

prepare_build

"${dn}"/prune_builds --timestamp-only --workdir "${workdir:?}"

0 comments on commit 8d03d0f

Please sign in to comment.