Skip to content
Snippets Groups Projects
Unverified Commit 30b83a43 authored by Oliver Smith's avatar Oliver Smith
Browse files

install_pmbootstrap.sh: fix crash if remote exists

In single runner setups, the gitlab CI runner code appears to keep the
git repositories and only re-initialize them. This preserves the remotes
that were added. If that is the case, just fetch the remote and don't
try to add it again.

Related: https://gitlab.com/postmarketOS/pmaports/-/jobs/748215671
parent be1ac2f2
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,32 @@
: "${PMBOOTSTRAP_TAG:="master"}"
: "${PMBOOTSTRAP_URL:="https://gitlab.com/postmarketOS/pmbootstrap.git"}"
# Add the "origin-original" remote to an existing pmaports.git clone, so
# pmbootstrap can use its channels.cfg.
add_remote_origin_original() {
# Skip if existing (happens in single runner setup)
remote_url="https://gitlab.com/postmarketOS/pmaports.git"
remote_url_existing="$(git -C "$pmaports" \
remote get-url origin-original 2>/dev/null \
|| true)"
if [ "$remote_url" = "$remote_url_existing" ]; then
echo "Remote 'origin-original' is already configured"
git -C "$pmaports" fetch -q origin-original
return
fi
# Add the remote, display the output only on error
if ! git -C "$pmaports" \
remote add -f origin-original \
"https://gitlab.com/postmarketOS/pmaports.git" \
>/tmp/git_remote_add 2>&1; then
echo "ERROR: failed to add original remote with git!"
echo
cat /tmp/git_remote_add
exit 1
fi
}
# Set up depends and binfmt_misc
depends="coreutils
git
......@@ -36,16 +62,7 @@ if [ -e "$pmaports/pmaports.cfg" ]; then
echo "Found pmaports.cfg in current dir"
pmaports_arg="--aports '$pmaports'"
# Add original remote, so pmbootstrap can use its channels.cfg
if ! git -C "$pmaports" \
remote add -f origin-original \
"https://gitlab.com/postmarketOS/pmaports.git" \
>/tmp/git_remote_add 2>&1; then
echo "ERROR: failed to add original remote with git!"
echo
cat /tmp/git_remote_add
exit 1
fi
add_remote_origin_original
# Use the channel of the current branch
mkdir -p ~pmos/.config
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment