flatcar-scripts/pkg_auto/sync_packages.sh
Krzesimir Nowak 4c5e550055 pkg-auto: Add package automation scripts
This adds some scripts I have been using for over a year to deal with
the weekly package updates.

It comes with a `README.md` which describes a workflow similar to my
own.

The `sync_packages.sh` and `update_packages.sh` scripts are currently
not used anywhere. The idea behind them was to use them for Github
Action, but that will come as a follow-up PR.
2024-11-27 16:00:57 +01:00

61 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
##
## Synces the packages with Gentoo.
##
## Parameters:
## -f: remove reports directory if it exists at startup
## -w: path to use for workdir
## -h: this help
##
## Positional:
## 1: config file
## 2: new branch name with updates
## 3: gentoo repo
##
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/impl/util.sh"
source "${PKG_AUTO_IMPL_DIR}/pkg_auto_lib.sh"
workdir=''
while [[ ${#} -gt 0 ]]; do
case ${1} in
-h)
print_help
exit 0
;;
-w)
if [[ -z ${2:-} ]]; then
fail 'missing value for -w'
fi
workdir=${2}
shift 2
;;
--)
shift
break
;;
-*)
fail "unknown flag '${1}'"
;;
*)
break
;;
esac
done
if [[ ${#} -ne 3 ]]; then
fail 'expected three positional parameters: a config file, a final branch name and a path to Gentoo repo'
fi
config_file=${1}; shift
saved_branch_name=${1}; shift
gentoo=${1}; shift
setup_workdir_with_config "${workdir}" "${config_file}"
perform_sync_with_gentoo "${gentoo}"
save_new_state "${saved_branch_name}"