diff options
author | agc <agc@pkgsrc.org> | 2007-07-14 14:51:19 +0000 |
---|---|---|
committer | agc <agc@pkgsrc.org> | 2007-07-14 14:51:19 +0000 |
commit | 45c75f52c612f579f1d21ceea445ddea7f757de2 (patch) | |
tree | e1fb103d036e8141e6c73f020483882e2c775cfc /pkgtools/genrpm | |
parent | 852ea323490364b75c491f68aaab934b17f14a82 (diff) | |
download | pkgsrc-45c75f52c612f579f1d21ceea445ddea7f757de2.tar.gz |
Some bug fixes following feedback from Aleksey Cheusov.
Check that some directories exist before trying to use them.
Calculate the architecture, overridable on the command line.
Diffstat (limited to 'pkgtools/genrpm')
-rw-r--r-- | pkgtools/genrpm/Makefile | 5 | ||||
-rw-r--r-- | pkgtools/genrpm/files/genrpm | 49 |
2 files changed, 35 insertions, 19 deletions
diff --git a/pkgtools/genrpm/Makefile b/pkgtools/genrpm/Makefile index 02a10ae8991..7071b6ed7a6 100644 --- a/pkgtools/genrpm/Makefile +++ b/pkgtools/genrpm/Makefile @@ -1,7 +1,6 @@ -# $NetBSD: Makefile,v 1.4 2007/02/22 19:27:02 wiz Exp $ +# $NetBSD: Makefile,v 1.5 2007/07/14 14:51:19 agc Exp $ -DISTNAME= genrpm-1.0 -PKGREVISION= 1 +DISTNAME= genrpm-1.1 CATEGORIES= pkgtools MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/genrpm/files/genrpm b/pkgtools/genrpm/files/genrpm index 9b6bdbdd134..626cf8ccf48 100644 --- a/pkgtools/genrpm/files/genrpm +++ b/pkgtools/genrpm/files/genrpm @@ -1,9 +1,9 @@ #! @SH@ -# $NetBSD: genrpm,v 1.1.1.1 2005/04/20 09:36:00 agc Exp $ +# $NetBSD: genrpm,v 1.2 2007/07/14 14:51:19 agc Exp $ # -# Copyright © 2005 Alistair G. Crooks. All rights reserved. +# Copyright © 2005,2007 Alistair Crooks. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -13,10 +13,7 @@ # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by Alistair G. Crooks -# 4. The name of the author may not be used to endorse or promote +# 3. The name of the author may not be used to endorse or promote # products derived from this software without specific prior written # permission. # @@ -58,6 +55,22 @@ check_prog() eval $_var=\"""\" } +# make sure we have a directory (given as argument) +safemkdir() +{ + _dir="$1" + + echo "Making directory \"${_dir}\"" + if [ ! -d ${_dir} ]; then + ${mkdir_cmd} -p ${_dir} + fi + + if [ ! -d ${_dir} ]; then + echo "can't create firectory ${_dir} - please do this by hand, and then restart" 2>&1 + exit 1 + fi +} + # our definitions DISTVENDOR=${DISTVENDOR:-"pkgsrc/genrpm"} DISTRIBUTION=${DISTRIBUTION:-"pkgsrc genrpm `date +%Y%m%d`"} @@ -89,6 +102,7 @@ DISTDIR=${DISTDIR:-@PKGSRCDIR@/distfiles} objdir=/usr/obj rpmdir=@PKGSRCDIR@/packages/rpms srpmdir=@PKGSRCDIR@/packages/srpms +arch=`uname -m` PKG_DBDIR=${PKG_DBDIR:-/var/db/pkg} PKGSRC=${PKGSRC:-@PKGSRCDIR@} @@ -105,6 +119,7 @@ metafiles="+BUILD_INFO +BUILD_VERSION +COMMENT +CONTENTS +DESC +SIZE_ALL +SIZE_P # check any given args while [ $# -gt 0 ]; do case "$1" in + --arch=*) arch=`echo "$1" | ${sed_cmd} -e 's|--arch=||'` ;; --distdir=*) DISTDIR=`echo "$1" | ${sed_cmd} -e 's|--distdir=||'` ;; --objdir=*) objdir=`echo "$1" | ${sed_cmd} -e 's|--objdir=||'` ;; --rpmdir=*) rpmdir=`echo "$1" | ${sed_cmd} -e 's|--rpmdir=||'` ;; @@ -118,13 +133,15 @@ while [ $# -gt 0 ]; do done # check canonical directories are there on NetBSD -if [ ! -d $redhatdir ]; then - ${mkdir_cmd} -p $redhatdir - (cd $redhatdir && ${ln_cmd} -s $objdir/rpm BUILD) - (cd $redhatdir && ${ln_cmd} -s $rpmdir RPMS) - (cd $redhatdir && ${ln_cmd} -s $srpmdir SRPMS) - (cd $redhatdir && ${ln_cmd} -s $objdir/rpm/SOURCES SOURCES) -fi +safemkdir ${redhatdir} +safemkdir ${rpmdir} +safemkdir ${rpmdir}/${arch} +safemkdir ${srpmdir} + +(cd $redhatdir && ${ln_cmd} -s $objdir/rpm BUILD) +(cd $redhatdir && ${ln_cmd} -s $rpmdir RPMS) +(cd $redhatdir && ${ln_cmd} -s $srpmdir SRPMS) +(cd $redhatdir && ${ln_cmd} -s $objdir/rpm/SOURCES SOURCES) # check that we have required packages installed for p in $reqpkgs; do @@ -189,7 +206,7 @@ while [ $# -gt 0 ]; do echo "Version: %{version}" >> $specfile echo "Release: %{release}" >> $specfile echo "Copyright: unknown" >> $specfile - echo "URL: `${pkg_info_cmd} -d $name | ${awk_cmd} '/^Homepage:/ { getline; print; exit }'`" >> $specfile + echo "URL: `${pkg_info_cmd} -d $name | ${awk_cmd} 'BEGIN { homepage=\"http://www.pkgsrc.org\"; }/^Homepage:/ { getline; homepage=$0 } END { print homepage }'`" >> $specfile echo "Packager: Alistair Crooks <genrpm@alistaircrooks.com>" >> $specfile echo "Distribution: ${DISTRIBUTION}" >> $specfile echo "Vendor: ${DISTVENDOR}" >> $specfile @@ -257,7 +274,7 @@ while [ $# -gt 0 ]; do fi echo "%description" >> $specfile - ${pkg_info_cmd} -qd $name | ${awk_cmd} 'NF == 0 { next } { print }' >> $specfile + ${pkg_info_cmd} -qd $name | ${awk_cmd} 'NF == 0 { next } { gsub("%", "percent"); print }' >> $specfile echo "" >> $specfile echo "%prep" >> $specfile @@ -292,7 +309,7 @@ while [ $# -gt 0 ]; do (cd $builddir && rpm $verbose $genpat $sign $pkgbase.spec) # tell people where we've put it/them - ${ls_cmd} -al $rpmdir/i386/$pkgname-* + ${ls_cmd} -al $rpmdir/${arch}/$pkgname-* # cleanup ${rm_cmd} -rf $builddir $objdir/rpm/$pkgname |