pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/genrpm Some bug fixes following feedback from...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8110aaa55d4f
branches:  trunk
changeset: 530920:8110aaa55d4f
user:      agc <agc%pkgsrc.org@localhost>
date:      Sat Jul 14 14:51:19 2007 +0000

description:
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:

 pkgtools/genrpm/Makefile     |   5 +--
 pkgtools/genrpm/files/genrpm |  49 +++++++++++++++++++++++++++++--------------
 2 files changed, 35 insertions(+), 19 deletions(-)

diffs (129 lines):

diff -r 906ca19e3ac5 -r 8110aaa55d4f pkgtools/genrpm/Makefile
--- a/pkgtools/genrpm/Makefile  Sat Jul 14 14:03:06 2007 +0000
+++ b/pkgtools/genrpm/Makefile  Sat Jul 14 14:51:19 2007 +0000
@@ -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 -r 906ca19e3ac5 -r 8110aaa55d4f pkgtools/genrpm/files/genrpm
--- a/pkgtools/genrpm/files/genrpm      Sat Jul 14 14:03:06 2007 +0000
+++ b/pkgtools/genrpm/files/genrpm      Sat Jul 14 14:51:19 2007 +0000
@@ -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 @@
        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 @@
 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 @@
 # 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 @@
 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 @@
                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@localhost>" >> $specfile
                echo "Distribution: ${DISTRIBUTION}" >> $specfile
                echo "Vendor: ${DISTVENDOR}" >> $specfile
@@ -257,7 +274,7 @@
                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 @@
                (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



Home | Main Index | Thread Index | Old Index