SHA256
1
0
forked from pool/qemu

Accepting request 876342 from home:bfrogers:branches:Virtualization

More tweaks to update_git.sh

OBS-URL: https://build.opensuse.org/request/show/876342
OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=623
This commit is contained in:
Bruce Rogers 2021-03-03 03:58:29 +00:00 committed by Git OBS Bridge
parent bc14630b77
commit bb0d3e6db4

View File

@ -14,25 +14,25 @@ check_requirements() {
RC=0
if [[ ! $(rpm -q git-core) ]]; then
echo "ERROR: Missing dependency: git-core"
RC=1
RC=1
fi
if [[ ! $(rpm -q osc) ]]; then
echo "ERROR: Missing dependency: osc package"
RC=1
RC=1
fi
if [[ ! $(rpm -q obs-service-format_spec_file) ]]; then
echo "ERROR: Missing dependency: obs-service-format_spec_file package"
RC=1
RC=1
fi
ONE_GIG_IN_1K_BLOCKS=1048576
AVAIL=$(df --output=avail /dev/shm | tail -1)
if [[ $AVAIL -lt $ONE_GIG_IN_1K_BLOCKS ]]; then
echo "ERROR: Please provide at least 1GB available space in /dev/shm"
RC=1
RC=1
fi
if [[ "$RC" = "1" ]]; then
echo "Script requires the above resources. Please resolve to use this workflow"
exit
exit
fi
}
@ -63,14 +63,14 @@ if [ "$GIT_UPSTREAM_COMMIT_ISH" != "LATEST" ]; then
case $1 in
help | -H | -h )
usage
exit
exit
;;
initbundle | git2pkg | pkg2git | refresh )
;;
* )
echo "Unknown command"
usage
exit
exit
;;
esac
fi
@ -184,7 +184,7 @@ for (( i=0; i <$REPO_COUNT; i++ )); do
echo "Using $GITREPO_COMMIT_ISH"
PATCH_RANGE_INDEX=$i
mkdir -p $GIT_DIR/$SUBDIR
git -C $GIT_DIR/$SUBDIR init
git -C $GIT_DIR/$SUBDIR -c init.defaultBranch=$GIT_BRANCH init
git -C $GIT_DIR/$SUBDIR remote add origin file://$(readlink -f \
${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
if [[ $(git -C $GIT_DIR/$SUBDIR ls-remote --heads origin $GIT_BRANCH) ]]; then
@ -241,19 +241,25 @@ for entry in ${ID_FILES[@]}; do
LOCAL_REPO=$(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
if [ -e $LOCAL_REPO ]; then
git -C $LOCAL_REPO remote remove bundlerepo || true
# git won't let you delete a branch we're on - so get onto master temporarily (TODO: is there a better approach?)
git -C $LOCAL_REPO checkout master -f
git -C $LOCAL_REPO branch -D frombundle || true
if [ -e $BUNDLE_DIR/$SUBDIR/$GITREPO_COMMIT_ISH.bundle ]; then
git -C $LOCAL_REPO remote add bundlerepo $BUNDLE_DIR/$SUBDIR/$GITREPO_COMMIT_ISH.bundle
git -C $LOCAL_REPO fetch bundlerepo FETCH_HEAD
git -C $LOCAL_REPO branch frombundle FETCH_HEAD
git -C $LOCAL_REPO branch -f frombundle FETCH_HEAD
git -C $LOCAL_REPO remote remove bundlerepo
else
# It's problematic to leave "stale" frombundle branches around
git -C $LOCAL_REPO branch -D frombundle || true
fi
else
if [ -e $BUNDLE_DIR/$SUBDIR/$GITREPO_COMMIT_ISH.bundle ]; then
# TODO: We should be able to handle this case with some more coding, but for now...
echo "No local repo $LOCAL_REPO available to process git bundle! Moving on..."
echo "No local repo $LOCAL_REPO available to process git bundle!"
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
echo "The above is FATAL when doing LATEST processing - please fix"
exit
else
echo "Moving on..."
fi
fi
fi
done
@ -270,12 +276,14 @@ rm -rf $GIT_DIR
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# TODO: WHAT IS THIS NEXT LINE EVEN DOING FOR US?? (OK, it's initing a repo, what do we rely on there?)
git clone -ls ${LOCAL_REPO_MAP[0]} $GIT_DIR -b master --single-branch &>/dev/null
# Here, the branch doesn't really matter, and we're not relying on a master branch - we're just making sure we are grabbing latest from upstream
# (while using a clone of "something close" as a way to quickly get most objects available as quickly as possible)
git clone -ls ${LOCAL_REPO_MAP[0]} $GIT_DIR -b $GIT_BRANCH --single-branch &>/dev/null
echo "Please wait..."
(cd $GIT_DIR && git remote add upstream \
$UPSTREAM_GIT_REPO &>/dev/null)
(cd $GIT_DIR && git remote update upstream &>/dev/null)
(cd $GIT_DIR && git checkout $NEW_COMMIT_ISH &>/dev/null)
(cd $GIT_DIR && git reset --hard $NEW_COMMIT_ISH &>/dev/null)
# As an alternative, we could add a --recurse-submodules to the checkout instead here as well, right?
#UPSTREAM DOESNT DO THIS (time takes 17 minutes!):
# (cd $GIT_DIR && git submodule update --init --recursive &>/dev/null)
@ -348,14 +356,11 @@ for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ $GITREPO_COMMIT_ISH =~ .*(.{40})[.]id ]]; then
GITREPO_COMMIT_ISH=${BASH_REMATCH[1]}
fi
git -C ${LOCAL_REPO_MAP[$i]} checkout -f frombundle
git -C ${LOCAL_REPO_MAP[$i]} branch -D $GIT_BRANCH
git -C ${LOCAL_REPO_MAP[$i]} checkout -b $GIT_BRANCH
git -C ${LOCAL_REPO_MAP[$i]} checkout -B $GIT_BRANCH frombundle
if [[ "$SUBDIR" = "" ]]; then
SUBDIR=SUPERPROJECT
fi
if ! $(git -C ${LOCAL_REPO_MAP[$i]} rebase --onto ${COMMIT_IDS_BY_SUBMODULE_PATH[$SUBDIR]} $GITREPO_COMMIT_ISH >/dev/null); then
# TODO: record that this one needs manual help!
if ! $(git -C ${LOCAL_REPO_MAP[$i]} rebase $GITREPO_COMMIT_ISH >/dev/null); then
echo "Rebase of ${LOCAL_REPO_MAP[$i]}, branch $GIT_BRANCH needs manual help"
REBASE_FAILS="${LOCAL_REPO_MAP[$i]} $REBASE_FAILS"
fi
@ -458,14 +463,12 @@ for entry in ${BUNDLE_FILES[@]}; do
if [[ -e $(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]}) ]]; then
mkdir -p $GIT_DIR/$SUBDIR
git -C $GIT_DIR/$SUBDIR init
git -C $GIT_DIR/$SUBDIR -c init.defaultBranch=$GIT_BRANCH init
git -C $GIT_DIR/$SUBDIR remote add origin file://$(readlink -f \
${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
# This tag reference, was added to resolve $GITREPO_COMMIT_ISH, which is tag as commit-id
#needed? git -C $GIT_DIR/$SUBDIR fetch --depth=1 origin $GIT_UPSTREAM_COMMIT_ISH
# Since origin may be shallow, we need to use the --update-shallow option
# Since origin may be shallow, we need to use the --update-shallow option
git -C $GIT_DIR/$SUBDIR fetch --update-shallow origin $GIT_BRANCH
#needed? git -C $GIT_DIR/$SUBDIR reset --hard $GITREPO_COMMIT_ISH
git -C $GIT_DIR/$SUBDIR remote add bundle $BUNDLE_DIR/$entry
git -C $GIT_DIR/$SUBDIR fetch bundle FETCH_HEAD
git -C $GIT_DIR/$SUBDIR format-patch -N --suffix= --no-renames -o $CMP_DIR -k --stat=72 \
@ -521,7 +524,7 @@ rm -rf $BUNDLE_DIR
tail -n +2 $i > $CMP_DIR/"${BASENAME:0:$KEEP_COUNT}".patch
rm $i
done
cp savedir/* $CMP_DIR || true
cp savedir/* $CMP_DIR/ || true
rm -rf savedir
# 4 digit xxxx-name used in the dest (remember that if 5 digit potential, then if not now 5 digit, add a 0 in front)
@ -795,7 +798,7 @@ if [[ ! -e $(readlink -f ${LOCAL_REPO_MAP[0]}) ]]; then
setup_common_vars
# TODO: The following doesn't really do what we need (we adjust later) FIX!!!
# git clone --depth 1 -b $GIT_BRANCH --single-branch $PACKAGE_MAIN_GIT_REPO ${LOCAL_REPO_MAP[0]}
git init ${LOCAL_REPO_MAP[0]}
git -c init.defaultBranch=$GIT_BRANCH init ${LOCAL_REPO_MAP[0]}
git -C ${LOCAL_REPO_MAP[0]} remote add origin $PACKAGE_MAIN_GIT_REPO &>/dev/null
git -C ${LOCAL_REPO_MAP[0]} fetch origin +refs/tags/initial:refs/tags/initial --no-tags
git -C ${LOCAL_REPO_MAP[0]} reset --hard initial
@ -804,10 +807,10 @@ if [[ ! -e $(readlink -f ${LOCAL_REPO_MAP[0]}) ]]; then
git -C ${LOCAL_REPO_MAP[0]} fetch --depth=1 origin +refs/tags/$GIT_UPSTREAM_COMMIT_ISH:refs/tags/$GIT_UPSTREAM_COMMIT_ISH --no-tags
git -C ${LOCAL_REPO_MAP[0]} remote add upstream $UPSTREAM_GIT_REPO &>/dev/null
bundle2local
git -C ${LOCAL_REPO_MAP[0]} checkout -b $GIT_BRANCH frombundle
git -C ${LOCAL_REPO_MAP[0]} checkout -B $GIT_BRANCH frombundle
echo "We set up a shallow local repo of the package's git superproject at"
echo "${LOCAL_REPO_MAP[0]}, and initialized it from the bundle."
echo "(no options processed)"
echo "${LOCAL_REPO_MAP[0]}, and initialized it from the bundle."
echo "(no options processed)"
echo "If you wish to make the repo complete for all qemu packaging work,"
echo "unshallow it first with git fetch --unshallow origin --all, then get"
echo "the submodules updated with git submodule update --init --recursive"
@ -843,7 +846,7 @@ for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ -e $(readlink -f ${LOCAL_REPO_MAP[$i]}) ]]; then
if [[ -e ${LOCAL_REPO_MAP[$i]}/.git/shallow ]]; then
echo "${LOCAL_REPO_MAP[$i]} is shallow, skipping checks"
continue
continue
fi
if [[ -d ${LOCAL_REPO_MAP[$i]}/.git/rebase-merge || \
-d ${LOCAL_REPO_MAP[$i]}/.git/rebase-apply ]]; then
@ -861,15 +864,15 @@ for (( i=0; i <$REPO_COUNT; i++ )); do
echo "(ensure git status --porcelain produces no output)"
exit
fi
if ! git -C ${LOCAL_REPO_MAP[$i]} checkout master --recurse-submodules -f &> /dev/null; then
if ! git -C ${LOCAL_REPO_MAP[$i]} checkout $GIT_BRANCH --recurse-submodules -f &> /dev/null; then
echo "Please clean up state of local repo ${LOCAL_REPO_MAP[$i]} before using script"
echo "(cannot check out master, incl. it's submodules)"
echo "(cannot check out $GIT_BRANCH, incl. it's submodules)"
exit
fi
# This does additional setup now that we've possibly grabbed additional submodules
if ! git -C ${LOCAL_REPO_MAP[$i]} submodule update --init --recursive &> /dev/null; then
echo "Please clean up state of local repo ${LOCAL_REPO_MAP[$i]} before using script"
echo "(cannot init and update master submodules)"
echo "(cannot init and update $GIT_BRANCH branch submodules)"
exit
fi
if [ "$(git -C ${LOCAL_REPO_MAP[$i]} status --porcelain)" ]; then
@ -899,7 +902,6 @@ if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
done
NEW_COMMIT_ISH_FULL=$(cd ${LOCAL_REPO_MAP[0]} && git rev-parse upstream/master)
NEW_COMMIT_ISH=${NEW_COMMIT_ISH_FULL:0:8}
git -C ${LOCAL_REPO_MAP[0]} checkout $NEW_COMMIT_ISH_FULL --recurse-submodules -f &> /dev/null
setup_common_vars
WRITE_LOG=0
echo "Processing LATEST upstream changes"