SHA256
1
0
forked from pool/qemu

Accepting request 875529 from home:bfrogers:branches:Virtualization

More workflow script tweaks

OBS-URL: https://build.opensuse.org/request/show/875529
OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=621
This commit is contained in:
Bruce Rogers 2021-02-26 21:03:22 +00:00 committed by Git OBS Bridge
parent ba2fece093
commit bc14630b77

View File

@ -8,30 +8,77 @@
#
# (default is git2pkg)
# TODO NOTES:
#==============================================================================
# after ensuring current status of local repo is clean, incl submodules, we checkout master+submodules, then also ensure they're clean, then checkout the commit or tag corresponding to latest / stable-release + submodules (but don't bother to verift that's clean) - so this is a detached HEAD for stable-release and IS master (almost certainly) for LATEST. WOW - is that what we need to be doing!?!?! At least it seems to be working for the cases I've seen!!!!
# initbundle operates from the current checked out state of the local superproject, to get the submodule ids - CORRECT!!!!
# the LATEST processing of cloning the local repo, clones master - but perhaps it doesn't matter? because it adds upstream as a remote and probably gets most things from there? INVESTIGATE!!!!!!!!!!!!!!!!!!!
# bundle2local checks out master in local repo to ensure we're off the frombundle branch (doesn't seem needed the way the script currently is). It fetches the bundle's head (FETCH_HEAD) REQUIRING that the base commit be present (which it seems to be. Then it creates the frombundle branch, with the current FETCH_HEAD (SAME AS IN BUNDLE, RIGHT?)
# The LATEST's rebase loop checks out the frombundle branch (with force), so we are now OFF of the "correct checkout" that happened at the beginning, it DELETES the GIT_BRANCH (so in this case it DIDN'T MATTER WHAT WAS THERE WHEN SCRIPT STARTED !!!!!!! WARNING !!!!!, branches off of the frombundle branch (w/checkout), then rebases that (which came from bundle) onto the current superproject, or submodule commit id.
# At this point, if the GIT_BRANCH rebased ok, it's ready for making a patchqueue, out of, if the rebase failed, it's time to manually fix that.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
check_requirements() {
RC=0
if [[ ! $(rpm -q git-core) ]]; then
echo "ERROR: Missing dependency: git-core"
RC=1
fi
if [[ ! $(rpm -q osc) ]]; then
echo "ERROR: Missing dependency: osc package"
RC=1
fi
if [[ ! $(rpm -q obs-service-format_spec_file) ]]; then
echo "ERROR: Missing dependency: obs-service-format_spec_file package"
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
fi
if [[ "$RC" = "1" ]]; then
echo "Script requires the above resources. Please resolve to use this workflow"
exit
fi
}
# LATEST processing implies updated upstream/master IS the right thing
# HOW do we protect against a bad bundle being created (we do have the build service's tracking of previous files - is that sufficient?
# initbundle - what does it need? Currently we take the default branch in local superproject for the superproject and submodule commit ids, so it needs to be right! (ie which ever branch it is (DECIDE!), make it the RIGHT ONE for this release. It takes the commits from the $GIT_BUNDLE branch of each of superproject and submodule repos, which are beyond above found commits. IT CERTIANLY SEEMS REASONABLE THAT WE WOULD HAVE THE $$GIT_BRANCH BRANCH BE THE DEFAULT AND CORRECT BUT HOW DO WE GUARANTEE THATS OK? GIVEN OUR REQS HERE QEMU_VERSION CAN BE GRABBED HERE IN LOCAL SUPERPROJECT RIGHT AWAY!
# bundle2local - what does it need? This checks out local master just to get off of frombundle (could have been $GIT_BRANCH as well) No other req's
# bundle2spec - what does it need? THIS SHOULD HAVE LATEST SPLIT OUT!!!! We allow this alone, so see what setup it alone needs - for this one particularly, we don't want to REQUIRE local repo. FOR NOW I ASSUME THE RIGHT THING IS CHECKED OUT!
#
# SEEMS WE SHOULD NOT,NOT,NOT require user to have previously updated, or set local repo a certain way, but for us to enforce it or actually do it
# TODO: confirm local repo present, correct remotes, correct local branches, somehow validate local branch content against remote, ...
#
# In both cases we DO require the $GIT_BRANCH to exist, and should confirm that the appropriate upstream basis commit is indeed part of that. In the LATEST case, we can treat master as a source for initial current upstream.
#==============================================================================
usage() {
echo "Usage:"
echo "bash ./git_update.sh <command>"
echo "description: package maintenance using a git-based workflow. Commands:"
echo " git2pkg (update package spec file and patches from git. Is default)"
echo " pkg2git (update git (frombundle branch) from the package "bundleofbundles")"
echo " refresh (refresh spec file from spec file template and "bundlofbundles")"
echo "(See script for details on doing 'LATEST' workflow)"
check_requirements
}
#==============================================================================
set -e
source ./config.sh
# If you're using LATEST, we assume you are an expert!
if [ "$GIT_UPSTREAM_COMMIT_ISH" != "LATEST" ]; then
if [ "$1" = "" ]; then
set -- git2pkg
else
case $1 in
help | -H | -h )
usage
exit
;;
initbundle | git2pkg | pkg2git | refresh )
;;
* )
echo "Unknown command"
usage
exit
;;
esac
fi
fi
check_requirements
# TODO: Here we should validate the variables that should be set in config.sh
REPO_COUNT=${#PATCH_PATH_MAP[@]}
@ -40,6 +87,8 @@ if [[ "$REPO_COUNT" != "${#LOCAL_REPO_MAP[@]}" ]]; then
exit
fi
check_requirements
# Zero based numbering, so we subtract 1 here:
if (( (REPO_COUNT * PATCH_RANGE) - 1 > 9999 )); then
FIVE_DIGIT_POTENTIAL=1
@ -671,10 +720,6 @@ rm -rf $BUNDLE_DIR
if [ -e qemu.changes.added ]; then
rm -f qemu.changes.added
fi
# Decide if there is a better way to handle the no change case:
#BFR if [[ "0" = "$(expr $CHANGED_COUNT + $DELETED_COUNT + $ADDED_COUNT)" ]]; then
#BFR osc revert bundles.tar.xz
#BFR fi
echo "git patch summary"
echo " unchanged: $UNCHANGED_COUNT"
echo " changed: $CHANGED_COUNT"
@ -737,18 +782,6 @@ fi
#==============================================================================
usage() {
echo "Usage:"
echo "bash ./git_update.sh <command>"
echo "description: package maintenance using a git-based workflow. Commands:"
echo " git2pkg (update package spec file and patches from git. Is default)"
echo " pkg2git (update git (frombundle branch) from the package "bundleofbundles")"
echo " refresh (refresh spec file from spec file template and "bundlofbundles")"
echo "(See script for details on doing 'LATEST' workflow)"
}
#==============================================================================
if [[ ! -e $(readlink -f ${LOCAL_REPO_MAP[0]}) ]]; then
echo "No local repo found at ${LOCAL_REPO_MAP[0]}"
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
@ -794,8 +827,8 @@ fi
# get the current state of the git superproject
# TODO: This sends output to stdout which we don't want to see
git -C ${LOCAL_REPO_MAP[0]} status --untracked-files=no --branch --porcelain=2 \
| awk '{print "var"NR"="$3}'
#git -C ${LOCAL_REPO_MAP[0]} status --untracked-files=no --branch --porcelain=2 \
# | awk '{print "var"NR"="$3}'
# $var1 is the current commit
# $var2 is the current branch or 'detached', if not on a branch
# $var3 is the current upstream branch (if set), as in eg 'origin/opensuse-5.0'
@ -803,7 +836,7 @@ git -C ${LOCAL_REPO_MAP[0]} status --untracked-files=no --branch --porcelain=2 \
# TODO: What checks should be different between LATEST and non-LATEST?
# If we don't actually patch from the submodule repo, we shouldn't care about what's in the local one
# Does non-LATEST really require master?
# Does non-LATEST really require master? (indeed - get rid of use or need of master as much as possible)
echo "WARNING: Script using local git repos. Some operations may be time consuming..."
# TODO: Most of these checks are not necessary
for (( i=0; i <$REPO_COUNT; i++ )); do
@ -923,9 +956,6 @@ else # not LATEST
setup_common_vars
NEW_COMMIT_ISH=
WRITE_LOG=1
if [ "$1" = "" ]; then
set -- git2pkg
fi
case $1 in
initbundle )
echo "Updating the bundle using the $GIT_BRANCH branch of the local repos."
@ -958,13 +988,6 @@ else # not LATEST
echo "SUCCESS"
tail -9 /tmp/refresh.log
;;
* )
echo "Unknown command"
usage
;;
help )
usage
;;
esac
fi
exit