Accepting request 875464 from home:bfrogers:branches:Virtualization
- Added a few more usability improvements for our git packaging workflow OBS-URL: https://build.opensuse.org/request/show/875464 OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=620
This commit is contained in:
parent
698c429494
commit
ba2fece093
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4c62b4f7cb23a896ae882f3ce7871a36a65d2c36850932fdeaf1df1c5a8c4988
|
||||
size 60624
|
||||
oid sha256:534e2f464e862407578fc3bc358f589e3f4dd2f5fda8fc89b357ea9cb376bc0d
|
||||
size 60640
|
||||
|
22
config.sh
22
config.sh
@ -4,6 +4,14 @@
|
||||
|
||||
# The next few VARIABLES are to be edited as required:
|
||||
|
||||
# Here is the git repo which tracks a separate upstream git based project
|
||||
# We take this approach so we can have our own tags and branches, and store
|
||||
# the patches in git for others to access outside of the bundle.
|
||||
PACKAGE_MAIN_GIT_REPO=https://github.com/openSUSE/qemu.git
|
||||
|
||||
# This is the upstream for the PACKAGE_MAIN_GIT_REPO
|
||||
UPSTREAM_GIT_REPO=https://gitlab.com/qemu-project/qemu.git
|
||||
|
||||
# The following specifies the upstream tag or commit upon which our patchqueue
|
||||
# gets rebased. The special value LATEST may be used to "automatically" track
|
||||
# the upstream development tree in the master branch
|
||||
@ -28,9 +36,8 @@ BUNDLE_DIR=/dev/shm/qemu-factory-bundle-dir
|
||||
NUMBERED_PATCHES=0
|
||||
|
||||
PATCH_RANGE=1000
|
||||
REPO_COUNT=36
|
||||
|
||||
# This tracks the git submodule path within the superproject (1st entry)
|
||||
# This array tracks all git submodule paths within the superproject (1st entry)
|
||||
PATCH_PATH_MAP=(
|
||||
""
|
||||
"roms/seabios/"
|
||||
@ -70,11 +77,7 @@ PATCH_PATH_MAP=(
|
||||
"roms/edk2/MdeModulePkg/Library/BrotliCompress/brotli/research/libdivsufsort/"
|
||||
)
|
||||
|
||||
# Perhaps we need to instead use the terminal local dirname as the index
|
||||
# and store the ~/git/ as a separate VARIABLE
|
||||
# This way, we only have one big array instead of two
|
||||
# BUT STILL WE NEED TO START WITH THE DATA STORED SOMEWHERE!!!!!!
|
||||
# (order must correspond to PATCH_PATH_MAP)
|
||||
# (order and count must correspond to PATCH_PATH_MAP)
|
||||
LOCAL_REPO_MAP=(
|
||||
~/git/qemu-opensuse
|
||||
~/git/qemu-seabios
|
||||
@ -113,8 +116,3 @@ LOCAL_REPO_MAP=(
|
||||
~/git/qemu-edk2-BrotliCompress-brotli-research-esaxx
|
||||
~/git/qemu-edk2-BrotliCompress-brotli-research-libdivsufsort
|
||||
)
|
||||
|
||||
# TEMPORARY! FOR NOW WE REQUIRE THESE LOCALLY TO DO WORK ON PACKAGE
|
||||
REQUIRED_LOCAL_REPO_MAP=(
|
||||
~/git/qemu-opensuse
|
||||
)
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Feb 26 15:31:46 UTC 2021 - Bruce Rogers <brogers@suse.com>
|
||||
|
||||
- Added a few more usability improvements for our git packaging
|
||||
workflow
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Feb 19 15:10:56 UTC 2021 - Bruce Rogers <brogers@suse.com>
|
||||
|
||||
|
309
update_git.sh
309
update_git.sh
@ -12,10 +12,10 @@
|
||||
|
||||
# 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!!!!!!!!!!!!!!!!!!!1
|
||||
# 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.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
|
||||
# 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.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
# 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?
|
||||
@ -34,6 +34,12 @@ source ./config.sh
|
||||
|
||||
# TODO: Here we should validate the variables that should be set in config.sh
|
||||
|
||||
REPO_COUNT=${#PATCH_PATH_MAP[@]}
|
||||
if [[ "$REPO_COUNT" != "${#LOCAL_REPO_MAP[@]}" ]]; then
|
||||
echo "PATCH_PATH_MAP and LOCAL_REPO_MAP array sizes do not agree - please fix"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Zero based numbering, so we subtract 1 here:
|
||||
if (( (REPO_COUNT * PATCH_RANGE) - 1 > 9999 )); then
|
||||
FIVE_DIGIT_POTENTIAL=1
|
||||
@ -72,28 +78,6 @@ fi
|
||||
|
||||
#==============================================================================
|
||||
|
||||
TEMP_CHECK() {
|
||||
|
||||
# Validate that all the local repos that we currently have patches in are available
|
||||
# TEMPORARY REQUIREMENT!
|
||||
for entry in ${REQUIRED_LOCAL_REPO_MAP[@]}; do
|
||||
if [[ -e $(readlink -f ${entry}) ]]; then
|
||||
if $(git -C $entry branch| grep -F "$GIT_BRANCH" >/dev/null); then
|
||||
:
|
||||
else
|
||||
echo "Didn't find the $GIT_BRANCH branch in repo at $entry"
|
||||
exit
|
||||
fi
|
||||
else
|
||||
echo "ERROR! For now, you need to have these local git repos available:"
|
||||
echo ${REQUIRED_LOCAL_REPO_MAP[@]}
|
||||
exit
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
||||
initbundle() {
|
||||
# The bundle tarball has git bundles stored in a directory structure which mimics the
|
||||
# submodule locations in the containing git repo. Also at that same dir level
|
||||
@ -102,20 +86,33 @@ initbundle() {
|
||||
# "{path/}{git_sha}.{bundle}", where {path/} isn't present for
|
||||
# the top (qemu) bundle (ie it's for submodules).
|
||||
|
||||
SUBMODULE_COMMIT_IDS=($(git -C ${LOCAL_REPO_MAP[0]} submodule status --recursive|awk '{print $1}'))
|
||||
SUBMODULE_DIRS=($(git -C ${LOCAL_REPO_MAP[0]} submodule status --recursive|awk '{print $2}'))
|
||||
SUBMODULE_COUNT=${#SUBMODULE_COMMIT_IDS[@]}
|
||||
# TODO: do this with simply math - ie: use (( ... ))
|
||||
if [[ "$REPO_COUNT" != "$(expr $SUBMODULE_COUNT + 1)" ]]; then
|
||||
echo "ERROR: submodule count doesn't match the REPO_COUNT variable in config.sh file!"
|
||||
exit
|
||||
fi
|
||||
rm -rf $GIT_DIR
|
||||
rm -rf $BUNDLE_DIR
|
||||
mkdir -p $BUNDLE_DIR
|
||||
if [[ -e ${LOCAL_REPO_MAP[$i]}/.git/shallow ]]; then
|
||||
if [[ -e bundles.tar.xz ]]; then
|
||||
tar --extract --xz -f bundles.tar.xz -C $BUNDLE_DIR .
|
||||
else
|
||||
echo "ERROR: Superproject at ${LOCAL_REPO_MAP[$i]} is shallow (so we assume submodules aren't"
|
||||
echo "recursively checked out), and there is not an existing bundle-of-bundles file, so we cannot"
|
||||
echo "correctly initialize the packages bundle-of-bundles. Please fully initilize git superproject"
|
||||
echo "before doing initbundle"
|
||||
exit
|
||||
fi
|
||||
else
|
||||
if [[ -e bundles.tar.xz ]]; then
|
||||
tar --extract --xz -f bundles.tar.xz -C $BUNDLE_DIR .
|
||||
else
|
||||
SUBMODULE_COMMIT_IDS=($(git -C ${LOCAL_REPO_MAP[0]} submodule status --recursive| cut -c 2- | awk '{print $1}'))
|
||||
SUBMODULE_DIRS=($(git -C ${LOCAL_REPO_MAP[0]} submodule status --recursive| cut -c 2- |awk '{print $2}'))
|
||||
SUBMODULE_COUNT=${#SUBMODULE_COMMIT_IDS[@]}
|
||||
# TODO: do this with simply math - ie: use (( ... ))
|
||||
if [[ "$REPO_COUNT" != "$(expr $SUBMODULE_COUNT + 1)" ]]; then
|
||||
echo "ERROR: submodule count doesn't match what's in config.sh"
|
||||
exit
|
||||
fi
|
||||
for (( i=0; i <$SUBMODULE_COUNT; i++ )); do
|
||||
mkdir -p $BUNDLE_DIR/${SUBMODULE_DIRS[$i]}
|
||||
# what should this file be? for now use an extension of id
|
||||
touch $BUNDLE_DIR/${SUBMODULE_DIRS[$i]}/${SUBMODULE_COMMIT_IDS[$i]}.id
|
||||
done
|
||||
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
|
||||
@ -125,8 +122,10 @@ else
|
||||
GIT_UPSTREAM_COMMIT=$(git -C ${LOCAL_REPO_MAP[0]} show-ref -d $GIT_UPSTREAM_COMMIT_ISH|grep -F "^{}"|awk '{print $1}')
|
||||
fi
|
||||
touch $BUNDLE_DIR/$GIT_UPSTREAM_COMMIT.id
|
||||
fi
|
||||
fi
|
||||
|
||||
# Now go through all the submodule local repos that are present and create a bundle file for the patches found there
|
||||
# Now go through all the submodule local repos that are present with a $GIT_BRANCH and create a bundle file for the patches found
|
||||
for (( i=0; i <$REPO_COUNT; i++ )); do
|
||||
if [[ -e $(readlink -f ${LOCAL_REPO_MAP[$i]}) ]]; then
|
||||
SUBDIR=${PATCH_PATH_MAP[$i]}
|
||||
@ -140,7 +139,7 @@ for (( i=0; i <$REPO_COUNT; i++ )); do
|
||||
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
|
||||
git -C $GIT_DIR/$SUBDIR fetch origin $GIT_BRANCH
|
||||
git -C $GIT_DIR/$SUBDIR fetch --update-shallow origin $GIT_BRANCH
|
||||
if [[ $(git -C $GIT_DIR/$SUBDIR rev-list $GITREPO_COMMIT_ISH..FETCH_HEAD) ]]; then
|
||||
git -C $GIT_DIR/$SUBDIR bundle create $BUNDLE_DIR/$SUBDIR$GITREPO_COMMIT_ISH.bundle $GITREPO_COMMIT_ISH..FETCH_HEAD
|
||||
#TODO: post-process repo info to avoid un-needed diffs (eg git vs https)
|
||||
@ -150,8 +149,9 @@ for (( i=0; i <$REPO_COUNT; i++ )); do
|
||||
fi
|
||||
fi
|
||||
done
|
||||
# keep diffs to a minimum - touch bundle files to "something common"
|
||||
# parameters chosen to allow bundle tarball exact reproducibility
|
||||
tar --format gnu --xz \
|
||||
--sort=name \
|
||||
--numeric-owner \
|
||||
--owner=0 \
|
||||
--group=0 \
|
||||
@ -204,8 +204,7 @@ for entry in ${ID_FILES[@]}; do
|
||||
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! Please create one"
|
||||
exit
|
||||
echo "No local repo $LOCAL_REPO available to process git bundle! Moving on..."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@ -225,7 +224,7 @@ rm -rf $GIT_DIR
|
||||
git clone -ls ${LOCAL_REPO_MAP[0]} $GIT_DIR -b master --single-branch &>/dev/null
|
||||
echo "Please wait..."
|
||||
(cd $GIT_DIR && git remote add upstream \
|
||||
git://git.qemu-project.org/qemu.git &>/dev/null)
|
||||
$UPSTREAM_GIT_REPO &>/dev/null)
|
||||
(cd $GIT_DIR && git remote update upstream &>/dev/null)
|
||||
(cd $GIT_DIR && git checkout $NEW_COMMIT_ISH &>/dev/null)
|
||||
# As an alternative, we could add a --recurse-submodules to the checkout instead here as well, right?
|
||||
@ -322,10 +321,69 @@ bundle2spec() {
|
||||
rm -f checkpatch.log
|
||||
rm -f checkthese
|
||||
rm -rf checkdir
|
||||
rm -rf savedir
|
||||
rm -rf $GIT_DIR
|
||||
rm -rf $CMP_DIR
|
||||
rm -rf $BUNDLE_DIR
|
||||
mkdir -p $BUNDLE_DIR
|
||||
mkdir savedir
|
||||
|
||||
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
# Handle case of casual user missing local repos.
|
||||
# To support this, we must grok the spec file's
|
||||
# list of patches for "reuse" in case we don't
|
||||
# have local repo to use for extracting bundle
|
||||
# contents. (here we assume the existing bundle
|
||||
# would then still correspond to the patches
|
||||
# listed in spec file for that repo)
|
||||
# WARNING:
|
||||
# The following groking expects the patch section
|
||||
# to be as this script lays it out, not modified!
|
||||
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
declare -a PATCHES_BY_SUBMODULE_PATH
|
||||
IN_PATCH_SECTION=0
|
||||
INDEX=$REPO_COUNT # "invalid" since zero based index of objects < one based count of objects
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" = "# Patches applied in base project:" ]]; then
|
||||
IN_PATCH_SECTION=1
|
||||
INDEX=0 # base project is 0 by definition
|
||||
continue
|
||||
fi
|
||||
if [[ "$line" =~ ^..Patches.applied.in.(.*)/:$ ]]; then
|
||||
REPO="${BASH_REMATCH[1]}/"
|
||||
IN_PATCH_SECTION=1
|
||||
for (( i=0; i <$REPO_COUNT; i++ )); do
|
||||
if [[ "$REPO" = "${PATCH_PATH_MAP[$i]}" ]]; then
|
||||
if [[ "$INDEX" != "$REPO_COUNT" ]]; then
|
||||
PATCHES_BY_SUBMODULE_PATH[$INDEX]=$ACCUMULATED_PATCHES
|
||||
unset ACCUMULATED_PATCHES
|
||||
fi
|
||||
INDEX=$i
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "$INDEX" = "$REPO_COUNT" ]]; then
|
||||
echo "ERROR: Failure groking spec file for patches!"
|
||||
exit
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
if [[ "$IN_PATCH_SECTION" = "0" ]]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "$line" =~ ^$ ]]; then
|
||||
PATCHES_BY_SUBMODULE_PATH[$INDEX]=$ACCUMULATED_PATCHES
|
||||
break;
|
||||
fi
|
||||
if [[ "$line" =~ ^Patch[0-9]*:[\ ]*(.*)$ ]]; then
|
||||
PATCH="${BASH_REMATCH[1]}"
|
||||
#echo "Patch is $PATCH"
|
||||
ACCUMULATED_PATCHES="$ACCUMULATED_PATCHES $PATCH"
|
||||
continue
|
||||
fi
|
||||
echo "ERROR: Failure groking spec file for patches!"
|
||||
exit
|
||||
done < qemu.spec
|
||||
|
||||
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
# CONVERT BUNDLES INTO COMMITS AND FILL SPEC FILE
|
||||
@ -349,12 +407,16 @@ for entry in ${BUNDLE_FILES[@]}; do
|
||||
fi
|
||||
done
|
||||
|
||||
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 remote add origin file://$(readlink -f \
|
||||
${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
|
||||
git -C $GIT_DIR/$SUBDIR fetch origin $GIT_BRANCH
|
||||
git -C $GIT_DIR/$SUBDIR reset --hard $GITREPO_COMMIT_ISH
|
||||
# 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
|
||||
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 \
|
||||
@ -362,6 +424,21 @@ for entry in ${BUNDLE_FILES[@]}; do
|
||||
--src-prefix=a/$SUBDIR --dst-prefix=b/$SUBDIR \
|
||||
--start-number=$(expr $PATCH_RANGE_INDEX \* $PATCH_RANGE) \
|
||||
$GITREPO_COMMIT_ISH..FETCH_HEAD > /dev/null
|
||||
PATCHES_BY_SUBMODULE_PATH[$PATCH_RANGE_INDEX]=""
|
||||
else
|
||||
# TODO: This doesn't handle numbered patches yet
|
||||
COUNTER=$(expr $PATCH_RANGE_INDEX \* $PATCH_RANGE)
|
||||
for patchname in ${PATCHES_BY_SUBMODULE_PATH[$PATCH_RANGE_INDEX]}; do
|
||||
VALUE="0000"$COUNTER
|
||||
if [ "$FIVE_DIGIT_POTENTIAL" = "1" ]; then
|
||||
PREFIX=$(echo $VALUE|tail -c 6)
|
||||
else
|
||||
PREFIX=$(echo $VALUE|tail -c 5)
|
||||
fi
|
||||
cp $patchname savedir/$PREFIX-$patchname
|
||||
let COUNTER+=1
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf $GIT_DIR
|
||||
@ -395,6 +472,10 @@ rm -rf $BUNDLE_DIR
|
||||
tail -n +2 $i > $CMP_DIR/"${BASENAME:0:$KEEP_COUNT}".patch
|
||||
rm $i
|
||||
done
|
||||
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)
|
||||
|
||||
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
|
||||
for i in [0-9][0-9][0-9][0-9]*-*.patch; do
|
||||
osc rm --force "$i"
|
||||
@ -606,14 +687,56 @@ rm -rf checkdir
|
||||
|
||||
osc service localrun format_spec_file
|
||||
# First, make the results of the older format_spec_file look like what I believe is the intended output
|
||||
# And then change the somewhat broken output of the new format_spec_file to what I believe is
|
||||
# the intended output
|
||||
# And then change THE POSSIBLY BROKEN OUTPUT from the new format_spec_file look like what I
|
||||
# believe is the intended output
|
||||
sed -i 's/^# spec file for package qemu$/# spec file for package qemu%{name_suffix}/g' qemu.spec
|
||||
sed -i 's/^# spec file for package qemu-linux-user$/# spec file for package qemu%{name_suffix}/g' qemu.spec
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
||||
setup_common_vars() {
|
||||
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
|
||||
QEMU_VERSION=$(git -C ${LOCAL_REPO_MAP[0]} show upstream/master:VERSION)
|
||||
MAJOR_VERSION=$(echo $QEMU_VERSION|awk -F. '{print $1}')
|
||||
MINOR_VERSION=$(echo $QEMU_VERSION|awk -F. '{print $2}')
|
||||
X=$(echo $QEMU_VERSION|awk -F. '{print $3}')
|
||||
# 0 = release, 50 = development cycle, 90..99 equate to release candidates
|
||||
if [ "$X" != "0" -a "$X" != "50" ]; then
|
||||
if [ "$NEXT_RELEASE_IS_MAJOR" = "0" ]; then
|
||||
SOURCE_VERSION=$MAJOR_VERSION.$[$MINOR_VERSION+1].0-rc$[X-90]
|
||||
GIT_BRANCH=opensuse-$MAJOR_VERSION.$[$MINOR_VERSION+1]
|
||||
else
|
||||
SOURCE_VERSION=$[$MAJOR_VERSION+1].0.0-rc$[X-90]
|
||||
GIT_BRANCH=opensuse-$[$MAJOR_VERSION+1].0
|
||||
fi
|
||||
else
|
||||
SOURCE_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$X
|
||||
if [ "$X" = "0" ]; then
|
||||
GIT_BRANCH=opensuse-$MAJOR_VERSION.$[$MINOR_VERSION]
|
||||
else
|
||||
if [ "$NEXT_RELEASE_IS_MAJOR" = "0" ]; then
|
||||
GIT_BRANCH=opensuse-$MAJOR_VERSION.$[$MINOR_VERSION+1]
|
||||
else
|
||||
GIT_BRANCH=opensuse-$[MAJOR_VERSION+1].0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
SOURCE_VERSION=$OLD_SOURCE_VERSION_AND_EXTRA
|
||||
QEMU_VERSION=$(tar JxfO qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz qemu-$SOURCE_VERSION/VERSION)
|
||||
if [ ! "$QEMU_VERSION" = "$OLD_SOURCE_VERSION_AND_EXTRA" ]; then
|
||||
echo "Tarball name (which we decode) doesn't correspond to the VERSION file contained therein"
|
||||
exit
|
||||
fi
|
||||
MAJOR_VERSION=$(echo $QEMU_VERSION|awk -F. '{print $1}')
|
||||
MINOR_VERSION=$(echo $QEMU_VERSION|awk -F. '{print $2}')
|
||||
GIT_BRANCH=opensuse-$MAJOR_VERSION.$MINOR_VERSION
|
||||
fi
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
||||
usage() {
|
||||
echo "Usage:"
|
||||
echo "bash ./git_update.sh <command>"
|
||||
@ -626,19 +749,45 @@ echo "(See script for details on doing 'LATEST' workflow)"
|
||||
|
||||
#==============================================================================
|
||||
|
||||
explain_setup() {
|
||||
echo "Currently we require local git repos at these locations:"
|
||||
echo "${REQUIRED_LOCAL_REPO_MAP[@]}"
|
||||
echo "Where each has as it's remote the uri: https://github.com/opensuse/*.git"
|
||||
echo "and where * is replaced by the qemu-whatever, and the remote is named origin"
|
||||
echo "and the qemu or qemu submodule repos as remotes named upstream"
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
||||
if [[ ! -e $(readlink -f ${LOCAL_REPO_MAP[0]}) ]]; then
|
||||
echo "ERROR: Local QEMU related git repos not found. Please follow these setup instructions:"
|
||||
explain_setup
|
||||
echo "No local repo found at ${LOCAL_REPO_MAP[0]}"
|
||||
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
|
||||
echo "Using LATEST config.sh setting is an expert mode. Set up local repos accordingly"
|
||||
exit
|
||||
fi
|
||||
read -p "Would you like me to set that up for you? (Y/N)" -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Got an affirmative answer, proceeding..."
|
||||
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 ${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
|
||||
GIT_UPSTREAM_COMMIT=$(git -C ${LOCAL_REPO_MAP[0]} ls-remote origin |grep -F "$GIT_UPSTREAM_COMMIT_ISH^{}"|awk '{print $1}')
|
||||
# Here we use *COMMIT_ISH, not *_COMMIT - is that an issue?
|
||||
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
|
||||
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 "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"
|
||||
echo "Be aware that this downloads a LOT of data (that's why we didn't just"
|
||||
echo "do that automatically. Then you may also fetch other branches from the"
|
||||
echo "origin remote, and get the latest upstream patches from the upstream"
|
||||
echo "remote. Refer to config.sh for submodule repos locations you can set"
|
||||
echo "up to also work on patches for the superproject's submodules."
|
||||
exit
|
||||
else
|
||||
echo "Script requires qemu superproject local git repo. Please provide in"
|
||||
echo "order to use this script."
|
||||
fi
|
||||
exit
|
||||
fi
|
||||
# There are some req's on needing a recent git, and a recent osc (double chk the osc part - I guess it's related to the osc service )
|
||||
@ -659,6 +808,10 @@ echo "WARNING: Script using local git repos. Some operations may be time consumi
|
||||
# TODO: Most of these checks are not necessary
|
||||
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
|
||||
fi
|
||||
if [[ -d ${LOCAL_REPO_MAP[$i]}/.git/rebase-merge || \
|
||||
-d ${LOCAL_REPO_MAP[$i]}/.git/rebase-apply ]]; then
|
||||
echo "ERROR! Rebase appears to be in progress in ${LOCAL_REPO_MAP[$i]}. Please resolve"
|
||||
@ -680,6 +833,7 @@ for (( i=0; i <$REPO_COUNT; i++ )); do
|
||||
echo "(cannot check out master, 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)"
|
||||
@ -713,35 +867,10 @@ if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
|
||||
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
|
||||
QEMU_VERSION=$(git -C ${LOCAL_REPO_MAP[0]} show upstream/master:VERSION)
|
||||
MAJOR_VERSION=$(echo $QEMU_VERSION|awk -F. '{print $1}')
|
||||
MINOR_VERSION=$(echo $QEMU_VERSION|awk -F. '{print $2}')
|
||||
X=$(echo $QEMU_VERSION|awk -F. '{print $3}')
|
||||
# 0 = release, 50 = development cycle, 90..99 equate to release candidates
|
||||
if [ "$X" != "0" -a "$X" != "50" ]; then
|
||||
if [ "$NEXT_RELEASE_IS_MAJOR" = "0" ]; then
|
||||
SOURCE_VERSION=$MAJOR_VERSION.$[$MINOR_VERSION+1].0-rc$[X-90]
|
||||
GIT_BRANCH=opensuse-$MAJOR_VERSION.$[$MINOR_VERSION+1]
|
||||
else
|
||||
SOURCE_VERSION=$[$MAJOR_VERSION+1].0.0-rc$[X-90]
|
||||
GIT_BRANCH=opensuse-$[$MAJOR_VERSION+1].0
|
||||
fi
|
||||
else
|
||||
SOURCE_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$X
|
||||
if [ "$X" = "0" ]; then
|
||||
GIT_BRANCH=opensuse-$MAJOR_VERSION.$[$MINOR_VERSION]
|
||||
else
|
||||
if [ "$NEXT_RELEASE_IS_MAJOR" = "0" ]; then
|
||||
GIT_BRANCH=opensuse-$MAJOR_VERSION.$[$MINOR_VERSION+1]
|
||||
else
|
||||
GIT_BRANCH=opensuse-$[MAJOR_VERSION+1].0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
setup_common_vars
|
||||
WRITE_LOG=0
|
||||
echo "Processing LATEST upstream changes"
|
||||
echo "(If SUCCESS is not printed upon completion, see /tmp/latest.log for issues)"
|
||||
TEMP_CHECK
|
||||
if [[ $QEMU_TARBALL =~ $BASE_RE$EXTRA_RE$SUFFIX_RE ]]; then
|
||||
OLD_COMMIT_ISH=${BASH_REMATCH[3]}
|
||||
else
|
||||
@ -791,28 +920,22 @@ else # not LATEST
|
||||
exit
|
||||
fi
|
||||
git -C ${LOCAL_REPO_MAP[0]} checkout $GIT_UPSTREAM_COMMIT_ISH --recurse-submodules -f &> /dev/null
|
||||
setup_common_vars
|
||||
NEW_COMMIT_ISH=
|
||||
SOURCE_VERSION=$OLD_SOURCE_VERSION_AND_EXTRA
|
||||
QEMU_VERSION=$(tar JxfO qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz qemu-$SOURCE_VERSION/VERSION)
|
||||
if [ ! "$QEMU_VERSION" = "$OLD_SOURCE_VERSION_AND_EXTRA" ]; then
|
||||
echo "Tarball name (which we decode) doesn't correspond to the VERSION file contained therein"
|
||||
exit
|
||||
fi
|
||||
MAJOR_VERSION=$(echo $QEMU_VERSION|awk -F. '{print $1}')
|
||||
MINOR_VERSION=$(echo $QEMU_VERSION|awk -F. '{print $2}')
|
||||
GIT_BRANCH=opensuse-$MAJOR_VERSION.$MINOR_VERSION
|
||||
WRITE_LOG=1
|
||||
if [ "$1" = "" ]; then
|
||||
set -- git2pkg
|
||||
fi
|
||||
case $1 in
|
||||
initbundle )
|
||||
initbundle
|
||||
echo "Updating the bundle using the $GIT_BRANCH branch of the local repos."
|
||||
echo "(If SUCCESS is not printed upon completion, see /tmp/initbundle.log for issues)"
|
||||
initbundle &> /tmp/initbundle.log
|
||||
echo "SUCCESS"
|
||||
;;
|
||||
git2pkg )
|
||||
echo "Updating the package using the $GIT_BRANCH branch of the local repos."
|
||||
echo "(If SUCCESS is not printed upon completion, see /tmp/git2pkg.log for issues)"
|
||||
TEMP_CHECK
|
||||
initbundle &> /tmp/git2pkg.log
|
||||
bundle2spec &>> /tmp/git2pkg.log
|
||||
echo "SUCCESS"
|
||||
@ -821,7 +944,6 @@ else # not LATEST
|
||||
pkg2git )
|
||||
echo "Exporting the package's git bundles to the local repo's frombundle branches..."
|
||||
echo "(If SUCCESS is not printed upon completion, see /tmp/pkg2git.log for issues)"
|
||||
TEMP_CHECK
|
||||
bundle2local &> /tmp/pkg2git.log
|
||||
echo "SUCCESS"
|
||||
echo "To modify package patches, use the frombundle branch as the basis for updating"
|
||||
@ -832,7 +954,6 @@ else # not LATEST
|
||||
echo "Updating the spec file and patches from the spec file template and the bundle"
|
||||
echo "of bundles (bundles.tar.xz)"
|
||||
echo "(If SUCCESS is not printed upon completion, see /tmp/refresh.log for issues)"
|
||||
TEMP_CHECK
|
||||
bundle2spec &> /tmp/refresh.log
|
||||
echo "SUCCESS"
|
||||
tail -9 /tmp/refresh.log
|
||||
|
Loading…
Reference in New Issue
Block a user