From 8d03d0f7e5141339411df029aa45cd6e79214c93 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Wed, 5 Dec 2018 09:02:26 -0500 Subject: [PATCH] restamp: new command to bump timestamp 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. --- coreos-assembler | 2 +- src/cmd-prune | 16 ++-------------- src/cmd-restamp | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 15 deletions(-) create mode 100755 src/cmd-restamp diff --git a/coreos-assembler b/coreos-assembler index 51aea99091..a26dd58ad4 100755 --- a/coreos-assembler +++ b/coreos-assembler @@ -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 diff --git a/src/cmd-prune b/src/cmd-prune index 68a5fc9091..9cef2781d8 100755 --- a/src/cmd-prune +++ b/src/cmd-prune @@ -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 @@ -41,9 +37,6 @@ while true; do shift KEEP_LAST_N="$1" ;; - --timestamp-only) - TIMESTAMP=1 - ;; --) shift break @@ -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:?}" diff --git a/src/cmd-restamp b/src/cmd-restamp new file mode 100755 index 0000000000..3732b5392d --- /dev/null +++ b/src/cmd-restamp @@ -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:?}"