49 lines
759 B
Bash
Executable File
49 lines
759 B
Bash
Executable File
#!/usr/bin/env bash
|
|
shopt -s nullglob
|
|
|
|
lockfile='.mainenance.lock'
|
|
|
|
usage() { echo "$0 <repo_name>"; }
|
|
|
|
spark_repo=$1
|
|
[[ "$spark_repo" ]] || {
|
|
usage
|
|
exit 1
|
|
}
|
|
|
|
cleanup() { rm -f "$lockfile"; }
|
|
|
|
lock() {
|
|
[[ -f "$lockfile" ]] && {
|
|
printf 'Lockfile found: %s\n' "$lockfile" >&2
|
|
return 1
|
|
}
|
|
|
|
echo $$ > "$lockfile"
|
|
lock_pid=$(<"$lockfile")
|
|
[[ $$ == "$lock_pid" ]] || return 1
|
|
}
|
|
|
|
cd "$HOME/public/$spark_repo" || exit $?
|
|
|
|
lock || exit 1
|
|
|
|
trap cleanup EXIT
|
|
|
|
for f in import/*; do
|
|
f_name="${f##*/}"
|
|
if [[ -f "$f_name" ]]; then
|
|
printf 'Package already exists: %s, not overwriting\n' "$f_name" >&2
|
|
else
|
|
mv -vf "$f" ./
|
|
new_pkgs+=( "$f_name" )
|
|
fi
|
|
done
|
|
|
|
repo-sign
|
|
repo-clean
|
|
|
|
for p in "${new_pkgs[@]}"; do
|
|
repo-add -n "$spark_repo.db.tar.gz" "$p"
|
|
done
|