56 lines
1.4 KiB
Bash
56 lines
1.4 KiB
Bash
|
#! /usr/bin/env bash
|
||
|
# Args: <repo> <repo-source> <remote> <remote-path> [<gpg>] [<collection>]
|
||
|
ARG_REPO="$1"
|
||
|
ARG_REPO_SOURCE="$2"
|
||
|
ARG_REMOTE="$3"
|
||
|
ARG_REMOTE_PATH="$4"
|
||
|
ARG_GPG="$5"
|
||
|
ARG_COLLECTION="$6"
|
||
|
|
||
|
#
|
||
|
# Generate
|
||
|
#
|
||
|
if [ -z "$NO_UPDATE" ]
|
||
|
then
|
||
|
REPO=()
|
||
|
FLATPAK=()
|
||
|
if [ -n "$ARG_GPG" ]
|
||
|
then
|
||
|
REPO=( "${REPO[@]}" "--gpg" "$ARG_GPG" )
|
||
|
FLATPAK=( "${FLATPAK[@]}" "--gpg-sign=$ARG_GPG" )
|
||
|
fi
|
||
|
if [ -n "$ARG_COLLECTION" ]
|
||
|
then
|
||
|
REPO=( "${REPO[@]}" "-c" "$ARG_COLLECTION" )
|
||
|
FLATPAK=( "${FLATPAK[@]}" "--collection-id=$ARG_COLLECTION" "--deploy-collection-id" )
|
||
|
fi
|
||
|
"$(dirname "$0")/update_repo.py" --no-fsync "${REPO[@]}" "$ARG_REPO" "$ARG_REPO_SOURCE" &&
|
||
|
flatpak build-update-repo --prune --prune-depth=5 "${FLATPAK[@]}" "$ARG_REPO"
|
||
|
fi &&
|
||
|
|
||
|
#
|
||
|
# Send data
|
||
|
#
|
||
|
if [ -z "$PORT" ]
|
||
|
then
|
||
|
export PORT=8000
|
||
|
fi &&
|
||
|
echo "PORT: $PORT" &&
|
||
|
export "LOCK_FILE=$(mktemp)" &&
|
||
|
( (
|
||
|
cd "$ARG_REPO" &&
|
||
|
exec python3 -m http.server --bind 127.0.0.1 "$PORT" 2> /dev/null &
|
||
|
SESSION="$!" &&
|
||
|
sleep 1 &&
|
||
|
exec 200> "$LOCK_FILE" &&
|
||
|
flock -x 200 &&
|
||
|
kill "$SESSION" &&
|
||
|
wait
|
||
|
rm "$LOCK_FILE"
|
||
|
) &) &&
|
||
|
(
|
||
|
exec 200> "$LOCK_FILE" &&
|
||
|
flock -x 200 &&
|
||
|
sleep 10 &&
|
||
|
ssh "$ARG_REMOTE" -R"$PORT":127.0.0.1:"$PORT" bash -c \''ostree remote add --force --no-gpg-verify --repo "$0" origin http://127.0.0.1:'"$PORT"'/ && ostree pull --repo "$0" --mirror origin && flatpak build-update-repo --prune --prune-depth=5 --no-update-summary --no-update-appstream --generate-static-deltas "$0" '\' "$ARG_REMOTE_PATH"
|
||
|
)
|