[NetworkManager/f20] update makerepo.sh
thaller
thaller at fedoraproject.org
Mon Feb 24 17:36:53 UTC 2014
commit 37b9dd1f1b6b6ebf64e648aaa0f2b1766f082a48
Author: Thomas Haller <thaller at redhat.com>
Date: Tue Feb 18 14:48:14 2014 +0100
update makerepo.sh
makerepo.sh | 40 ++++++++++++++++++++++++++++++----------
1 files changed, 30 insertions(+), 10 deletions(-)
---
diff --git a/makerepo.sh b/makerepo.sh
index ff4b0f9..593f62f 100755
--- a/makerepo.sh
+++ b/makerepo.sh
@@ -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
More information about the scm-commits
mailing list