#109 Fix hardcoded path
Opened 11 months ago by et7f3. Modified 11 months ago
et7f3/rpmdevtools main  into  main

file modified
+6 -6
@@ -61,8 +61,8 @@ 

      types=

      if [[ -z $RPM_BUILD_ROOT ]] ; then

          indent="                     "

-         types=$(ls $SPECDIR/spectemplate-*.spec 2>/dev/null | \

-             sed 's,.*spectemplate-,,;s,\.spec$,,' | tr '\n' ' ' | \

+         types=$(find "${SPECDIR}" -maxdepth 1 -name 'spectemplate-*.spec' 2>/dev/null | \

+             sed 's,.*spectemplate-,,;s,\.spec$,,' | \

              fmt -w 60 | sed "s/^/$indent/")

          [[ -z $types ]] && types="${indent}None ($SPECDIR/spectemplate-*.spec)"

      fi
@@ -117,7 +117,7 @@ 

              specfile="$1"

              specfile_set=1

              case $specfile in

-                 *.spec) [[ -z $appname ]] && appname="$(basename $1 .spec)" ;;

+                 *.spec) [[ -z $appname ]] && appname="$(basename "${1}" .spec)" ;;

              esac

              ;;

          -m|--macros)
@@ -140,7 +140,7 @@ 

              ;;

          *.spec)

              [[ -z $specfile ]] && specfile="$1"

-             appname="$(basename $1 .spec)"

+             appname="$(basename "${1}" .spec)"

              ;;

          *)

              appname="$1"
@@ -162,7 +162,7 @@ 

          > /dev/stderr

  fi

  # major * 10000 + minor * 100 ( + micro perhaps later )

- rpmver=$(( $rpmmaj * 10000 + $rpmmin * 100 ))

+ rpmver=$(( rpmmaj * 10000 + rpmmin * 100 ))

  

  specfilter=

  if [[ -z $spectype ]] ; then
@@ -299,7 +299,7 @@ 

      chlog="s|^%changelog\\s*|%changelog\\n* $(LC_ALL=C date --utc +'%a %b %d %Y') $(rpmdev-packager)\\n- |Mg"

  fi

  

- cat "$tempspec" | sed -rne "

+ sed < "${tempspec}" -rne "

  1h

  1!H

  $ {

file modified
+22 -22
@@ -16,18 +16,18 @@ 

  #       copyright (c) 2002 Owl River Company - Columbus OH

  #       info@owlriver.com -- GPL v.2

  #

- [ "x$1" = "x-d" ] && {

+ [ "$1" = "-d" ] && {

      DEBUG="y"

      export DEBUG

      shift 1

  }

  #

- IAM=`id -un`

+ IAM=$(id -un)

  #       returns bare username

  #

- PASSWDDIR=`grep ^$IAM: /etc/passwd | awk -F":" '{print $6}'`

+ PASSWDDIR=$(grep ^"${IAM}": /etc/passwd | awk -F':' '{print $6}')

  HOMEDIR=${HOME:=$PASSWDDIR}

- [ ! -d $HOMEDIR ] && {

+ [ ! -d "${HOMEDIR}" ] && {

      echo "ERROR: Home directory for user $IAM not found in /etc/passwd."

      exit 1

  }
@@ -36,16 +36,16 @@ 

  #

  #

  RPMMACROS="$HOMEDIR/.rpmmacros"

- touch $RPMMACROS

+ touch "${RPMMACROS}"

  #

- TOPDIR="%_topdir"

- ISTOP=`grep -c ^$TOPDIR $RPMMACROS`

- [ $ISTOP -lt 1 ] && {

-     cat <<\EOF >> $RPMMACROS

+ case $(rpm --eval '%{_topdir}') in

+   '%{_topdir}')

+     cat <<\EOF >> "${RPMMACROS}"

  

- %_topdir %(echo $HOME)/rpmbuild

+ %_topdir %{getenv:HOME}/rpmbuild

  EOF

- }

+   ;;

+ esac

  #

  #MAKE="%make "

  #ISTOP=`grep -c ^$MAKE $RPMMACROS`
@@ -53,21 +53,21 @@ 

  #       echo "$MAKE  make" >> $RPMMACROS

  #       }

  #

- ISTOP=`grep -c ^%__arch_install_post $RPMMACROS`

- [ $ISTOP -lt 1 ] && {

-     cat <<\EOF >> $RPMMACROS

+ ISTOP=$(grep -c ^%__arch_install_post "${RPMMACROS}")

+ [ "${ISTOP}" -lt 1 ] && {

+     cat <<\EOF >> "${RPMMACROS}"

  

  %__arch_install_post \

      [ "%{buildarch}" = "noarch" ] || QA_CHECK_RPATHS=1 ; \

-     case "${QA_CHECK_RPATHS:-}" in [1yY]*) /usr/lib/rpm/check-rpaths ;; esac \

-     /usr/lib/rpm/check-buildroot

+     case "${QA_CHECK_RPATHS:-}" in [1yY]*) %{_rpmconfigdir}/check-rpaths ;; esac \

+     %{_rpmconfigdir}/check-buildroot

  EOF

  }

- RPMDIR=`rpm --eval "%{_rpmdir}"`

- SRCDIR=`rpm --eval "%{_sourcedir}"`

- SPECDIR=`rpm --eval "%{_specdir}"`

- SRPMDIR=`rpm --eval "%{_srcrpmdir}"`

- BUILDDIR=`rpm --eval "%{_builddir}"`

+ RPMDIR=$(rpm --eval "%{_rpmdir}")

+ SRCDIR=$(rpm --eval "%{_sourcedir}")

+ SPECDIR=$(rpm --eval "%{_specdir}")

+ SRPMDIR=$(rpm --eval "%{_srcrpmdir}")

+ BUILDDIR=$(rpm --eval "%{_builddir}")

  [ "x$DEBUG" != "x" ] && {

      echo "$IAM       $HOMEDIR    $RPMMACROS"

      echo "$RPMDIR    $SRCDIR     $SPECDIR"
@@ -75,7 +75,7 @@ 

  }

  #

  for i in $RPMDIR $SRCDIR $SPECDIR $SRPMDIR $BUILDDIR ; do

-     [ ! -d $i ] && mkdir -p $i

+     [ ! -d "${i}" ] && mkdir -p "${i}"

  done

  #

  exit 0

The first commit is only cosmetic and can be dropped (but I like to work on modern/valid shell syntax).
The second commit remove hardcoded path. I have rpm in non standard location and it this macro made all my build fail (I was mad when I searched where it was called but forgot the ~/.rpmmacros: I now understand this warning from redhat https://access.redhat.com/documentation/fr-fr/red_hat_enterprise_linux/8/html/packaging_and_distributing_software/advanced-topics#using-the-custom-macros_more-on-macros)
The third commit is to reduce content of ~/.rpmmacros in hope we can get rid of it one day.

Next step is copy __arch_install_post upstream ?

Metadata