X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=contrib%2Fbuild-rpm;h=dd56a5de07556d1536c22a36c75e50c0557833be;hb=429d437d13a539fa64939a06f7711423c320e81d;hp=9596684935fd4849c520a1f3da890b9bdc8664ce;hpb=11181bbeb6d1b9fc536cdf040eb6e0d837a40162;p=tools%2Fe2fsprogs.git diff --git a/contrib/build-rpm b/contrib/build-rpm index 9596684..dd56a5d 100644 --- a/contrib/build-rpm +++ b/contrib/build-rpm @@ -1,5 +1,10 @@ #!/bin/sh +# enable xtrace output if requested +if [ -n ${ENABLE_XTRACE:-''} ]; then + set -x +fi + # Build an e2fsprogs RPM from cvs pwd=`pwd` @@ -8,8 +13,11 @@ pkgname=`grep Name: e2fsprogs.spec | awk '{print $2;}'` pkgvers=`grep Version: e2fsprogs.spec | awk '{print $2;}'` builddir=${pkgname}-${pkgvers} +# ensure that $TMP is set to something +TMP=${TMP:-'/tmp'} + cd .. -tmpdir=`mktemp -d rpmtmp.XXXXXX` +tmpdir=`mktemp -d ${RPM_TMPDIR:-$TMP}/rpmtmp.XXXXXX` # We need to build a tarball for the SRPM using $builddir as the # directory name (since that's what RPM will expect it to unpack @@ -21,8 +29,75 @@ cp -sR `pwd`/$currdir $tmpdir/$builddir || exit 1 # Remove any build files from the temporary tarball directory [ -f $tmpdir/$builddir/Makefile ] && make -C $tmpdir/$builddir distclean -EXCLUDE="--exclude .hg*" +EXCLUDE="--exclude .hg* --exclude .pc* --exclude .git*" (cd $tmpdir && tar czfh ${builddir}.tar.gz $EXCLUDE $builddir) [ "`rpmbuild --version 2> /dev/null`" ] && RPM=rpmbuild || RPM=rpm -$RPM --define "_sourcedir `pwd`/$tmpdir" -ba $currdir/e2fsprogs.spec || exit $? + +# which distro and release +DISTRO=$(lsb_release -is) +RELEASE=$(lsb_release -rs) +# now the hacks in case either is empty +if [ -z "$DISTRO" ]; then + echo "You really ought to install the lsb_release binary for this distro" + if grep "Fedora " /etc/issue; then + DISTRO="Fedora" + fi + if grep "SUSE Linux Enterprise Server " /etc/issue; then + DISTRO="SUSE LINUX" + fi + if grep "Red Hat Enterprise Linux" /etc/system-release; then + DISTRO="RedHatEnterprise" + fi +fi +if [ -z "$DISTRO" ]; then + echo "Could not determine the distribution. Please install the lsb_release binary" + exit 1 +fi +if [ -z "$RELEASE" ]; then + echo "You really ought to install the lsb_release binary for this distro" + case "$DISTRO" in + Fedora) + RELEASE=$(grep Fedora /etc/issue | sed -e 's/Fedora release //' -e 's/ .*//') + ;; + SUSE\ LINUX) + RELEASE=$(grep SUSE /etc/issue | sed -e 's/SUSE Linux Enterprise Server //' -e 's/ .*//') + ;; + RedHatEnterprise) + RELEASE=$(grep 'Red Hat' /etc/system-release | sed -e 's/Red Hat Enterprise Linux release //' -e 's/ .*//') + ;; + esac +fi +if [ -z "$RELEASE" ]; then + echo "Could not determine the release. Please install the lsb_release binary" + exit 1 +fi +case "$DISTRO-$RELEASE" in + AlmaLinux*) DISTRO=RHEL; RELEASE=7+;; + openEuler-2[0-9]*) DISTRO=RHEL; RELEASE=7+;; + RedHatEnterpriseServer-6*|CentOS-6*|Fedora-1[1-4]) DISTRO=RHEL; RELEASE=6;; + RedHatEnterprise*|Fedora*|CentOS*) DISTRO=RHEL; RELEASE=7+;; + Rocky*) DISTRO=RHEL; RELEASE=7+;; + Scientific-6*) DISTRO=RHEL; RELEASE=6;; + Scientific*) DISTRO=RHEL; RELEASE=7+;; + SUSE\ LINUX-1[1-5]* | SUSE-1[2-5]*) DISTRO=SUSE_LINUX; RELEASE=11+;; +esac + +SPECFILE="$currdir/e2fsprogs-${DISTRO// /_}-$RELEASE.spec" +if [ ! -f "$SPECFILE" ]; then + SPECFILE="$currdir/e2fsprogs.spec" +fi +echo "using SPECFILE=$SPECFILE" +grep VERSION $currdir/version.h +grep Version: $SPECFILE +grep Release: $SPECFILE + +$RPM --define "_sourcedir $tmpdir" \ + --define "_topdir ${RPM_TOPDIR:-$(rpm -E %_topdir)}" \ + --define "_tmpdir ${RPM_TMPDIR:-$TMP}" \ + --define "extra_config_flags ${EXTRA_CONFIG_FLAGS:-''}" \ + -ba $SPECFILE + +rpm_exit=$? +rm -rf $tmpdir +exit $rpm_exit