Accepting request 733859 from home:bfrogers:branches:Virtualization

Some more script cleanups

OBS-URL: https://build.opensuse.org/request/show/733859
OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=490
This commit is contained in:
Bruce Rogers 2019-09-28 15:46:49 +00:00 committed by Git OBS Bridge
parent 3035d7a3d1
commit c32cc11b03
13 changed files with 685 additions and 777 deletions

View File

@ -8,18 +8,18 @@ template. The patches included are inserted into the spec file by scripts
described below.
If you are not modifying any patches or their order, but just need to update the
spec file from a changed template, run the refresh.sh script.
spec file from a changed template, run 'bash ./update_git.sh refresh'.
If the set of patches is being modified, including their order, you will want to
first run pkg2git.sh, in order to get the current patch queue made available in
a local git branch named frombundle. (qemu packaging now includes a "bundle of
git bundles" stored as a package source file, which contains the "git version"
of the package patches.) You will create an altered patch queue in the
$GIT_BRANCH branch (see config.sh for actual name), and use the frombundle branch
as a starting point (eg perhaps start by doing git reset --hard frombundle, then
cherry-pick upstream patches from there). Once you have the patch queue ready to
go run git2pkg.sh to update the bundle of bundles (bundles.tsr.xz file) as well
as the spec and patch files.
first run 'bash ./update_git.sh pkg2git', in order to get the current patch
queue made available in a local git branch named frombundle. (qemu packaging now
includes a "bundle of git bundles" stored as a package source file, which
contains the "git version" of the package patches.) You will create an altered
patch queue in the $GIT_BRANCH branch (see config.sh for actual name), and use
the frombundle branch as a starting point (eg perhaps start by doing git reset
--hard frombundle, then cherry-pick upstream patches from there). Once you have
the patch queue ready to go run 'bash ./update_git.sh git2pkg' to update the
bundle of bundles (bundles.tsr.xz file) as well as the spec and patch files.
Additional Notes:

View File

@ -1,57 +0,0 @@
#!/bin/bash
#
# This script takes patches stored in the bundle and places
# them into a branch named frombundle for each local repo it
# finds.
# NYI: report if the required base commit isn't there - they may need to fetch the latest from upstream
set -e
source ./config.sh
rm -rf $GIT_DIR
rm -rf $CMP_DIR
rm -rf $BUNDLE_DIR
rm -f checkpatch.log
mkdir -p $BUNDLE_DIR
tar xJf bundles.tar.xz -C $BUNDLE_DIR
BUNDLE_FILES=$(find $BUNDLE_DIR -printf "%P\n"|grep "bundle$")
for entry in ${BUNDLE_FILES[@]}; do
if [[ $entry =~ ^(.*)[/]*([a-f0-9]{40})[.]bundle$ ]]; then
SUBDIR=${BASH_REMATCH[1]}
GITREPO_COMMIT_ISH=${BASH_REMATCH[2]}
else
echo "ERROR! BAD BUNDLE CONTENT!"
exit
fi
for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ "$SUBDIR" = "${PATCH_PATH_MAP[$i]}" ]]; then
PATCH_RANGE_INDEX=$i
break
fi
done
LOCAL_REPO=$(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
if [ -e $LOCAL_REPO ]; then
echo "Found local repo $LOCAL_REPO corresponding to archived git bundle"
else
echo "No local repo $LOCAL_REPO corresponding to archived git bundle"
fi
git -C $LOCAL_REPO remote remove bundlerepo || true
# git won't let you delete this branch if it's the current branch (returns 1) HOW TO HANDLE?
# detect this case, and ask user to switch to another branch? or do it for them - switch to master killing any "state" for this branch
git -C $LOCAL_REPO branch -D frombundle || true
git -C $LOCAL_REPO remote add bundlerepo $BUNDLE_DIR/$entry
# in next, the head may be FETCH_HEAD or HEAD depending on how we created:
git -C $LOCAL_REPO fetch bundlerepo FETCH_HEAD
#git -C $LOCAL_REPO fetch bundlerepo HEAD
git -C $LOCAL_REPO branch frombundle FETCH_HEAD
git -C $LOCAL_REPO remote remove bundlerepo
done
echo "For each local repo found a branch named frombundle contains the patches from the bundle."
echo "Use this as the starting point for making changes to the $GIT_BRANCH, which gets used as"
echo "the source when updating the bundle stored with the package."
rm -rf $BUNDLE_DIR

View File

@ -1,476 +0,0 @@
#!/bin/bash
#
# Instead of a quilt workflow, we use a git tree that contains
# all the commits on top of a qemu source tarball.
#
# When updating this package, just either update the git tree
# below (use rebase!) or change the tree path and use your own
#
# That way we can easily rebase against the next stable release
# when it comes.
# TODO:
# * don't re-create bundles that are the same, and if no change
# don't re-create the bunde-of-bundles
# * somehow for the LATEST case, keep track of the patches which
# have come and gone until we apply the whole set to the changelog
# * also when that update comes, include the Referece: references as
# being included into the update
set -e
source ./config.sh
rm -rf $GIT_DIR
rm -rf $CMP_DIR
rm -rf $BUNDLE_DIR
rm -f checkpatch.log
rm -rf checkthese
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
# This is just a safety valve in case the above gets edited wrong:
if ! [ "$GIT_BRANCH" = "master" ]; then
echo "LATEST implies master branch, please fix configuration"
exit
fi
(cd ${LOCAL_REPO_MAP[0]} && git remote update upstream)
fi
BASE_RE="qemu-[[:digit:]]+(\.[[:digit:]]+){2}(-rc[[:digit:]])?"
EXTRA_RE="\+git\.[[:digit:]]+\.([[:xdigit:]]+)"
SUFFIX_RE="\.tar\.xz"
SIG_SUFFIX_RE="\.tar\.xz\.sig"
QEMU_TARBALL=($(find -maxdepth 1 -type f -regextype posix-extended -regex \
"\./$BASE_RE($EXTRA_RE)?$SUFFIX_RE" -printf "%f "))
QEMU_TARBALL_SIG=($(find -maxdepth 1 -type f -regextype posix-extended -regex \
"\./$BASE_RE($EXTRA_RE)?$SIG_SUFFIX_RE" -printf "%f "))
if [ ${#QEMU_TARBALL[@]} -gt 1 ]; then
echo "Multiple qemu tarballs detected. Please clean up"
exit
fi
if [ ${#QEMU_TARBALL_SIG[@]} -gt 1 ]; then
echo "Multiple qemu tarballs signature files detected. Please clean up"
exit
fi
# It's ok for either of these to be empty when using "LATEST"
OLD_SOURCE_VERSION_AND_EXTRA=$(echo $QEMU_TARBALL 2>/dev/null | head --bytes=-8\
| cut --bytes=6-)
VERSION_EXTRA=$(echo $OLD_SOURCE_VERSION_AND_EXTRA|awk -F+ '{if ($2) print \
"+"$2}')
if [ "$OLD_SOURCE_VERSION_AND_EXTRA" = "" ]; then
echo "Warning: No tarball found"
fi
mkdir -p $BUNDLE_DIR
# This 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
# is a file named repo which contains the one line git repo url (with git:// or
# http(s) prefix). The bundles are named as follows:
# "{path/}{git_sha}.{patch_prefix}.{bundle}", where {path/} isn't present for
# the top (qemu) bundle (ie it's for submodules).
tar xJf bundles.tar.xz -C $BUNDLE_DIR
# !!! The following may be overkill, since it seems that find does do a depth first, which is all we need
BUNDLE_FILES=$(find $BUNDLE_DIR -printf "%P\n"|grep "bundle$")
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
if [[ $QEMU_TARBALL =~ $BASE_RE$EXTRA_RE$SUFFIX_RE ]]; then
OLD_COMMIT_ISH=${BASH_REMATCH[3]}
else
#Assume release (or release candidate) tarball with equivalent tag:
OLD_COMMIT_ISH=$(cd ${LOCAL_REPO_MAP[0]} && git rev-list --abbrev-commit \
--abbrev=9 -1 v$OLD_SOURCE_VERSION_AND_EXTRA)
fi
if [ ${#QEMU_TARBALL_SIG[@]} -ne 0 ]; then
echo "INFO: Ignoring signature file: $QEMU_TARBALL_SIG"
QEMU_TARBALL_SIG=
fi
NEW_COMMIT_ISH=$(cd ${LOCAL_REPO_MAP[0]} && git rev-parse --short=9 \
upstream/$GIT_BRANCH)
NOW_SECONDS=$(date +%s)
git clone -ls ${LOCAL_REPO_MAP[0]} $GIT_DIR -b $GIT_BRANCH --single-branch &>/dev/null
if [ "$OLD_COMMIT_ISH" != "$NEW_COMMIT_ISH" ]; then
echo "Please wait..."
(cd $GIT_DIR && git remote add upstream \
git://git.qemu-project.org/qemu.git &>/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 submodule update --init --recursive &>/dev/null)
VERSION_EXTRA=+git.$NOW_SECONDS.$NEW_COMMIT_ISH
fi
QEMU_VERSION=$(cat $GIT_DIR/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]
else
SOURCE_VERSION=$[$MAJOR_VERSION+1].0.0-rc$[X-90]
fi
else
SOURCE_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$X
fi
if [ "$OLD_COMMIT_ISH" != "$NEW_COMMIT_ISH" ]; then
if (cd ${LOCAL_REPO_MAP[0]} && git describe --exact-match $NEW_COMMIT_ISH \
&>/dev/null); then
if [ "$X" = "50" ]; then
echo "Ignoring non-standard tag"
else
# there is no VERSION_EXTRA
VERSION_EXTRA=
fi
fi
(cd $GIT_DIR/roms/seabios && git describe --tags --long --dirty > \
.version)
(cd $GIT_DIR/roms/skiboot && ./make_version.sh > .version)
echo "Almost there..."
tar --exclude=.git --transform "s,$GIT_DIR,qemu-$SOURCE_VERSION," \
-Pcf qemu-$SOURCE_VERSION$VERSION_EXTRA.tar $GIT_DIR
echo "New tarball created. Attempting rebase..."
if ! (cd $GIT_DIR && git rebase upstream/$GIT_BRANCH $GIT_BRANCH); then
echo "rebasing master on upstream/master needs human assistance." \
"Exiting"
(cd $GIT_DIR && git rebase --abort)
rm qemu-$SOURCE_VERSION$VERSION_EXTRA.tar
exit
fi
echo "WARNING: To rebase, master is being checked out"
if ! (cd ${LOCAL_REPO_MAP[0]} && git rebase upstream/$GIT_BRANCH \
$GIT_BRANCH); then
echo "WARNING: Script error? rebasing master on upstream/master" \
"succeeded in temp"
echo "dir but failed in local tree! Please investigate"
(cd ${LOCAL_REPO_MAP[0]} && git rebase --abort)
rm qemu-$SOURCE_VERSION$VERSION_EXTRA.tar
exit
fi
echo "Rebase successful"
osc rm --force qemu-$OLD_SOURCE_VERSION_AND_EXTRA.tar.xz &>/dev/null ||\
true
osc rm --force qemu-$OLD_SOURCE_VERSION_AND_EXTRA.tar.xz.sig \
&>/dev/null || true
unset QEMU_TARBALL_SIG
xz -T 0 qemu-$SOURCE_VERSION$VERSION_EXTRA.tar
osc add qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz
fi
# We're done with GIT_UPSTREAM_COMMIT_ISH carrying the special value LATEST
GIT_UPSTREAM_COMMIT_ISH=$NEW_COMMIT_ISH
WRITE_LOG=0
else # not based on LATEST upstream master, rather any upstream commitish
if [ "$OLD_SOURCE_VERSION_AND_EXTRA" = "" ]; then
echo "Failure: tarball required which corresponds to commitish:" \
"$GIT_UPSTREAM_COMMITISH"
exit
fi
if [ -d "${LOCAL_REPO_MAP[0]}" ]; then
echo "Processing local git tree branch: $GIT_BRANCH, using commitish:"\
"$GIT_UPSTREAM_COMMIT_ISH"
if ! (cd ${LOCAL_REPO_MAP[0]} && git show-branch $GIT_BRANCH &>/dev/null)
then
echo "Error: Branch $GIT_BRANCH not found - please create a remote"\
"tracking branch of origin/$GIT_BRANCH"
exit
fi
for entry in ${BUNDLE_FILES[@]}; do
if [[ $entry =~ ^(.*)[/]*([a-f0-9]{40})[.]bundle$ ]]; then
SUBDIR=${BASH_REMATCH[1]}
GITREPO_COMMIT_ISH=${BASH_REMATCH[2]}
else
echo "ERROR! BAD BUNDLE CONTENT!"
exit
fi
for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ "$SUBDIR" = "${PATCH_PATH_MAP[$i]}" ]]; then
PATCH_RANGE_INDEX=$i
break
fi
done
# !!!!! REVIEW WHERE THIS mkdir SHOULD BE HAPPENING (kind of replaces the clone operation)
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
git -C $GIT_DIR/$SUBDIR remote add bundle $BUNDLE_DIR/$entry
# depending on how created, the bundle's head is called HEAD or FETCH_HEAD
#git -C $GIT_DIR/$SUBDIR fetch bundle 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 \
--indent-heuristic --zero-commit --no-signature --full-index \
--src-prefix=a/$SUBDIR --dst-prefix=b/$SUBDIR \
--start-number=$(expr $PATCH_RANGE_INDEX \* $PATCH_RANGE) \
$GITREPO_COMMIT_ISH..FETCH_HEAD > /dev/null
done
# ( THIS ISNT WORKING - IS OLD HISTORY:)
else
echo "Processing $GIT_BRANCH branch of remote git tree, using"\
"commitish: $GIT_UPSTREAM_COMMIT_ISH"
echo "(For fast processing, consider establishing a local git tree"\
"at ${LOCAL_REPO_MAP[0]})"
# NYI - should be able to combine with local case for the most part
fi
QEMU_VERSION=$(cat $GIT_DIR/VERSION)
SOURCE_VERSION=$OLD_SOURCE_VERSION_AND_EXTRA
NEW_COMMIT_ISH=
WRITE_LOG=1
fi
rm -rf $GIT_DIR
rm -rf $BUNDLE_DIR
(
CHANGED_COUNT=0
UNCHANGED_COUNT=0
DELETED_COUNT=0
ADDED_COUNT=0
TOTAL_COUNT=0
shopt -s nullglob
for i in $CMP_DIR/*; do
# index line isn't consistent, so cut full index to normal line length
sed -E -i 's/(^index [a-f0-9]{28})[a-f0-9]{12}([.][.][a-f0-9]{28})[a-f0-9]{12}( [0-9]{6}$)/\1\2\3/' $i
BASENAME=$(basename $i)
if [ "$FIVE_DIGIT_POTENTIAL" = "1" ]; then
if [[ $BASENAME =~ [[:digit:]]{4}-.* ]]; then
BASENAME=0$BASENAME
fi
fi
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
KEEP_COUNT=40+4+$FIVE_DIGIT_POTENTIAL+1
else
KEEP_COUNT=40
fi
tail -n +2 $i > $CMP_DIR/${BASENAME:0:$KEEP_COUNT}.patch
rm $i
done
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
for i in [0-9]*.patch; do
osc rm --force $i
echo "calling osc rm on $i"
done
# we need to make sure that w/out the numbered prefixes, the patchnames are all unique
mkdir checkdir
for i in $CMP_DIR/*; do
BASENAME=$(basename $i)
FINALNAME=${BASENAME:4+$FIVE_DIGIT_POTENTIAL+1:40+1+5}
if [[ -e checkdir/$FINALNAME ]]; then
echo "ERROR! Patch name $FINALNAME is not unique! Please modify patch subject to achieve uniqueness"
exit 1
fi
cp $i checkdir/$FINALNAME
done
CHECK_DIR=checkdir
cp $CMP_DIR/*.patch .
else
CHECK_DIR=$CMP_DIR
fi
#step 0, and 0.1 are done above - question remains if the numbered case should use check dir
rm -f checkthese
if [ "$FIVE_DIGIT_POTENTIAL" = "0" ]; then
CHECK_PREFIX="0"
else
CHECK_PREFIX="00"
fi
for i in $CHECK_DIR/*; do
BASENAME=$(basename $i)
if [ -e $BASENAME ]; then
if cmp -s $i $BASENAME; then
touch --reference=$BASENAME $i
rm $BASENAME
let UNCHANGED_COUNT+=1
else
if [ "${BASENAME:0:1+$FIVE_DIGIT_POTENTIAL}" = "$CHECK_PREFIX" ]; then
echo "$BASENAME" >> checkthese
fi
rm $BASENAME
let CHANGED_COUNT+=1
let TOTAL_COUNT+=1
fi
else
echo " $BASENAME" >> qemu.changes.added
if [ "${BASENAME:0:1+$FIVE_DIGIT_POTENTIAL}" = "$CHECK_PREFIX" ]; then
echo "$BASENAME" >> checkthese
fi
let ADDED_COUNT+=1
let TOTAL_COUNT+=1
fi
done
if [ "$FIVE_DIGIT_POTENTIAL" = "0" ]; then
NUMBERED_PATCH_RE="^[[:digit:]]{4}-.*[.]patch$"
else
NUMBERED_PATCH_RE="^[[:digit:]]{5}-.*[.]patch$"
fi
#NEXT is #2 in lgorithm
for i in *.patch; do
if [[ $i =~ $NUMBERED_PATCH_RE ]]; then
if [[ "$NUMBERED_PATCHES" = "1" ]]; then
osc rm --force $i
echo "calling osc rm on $i"
echo " $i" >> qemu.changes.deleted
let DELETED_COUNT+=1
let TOTAL_COUNT+=1
fi
else
osc rm --force $i
echo "calling osc rm on $i"
echo " $i" >> qemu.changes.deleted
let DELETED_COUNT+=1
let TOTAL_COUNT+=1
fi
done
mv $CHECK_DIR/* .
if [ -e qemu.changes.added ]; then
xargs osc add < qemu.changes.added
echo "calling osc add on:"; cat qemu.changes.added
fi
# NYI do we need this check?
if [ ! -e checkpatch.pl ]; then
tar Jxf qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz \
qemu-$SOURCE_VERSION/scripts/checkpatch.pl --strip-components=2
fi
if [[ -e checkthese ]]; then
for i in $(cat checkthese); do
./checkpatch.pl --no-tree --terse --no-summary --summary-file \
--patch $i >> checkpatch.log || true
done
fi
rm -f checkthese
rm -f checkpatch.pl
if [ -s checkpatch.log ]; then
echo "WARNING: Issues reported by qemu patch checker. Please handle" \
"ERROR items now:"
cat checkpatch.log
fi
rm -f checkpatch.log
if [ "$TOTAL_COUNT" != "0" -a "$VERSION_EXTRA" != "" -a "$OLD_COMMIT_ISH" =\
"$NEW_COMMIT_ISH" ]; then
# Patches changed, so update the version using current time
VERSION_EXTRA=+git.$NOW_SECONDS.$OLD_COMMIT_ISH
osc mv qemu-$OLD_SOURCE_VERSION_AND_EXTRA.tar.xz \
qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz
osc add qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz
fi
echo "QEMU version file: $QEMU_VERSION"
echo "QEMU source version: $SOURCE_VERSION"
echo "QEMU version extra: $VERSION_EXTRA"
SEABIOS_VERSION=$(tar JxfO qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz \
qemu-$SOURCE_VERSION/roms/seabios/.version | cut -d '-' -f 2)
for package in qemu; do
while IFS= read -r line; do
if [ "$line" = "PATCH_FILES" ]; then
for i in [0-9]*-*.patch; do
NUM=${i%%-*}
DIV=$((10#$NUM/$PATCH_RANGE))
REM=$((10#$NUM%$PATCH_RANGE))
if [[ "$REM" = "0" ]]; then
if [[ "$DIV" = "0" ]]; then
echo "# Patches applied in base project:"
else
echo "# Patches applied in ${PATCH_PATH_MAP[$DIV]}:"
fi
fi
if [[ "$FIVE_DIGIT_POTENTIAL" != "0" ]]; then
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
PATCH_NUMBER=${i%%-*}
echo -e "Patch$NUM: ${i:${#PATCH_NUMBER}+1:40+1+5}"
else
echo -e "Patch$NUM: $i"
fi
else
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
PATCH_NUMBER=${i%%-*}
echo -e "Patch$NUM: ${i:${#PATCH_NUMBER}+1:40+1+5}"
else
echo -e "Patch$NUM: $i"
fi
fi
done
elif [ "$line" = "PATCH_EXEC" ]; then
for i in [0-9]*-*.patch; do
S=$(grep "^Include-If: " $i) || true
NUM=${i%%-*}
if [ "$S" != "" ]; then
echo "${S:12}"
echo "%patch$NUM -p1"
echo "%endif"
else
echo "%patch$NUM -p1"
fi
done
elif [ "$line" = "QEMU_VERSION" ]; then
echo "%define qemuver $QEMU_VERSION$VERSION_EXTRA"
echo "%define srcver $SOURCE_VERSION$VERSION_EXTRA"
echo "Version: %qemuver"
elif [[ "$line" =~ ^Source: ]]; then
echo "$line"
if [ ${#QEMU_TARBALL_SIG[@]} -eq 1 ]; then
# We assume the signature file corresponds - just add .sig
echo "$line.sig"|sed 's/^Source: /Source99:/'
fi
elif [ "$line" = "SEABIOS_VERSION" ]; then
echo "Version: $SEABIOS_VERSION"
else
echo "$line"
fi
done < $package.spec.in > $CMP_DIR/$package.spec
if cmp -s $package.spec $CMP_DIR/$package.spec; then
echo "$package.spec unchanged"
else
mv $CMP_DIR/$package.spec $package.spec
echo "$package.spec regenerated"
let PACKAGE_CHANGED_COUNT+=1
fi
if [ "$WRITE_LOG" = "1" ]; then
# Factory requires all deleted and added patches to be mentioned
if [ -e qemu.changes.deleted ] || [ -e qemu.changes.added ]; then
echo "Patch queue updated from ${GIT_TREE} ${GIT_BRANCH}" > \
$package.changes.proposed
fi
if [ -e qemu.changes.deleted ]; then
echo "* Patches dropped:" >> $package.changes.proposed
cat qemu.changes.deleted >> $package.changes.proposed
fi
if [ -e qemu.changes.added ]; then
echo "* Patches added:" >> $package.changes.proposed
cat qemu.changes.added >> $package.changes.proposed
fi
if [ -e $package.changes.proposed ]; then
osc vc --file=$package.changes.proposed $package
rm -f $package.changes.proposed
fi
fi
done
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
rm -f [0-9]*-*.patch
fi
if [ -e qemu.changes.deleted ]; then
rm -f qemu.changes.deleted
fi
if [ -e qemu.changes.added ]; then
rm -f qemu.changes.added
fi
echo "git patch summary"
echo " unchanged: $UNCHANGED_COUNT"
echo " changed: $CHANGED_COUNT"
echo " deleted: $DELETED_COUNT"
echo " added: $ADDED_COUNT"
)
rm -rf $CMP_DIR
rm -rf checkdir
osc service localrun format_spec_file

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8a7ef5da00d22168bf2d214e6d45814486f0f845d14a85578b7d434cd71d49e3
size 37796
oid sha256:2aa664ee29f9254cf714362c9239c1b5b549f0d2d836cf30c25a9ed0962da796
size 37808

View File

@ -1,50 +0,0 @@
#!/bin/bash
#
# This script simply does some basic checks on the bundle tarball
# TODO: report if the required base commit isn't there - they may need to fetch the latest from upstream
set -e
source ./config.sh
rm -rf $GIT_DIR
rm -rf $BUNDLE_DIR
mkdir -p $GIT_DIR
mkdir -p $BUNDLE_DIR
tar xJf bundles.tar.xz -C $BUNDLE_DIR
BUNDLE_FILES=$(find $BUNDLE_DIR -printf "%P\n"|grep "bundle$")
git -C $GIT_DIR init
# !!!! I suspect that given the current format of the bundles dir struct, the 1st isn't used
# I suspect also that we are getting a redundant ./ in the path which isn't helpful
for entry in ${BUNDLE_FILES[@]}; do
if [[ $entry =~ ^(.*)[/]*([a-f0-9]{40})[.]bundle$ ]]; then
SUBDIR=${BASH_REMATCH[1]}
GITREPO_COMMIT_ISH=${BASH_REMATCH[2]}
else
echo "ERROR! BAD BUNDLE CONTENT!"
exit
fi
for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ "$SUBDIR" = "${PATCH_PATH_MAP[$i]}" ]]; then
PATCH_RANGE_INDEX=$i
break
fi
done
if [ "$(git -C $GIT_DIR bundle verify $BUNDLE_DIR/$entry 2>&1>/dev/null|tail --lines=1)" == "error: $GITREPO_COMMIT_ISH" ]; then
echo "Verified bundle name matches bundle's base commit as expected"
fi
git bundle list-heads $BUNDLE_DIR/$entry
LOCAL_REPO=$(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
if [ -e $LOCAL_REPO ]; then
echo "Found local repo $LOCAL_REPO corresponding to archived git bundle, verifying base commit is present (ok if no error)..."
git -C $LOCAL_REPO verify-commit $GITREPO_COMMIT_ISH || true
else
echo "No local repo $LOCAL_REPO corresponding to archived git bundle"
fi
done
rm -rf $GIT_DIR
rm -rf $BUNDLE_DIR

View File

@ -1,3 +1,7 @@
#!/bin/bash
# config.sh:
# The next few VARIABLES may be edited (or uncommented) as required:
# The commit upon which our patchqueue gets rebased. The special value LATEST

View File

@ -1,39 +0,0 @@
#!/bin/bash
set -e
source ./config.sh
echo "Updating the package from the $GIT_BRANCH branch of the local repos."
echo "(If SUCCESS is not printed upon completion, see /tmp/git2pkg.log for issues)"
# TEMPORARY! FOR NOW WE REQUIRE THESE LOCALLY TO DO WORK ON PACKAGE
REQUIRED_LOCAL_REPO_MAP=(
~/git/qemu-opensuse
~/git/qemu-seabios
~/git/qemu-ipxe
~/git/qemu-sgabios
~/git/qemu-skiboot
~/git/qemu-keycodemapdb
)
# 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[@]}
fi
done
./initbundle.sh &> /tmp/git2pkg.log
./bundle2spec.sh &>> /tmp/git2pkg.log
echo "SUCCESS"
tail -9 /tmp/git2pkg.log

View File

@ -1,58 +0,0 @@
#!/bin/bash
source ./config.sh
set -e
# What is needed to "start"?
# it all begins with an upstream repo, which may have submodules, incl. recursively (each represents another repo)
# To facilitate speedy work on this upstream repo, we want to have local clones of these repos
# Next we have a tarball, either that we created from the repo, or that upstream provided
# To alter the content of this tarball, lets use git to track these changes, and produce patches which can be included
# in the package spec file
# The following can get things a bit out of the expected order, but I don't think that is really much of a problem, as long as we're guaranteed to patch the superproject before any of it's submodules
# !!!! actually the simply submodule status --recursive w/out the additional processing we do for the groking of the bundle files
SUBMODULE_COMMIT_IDS=($(git -C ~/git/qemu-opensuse submodule status --recursive|awk '{print $1}'))
SUBMODULE_DIRS=($(git -C ~/git/qemu-opensuse submodule status --recursive|awk '{print $2}'))
SUBMODULE_COUNT=${#SUBMODULE_COMMIT_IDS[@]}
# !!! I should be able to 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 $BUNDLE_DIR
mkdir -p $BUNDLE_DIR
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
# also handle the superproject (I need to make this smarter, or change something - works for tag, but not normal commit:
GIT_UPSTREAM_COMMIT=$(git -C ~/git/qemu-opensuse show-ref -d $GIT_UPSTREAM_COMMIT_ISH|grep -F "^{}"|awk '{print $1}')
touch $BUNDLE_DIR/$GIT_UPSTREAM_COMMIT.id
# Now go through all the submodule local repos that are present and create a bundle file for the patches found there
rm -rf $GIT_DIR
for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ -e $(readlink -f ${LOCAL_REPO_MAP[$i]}) ]]; then
SUBDIR=${PATCH_PATH_MAP[$i]}
GITREPO_COMMIT_ISH=($BUNDLE_DIR/$SUBDIR*.id)
if [[ $GITREPO_COMMIT_ISH =~ .*(.{40})[.]id ]]; then
GITREPO_COMMIT_ISH=${BASH_REMATCH[1]}
fi
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 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 bundle create $BUNDLE_DIR/$SUBDIR$GITREPO_COMMIT_ISH.bundle $GITREPO_COMMIT_ISH..FETCH_HEAD || true
git -C $(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]}) remote get-url origin >$BUNDLE_DIR/$SUBDIR/repo
fi
done
tar cJvf bundles.tar.xz -C $BUNDLE_DIR .
rm -rf $BUNDLE_DIR
rm -rf $GIT_DIR

View File

@ -1,40 +0,0 @@
#!/bin/bash
set -e
source ./config.sh
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)"
# TEMPORARY! FOR NOW WE REQUIRE THESE LOCALLY TO DO WORK ON PACKAGE
REQUIRED_LOCAL_REPO_MAP=(
~/git/qemu-opensuse
~/git/qemu-seabios
~/git/qemu-ipxe
~/git/qemu-sgabios
~/git/qemu-skiboot
~/git/qemu-keycodemapdb
)
# 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[@]}
fi
done
./bundle2local.sh &> /tmp/pkg2git.log
echo "SUCCESS"
echo "To modify package patches, use the frombundle branch as the basis for updating"
echo "the $GIT_BRANCH branch with the new patch queue."
echo "Then export the changes back to the package using git2pkg.sh"

View File

@ -112,9 +112,10 @@ Source11: supported.ppc.txt
Source12: supported.x86.txt
Source13: supported.s390.txt
# this is to make lint happy
Source300: qemu-rpmlintrc
Source200: qemu-rpmlintrc
%endif # qemu
Source400: update_git.sh
Source300: update_git.sh
Source301: config.sh
# Upstream First -- https://wiki.qemu.org/Contribute/SubmitAPatch
# This patch queue is auto-generated - see README.PACKAGING for process

View File

@ -110,9 +110,10 @@ Source11: supported.ppc.txt
Source12: supported.x86.txt
Source13: supported.s390.txt
# this is to make lint happy
Source300: qemu-rpmlintrc
Source200: qemu-rpmlintrc
%endif # qemu
Source400: update_git.sh
Source300: update_git.sh
Source301: config.sh
# Upstream First -- https://wiki.qemu.org/Contribute/SubmitAPatch
# This patch queue is auto-generated - see README.PACKAGING for process

View File

@ -1,40 +0,0 @@
#!/bin/bash
set -e
source ./config.sh
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)"
# TEMPORARY! FOR NOW WE REQUIRE THESE LOCALLY TO DO WORK ON PACKAGE
REQUIRED_LOCAL_REPO_MAP=(
~/git/qemu-opensuse
~/git/qemu-seabios
~/git/qemu-ipxe
~/git/qemu-sgabios
~/git/qemu-skiboot
~/git/qemu-keycodemapdb
)
# 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[@]}
fi
done
./bundle2spec.sh &> /tmp/refresh.log
echo "SUCCESS"
tail -9 /tmp/refresh.log

View File

@ -1,2 +1,664 @@
#!/bin/bash
echo "This tool is no longer used. Refer to README.PACKAGING for current tooling"
# update_git.sh: script to manage package maintenance using a git-based
# workflow. Commands are as follows:
# git2pkg (update package spec file and patches from git)
# pkg2git (update git (frombundle branch) from the package "bundleofbundles")
# refresh (refresh spec file from spec file template and "bundlofbundles")
#
# (default is git2pkg)
set -e
source ./config.sh
TEMP_CHECK() {
# TEMPORARY! FOR NOW WE REQUIRE THESE LOCALLY TO DO WORK ON PACKAGE
REQUIRED_LOCAL_REPO_MAP=(
~/git/qemu-opensuse
~/git/qemu-seabios
~/git/qemu-ipxe
~/git/qemu-sgabios
~/git/qemu-skiboot
~/git/qemu-keycodemapdb
)
# 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[@]}
fi
done
}
#==============================================================================
initbundle() {
# What is needed to "start"?
# it all begins with an upstream repo, which may have submodules, incl. recursively (each represents another repo)
# To facilitate speedy work on this upstream repo, we want to have local clones of these repos
# Next we have a tarball, either that we created from the repo, or that upstream provided
# To alter the content of this tarball, lets use git to track these changes, and produce patches which can be included
# in the package spec file
# The following can get things a bit out of the expected order, but I don't think that is really much of a problem, as long as we're guaranteed to patch the superproject before any of it's submodules
# !!!! actually the simply submodule status --recursive w/out the additional processing we do for the groking of the bundle files
SUBMODULE_COMMIT_IDS=($(git -C ~/git/qemu-opensuse submodule status --recursive|awk '{print $1}'))
SUBMODULE_DIRS=($(git -C ~/git/qemu-opensuse submodule status --recursive|awk '{print $2}'))
SUBMODULE_COUNT=${#SUBMODULE_COMMIT_IDS[@]}
# !!! I should be able to 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 $BUNDLE_DIR
mkdir -p $BUNDLE_DIR
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
# also handle the superproject (I need to make this smarter, or change something - works for tag, but not normal commit:
GIT_UPSTREAM_COMMIT=$(git -C ~/git/qemu-opensuse show-ref -d $GIT_UPSTREAM_COMMIT_ISH|grep -F "^{}"|awk '{print $1}')
touch $BUNDLE_DIR/$GIT_UPSTREAM_COMMIT.id
# Now go through all the submodule local repos that are present and create a bundle file for the patches found there
rm -rf $GIT_DIR
for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ -e $(readlink -f ${LOCAL_REPO_MAP[$i]}) ]]; then
SUBDIR=${PATCH_PATH_MAP[$i]}
GITREPO_COMMIT_ISH=($BUNDLE_DIR/$SUBDIR*.id)
if [[ $GITREPO_COMMIT_ISH =~ .*(.{40})[.]id ]]; then
GITREPO_COMMIT_ISH=${BASH_REMATCH[1]}
fi
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 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 bundle create $BUNDLE_DIR/$SUBDIR$GITREPO_COMMIT_ISH.bundle $GITREPO_COMMIT_ISH..FETCH_HEAD || true
git -C $(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]}) remote get-url origin >$BUNDLE_DIR/$SUBDIR/repo
fi
done
tar cJvf bundles.tar.xz -C $BUNDLE_DIR .
rm -rf $BUNDLE_DIR
rm -rf $GIT_DIR
}
#==============================================================================
bundle2local() {
rm -rf $GIT_DIR
rm -rf $CMP_DIR
rm -rf $BUNDLE_DIR
rm -f checkpatch.log
mkdir -p $BUNDLE_DIR
tar xJf bundles.tar.xz -C $BUNDLE_DIR
BUNDLE_FILES=$(find $BUNDLE_DIR -printf "%P\n"|grep "bundle$")
for entry in ${BUNDLE_FILES[@]}; do
if [[ $entry =~ ^(.*)[/]*([a-f0-9]{40})[.]bundle$ ]]; then
SUBDIR=${BASH_REMATCH[1]}
GITREPO_COMMIT_ISH=${BASH_REMATCH[2]}
else
echo "ERROR! BAD BUNDLE CONTENT!"
exit
fi
for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ "$SUBDIR" = "${PATCH_PATH_MAP[$i]}" ]]; then
PATCH_RANGE_INDEX=$i
break
fi
done
LOCAL_REPO=$(readlink -f ${LOCAL_REPO_MAP[$PATCH_RANGE_INDEX]})
if [ -e $LOCAL_REPO ]; then
echo "Found local repo $LOCAL_REPO corresponding to archived git bundle"
else
echo "No local repo $LOCAL_REPO corresponding to archived git bundle"
fi
git -C $LOCAL_REPO remote remove bundlerepo || true
# git won't let you delete this branch if it's the current branch (returns 1) HOW TO HANDLE?
# detect this case, and ask user to switch to another branch? or do it for them - switch to master killing any "state" for this branch
git -C $LOCAL_REPO branch -D frombundle || true
git -C $LOCAL_REPO remote add bundlerepo $BUNDLE_DIR/$entry
# in next, the head may be FETCH_HEAD or HEAD depending on how we created:
git -C $LOCAL_REPO fetch bundlerepo FETCH_HEAD
#git -C $LOCAL_REPO fetch bundlerepo HEAD
git -C $LOCAL_REPO branch frombundle FETCH_HEAD
git -C $LOCAL_REPO remote remove bundlerepo
done
echo "For each local repo found a branch named frombundle contains the patches from the bundle."
echo "Use this as the starting point for making changes to the $GIT_BRANCH, which gets used as"
echo "the source when updating the bundle stored with the package."
rm -rf $BUNDLE_DIR
}
#==============================================================================
bundle2spec() {
rm -rf $GIT_DIR
rm -rf $CMP_DIR
rm -rf $BUNDLE_DIR
rm -f checkpatch.log
rm -rf checkthese
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
# This is just a safety valve in case the above gets edited wrong:
if ! [ "$GIT_BRANCH" = "master" ]; then
echo "LATEST implies master branch, please fix configuration"
exit
fi
(cd ${LOCAL_REPO_MAP[0]} && git remote update upstream)
fi
BASE_RE="qemu-[[:digit:]]+(\.[[:digit:]]+){2}(-rc[[:digit:]])?"
EXTRA_RE="\+git\.[[:digit:]]+\.([[:xdigit:]]+)"
SUFFIX_RE="\.tar\.xz"
SIG_SUFFIX_RE="\.tar\.xz\.sig"
QEMU_TARBALL=($(find -maxdepth 1 -type f -regextype posix-extended -regex \
"\./$BASE_RE($EXTRA_RE)?$SUFFIX_RE" -printf "%f "))
QEMU_TARBALL_SIG=($(find -maxdepth 1 -type f -regextype posix-extended -regex \
"\./$BASE_RE($EXTRA_RE)?$SIG_SUFFIX_RE" -printf "%f "))
if [ ${#QEMU_TARBALL[@]} -gt 1 ]; then
echo "Multiple qemu tarballs detected. Please clean up"
exit
fi
if [ ${#QEMU_TARBALL_SIG[@]} -gt 1 ]; then
echo "Multiple qemu tarballs signature files detected. Please clean up"
exit
fi
# It's ok for either of these to be empty when using "LATEST"
OLD_SOURCE_VERSION_AND_EXTRA=$(echo $QEMU_TARBALL 2>/dev/null | head --bytes=-8\
| cut --bytes=6-)
VERSION_EXTRA=$(echo $OLD_SOURCE_VERSION_AND_EXTRA|awk -F+ '{if ($2) print \
"+"$2}')
if [ "$OLD_SOURCE_VERSION_AND_EXTRA" = "" ]; then
echo "Warning: No tarball found"
fi
mkdir -p $BUNDLE_DIR
# This 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
# is a file named repo which contains the one line git repo url (with git:// or
# http(s) prefix). The bundles are named as follows:
# "{path/}{git_sha}.{patch_prefix}.{bundle}", where {path/} isn't present for
# the top (qemu) bundle (ie it's for submodules).
tar xJf bundles.tar.xz -C $BUNDLE_DIR
# !!! The following may be overkill, since it seems that find does do a depth first, which is all we need
BUNDLE_FILES=$(find $BUNDLE_DIR -printf "%P\n"|grep "bundle$")
if [ "$GIT_UPSTREAM_COMMIT_ISH" = "LATEST" ]; then
if [[ $QEMU_TARBALL =~ $BASE_RE$EXTRA_RE$SUFFIX_RE ]]; then
OLD_COMMIT_ISH=${BASH_REMATCH[3]}
else
#Assume release (or release candidate) tarball with equivalent tag:
OLD_COMMIT_ISH=$(cd ${LOCAL_REPO_MAP[0]} && git rev-list --abbrev-commit \
--abbrev=9 -1 v$OLD_SOURCE_VERSION_AND_EXTRA)
fi
if [ ${#QEMU_TARBALL_SIG[@]} -ne 0 ]; then
echo "INFO: Ignoring signature file: $QEMU_TARBALL_SIG"
QEMU_TARBALL_SIG=
fi
NEW_COMMIT_ISH=$(cd ${LOCAL_REPO_MAP[0]} && git rev-parse --short=9 \
upstream/$GIT_BRANCH)
NOW_SECONDS=$(date +%s)
git clone -ls ${LOCAL_REPO_MAP[0]} $GIT_DIR -b $GIT_BRANCH --single-branch &>/dev/null
if [ "$OLD_COMMIT_ISH" != "$NEW_COMMIT_ISH" ]; then
echo "Please wait..."
(cd $GIT_DIR && git remote add upstream \
git://git.qemu-project.org/qemu.git &>/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 submodule update --init --recursive &>/dev/null)
VERSION_EXTRA=+git.$NOW_SECONDS.$NEW_COMMIT_ISH
fi
QEMU_VERSION=$(cat $GIT_DIR/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]
else
SOURCE_VERSION=$[$MAJOR_VERSION+1].0.0-rc$[X-90]
fi
else
SOURCE_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$X
fi
if [ "$OLD_COMMIT_ISH" != "$NEW_COMMIT_ISH" ]; then
if (cd ${LOCAL_REPO_MAP[0]} && git describe --exact-match $NEW_COMMIT_ISH \
&>/dev/null); then
if [ "$X" = "50" ]; then
echo "Ignoring non-standard tag"
else
# there is no VERSION_EXTRA
VERSION_EXTRA=
fi
fi
(cd $GIT_DIR/roms/seabios && git describe --tags --long --dirty > \
.version)
(cd $GIT_DIR/roms/skiboot && ./make_version.sh > .version)
echo "Almost there..."
tar --exclude=.git --transform "s,$GIT_DIR,qemu-$SOURCE_VERSION," \
-Pcf qemu-$SOURCE_VERSION$VERSION_EXTRA.tar $GIT_DIR
echo "New tarball created. Attempting rebase..."
if ! (cd $GIT_DIR && git rebase upstream/$GIT_BRANCH $GIT_BRANCH); then
echo "rebasing master on upstream/master needs human assistance." \
"Exiting"
(cd $GIT_DIR && git rebase --abort)
rm qemu-$SOURCE_VERSION$VERSION_EXTRA.tar
exit
fi
echo "WARNING: To rebase, master is being checked out"
if ! (cd ${LOCAL_REPO_MAP[0]} && git rebase upstream/$GIT_BRANCH \
$GIT_BRANCH); then
echo "WARNING: Script error? rebasing master on upstream/master" \
"succeeded in temp"
echo "dir but failed in local tree! Please investigate"
(cd ${LOCAL_REPO_MAP[0]} && git rebase --abort)
rm qemu-$SOURCE_VERSION$VERSION_EXTRA.tar
exit
fi
echo "Rebase successful"
osc rm --force qemu-$OLD_SOURCE_VERSION_AND_EXTRA.tar.xz &>/dev/null ||\
true
osc rm --force qemu-$OLD_SOURCE_VERSION_AND_EXTRA.tar.xz.sig \
&>/dev/null || true
unset QEMU_TARBALL_SIG
xz -T 0 qemu-$SOURCE_VERSION$VERSION_EXTRA.tar
osc add qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz
fi
# We're done with GIT_UPSTREAM_COMMIT_ISH carrying the special value LATEST
GIT_UPSTREAM_COMMIT_ISH=$NEW_COMMIT_ISH
WRITE_LOG=0
else # not based on LATEST upstream master, rather any upstream commitish
if [ "$OLD_SOURCE_VERSION_AND_EXTRA" = "" ]; then
echo "Failure: tarball required which corresponds to commitish:" \
"$GIT_UPSTREAM_COMMITISH"
exit
fi
if [ -d "${LOCAL_REPO_MAP[0]}" ]; then
echo "Processing local git tree branch: $GIT_BRANCH, using commitish:"\
"$GIT_UPSTREAM_COMMIT_ISH"
if ! (cd ${LOCAL_REPO_MAP[0]} && git show-branch $GIT_BRANCH &>/dev/null)
then
echo "Error: Branch $GIT_BRANCH not found - please create a remote"\
"tracking branch of origin/$GIT_BRANCH"
exit
fi
for entry in ${BUNDLE_FILES[@]}; do
if [[ $entry =~ ^(.*)[/]*([a-f0-9]{40})[.]bundle$ ]]; then
SUBDIR=${BASH_REMATCH[1]}
GITREPO_COMMIT_ISH=${BASH_REMATCH[2]}
else
echo "ERROR! BAD BUNDLE CONTENT!"
exit
fi
for (( i=0; i <$REPO_COUNT; i++ )); do
if [[ "$SUBDIR" = "${PATCH_PATH_MAP[$i]}" ]]; then
PATCH_RANGE_INDEX=$i
break
fi
done
# !!!!! REVIEW WHERE THIS mkdir SHOULD BE HAPPENING (kind of replaces the clone operation)
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
git -C $GIT_DIR/$SUBDIR remote add bundle $BUNDLE_DIR/$entry
# depending on how created, the bundle's head is called HEAD or FETCH_HEAD
#git -C $GIT_DIR/$SUBDIR fetch bundle 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 \
--indent-heuristic --zero-commit --no-signature --full-index \
--src-prefix=a/$SUBDIR --dst-prefix=b/$SUBDIR \
--start-number=$(expr $PATCH_RANGE_INDEX \* $PATCH_RANGE) \
$GITREPO_COMMIT_ISH..FETCH_HEAD > /dev/null
done
# ( THIS ISNT WORKING - IS OLD HISTORY:)
else
echo "Processing $GIT_BRANCH branch of remote git tree, using"\
"commitish: $GIT_UPSTREAM_COMMIT_ISH"
echo "(For fast processing, consider establishing a local git tree"\
"at ${LOCAL_REPO_MAP[0]})"
# NYI - should be able to combine with local case for the most part
fi
QEMU_VERSION=$(cat $GIT_DIR/VERSION)
SOURCE_VERSION=$OLD_SOURCE_VERSION_AND_EXTRA
NEW_COMMIT_ISH=
WRITE_LOG=1
fi
rm -rf $GIT_DIR
rm -rf $BUNDLE_DIR
(
CHANGED_COUNT=0
UNCHANGED_COUNT=0
DELETED_COUNT=0
ADDED_COUNT=0
TOTAL_COUNT=0
shopt -s nullglob
for i in $CMP_DIR/*; do
# index line isn't consistent, so cut full index to normal line length
sed -E -i 's/(^index [a-f0-9]{28})[a-f0-9]{12}([.][.][a-f0-9]{28})[a-f0-9]{12}( [0-9]{6}$)/\1\2\3/' $i
BASENAME=$(basename $i)
if [ "$FIVE_DIGIT_POTENTIAL" = "1" ]; then
if [[ $BASENAME =~ [[:digit:]]{4}-.* ]]; then
BASENAME=0$BASENAME
fi
fi
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
KEEP_COUNT=40+4+$FIVE_DIGIT_POTENTIAL+1
else
KEEP_COUNT=40
fi
tail -n +2 $i > $CMP_DIR/${BASENAME:0:$KEEP_COUNT}.patch
rm $i
done
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
for i in [0-9]*.patch; do
osc rm --force $i
echo "calling osc rm on $i"
done
# we need to make sure that w/out the numbered prefixes, the patchnames are all unique
mkdir checkdir
for i in $CMP_DIR/*; do
BASENAME=$(basename $i)
FINALNAME=${BASENAME:4+$FIVE_DIGIT_POTENTIAL+1:40+1+5}
if [[ -e checkdir/$FINALNAME ]]; then
echo "ERROR! Patch name $FINALNAME is not unique! Please modify patch subject to achieve uniqueness"
exit 1
fi
cp $i checkdir/$FINALNAME
done
CHECK_DIR=checkdir
cp $CMP_DIR/*.patch .
else
CHECK_DIR=$CMP_DIR
fi
#step 0, and 0.1 are done above - question remains if the numbered case should use check dir
rm -f checkthese
if [ "$FIVE_DIGIT_POTENTIAL" = "0" ]; then
CHECK_PREFIX="0"
else
CHECK_PREFIX="00"
fi
for i in $CHECK_DIR/*; do
BASENAME=$(basename $i)
if [ -e $BASENAME ]; then
if cmp -s $i $BASENAME; then
touch --reference=$BASENAME $i
rm $BASENAME
let UNCHANGED_COUNT+=1
else
if [ "${BASENAME:0:1+$FIVE_DIGIT_POTENTIAL}" = "$CHECK_PREFIX" ]; then
echo "$BASENAME" >> checkthese
fi
rm $BASENAME
let CHANGED_COUNT+=1
let TOTAL_COUNT+=1
fi
else
echo " $BASENAME" >> qemu.changes.added
if [ "${BASENAME:0:1+$FIVE_DIGIT_POTENTIAL}" = "$CHECK_PREFIX" ]; then
echo "$BASENAME" >> checkthese
fi
let ADDED_COUNT+=1
let TOTAL_COUNT+=1
fi
done
if [ "$FIVE_DIGIT_POTENTIAL" = "0" ]; then
NUMBERED_PATCH_RE="^[[:digit:]]{4}-.*[.]patch$"
else
NUMBERED_PATCH_RE="^[[:digit:]]{5}-.*[.]patch$"
fi
#NEXT is #2 in lgorithm
for i in *.patch; do
if [[ $i =~ $NUMBERED_PATCH_RE ]]; then
if [[ "$NUMBERED_PATCHES" = "1" ]]; then
osc rm --force $i
echo "calling osc rm on $i"
echo " $i" >> qemu.changes.deleted
let DELETED_COUNT+=1
let TOTAL_COUNT+=1
fi
else
osc rm --force $i
echo "calling osc rm on $i"
echo " $i" >> qemu.changes.deleted
let DELETED_COUNT+=1
let TOTAL_COUNT+=1
fi
done
mv $CHECK_DIR/* .
if [ -e qemu.changes.added ]; then
xargs osc add < qemu.changes.added
echo "calling osc add on:"; cat qemu.changes.added
fi
# NYI do we need this check?
if [ ! -e checkpatch.pl ]; then
tar Jxf qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz \
qemu-$SOURCE_VERSION/scripts/checkpatch.pl --strip-components=2
fi
if [[ -e checkthese ]]; then
for i in $(cat checkthese); do
./checkpatch.pl --no-tree --terse --no-summary --summary-file \
--patch $i >> checkpatch.log || true
done
fi
rm -f checkthese
rm -f checkpatch.pl
if [ -s checkpatch.log ]; then
echo "WARNING: Issues reported by qemu patch checker. Please handle" \
"ERROR items now:"
cat checkpatch.log
fi
rm -f checkpatch.log
if [ "$TOTAL_COUNT" != "0" -a "$VERSION_EXTRA" != "" -a "$OLD_COMMIT_ISH" =\
"$NEW_COMMIT_ISH" ]; then
# Patches changed, so update the version using current time
VERSION_EXTRA=+git.$NOW_SECONDS.$OLD_COMMIT_ISH
osc mv qemu-$OLD_SOURCE_VERSION_AND_EXTRA.tar.xz \
qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz
osc add qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz
fi
echo "QEMU version file: $QEMU_VERSION"
echo "QEMU source version: $SOURCE_VERSION"
echo "QEMU version extra: $VERSION_EXTRA"
SEABIOS_VERSION=$(tar JxfO qemu-$SOURCE_VERSION$VERSION_EXTRA.tar.xz \
qemu-$SOURCE_VERSION/roms/seabios/.version | cut -d '-' -f 2)
for package in qemu; do
while IFS= read -r line; do
if [ "$line" = "PATCH_FILES" ]; then
for i in [0-9]*-*.patch; do
NUM=${i%%-*}
DIV=$((10#$NUM/$PATCH_RANGE))
REM=$((10#$NUM%$PATCH_RANGE))
if [[ "$REM" = "0" ]]; then
if [[ "$DIV" = "0" ]]; then
echo "# Patches applied in base project:"
else
echo "# Patches applied in ${PATCH_PATH_MAP[$DIV]}:"
fi
fi
if [[ "$FIVE_DIGIT_POTENTIAL" != "0" ]]; then
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
PATCH_NUMBER=${i%%-*}
echo -e "Patch$NUM: ${i:${#PATCH_NUMBER}+1:40+1+5}"
else
echo -e "Patch$NUM: $i"
fi
else
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
PATCH_NUMBER=${i%%-*}
echo -e "Patch$NUM: ${i:${#PATCH_NUMBER}+1:40+1+5}"
else
echo -e "Patch$NUM: $i"
fi
fi
done
elif [ "$line" = "PATCH_EXEC" ]; then
for i in [0-9]*-*.patch; do
S=$(grep "^Include-If: " $i) || true
NUM=${i%%-*}
if [ "$S" != "" ]; then
echo "${S:12}"
echo "%patch$NUM -p1"
echo "%endif"
else
echo "%patch$NUM -p1"
fi
done
elif [ "$line" = "QEMU_VERSION" ]; then
echo "%define qemuver $QEMU_VERSION$VERSION_EXTRA"
echo "%define srcver $SOURCE_VERSION$VERSION_EXTRA"
echo "Version: %qemuver"
elif [[ "$line" =~ ^Source: ]]; then
echo "$line"
if [ ${#QEMU_TARBALL_SIG[@]} -eq 1 ]; then
# We assume the signature file corresponds - just add .sig
echo "$line.sig"|sed 's/^Source: /Source99:/'
fi
elif [ "$line" = "SEABIOS_VERSION" ]; then
echo "Version: $SEABIOS_VERSION"
else
echo "$line"
fi
done < $package.spec.in > $CMP_DIR/$package.spec
if cmp -s $package.spec $CMP_DIR/$package.spec; then
echo "$package.spec unchanged"
else
mv $CMP_DIR/$package.spec $package.spec
echo "$package.spec regenerated"
let PACKAGE_CHANGED_COUNT+=1
fi
if [ "$WRITE_LOG" = "1" ]; then
# Factory requires all deleted and added patches to be mentioned
if [ -e qemu.changes.deleted ] || [ -e qemu.changes.added ]; then
echo "Patch queue updated from ${GIT_TREE} ${GIT_BRANCH}" > \
$package.changes.proposed
fi
if [ -e qemu.changes.deleted ]; then
echo "* Patches dropped:" >> $package.changes.proposed
cat qemu.changes.deleted >> $package.changes.proposed
fi
if [ -e qemu.changes.added ]; then
echo "* Patches added:" >> $package.changes.proposed
cat qemu.changes.added >> $package.changes.proposed
fi
if [ -e $package.changes.proposed ]; then
osc vc --file=$package.changes.proposed $package
rm -f $package.changes.proposed
fi
fi
done
if [[ "$NUMBERED_PATCHES" = "0" ]]; then
rm -f [0-9]*-*.patch
fi
if [ -e qemu.changes.deleted ]; then
rm -f qemu.changes.deleted
fi
if [ -e qemu.changes.added ]; then
rm -f qemu.changes.added
fi
echo "git patch summary"
echo " unchanged: $UNCHANGED_COUNT"
echo " changed: $CHANGED_COUNT"
echo " deleted: $DELETED_COUNT"
echo " added: $ADDED_COUNT"
)
rm -rf $CMP_DIR
rm -rf checkdir
osc service localrun format_spec_file
}
#==============================================================================
usage() {
echo "Usage:"
echo "git_update.sh: script to manage package maintenance using a git-based"
echo "workflow. Commands are as follows:"
echo " git2pkg (update package spec file and patches from git)"
echo " pkg2git (update git (frombundle branch) from the package "bundleofbundles")"
echo " refresh (refresh spec file from spec file template and "bundlofbundles")"
echo " (default is git2pkg)"
}
#==============================================================================
if [ "$1" = "" ]; then
set -- git2pkg
fi
case $1 in
initbundle )
initbundle
;;
git2pkg )
echo "Updating the package from 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"
tail -9 /tmp/git2pkg.log
;;
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"
echo "the $GIT_BRANCH branch with the new patch queue."
echo "Then export the changes back to the package using git2pkg.sh"
;;
refresh )
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
;;
* )
echo "Unknown command"
usage
;;
help )
usage
;;
esac