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:
parent
bc14630b77
commit
bb0d3e6db4
@ -14,25 +14,25 @@ check_requirements() {
|
|||||||
RC=0
|
RC=0
|
||||||
if [[ ! $(rpm -q git-core) ]]; then
|
if [[ ! $(rpm -q git-core) ]]; then
|
||||||
echo "ERROR: Missing dependency: git-core"
|
echo "ERROR: Missing dependency: git-core"
|
||||||
RC=1
|
RC=1
|
||||||
fi
|
fi
|
||||||
if [[ ! $(rpm -q osc) ]]; then
|
if [[ ! $(rpm -q osc) ]]; then
|
||||||
echo "ERROR: Missing dependency: osc package"
|
echo "ERROR: Missing dependency: osc package"
|
||||||
RC=1
|
RC=1
|
||||||
fi
|
fi
|
||||||
if [[ ! $(rpm -q obs-service-format_spec_file) ]]; then
|
if [[ ! $(rpm -q obs-service-format_spec_file) ]]; then
|
||||||
echo "ERROR: Missing dependency: obs-service-format_spec_file package"
|
echo "ERROR: Missing dependency: obs-service-format_spec_file package"
|
||||||
RC=1
|
RC=1
|
||||||
fi
|
fi
|
||||||
ONE_GIG_IN_1K_BLOCKS=1048576
|
ONE_GIG_IN_1K_BLOCKS=1048576
|
||||||
AVAIL=$(df --output=avail /dev/shm | tail -1)
|
AVAIL=$(df --output=avail /dev/shm | tail -1)
|
||||||
if [[ $AVAIL -lt $ONE_GIG_IN_1K_BLOCKS ]]; then
|
if [[ $AVAIL -lt $ONE_GIG_IN_1K_BLOCKS ]]; then
|
||||||
echo "ERROR: Please provide at least 1GB available space in /dev/shm"
|
echo "ERROR: Please provide at least 1GB available space in /dev/shm"
|
||||||
RC=1
|
RC=1
|
||||||
fi
|
fi
|
||||||
if [[ "$RC" = "1" ]]; then
|
if [[ "$RC" = "1" ]]; then
|
||||||
echo "Script requires the above resources. Please resolve to use this workflow"
|
echo "Script requires the above resources. Please resolve to use this workflow"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,14 +63,14 @@ if [ "$GIT_UPSTREAM_COMMIT_ISH" != "LATEST" ]; then
|
|||||||
case $1 in
|
case $1 in
|
||||||
help | -H | -h )
|
help | -H | -h )
|
||||||
usage
|
usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
initbundle | git2pkg | pkg2git | refresh )
|
initbundle | git2pkg | pkg2git | refresh )
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo "Unknown command"
|
echo "Unknown command"
|
||||||
usage
|
usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
@ -184,7 +184,7 @@ for (( i=0; i <$REPO_COUNT; i++ )); do
|
|||||||
echo "Using $GITREPO_COMMIT_ISH"
|
echo "Using $GITREPO_COMMIT_ISH"
|
||||||
PATCH_RANGE_INDEX=$i
|
PATCH_RANGE_INDEX=$i
|
||||||
mkdir -p $GIT_DIR/$SUBDIR
|
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 \
|
git -C $GIT_DIR/$SUBDIR remote add origin file://$(readlink -f \
|
||||||
${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
|
${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
|
||||||
if [[ $(git -C $GIT_DIR/$SUBDIR ls-remote --heads origin $GIT_BRANCH) ]]; then
|
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]})
|
LOCAL_REPO=$(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
|
||||||
if [ -e $LOCAL_REPO ]; then
|
if [ -e $LOCAL_REPO ]; then
|
||||||
git -C $LOCAL_REPO remote remove bundlerepo || true
|
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
|
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 remote add bundlerepo $BUNDLE_DIR/$SUBDIR/$GITREPO_COMMIT_ISH.bundle
|
||||||
git -C $LOCAL_REPO fetch bundlerepo FETCH_HEAD
|
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
|
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
|
fi
|
||||||
else
|
else
|
||||||
if [ -e $BUNDLE_DIR/$SUBDIR/$GITREPO_COMMIT_ISH.bundle ]; then
|
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...
|
# 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
|
||||||
fi
|
fi
|
||||||
done
|
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?)
|
# 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..."
|
echo "Please wait..."
|
||||||
(cd $GIT_DIR && git remote add upstream \
|
(cd $GIT_DIR && git remote add upstream \
|
||||||
$UPSTREAM_GIT_REPO &>/dev/null)
|
$UPSTREAM_GIT_REPO &>/dev/null)
|
||||||
(cd $GIT_DIR && git remote update upstream &>/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?
|
# 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!):
|
#UPSTREAM DOESNT DO THIS (time takes 17 minutes!):
|
||||||
# (cd $GIT_DIR && git submodule update --init --recursive &>/dev/null)
|
# (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
|
if [[ $GITREPO_COMMIT_ISH =~ .*(.{40})[.]id ]]; then
|
||||||
GITREPO_COMMIT_ISH=${BASH_REMATCH[1]}
|
GITREPO_COMMIT_ISH=${BASH_REMATCH[1]}
|
||||||
fi
|
fi
|
||||||
git -C ${LOCAL_REPO_MAP[$i]} checkout -f frombundle
|
git -C ${LOCAL_REPO_MAP[$i]} checkout -B $GIT_BRANCH frombundle
|
||||||
git -C ${LOCAL_REPO_MAP[$i]} branch -D $GIT_BRANCH
|
|
||||||
git -C ${LOCAL_REPO_MAP[$i]} checkout -b $GIT_BRANCH
|
|
||||||
if [[ "$SUBDIR" = "" ]]; then
|
if [[ "$SUBDIR" = "" ]]; then
|
||||||
SUBDIR=SUPERPROJECT
|
SUBDIR=SUPERPROJECT
|
||||||
fi
|
fi
|
||||||
if ! $(git -C ${LOCAL_REPO_MAP[$i]} rebase --onto ${COMMIT_IDS_BY_SUBMODULE_PATH[$SUBDIR]} $GITREPO_COMMIT_ISH >/dev/null); then
|
if ! $(git -C ${LOCAL_REPO_MAP[$i]} rebase $GITREPO_COMMIT_ISH >/dev/null); then
|
||||||
# TODO: record that this one needs manual help!
|
|
||||||
echo "Rebase of ${LOCAL_REPO_MAP[$i]}, branch $GIT_BRANCH needs manual help"
|
echo "Rebase of ${LOCAL_REPO_MAP[$i]}, branch $GIT_BRANCH needs manual help"
|
||||||
REBASE_FAILS="${LOCAL_REPO_MAP[$i]} $REBASE_FAILS"
|
REBASE_FAILS="${LOCAL_REPO_MAP[$i]} $REBASE_FAILS"
|
||||||
fi
|
fi
|
||||||
@ -458,14 +463,12 @@ for entry in ${BUNDLE_FILES[@]}; do
|
|||||||
|
|
||||||
if [[ -e $(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]}) ]]; then
|
if [[ -e $(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]}) ]]; then
|
||||||
mkdir -p $GIT_DIR/$SUBDIR
|
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 \
|
git -C $GIT_DIR/$SUBDIR remote add origin file://$(readlink -f \
|
||||||
${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
|
${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
|
||||||
# This tag reference, was added to resolve $GITREPO_COMMIT_ISH, which is tag as commit-id
|
# 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
|
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 remote add bundle $BUNDLE_DIR/$entry
|
||||||
git -C $GIT_DIR/$SUBDIR fetch bundle FETCH_HEAD
|
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 \
|
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
|
tail -n +2 $i > $CMP_DIR/"${BASENAME:0:$KEEP_COUNT}".patch
|
||||||
rm $i
|
rm $i
|
||||||
done
|
done
|
||||||
cp savedir/* $CMP_DIR || true
|
cp savedir/* $CMP_DIR/ || true
|
||||||
rm -rf savedir
|
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)
|
# 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
|
setup_common_vars
|
||||||
# TODO: The following doesn't really do what we need (we adjust later) FIX!!!
|
# 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 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]} 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]} fetch origin +refs/tags/initial:refs/tags/initial --no-tags
|
||||||
git -C ${LOCAL_REPO_MAP[0]} reset --hard initial
|
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]} 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
|
git -C ${LOCAL_REPO_MAP[0]} remote add upstream $UPSTREAM_GIT_REPO &>/dev/null
|
||||||
bundle2local
|
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 "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 "${LOCAL_REPO_MAP[0]}, and initialized it from the bundle."
|
||||||
echo "(no options processed)"
|
echo "(no options processed)"
|
||||||
echo "If you wish to make the repo complete for all qemu packaging work,"
|
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 "unshallow it first with git fetch --unshallow origin --all, then get"
|
||||||
echo "the submodules updated with git submodule update --init --recursive"
|
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 $(readlink -f ${LOCAL_REPO_MAP[$i]}) ]]; then
|
||||||
if [[ -e ${LOCAL_REPO_MAP[$i]}/.git/shallow ]]; then
|
if [[ -e ${LOCAL_REPO_MAP[$i]}/.git/shallow ]]; then
|
||||||
echo "${LOCAL_REPO_MAP[$i]} is shallow, skipping checks"
|
echo "${LOCAL_REPO_MAP[$i]} is shallow, skipping checks"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [[ -d ${LOCAL_REPO_MAP[$i]}/.git/rebase-merge || \
|
if [[ -d ${LOCAL_REPO_MAP[$i]}/.git/rebase-merge || \
|
||||||
-d ${LOCAL_REPO_MAP[$i]}/.git/rebase-apply ]]; then
|
-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)"
|
echo "(ensure git status --porcelain produces no output)"
|
||||||
exit
|
exit
|
||||||
fi
|
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 "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
|
exit
|
||||||
fi
|
fi
|
||||||
# This does additional setup now that we've possibly grabbed additional submodules
|
# 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
|
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 "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
|
exit
|
||||||
fi
|
fi
|
||||||
if [ "$(git -C ${LOCAL_REPO_MAP[$i]} status --porcelain)" ]; then
|
if [ "$(git -C ${LOCAL_REPO_MAP[$i]} status --porcelain)" ]; then
|
||||||
@ -899,7 +902,6 @@ if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
|
|||||||
done
|
done
|
||||||
NEW_COMMIT_ISH_FULL=$(cd ${LOCAL_REPO_MAP[0]} && git rev-parse upstream/master)
|
NEW_COMMIT_ISH_FULL=$(cd ${LOCAL_REPO_MAP[0]} && git rev-parse upstream/master)
|
||||||
NEW_COMMIT_ISH=${NEW_COMMIT_ISH_FULL:0:8}
|
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
|
setup_common_vars
|
||||||
WRITE_LOG=0
|
WRITE_LOG=0
|
||||||
echo "Processing LATEST upstream changes"
|
echo "Processing LATEST upstream changes"
|
||||||
|
Loading…
Reference in New Issue
Block a user