commit 03bb2914eabf0d4ae7fcd59da272db326969288a Author: Elliot Lee Date: Wed Jun 12 12:59:50 2002 +0000 Initial revision diff --git a/brp-compress b/brp-compress new file mode 100755 index 0000000..897a765 --- /dev/null +++ b/brp-compress @@ -0,0 +1,56 @@ +#!/bin/sh + +# If using normal root, avoid changing anything. +if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then + exit 0 +fi + +cd $RPM_BUILD_ROOT + +# Compress man pages +COMPRESS="gzip -9" +COMPRESS_EXT=.gz + +for d in ./usr/man/man* ./usr/man/*/man* ./usr/info \ + ./usr/share/man/man* ./usr/share/man/*/man* ./usr/share/info \ + ./usr/kerberos/man ./usr/X11R6/man/man* ./usr/lib/perl5/man/man* \ + ./usr/share/doc/*/man/man* ./usr/lib/*/man/man* +do + [ -d $d ] || continue + for f in `find $d -type f` + do + [ -f "$f" ] || continue + [ "`basename $f`" = "dir" ] && continue + + case "$f" in + *.Z) gunzip $f; b=`echo $f | sed -e 's/\.Z$//'`;; + *.gz) gunzip $f; b=`echo $f | sed -e 's/\.gz$//'`;; + *.bz2) bunzip2 $f; b=`echo $f | sed -e 's/\.bz2$//'`;; + *) b=$f;; + esac + + $COMPRESS $b /dev/null || { + inode=`ls -i $b | awk '{ print $1 }'` + others=`find $d -type f -inum $inode` + if [ -n "$others" ]; then + for afile in $others ; do + [ "$afile" != "$b" ] && rm -f $afile + done + $COMPRESS -f $b + for afile in $others ; do + [ "$afile" != "$b" ] && ln $b$COMPRESS_EXT $afile$COMPRESS_EXT + done + else + $COMPRESS -f $b + fi + } + done + + for f in `find $d -type l` + do + l=`ls -l $f | sed -e 's/.* -> //' -e 's/\.gz$//' -e 's/\.bz2$//' -e 's/\.Z$//'` + rm -f $f + b=`echo $f | sed -e 's/\.gz$//' -e 's/\.bz2$//' -e 's/\.Z$//'` + ln -sf $l$COMPRESS_EXT $b$COMPRESS_EXT + done +done diff --git a/brp-redhat b/brp-redhat new file mode 100755 index 0000000..bdd5048 --- /dev/null +++ b/brp-redhat @@ -0,0 +1,13 @@ +#!/bin/sh + +# These are the build root policies that Red Hat invokes at the end +# of the %install scriptlet. + +# Compress man pages (Red Hat uses GNU gzip) +/usr/lib/rpm/redhat/brp-compress + +# Strip ELF binaries (Red Hat uses GNU binutils). +/usr/lib/rpm/redhat/brp-strip + +# Strip even more sections (Red Hat uses GNU binutils). +/usr/lib/rpm/redhat/brp-strip-comment-note diff --git a/brp-sparc64-linux b/brp-sparc64-linux new file mode 100755 index 0000000..5e511b3 --- /dev/null +++ b/brp-sparc64-linux @@ -0,0 +1,41 @@ +#!/bin/sh +# If using normal root, avoid changing anything. +if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then + exit 0 +fi +files= +LC_ALL= +LANG= + +# Move 64bit ELF objects from /lib, /usr/lib, /usr/X11R6/lib to */lib64 +# directories + +for f in `find $RPM_BUILD_ROOT{,/usr,/usr/X11R6}/lib -maxdepth 1 -type f -o -type l 2>/dev/null`; do + ff=$f + while [ -L $ff ]; do + l=`ls -l $ff | awk '{ print $11 }'` + case $l in + /*) ff=$RPM_BUILD_ROOT$l ;; + *) ff=`dirname $ff`/$l ;; + esac + done + if file $ff 2>/dev/null | grep ': ELF 64-bit .SB' | grep -v ': ELF 64-bit .SB executable' > /dev/null; then + files="$files $f" + elif file $ff 2>/dev/null | grep 'ar archive' > /dev/null; then + if objdump -h $ff 2>/dev/null | grep ':[ ]*file format elf64-sparc' > /dev/null; then + files="$files $f" + fi + fi +done +for f in $files; do + d=`dirname $f` + n=`basename $f` + if [ ! -d ${d}64 ]; then mkdir -p ${d}64; fi + if [ -L $f ]; then + l=`ls -l $f | awk '{ print $11 }' | sed 's_lib\(/[^/]*\)$_lib64\1_'` + ln -sf $l ${d}64/$n + rm -f $f + else + mv -f $f ${d}64/$n + fi +done diff --git a/brp-strip b/brp-strip new file mode 100755 index 0000000..f959134 --- /dev/null +++ b/brp-strip @@ -0,0 +1,12 @@ +#!/bin/sh +# If using normal root, avoid changing anything. +if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then + exit 0 +fi + +# Strip ELF binaries +for f in `find $RPM_BUILD_ROOT -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \ + grep -v ' shared object,' | \ + sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped/\1/p'`; do + strip -g $f || : +done diff --git a/brp-strip-comment-note b/brp-strip-comment-note new file mode 100755 index 0000000..1c853cf --- /dev/null +++ b/brp-strip-comment-note @@ -0,0 +1,17 @@ +#!/bin/sh +# If using normal root, avoid changing anything. +if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then + exit 0 +fi + +# Strip .comment and .note sections (the latter only if it is not allocated) +# for already stripped elf files in the build root +for f in `find $RPM_BUILD_ROOT -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; | \ + sed -n -e 's/^\(.*\):[ ]*ELF.*, stripped/\1/p'`; do + note="-R .note" + if objdump -h $f | grep '^[ ]*[0-9]*[ ]*.note[ ]' -A 1 | \ + grep ALLOC >/dev/null; then + note= + fi + strip -R .comment $note $f || : +done diff --git a/brp-strip-shared b/brp-strip-shared new file mode 100755 index 0000000..501a278 --- /dev/null +++ b/brp-strip-shared @@ -0,0 +1,17 @@ +#!/bin/sh +# Conectiva brp - strip shared libraries. Based on Red Hat's brp-strip. +# Thu Apr 20 - Guilherme Manika +# Created file + +if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then + exit 0 +fi + +# Strip ELF shared objects +# Please note we don't restrict our search to executable files because +# our libraries are not (should not be, at least) +x. +for f in `find $RPM_BUILD_ROOT -type f -a -exec file {} \; | \ + grep ' shared object,' | \ + sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped/\1/p'`; do + strip --strip-unneeded $f +done diff --git a/find-lang.sh b/find-lang.sh new file mode 100755 index 0000000..d333e48 --- /dev/null +++ b/find-lang.sh @@ -0,0 +1,95 @@ +#!/bin/sh +#findlang - automagically generate list of language specific files +#for inclusion in an rpm spec file. +#This does assume that the *.mo files are under .../share/locale/... +#Run with no arguments gets a usage message. + +#findlang is copyright (c) 1998 by W. L. Estes + +#Redistribution and use of this software are hereby permitted for any +#purpose as long as this notice and the above copyright notice remain +#in tact and are included with any redistribution of this file or any +#work based on this file. + +#changes: +# 1999-10-19 Artur Frysiak +# * added support for GNOME help files +# * start support for KDE help files + +usage () { +cat <&2 +elif [ ! -d $1 ] ; then + echo $0: $1: no such directory + exit 1 +else TOP_DIR="`echo $1|sed -e 's:/$::'`" +fi +shift + +if [ -z "$1" ] ; then usage +else NAME=$1 +fi +shift + +GNOME=# +KDE=# +MO= +MO_NAME=$NAME.lang + +while test $# -gt 0 ; do + case "${1}" in + --with-gnome ) + GNOME= + shift + ;; + --with-kde ) + KDE_HELP= + shift + ;; + --without-mo ) + MO=# + shift + ;; + * ) + MO_NAME=${1} + shift + ;; + esac +done + +find $TOP_DIR -type f|sed ' +1i\ +%defattr (644, root, root, 755) +s:'"$TOP_DIR"':: +'"$MO"'s:\(.*/share/locale/\)\([^/_]\+\)\(.*'"$NAME"'\.mo$\):%lang(\2) \1\2\3: +'"$GNOME"'s:\(.*/gnome/help/'"$NAME"'/\)\([^/_]\+\):%lang(\2) \1\2: +s:^\([^%].*\):: +s:%lang(C) :: +' > $MO_NAME + +find $TOP_DIR -type d|sed ' +s:'"$TOP_DIR"':: +'"$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1: +'"$GNOME"'s:\(.*/gnome/help/'"$NAME"'/\)\([^/_]\+\):%dir %lang(\2) \1\2: +s:^\([^%].*\):: +s:%lang(C) :: +' >> $MO_NAME diff --git a/find-provides b/find-provides new file mode 100755 index 0000000..2743a08 --- /dev/null +++ b/find-provides @@ -0,0 +1,61 @@ +#!/bin/bash + +# This script reads filenames from STDIN and outputs any relevant provides +# information that needs to be included in the package. + +filelist=`sed "s/['\"]/\\\&/g"` + +solist=$(echo $filelist | grep "\\.so" | grep -v "^/lib/ld.so" | \ + xargs file -L 2>/dev/null | grep "ELF.*shared object" | cut -d: -f1) +pythonlist= +tcllist= + +# +# --- Alpha does not mark 64bit dependencies +case `uname -m` in + alpha*) mark64="" ;; + *) mark64="()(64bit)" ;; +esac + +# +# --- Library sonames and weak symbol versions (from glibc). +for f in $solist; do + soname=$(objdump -p $f | awk '/SONAME/ {print $2}') + + lib64=`if file -L $f 2>/dev/null | \ + grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` + if [ "$soname" != "" ]; then + if [ ! -L $f ]; then + echo $soname$lib64 + objdump -p $f | awk ' + BEGIN { START=0 ; } + /Version definitions:/ { START=1; } + /^[0-9]/ && (START==1) { print $4; } + /^$/ { START=0; } + ' | \ + grep -v $soname | \ + while read symbol ; do + echo "$soname($symbol)`echo $lib64 | sed 's/()//'`" + done + fi + else + echo ${f##*/}$lib64 + fi +done | sort -u + +# +# --- Perl modules. +[ -x /usr/lib/rpm/redhat/perl.prov ] && + echo $filelist | tr '[:blank:]' \\n | grep '\.pm$' | /usr/lib/rpm/redhat/perl.prov | sort -u + +# +# --- Python modules. +[ -x /usr/lib/rpm/redhat/python.prov -a -n "$pythonlist" ] && + echo $pythonlist | tr '[:blank:]' \\n | /usr/lib/rpm/redhat/python.prov | sort -u + +# +# --- Tcl modules. +[ -x /usr/lib/rpm/redhat/tcl.prov -a -n "$tcllist" ] && + echo $tcllist | tr '[:blank:]' \\n | /usr/lib/rpm/redhat/tcl.prov | sort -u + +exit 0 diff --git a/find-requires b/find-requires new file mode 100755 index 0000000..c3dade5 --- /dev/null +++ b/find-requires @@ -0,0 +1,133 @@ +#!/bin/bash + +# +# Auto-generate requirements for executables (both ELF and a.out) and library +# sonames, script interpreters, and perl modules. +# + +ulimit -c 0 + +# +# --- Set needed to 0 for traditional find-requires behavior. +needed=1 +if [ X"$1" = Xldd ]; then + needed=0 +elif [ X"$1" = Xobjdump ]; then + needed=1 +fi + +# +# --- Grab the file manifest and classify files. +filelist=`sed "s/['\"]/\\\&/g"` +exelist=`echo $filelist | xargs -r file | egrep -v ":.* (commands|script) " | \ + grep ":.*executable" | cut -d: -f1` +scriptlist=`echo $filelist | xargs -r file | \ + egrep ":.* (commands|script) " | cut -d: -f1` +liblist=`echo $filelist | xargs -r file | \ + grep ":.*shared object" | cut -d : -f1` + +interplist= +perllist= +pythonlist= +tcllist= + +# +# --- Alpha does not mark 64bit dependencies +case `uname -m` in + alpha*) mark64="" ;; + *) mark64="()(64bit)" ;; +esac + +if [ "$needed" -eq 0 ]; then +# +# --- Executable dependency sonames. + for f in $exelist; do + [ -r $f -a -x $f ] || continue + lib64=`if file -L $f 2>/dev/null | \ + grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` + ldd $f | awk '/=>/ { + if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) { + gsub(/'\''"/,"\\&",$1); + printf "%s'$lib64'\n", $1 + } + }' + done | xargs -r -n 1 basename | sort -u + +# +# --- Library dependency sonames. + for f in $liblist; do + [ -r $f ] || continue + lib64=`if file -L $f 2>/dev/null | \ + grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` + ldd $f | awk '/=>/ { + if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) { + gsub(/'\''"/,"\\&",$1); + printf "%s'$lib64'\n", $1 + } + }' + done | xargs -r -n 1 basename | sort -u +fi + +# +# --- Script interpreters. +for f in $scriptlist; do + [ -r $f -a -x $f ] || continue + interp=`head -1 $f | sed -e 's/^\#\![ ]*//' | cut -d" " -f1` + interplist="$interplist $interp" + case $interp in + */perl) perllist="$perllist $f" ;; + esac +done +[ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; } + +# +# --- Add perl module files to perllist. +for f in $filelist; do + [ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f" +done + +# +# --- Weak symbol versions (from glibc). +[ -n "$mark64" ] && mark64="(64bit)" +for f in $liblist $exelist ; do + [ -r $f ] || continue + lib64=`if file -L $f 2>/dev/null | \ + grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` + objdump -p $f | awk 'BEGIN { START=0; LIBNAME=""; needed='$needed'; } + /^$/ { START=0; } + /^Dynamic Section:$/ { START=1; } + (START==1) && /NEEDED/ { + if (needed) { + if ("'$lib64'" != "") { + sub(/$/, "()'$lib64'", $2) ; + } + print $2 ; + } + } + /^Version References:$/ { START=2; } + (START==2) && /required from/ { + sub(/:/, "", $3); + LIBNAME=$3; + } + (START==2) && (LIBNAME!="") && ($4!="") && (($4~/^GLIBC_*/) || ($4~/^GCC_*/)) { + print LIBNAME "(" $4 ")'$lib64'"; + } + ' +done | sort -u + +# +# --- Perl modules. +[ -x /usr/lib/rpm/redhat/perl.req -a -n "$perllist" ] && \ + echo $perllist | tr '[:blank:]' \\n | /usr/lib/rpm/redhat/perl.req | sort -u + +# +# --- Python modules. +[ -x /usr/lib/rpm/redhat/python.req -a -n "$pythonlist" ] && \ + echo $pythonlist | tr '[:blank:]' \\n | /usr/lib/rpm/redhat/python.req | sort -u + +# +# --- Tcl modules. +[ -x /usr/lib/rpm/redhat/tcl.req -a -n "$tcllist" ] && \ + echo $tcllist | tr '[:blank:]' \\n | /usr/lib/rpm/redhat/tcl.req | sort -u + +exit 0 diff --git a/macros b/macros new file mode 100644 index 0000000..7cd98b6 --- /dev/null +++ b/macros @@ -0,0 +1,115 @@ +# Per-platform rpm configuration file. + +#============================================================================== +# ---- per-platform macros. +# +%_arch i386 +%_vendor redhat +%_os linux +%_gnu -gnu +%_target_platform %{_target_cpu}-%{_vendor}-%{_target_os} +%optflags -O2 -march=i386 -mcpu=i686 -g + +#============================================================================== +# ---- configure macros. +# +%_prefix /usr +%_exec_prefix %{_prefix} +%_bindir %{_exec_prefix}/bin +%_sbindir %{_exec_prefix}/sbin +%_libexecdir %{_exec_prefix}/libexec +%_datadir %{_prefix}/share +%_sysconfdir /etc +%_sharedstatedir %{_prefix}/com +%_localstatedir /var +%_lib lib +%_libdir %{_exec_prefix}/%{_lib} +%_includedir %{_prefix}/include +%_oldincludedir /usr/include +%_infodir /usr/share/info +%_mandir /usr/share/man +%_initrddir %{_sysconfdir}/rc.d/init.d + +%_defaultdocdir %{_usr}/share/doc + +#============================================================================== +# ---- configure and makeinstall. +# +%configure \ + CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \ + CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \ + FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \ + ./configure %{_target_platform} \\\ + --prefix=%{_prefix} \\\ + --exec-prefix=%{_exec_prefix} \\\ + --bindir=%{_bindir} \\\ + --sbindir=%{_sbindir} \\\ + --sysconfdir=%{_sysconfdir} \\\ + --datadir=%{_datadir} \\\ + --includedir=%{_includedir} \\\ + --libdir=%{_libdir} \\\ + --libexecdir=%{_libexecdir} \\\ + --localstatedir=%{_localstatedir} \\\ + --sharedstatedir=%{_sharedstatedir} \\\ + --mandir=%{_mandir} \\\ + --infodir=%{_infodir} + +%makeinstall \ + make \\\ + prefix=%{?buildroot:%{buildroot}}%{_prefix} \\\ + exec_prefix=%{?buildroot:%{buildroot}}%{_exec_prefix} \\\ + bindir=%{?buildroot:%{buildroot}}%{_bindir} \\\ + sbindir=%{?buildroot:%{buildroot}}%{_sbindir} \\\ + sysconfdir=%{?buildroot:%{buildroot}}%{_sysconfdir} \\\ + datadir=%{?buildroot:%{buildroot}}%{_datadir} \\\ + includedir=%{?buildroot:%{buildroot}}%{_includedir} \\\ + libdir=%{?buildroot:%{buildroot}}%{_libdir} \\\ + libexecdir=%{?buildroot:%{buildroot}}%{_libexecdir} \\\ + localstatedir=%{?buildroot:%{buildroot}}%{_localstatedir} \\\ + sharedstatedir=%{?buildroot:%{buildroot}}%{_sharedstatedir} \\\ + mandir=%{?buildroot:%{buildroot}}%{_mandir} \\\ + infodir=%{?buildroot:%{buildroot}}%{_infodir} \\\ + install + +%_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\ + && RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\ + [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-j$RPM_BUILD_NCPUS") + + +#============================================================================== +# ---- Build policy macros. +# +#--------------------------------------------------------------------- +# Expanded at end of %install scriptlet. +# + +%__arch_install_post %{nil} + +%__os_install_post \ + /usr/lib/rpm/redhat/brp-compress \ + /usr/lib/rpm/redhat/brp-strip \ + /usr/lib/rpm/redhat/brp-strip-comment-note \ +%{nil} + +%__spec_install_post\ + %{__arch_install_post}\ + %{__os_install_post}\ +%{nil} + +#--------------------------------------------------------------------- +# Expanded at end of %prep +# +%__id_u %{__id} -u +%__chown_Rhf %{__chown} -Rhf +%__chgrp_Rhf %{__chgrp} -Rhf +%_fixowner [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root +%_fixgroup [ `%{__id_u}` = '0' ] && %{__chgrp_Rhf} root +%_fixperms %{__chmod} -Rf a+rX,g-w,o-w +#--------------------------------------------------------------------- +# Always use %defattr(-,root,root) in %files (added in rpm-4.0.4) +# +#%files(n:f:) %%files%{?-f: -f %{-f*}}%{?-n: -n %{-n*}} %{?1}\ +#%defattr(-,root,root,-)\ +#%{nil} + + diff --git a/perl.prov b/perl.prov new file mode 100755 index 0000000..adf987f --- /dev/null +++ b/perl.prov @@ -0,0 +1,180 @@ +#!/usr/bin/perl + +# RPM (and it's source code) is covered under two separate licenses. + +# The entire code base may be distributed under the terms of the GNU +# General Public License (GPL), which appears immediately below. +# Alternatively, all of the source code in the lib subdirectory of the +# RPM source code distribution as well as any code derived from that +# code may instead be distributed under the GNU Library General Public +# License (LGPL), at the choice of the distributor. The complete text +# of the LGPL appears at the bottom of this file. + +# This alternative is allowed to enable applications to be linked +# against the RPM library (commonly called librpm) without forcing +# such applications to be distributed under the GPL. + +# Any questions regarding the licensing of RPM should be addressed to +# Erik Troan . + +# a simple script to print the proper name for perl libraries. + +# To save development time I do not parse the perl grammmar but +# instead just lex it looking for what I want. I take special care to +# ignore comments and pod's. + +# it would be much better if perl could tell us the proper name of a +# given script. + +# The filenames to scan are either passed on the command line or if +# that is empty they are passed via stdin. + +# If there are lines in the file which match the pattern +# (m/^\s*\$VERSION\s*=\s+/) +# then these are taken to be the version numbers of the modules. +# Special care is taken with a few known idioms for specifying version +# numbers of files under rcs/cvs control. + +# If there are strings in the file which match the pattern +# m/^\s*\$RPM_Provides\s*=\s*["'](.*)['"]/i +# then these are treated as additional names which are provided by the +# file and are printed as well. + +# I plan to rewrite this in C so that perl is not required by RPM at +# build time. + +# by Ken Estes Mail.com kestes@staff.mail.com + +if ("@ARGV") { + foreach (@ARGV) { + process_file($_); + } +} else { + + # notice we are passed a list of filenames NOT as common in unix the + # contents of the file. + + foreach (<>) { + process_file($_); + } +} + + +foreach $module (sort keys %require) { + if (length($require{$module}) == 0) { + print "perl($module)\n"; + } else { + + # I am not using rpm3.0 so I do not want spaces arround my + # operators. Also I will need to change the processing of the + # $RPM_* variable when I upgrade. + + print "perl($module) = $require{$module}\n"; + } +} + +exit 0; + + + +sub process_file { + + my ($file) = @_; + chomp $file; + + open(FILE, "<$file") || return; + + my ($package, $version, $incomment, $inover) = (); + + while () { + + # skip the documentation + + # we should not need to have item in this if statement (it + # properly belongs in the over/back section) but people do not + # read the perldoc. + + if (m/^=(head1|head2|pod|item)/) { + $incomment = 1; + } + + if (m/^=(cut)/) { + $incomment = 0; + $inover = 0; + } + + if (m/^=(over)/) { + $inover = 1; + } + + if (m/^=(back)/) { + $inover = 0; + } + + if ($incomment || $inover) { + next; + } + + # skip the data section + if (m/^__(DATA|END)__$/) { + last; + } + + # not everyone puts the package name of the file as the first + # package name so we report all namespaces as if they were + # provided packages (really ugly). + + if (m/^\s*package\s+([_:a-zA-Z0-9]+)\s*;/) { + $package=$1; + undef $version; + $require{$package}=undef; + } + + # after we found the package name take the first assignment to + # $VERSION as the version number. Exporter requires that the + # variable be called VERSION so we are safe. + + # here are examples of VERSION lines from the perl distribution + + #FindBin.pm:$VERSION = $VERSION = sprintf("%d.%02d", q$Revision$ =~ /(\d+)\.(\d+)/); + #ExtUtils/Install.pm:$VERSION = substr q$Revision$, 10; + #CGI/Apache.pm:$VERSION = (qw$Revision$)[1]; + #DynaLoader.pm:$VERSION = $VERSION = "1.03"; # avoid typo warning + + if ( + ($package) && + (m/^\s*\$VERSION\s*=\s+/) + ) { + + # first see if the version string contains the string + # '$Revision' this often causes bizzare strings and is the most + # common method of non static numbering. + + if (m/(\$Revision: (\d+[.0-9]+))/) { + $version= $2; + } elsif (m/[\'\"]?(\d+[.0-9]+)[\'\"]?/) { + + # look for a static number hard coded in the script + + $version= $1; + } + $require{$package}=$version; + } + + # Each keyword can appear multiple times. Don't + # bother with datastructures to store these strings, + # if we need to print it print it now. + + if ( m/^\s*\$RPM_Provides\s*=\s*["'](.*)['"]/i) { + foreach $_ (spit(/\s+/, $1)) { + print "$_\n"; + } + } + + } + + close(FILE) || + die("$0: Could not close file: '$file' : $!\n"); + + return ; +} diff --git a/perl.req b/perl.req new file mode 100755 index 0000000..a0a077b --- /dev/null +++ b/perl.req @@ -0,0 +1,224 @@ +#!/usr/bin/perl + +# RPM (and it's source code) is covered under two separate licenses. + +# The entire code base may be distributed under the terms of the GNU +# General Public License (GPL), which appears immediately below. +# Alternatively, all of the source code in the lib subdirectory of the +# RPM source code distribution as well as any code derived from that +# code may instead be distributed under the GNU Library General Public +# License (LGPL), at the choice of the distributor. The complete text +# of the LGPL appears at the bottom of this file. + +# This alternatively is allowed to enable applications to be linked +# against the RPM library (commonly called librpm) without forcing +# such applications to be distributed under the GPL. + +# Any questions regarding the licensing of RPM should be addressed to +# Erik Troan . + +# a simple makedepends like script for perl. + +# To save development time I do not parse the perl grammmar but +# instead just lex it looking for what I want. I take special care to +# ignore comments and pod's. + +# It would be much better if perl could tell us the dependencies of a +# given script. + +# The filenames to scan are either passed on the command line or if +# that is empty they are passed via stdin. + +# If there are strings in the file which match the pattern +# m/^\s*\$RPM_Requires\s*=\s*["'](.*)['"]/i +# then these are treated as additional names which are required by the +# file and are printed as well. + +# I plan to rewrite this in C so that perl is not required by RPM at +# build time. + +# by Ken Estes Mail.com kestes@staff.mail.com + +if ("@ARGV") { + foreach (@ARGV) { + process_file($_); + } +} else { + + # notice we are passed a list of filenames NOT as common in unix the + # contents of the file. + + foreach (<>) { + process_file($_); + } +} + + +foreach $module (sort keys %require) { + if (length($require{$module}) == 0) { + print "perl($module)\n"; + } else { + + # I am not using rpm3.0 so I do not want spaces arround my + # operators. Also I will need to change the processing of the + # $RPM_* vairable when I upgrage. + + print "perl($module) >= $require{$module}\n"; + } +} + +exit 0; + + + +sub process_file { + + my ($file) = @_; + chomp $file; + + open(FILE, "<$file") || return; + + while () { + + # skip the documentation + + # we should not need to have item in this if statement (it + # properly belongs in the over/back section) but people do not + # read the perldoc. + + if ( (m/^=(head1|head2|pod|item)/) .. (m/^=(cut)/) ) { + next; + } + + if ( (m/^=(over)/) .. (m/^=(back)/) ) { + next; + } + + # skip the data section + if (m/^__(DATA|END)__$/) { + last; + } + + # Each keyword can appear multiple times. Don't + # bother with datastructures to store these strings, + # if we need to print it print it now. + + if ( m/^\s*\$RPM_Requires\s*=\s*["'](.*)['"]/i) { + foreach $_ (split(/\s+/, $1)) { + print "$_\n"; + } + } + + if ( + +# ouch could be in a eval, perhaps we do not want these since we catch +# an exception they must not be required + +# eval { require Term::ReadLine } or die $@; +# eval "require Term::Rendezvous;" or die $@; +# eval { require Carp } if defined $^S; # If error/warning during compilation, + + + (m/^(\s*) # we hope the inclusion starts the line + (require|use)\s+(?!\{) # do not want 'do {' loops + # quotes around name are always legal + [\'\"]?([^\;\ \'\"\t]*)[\'\"]?[\t\;\ ] + # the syntax for 'use' allows version requirements + \s*([.0-9]*) + /x) + ) { + my ($whitespace, $statement, $module, $version) = ($1, $2, $3,$4); + + # we only consider require statements that are flush against + # the left edge. any other require statements give too many + # false positives, as they are usually inside of an if statement + # as a fallback module or a rarely used option + + ($whitespace ne "" && $statement eq "require") && next; + + # if there is some interpolation of variables just skip this + # dependency, we do not want + # do "$ENV{LOGDIR}/$rcfile"; + + ($module =~ m/\$/) && next; + + # skip if the phrase was "use of" -- shows up in gimp-perl, et al + next if $module eq 'of'; + + # if the module ends in a comma we probaly caught some + # documentation of the form 'check stuff,\n do stuff, clean + # stuff.' there are several of these in the perl distribution + + ($module =~ m/[,>]$/) && next; + + # if the module name starts in a dot it is not a module name. + # Is this necessary? Please give me an example if you turn this + # back on. + + # ($module =~ m/^\./) && next; + + # if the module ends with .pm strip it to leave only basename. + # starts with /, which means its an absolute path to a file + if ($module =~ m(^/)) { + print "$module\n"; + next; + } + + # sometimes people do use POSIX qw(foo), or use POSIX(qw(foo)) etc + # we can strip qw.*$, as well as (.*$: + $module =~ s/qw.*$//; + $module =~ s/\(*$//; + + $module =~ s/\.pm$//; + + # some perl programmers write 'require URI/URL;' when + # they mean 'require URI::URL;' + + $module =~ s/\//::/; + + # trim off trailing parenthesis if any. Sometimes people pass + # the module an empty list. + + $module =~ s/\(\s*\)$//; + + if ( $module =~ m/^[0-9._]+$/ ) { + # if module is a number then both require and use interpret that + # to mean that a particular version of perl is specified + + if ($module =~ /5.00/) { + print "perl >= 0:$module\n"; + next; + } + else { + print "perl >= 1:$module\n"; + next; + } + + }; + + # ph files do not use the package name inside the file. + # perlmodlib documentation says: + + # the .ph files made by h2ph will probably end up as + # extension modules made by h2xs. + + # so do not expend much effort on these. + + + # there is no easy way to find out if a file named systeminfo.ph + # will be included with the name sys/systeminfo.ph so only use the + # basename of *.ph files + + ($module =~ m/\.ph$/) && next; + + $require{$module}=$version; + $line{$module}=$_; + } + + } + + close(FILE) || + die("$0: Could not close file: '$file' : $!\n"); + + return ; +} diff --git a/rpmrc b/rpmrc new file mode 100644 index 0000000..f2b8c29 --- /dev/null +++ b/rpmrc @@ -0,0 +1 @@ +macrofiles: /usr/lib/rpm/macros:/usr/lib/rpm/redhat/macros:/etc/rpm/macros.specspo:/etc/rpm/macros.cdb