2015-04-20 16:11:01 +02:00
|
|
|
#!/bin/bash -e
|
|
|
|
#
|
|
|
|
# based on qemu's update_git.sh this program updates the patches
|
|
|
|
# applied on top of a tarball based on commmits in git
|
2015-04-20 16:23:20 +02:00
|
|
|
#
|
|
|
|
# how to use:
|
|
|
|
# quilt setup rpmlint.spec
|
|
|
|
# cp rpmlint-$RPMLINTVERSION/series .
|
|
|
|
# mkdir ~/git; cd ~/git
|
|
|
|
# git clone git://git.code.sf.net/p/rpmlint/code rpmlint-code
|
|
|
|
# git checkout -b opensuse-$RPMLINTVERSION v$RPMLINTVERSION
|
|
|
|
# git quiltimport --patches /where/rpmlint/checkout/is
|
|
|
|
# ... add/remove/rebase patches
|
|
|
|
# ... to rebase to a new version create branch and modify versions below
|
|
|
|
# when done run update_git.sh
|
2015-04-20 16:11:01 +02:00
|
|
|
|
2015-05-19 14:23:59 +02:00
|
|
|
GIT_TREE=https://github.com/lnussel/rpmlint-code.git
|
2015-04-20 16:11:01 +02:00
|
|
|
GIT_LOCAL_TREE=~/git/rpmlint-code
|
|
|
|
GIT_BRANCH=opensuse-1.6
|
|
|
|
GIT_UPSTREAM_TAG=v1.6
|
|
|
|
|
|
|
|
cleanup()
|
|
|
|
{
|
2015-04-20 16:23:20 +02:00
|
|
|
[ -z "$GIT_DIR" ] || rm -rf "$GIT_DIR"
|
|
|
|
[ -z "$CMP_DIR" ] || rm -rf "$GIT_DIR"
|
2015-04-20 16:11:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
GIT_DIR=`mktemp -d --tmpdir update_git.XXXXXXXXXX`
|
|
|
|
CMP_DIR=`mktemp -d --tmpdir update_git.XXXXXXXXXX`
|
|
|
|
|
|
|
|
if [ -d "$GIT_LOCAL_TREE" ]; then
|
|
|
|
echo "Processing $GIT_BRANCH branch of local git tree, using tag:" \
|
|
|
|
"$GIT_UPSTREAM_TAG"
|
|
|
|
if ! (cd $GIT_LOCAL_TREE && 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
|
|
|
|
git clone -ls $GIT_LOCAL_TREE $GIT_DIR -b $GIT_BRANCH
|
|
|
|
if ! (cd $GIT_LOCAL_TREE && git remote show upstream &>/dev/null); then
|
|
|
|
echo "Remote for upstream git tree not found. Next time add remote" \
|
|
|
|
"named upstream for $GIT_TREE and update"
|
|
|
|
(cd $GIT_DIR && git remote add upstream "$GIT_TREE")
|
|
|
|
(cd $GIT_DIR && git remote update)
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Processing $GIT_BRANCH branch of remote git tree, using tag:" \
|
|
|
|
"$GIT_UPSTREAM_TAG"
|
|
|
|
echo "(For much fast processing, consider establishing a local git tree" \
|
|
|
|
"at $GIT_LOCAL_TREE)"
|
|
|
|
git clone $GIT_TREE $GIT_DIR -b $GIT_BRANCH
|
|
|
|
(cd $GIT_DIR && git remote add upstream "$GIT_TREE")
|
|
|
|
(cd $GIT_DIR && git remote update)
|
|
|
|
fi
|
|
|
|
(cd $GIT_DIR && git format-patch -N $GIT_UPSTREAM_TAG --suffix=.tmp -o $CMP_DIR >/dev/null)
|
|
|
|
|
|
|
|
CHANGED_COUNT=0
|
|
|
|
UNCHANGED_COUNT=0
|
|
|
|
DELETED_COUNT=0
|
|
|
|
ADDED_COUNT=0
|
|
|
|
|
|
|
|
shopt -s nullglob
|
|
|
|
|
|
|
|
patches=()
|
|
|
|
for i in $CMP_DIR/*.tmp; do
|
|
|
|
basename="${i##*/}"
|
|
|
|
newname=${basename%.tmp}
|
|
|
|
newname=${newname%.diff} # remove .diff suffix it exist
|
|
|
|
# limit file names to 40 chars before extension
|
|
|
|
newname=${newname:0:40}.diff
|
2015-05-19 14:23:59 +02:00
|
|
|
# remove git signature and commit hash to make content
|
|
|
|
# independent of git version
|
|
|
|
head -n -3 "$i" | tail -n +2 > "$CMP_DIR/$newname"
|
2015-04-20 16:11:01 +02:00
|
|
|
rm "$i"
|
|
|
|
localname=${newname#*-}
|
|
|
|
patches+=("$localname")
|
|
|
|
if [ -e "$localname" ]; then
|
|
|
|
if cmp -s "$CMP_DIR/$newname" "$localname"; then
|
|
|
|
rm "$CMP_DIR/$newname"
|
|
|
|
let UNCHANGED_COUNT+=1
|
|
|
|
else
|
|
|
|
mv "$CMP_DIR/$newname" "$localname"
|
|
|
|
let CHANGED_COUNT+=1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
mv "$CMP_DIR/$newname" "$localname"
|
|
|
|
let ADDED_COUNT+=1
|
|
|
|
echo " $localname" >> qemu.changes.added
|
|
|
|
osc add "$localname"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# delete dropped patches
|
|
|
|
for patch in *.diff; do
|
|
|
|
keep=
|
|
|
|
for i in "${patches[@]}"; do
|
|
|
|
if [ "$i" = "$patch" ]; then
|
|
|
|
keep=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -z "$keep" ]; then
|
|
|
|
osc rm --force $patch
|
|
|
|
let DELETED_COUNT+=1
|
|
|
|
echo " $patch" >> qemu.changes.deleted
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for package in rpmlint; do
|
|
|
|
skip=
|
|
|
|
while IFS= read -r line; do
|
|
|
|
if [ "$line" = "# PATCHLIST END" ]; then
|
|
|
|
skip=
|
|
|
|
i=0
|
|
|
|
for patch in "${patches[@]}"; do
|
2015-05-19 14:23:59 +02:00
|
|
|
printf "Patch%02d: %s\n" "$i" "$patch"
|
2015-04-20 16:11:01 +02:00
|
|
|
let i+=1
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if [ -z "$skip" ]; then
|
|
|
|
echo "$line"
|
|
|
|
fi
|
|
|
|
if [ "$line" = "# PATCHLIST BEGIN" ]; then
|
|
|
|
skip=1
|
|
|
|
fi
|
|
|
|
done < $package.spec > $package.spec.new
|
2015-05-19 14:23:59 +02:00
|
|
|
mv $package.spec.new $package.spec
|
2015-04-20 16:11:01 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
done
|
|
|
|
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"
|