From 2119432cdd7a77840b73cae32b9dc3597ac54d98 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 28 Feb 2014 15:27:58 +0100 Subject: [PATCH] contrib/makerepo: update makerepo.sh to better detect rhpkg/fedpkg Also, allow makerepo.sh not to be in the root directory of the dist-git checkout. Instead, your current working directory must now be inside the git working copy Signed-off-by: Thomas Haller --- contrib/fedora/utils/makerepo.sh | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/contrib/fedora/utils/makerepo.sh b/contrib/fedora/utils/makerepo.sh index b7581f9ebf..ecee47574a 100755 --- a/contrib/fedora/utils/makerepo.sh +++ b/contrib/fedora/utils/makerepo.sh @@ -7,10 +7,24 @@ die() { exit 1 } -if grep -q '^NAME="Red Hat Enterprise Linux' /etc/os-release ; then - FEDPKG=rhpkg -else - FEDPKG=fedpkg +srcdir="$(readlink -f "$(git rev-parse --show-toplevel 2>/dev/null)")" +[[ "x$srcdir" != x ]] || die "Could not detect dist-git directory (are you inside the git working directory?)" +cd "$srcdir" || die "Could not switch to dist-git directory" + + +(test -f $srcdir/NetworkManager.spec \ + && test -f $srcdir/sources) || { + die "**Error**: Directory "\`$srcdir\'" does not look like the NM pkg dir." \ + "Copy the file \"$(readlink -f "$0")\" to the dist-git base directory" +} + +if [[ "$FEDPKG" == "" ]]; then + REMOTES="$(git remote -v 2>/dev/null)" || die "not inside dist-git repository? >>$PWD<<" + if echo "$REMOTES" | grep -q -F 'pkgs.devel.redhat.com' ; then + FEDPKG=rhpkg + else + FEDPKG=fedpkg + fi fi split_patch() { @@ -81,15 +95,6 @@ for ARG; do esac done -srcdir="$(dirname "$(readlink -f "$0")")" - -(test -f $srcdir/NetworkManager.spec \ - && test -f $srcdir/sources) || { - 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\`"