update makerepo.sh

This commit is contained in:
Thomas Haller 2014-02-18 14:48:14 +01:00
parent f5efae3b83
commit 37b9dd1f1b
1 changed files with 30 additions and 10 deletions

View File

@ -9,6 +9,13 @@ die() {
DIRNAME=NetworkManager-0.9.9.0
if grep -q '^NAME="Red Hat Enterprise Linux' /etc/os-release ; then
FEDPKG=rhpkg
else
FEDPKG=fedpkg
fi
split_patch() {
# patches created with git-format-patch that contain more then one
# commit, cannot be easily reverted with patch, because patch works
@ -53,6 +60,15 @@ unset REVERT_COUNT
LOCAL=0
for ARG; do
case "$ARG" in
-h|-?|help|--help)
echo "SYNOPSIS: $(basename "$0") [local|-l] [-?|-h|--help|help] [NUM]"
echo " - If [NUM] is omitted, it will revert all patches from the spec file,"
echo " otherwise only the last NUM patches."
echo " - When specifying 'local', it will also call \`$FEDPKG local\` to configure"
echo " and build the output directory."
echo " TIP: symlink your local git clone of NetworkManager to './.git/local'."
exit 0
;;
local|-l)
LOCAL=1
;;
@ -72,12 +88,13 @@ srcdir="$(dirname "$(readlink -f "$0")")"
(test -f $srcdir/NetworkManager.spec \
&& test -f $srcdir/sources) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the NM pkg dir"
echo "**Error**: Directory "\`$srcdir\'" does not look like the NM pkg dir."
echo "Copy the file \"$(readlink -f "$0")\" to the dist-git base directory"
exit 1
}
# generate the clean dir
fedpkg prep || die "error while \`fedpkg prep\`"
$FEDPKG prep || die "error while \`$FEDPKG prep\`"
pushd "$DIRNAME"
git init .
@ -90,6 +107,7 @@ pushd "$DIRNAME"
git fetch local 'refs/remotes/origin/*:refs/remotes/origin/*'
fi
git remote add origin git://anongit.freedesktop.org/NetworkManager/NetworkManager
git remote 'set-url' --push origin "ssh://$USER@git.freedesktop.org/git/NetworkManager/NetworkManager"
git commit --allow-empty -m '*** empty initial commit' # useful, to rebase the following commit
git add -f -A .
git commit -m '*** add all'
@ -150,16 +168,18 @@ pushd "$DIRNAME"
git commit --allow-empty -m "$COMMIT_MSG"
# first try git-am to preserve the commit message, otherwise just revert the last commit
git am "../${LAST_PATCH[$i]}" || (
if git am "../${LAST_PATCH[$i]}"; then
# The tree to the version before should be identical after reapplying the patch.
# Just to be sure, reset the commit.
git reset "${BASECOMMIT[$((i+1))]}" -- .
COMMIT_MSG="$(git log -n1 --format='%s' "$BASECOMMIT_REVERT" | sed 's/<< revert \(Patch.*"\)$/-- after reapplying \1\n\ngit-am did not fully restore the previous state/')"
git commit -m "$COMMIT_MSG" || echo "NOTHING TO COMMIT"
else
git am --abort
git reset "${BASECOMMIT[$((i+1))]}" -- .
COMMIT_MSG="$(git log -n1 --format='%s' "$BASECOMMIT_REVERT" | sed 's/<< revert \(Patch.*"\)$/>> reapply \1/')"
git commit --allow-empty -m "$COMMIT_MSG"
)
# The tree to the version before should be identical after reapplying the patch.
# Just to be sure, reset the commit.
git reset "${BASECOMMIT[$((i+1))]}" -- .
EDITOR=true git commit --amend --no-edit
fi
git reset --hard HEAD
done
fi
@ -168,7 +188,7 @@ popd
if [[ $LOCAL != 0 ]]; then
rm -rf ./.makerepo.git/
mv "$DIRNAME/.git" ./.makerepo.git/
fedpkg local
$FEDPKG local
mv ./.makerepo.git/ "$DIRNAME/.git"
pushd "$DIRNAME"
git checkout -- .gitignore