aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2014-09-08 12:39:19 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2014-09-12 22:26:43 +0200
commitaa832f67a55e851fbd7de69ffda44b7d82cd8bf8 (patch)
treea2a4aecc97e508296841c188cd7daed25201b7c9
parent986531bbeb989ec830b07bd661ffd29ba844e736 (diff)
downloadrpm-setup-aa832f67a55e851fbd7de69ffda44b7d82cd8bf8.tar
rpm-setup-aa832f67a55e851fbd7de69ffda44b7d82cd8bf8.tar.gz
rpm-setup-aa832f67a55e851fbd7de69ffda44b7d82cd8bf8.tar.bz2
rpm-setup-aa832f67a55e851fbd7de69ffda44b7d82cd8bf8.tar.xz
rpm-setup-aa832f67a55e851fbd7de69ffda44b7d82cd8bf8.zip
drop most of the script-based dependency generation bits
Use rpmdeps to generate any "normal" dependencies even for the kernel module stuff, drop all other unnecessary duplication like elf, libtool and pkgconfig deps. But for TCL, which is broken since forever (we don't package the needed prov/req scripts since at least 2007)
-rw-r--r--Makefile.am4
-rw-r--r--NEWS2
-rw-r--r--UPSTREAM6
-rwxr-xr-xfind-provides.in110
-rwxr-xr-xfind-requires.in223
-rwxr-xr-xpythoneggs.py183
-rwxr-xr-xrubygems.rb116
7 files changed, 7 insertions, 637 deletions
diff --git a/Makefile.am b/Makefile.am
index aba0c4e..43f098f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,9 +40,7 @@ pkg_scripts = \
perl.req \
perl.req-from-meta \
php.prov \
- php.req \
- pythoneggs.py \
- rubygems.rb
+ php.req
pkg_gscripts = \
find-provides \
diff --git a/NEWS b/NEWS
index 956dd03..d4aa0f2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,11 @@
- convert perl-base deps to internal generator
+- drop most of the script-based dependency generation bits
- use internal dependency generator instead of "external generator"
(like all other distros) which is way much faster :-)
See:
o http://www.rpm.org/wiki/PackagerDocs/DependencyGenerator
o http://laiskiainen.org/blog/?p=35
+ side effect: we now output lowercase perl provides/requires (eg: "perl(urpm)")
- use upstream pkgconfigdeps.sh as we only have more checks because we were
still using the external generator
diff --git a/UPSTREAM b/UPSTREAM
deleted file mode 100644
index 412e70e..0000000
--- a/UPSTREAM
+++ /dev/null
@@ -1,6 +0,0 @@
-"-" denotes upstream features we lack
-"+" denotes Mageia features
-
-Other divergences:
-
-- perl.prov, perl.req: quite some work prior to merge but doable
diff --git a/find-provides.in b/find-provides.in
index 1e16d3c..1f95f86 100755
--- a/find-provides.in
+++ b/find-provides.in
@@ -5,51 +5,12 @@
filelist=`sed "s/['\"]/\\\&/g"`
-solist=$(echo "$filelist" | egrep -v "^/lib/ld\.so|/usr/lib(64)?/gcj/" | egrep '(/usr(/X11R6)?)?/lib(64)?/.*\.so' | \
- xargs file -L 2>/dev/null | grep "ELF.*shared object" | cut -d: -f1)
-pythonlist=
-tcllist=
rubygemlist=$(echo "$filelist"| egrep "\.gemspec$")
-mavenlist=$(echo "$filelist" |egrep '/usr/share/maven-fragments/*')
-osgilist=$(echo "$filelist" |egrep "^(.*\.jar|((/usr/lib(64)|/usr/share).*/MANIFEST.MF))")
# fix parsing output of objdump when localized (mga#7883):
export LC_ALL=C
#
-# --- 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 2>/dev/null | 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 2>/dev/null | 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
-
-#
# --- If libperl.so is found in buildroot, we provide perlapi-<version>
if [ -n "`echo $filelist | grep -e '/CORE/libperl\.so'`" ]; then
for i in $filelist; do
@@ -67,24 +28,6 @@ if [ -n "`echo $filelist | grep -e '/CORE/libperl\.so'`" ]; then
fi
#
-# --- Perl modules.
-[ -x @RPMVENDORDIR@/perl.prov ] &&
- echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/perl.prov | grep 'perl([[:upper:]]' | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/perl.prov failed' >&2 && exit 1
-
-#
-# --- Python modules.
-[ -x @RPMVENDORDIR@/pythoneggs.py -a -n "$filelist" ] &&
- echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/pythoneggs.py --provides | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/pythoneggs.py failed' >&2 && exit 1
-
-#
-# --- Tcl modules.
-[ -x @RPMVENDORDIR@/tcl.prov -a -n "$tcllist" ] &&
- echo "$tcllist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/tcl.prov | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/tcl.prov failed' >&2 && exit 1
-
-#
# --- Php modules.
[ -x @RPMVENDORDIR@/php.prov ] &&
echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/php.prov | sort -u \
@@ -97,36 +40,13 @@ fi
&& test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/kmod.prov failed' >&2 && exit 1
#
-# --- Pkgconfig deps
-[ -x @RPMLIBDIR@/pkgconfigdeps.sh ] &&
- echo "$filelist" | tr '[:blank:]' \\n | @RPMLIBDIR@/pkgconfigdeps.sh -P | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMLIBDIR@/pkgconfigdeps.sh failed' >&2 && exit 1
-
-#
-# --- mimehandler
-[ -x @RPMLIBDIR@/desktop-file.prov ] &&
- echo "$filelist" | tr '[:blank:]' \\n | @RPMLIBDIR@/desktop-file.prov --provides | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMLIBDIR@/desktop-file.prov failed' >&2 && exit 1
-
-#
-# --- fonts
-[ -x @RPMLIBDIR@/fontconfig.prov ] &&
- echo "$filelist" | tr '[:blank:]' \\n | @RPMLIBDIR@/fontconfig.prov --provides | sort -u
-
-#
# --- typelib() gobject-introspection bindings
[ -x @RPMVENDORDIR@/gi-find-deps.sh ] &&
echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/gi-find-deps.sh -P | sort -u \
&& test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/gi-find-deps.sh failed' >&2 && exit 1
-if [ -n "$LIBTOOLDEP" ]; then
-#
-# --- libtooldep deps
-[ -x @RPMLIBDIR@/libtooldeps.sh ] &&
- echo "$filelist" | tr '[:blank:]' \\n | @RPMLIBDIR@/libtooldeps.sh -P | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/libtooldeps.sh failed' >&2 && exit 1
-
-fi
+[ -x /usr/lib/rpm/rpmdeps -a -n "$filelist" ] &&
+ echo $filelist | tr '[:blank:]' \\n | /usr/lib/rpm/rpmdeps --provides
#
# --- Ruby gems
@@ -144,14 +64,6 @@ for i in `echo $filelist | tr '[:blank:]' "\n" | egrep '(/usr(/X11R6)?)?/lib(|64
done | sort -u
#
-# --- mono provides
-if [ -x /usr/bin/mono-find-provides ]; then
-echo $filelist | tr '[:blank:]' '\n' | /usr/bin/mono-find-provides \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: /usr/bin/mono-find-provides failed' >&2 && exit 1
-fi
-
-
-#
# --- haskell provides
if [ -x /usr/bin/haskell-find-provides ]; then
echo $filelist | tr '[:blank:]' '\n' | /usr/bin/haskell-find-provides \
@@ -168,22 +80,4 @@ fi
echo "$solist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/gstreamer1.0.prov | sort -u \
&& test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/gstreamer1.0.prov failed' >&2 && exit 1
-#
-# --- osgi provides
-if [ -x @RPMLIBDIR@/osgi.prov ];then
- if [ ! -z "$osgilist" ]; then
- echo "$osgilist" | tr '[:blank:]' '\n' | @RPMLIBDIR@/osgi.prov \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMLIBDIR@/osgi.prov failed' >&2 && exit 1
- fi
-fi
-
-#
-# --- maven provides
-if [ -x @RPMLIBDIR@/maven.prov ];then
- if [ ! -z "$mavenlist" ]; then
- echo "$mavenlist" | tr '[:blank:]' '\n' | @RPMLIBDIR@/maven.prov \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMLIBDIR@/maven.prov failed' >&2 && exit 1
- fi
-fi
-
exit 0
diff --git a/find-requires.in b/find-requires.in
index ab365a5..e15d5a6 100755
--- a/find-requires.in
+++ b/find-requires.in
@@ -38,170 +38,11 @@ fi
#
-# --- Grab the file manifest and classify files.
-#filelist=`sed "s/['\"]/\\\&/g"`
filelist=`sed "s/[]['\"*?{}]/\\\\\&/g"`
-exelist=`echo "$filelist" | xargs -r file | egrep -v ":.* (commands|script) " | \
- grep ":.*ELF.*executable" | cut -d: -f1`
-scriptlist=`echo "$filelist" | grep -v /usr/doc | grep -v /usr/share/doc | xargs -r file | \
- egrep ":.* (commands|script)" | cut -d: -f1`
-liblist=`echo "$filelist" | egrep -v "/usr/lib(64)?/gcj/" | xargs -r file | \
- grep ":.*shared object" | cut -d : -f1`
-ocamllist=`echo "$filelist" | xargs -r file | \
- grep ":.*Objective caml interface file" | cut -d : -f1`
phplist=`echo "$filelist" | grep -v /usr/doc | grep -v /usr/share/doc | egrep "\.php$"`
-mavenlist=$(echo "$filelist" |egrep '/usr/share/maven-fragments/*')
-osgilist=$(echo "$filelist" |egrep "^(.*\.jar|((/usr/lib(64)|/usr/share).*/MANIFEST.MF))")
-javadoclist=$(echo "$filelist" |egrep '/usr/share/javadoc/*')
-interplist=
-perllist=
-pythonlist=
-tcllist=
rubygemlist=`echo "$filelist"| egrep "\.gemspec$"`
-uniqdeplist=
-
-#
-# --- 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/) {
- gsub(/'\''"/,"\\&",$1);
- printf "%s'$lib64'\n", $1
- }
- }'
- done | xargs -r -n 1 basename | sort -u | grep -v 'libsafe|libfakeroot'
-
-#
-# --- 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/) {
- gsub(/'\''"/,"\\&",$1);
- printf "%s'$lib64'\n", $1
- }
- }'
- done | xargs -r -n 1 basename | sort -u | grep -v 'libsafe|libfakeroot'
-fi
-
-#
-# --- Script interpreters.
-for f in $scriptlist; do
- [ -r $f -a -x $f ] || continue
- interp=`head -n 1 $f | grep '^#!' | sed -e 's/^\#\![ ]*//' | cut -d" " -f1`
- if [[ "$interp" == *bin/env ]]; then
- arg=`head -n 1 $f | grep '^#!' | sed -e 's/^\#\![ ]*//' | cut -d" " -f2`
- interp="`which $arg`"
- fi
- case $interp in
- # we really don't need to add these dependencies as they're required by
- # glibc and therefore guaranteed to be satisfied
- */sh|*/bash)
- continue
- ;;
- # we already have dedicated dependency generators for these
- */python)
- pythonlist="$pythonlist $f"
- ;;
- */perl)
- perllist="$perllist $f"
- ;;
- */ruby)
- rubylist="$rubylist $f"
- ;;
- *)
- interplist="$interplist $interp"
- ;;
- esac
-done
-if [ -n "$interplist" ]; then
- tmpdeplist=
- for i in `echo "$interplist" | tr '[:blank:]' \\\n `; do
- dep=`rpm -qf $i --qf '%{name}\n'` && i=$dep
- if [[ -z `echo $uniqdeplist $tmpdeplist|grep "$i"` ]]; then
- tmpdeplist+="$i\n"
- fi
- done
- echo -n -e $tmpdeplist | sort -u | grep -v 'libsafe|libfakeroot'
- uniqdeplist="$tmpdeplist"
-fi
-
-#
-# --- 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 | grep -v 'libsafe|libfakeroot'
-
-# --- OCaml dependency
-if [ -x /usr/bin/ocamlc -a -n "$ocamllist" ]; then
- version=`ocamlc -v | grep version | awk '{print $6}' | sed -e 's/+/./'`
- echo "ocaml = $version"
-fi
-
-#
-# --- Perl modules.
-perlmymeta=$( echo $filelist | tr '[:blank:]' \\n | egrep 'doc/[^/]+/MYMETA.(yml|json)$' | head -1 )
-perlmeta=$( echo $filelist | tr '[:blank:]' \\n | egrep 'doc/[^/]+/META.(yml|json)$' | head -1 )
-if [ -n "$perlmymeta" ]
-then
- [ -x @RPMVENDORDIR@/perl.req-from-meta ] && \
- @RPMVENDORDIR@/perl.req-from-meta $perlmymeta \
- && test ${PIPESTATUS[0]} -ne 0 && echo 'error: @RPMVENDORDIR@/perl.req-from-meta failed' >&2 && exit 1
-elif [ -n "$perlmeta" ]
-then
- [ -x @RPMVENDORDIR@/perl.req-from-meta ] && \
- @RPMVENDORDIR@/perl.req-from-meta $perlmeta \
- && test ${PIPESTATUS[0]} -ne 0 && echo 'error: @RPMVENDORDIR@/perl.req-from-meta failed' >&2 && exit 1
-else
- [ -x @RPMVENDORDIR@/perl.req -a -n "$perllist" ] && \
- echo $perllist | tr '[:blank:]' \\n | @RPMVENDORDIR@/perl.req | grep 'perl([[:upper:]]' | egrep -v '^perl\((Be|FreeBSD|HPUX|Mac|MSDOS|MVS|OS2|Riscos|SGI|Solaris|VMS|Win32|WinNT)::' | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/perl.req failed' >&2 && exit 1
-fi
-
#
# --- If libperl.so exists and if XS modules are found, depend on perlapi-<version> and libperl.so
if [ -n "$perllist" ]; then
@@ -218,17 +59,8 @@ if [ -n "$perllist" ]; then
fi
fi
-#
-# --- Python modules.
-[ -x @RPMVENDORDIR@/pythoneggs.py -a -n "$filelist" ] && \
- echo $filelist | tr '[:blank:]' \\n | @RPMVENDORDIR@/pythoneggs.py --requires | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/pythoneggs.py failed' >&2 && exit 1
-
-#
-# --- Tcl modules.
-[ -x @RPMVENDORDIR@/tcl.req -a -n "$tcllist" ] && \
- echo $tcllist | tr '[:blank:]' \\n | @RPMVENDORDIR@/tcl.req | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/tcl.req failed' >&2 && exit 1
+[ -x /usr/lib/rpm/rpmdeps -a -n "$filelist" ] && \
+ echo $filelist | tr '[:blank:]' \\n | /usr/lib/rpm/rpmdeps --requires
#
# --- Php modules.
@@ -237,26 +69,11 @@ fi
&& test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/php.req failed' >&2 && exit 1
#
-# --- Pkgconfig deps
-[ -x @RPMLIBDIR@/pkgconfigdeps.sh ] &&
- echo "$filelist" | tr '[:blank:]' \\n | @RPMLIBDIR@/pkgconfigdeps.sh -R | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMLIBDIR@/pkgconfigdeps.sh failed' >&2 && exit 1
-
-#
# --- typelib() gobject-introspection bindings
[ -x @RPMVENDORDIR@/gi-find-deps.sh ] &&
echo "$filelist" | tr '[:blank:]' \\n | @RPMVENDORDIR@/gi-find-deps.sh -R | sort -u \
&& test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/gi-find-deps.sh failed' >&2 && exit 1
-if [ -n "$LIBTOOLDEP" ]; then
-#
-# --- libtooldep deps
-[ -x @RPMLIBDIR@/libtooldeps.sh ] &&
- echo "$filelist" | tr '[:blank:]' \\n | @RPMLIBDIR@/libtooldeps.sh -R | sort -u \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMVENDORDIR@/libtooldeps.sh failed' >&2 && exit 1
-
-fi
-
#
# --- Ruby gems
[ -x /usr/bin/ruby -a -x @RPMVENDORDIR@/rubygems.rb -a -n "$rubygemlist" ] &&
@@ -290,50 +107,14 @@ for i in `echo $filelist | tr '[:blank:]' "\n" | egrep "(/usr(/X11R6)?)?/lib(|64
done | egrep -v 'devel\(linux-gate|linux-vdso32|linux-vdso64|lib(c|pthread|rt)(\(64bit\))?\)' | sort -u
#
-# --- pkgconfig
-echo $filelist | tr '[:blank:]' '\n' | egrep -q '/usr/(share|lib(64)?)/pkgconfig/.*\.pc' && echo pkgconfig
-
-#
# --- multiarch-utils
echo $filelist | tr '[:blank:]' '\n' | grep -q '/multiarch-.*-linux/' && echo multiarch-utils
#
-# --- mono requires
-if [ -x /usr/bin/mono-find-requires ]; then
-echo $filelist | tr '[:blank:]' '\n' | /usr/bin/mono-find-requires \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: /usr/bin/mono-find-requires failed' >&2 && exit 1
-fi
-
-#
# haskell requires
if [ -x /usr/bin/haskell-find-requires ]; then
echo $filelist | tr '[:blank:]' '\n' | /usr/bin/haskell-find-requires \
&& test ${PIPESTATUS[2]} -ne 0 && echo 'error: /usr/bin/haskell-find-requires failed' >&2 && exit 1
fi
-# --- osgi requires
-if [ -x @RPMLIBDIR@/osgi.req ];then
- if [ ! -z "$osgilist" ]; then
- echo "$osgilist" | tr '[:blank:]' '\n' | @RPMLIBDIR@/osgi.req \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMLIBDIR@/osgi.req failed' >&2 && exit 1
- fi
-fi
-
-#
-# --- maven requires
-if [ -x @RPMLIBDIR@/maven.req ];then
- if [ ! -z "$mavenlist" ]; then
- echo "$mavenlist" | tr '[:blank:]' '\n' | @RPMLIBDIR@/maven.req \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMLIBDIR@/maven.req failed' >&2 && exit 1
- fi
-fi
-
-# --- javadoc requires
-if [ -x @RPMLIBDIR@/javadoc.req ];then
- if [ ! -z "$javadoclist" ]; then
- echo "$javadoclist" | tr '[:blank:]' '\n' | @RPMLIBDIR@/javadoc.req \
- && test ${PIPESTATUS[2]} -ne 0 && echo 'error: @RPMLIBDIR@/javadoc.req failed' >&2 && exit 1
- fi
-fi
-
exit 0
diff --git a/pythoneggs.py b/pythoneggs.py
deleted file mode 100755
index 178610f..0000000
--- a/pythoneggs.py
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-#
-# Copyright 2010 Per Øyvind Karlsen <peroyvind@mandriva.org>
-#
-# This program is free software. It may be redistributed and/or modified under
-# the terms of the LGPL version 2.1 (or later).
-#
-# RPM5 python (egg) dependency generator.
-#
-
-from getopt import getopt
-from os.path import basename, dirname, isdir, sep, splitext
-from sys import argv, stdin, version
-from pkg_resources import Distribution, FileMetadata, PathMetadata
-from distutils.sysconfig import get_python_lib
-
-
-opts, args = getopt(argv[1:], 'hPRSCOE',
- ['help', 'provides', 'requires', 'suggests', 'conflicts', 'obsoletes', 'extras'])
-
-Provides = False
-Requires = False
-Suggests = False
-Conflicts = False
-Obsoletes = False
-Extras = False
-
-for o, a in opts:
- if o in ('-h', '--help'):
- print '-h, --help\tPrint help'
- print '-P, --provides\tPrint Provides'
- print '-R, --requires\tPrint Requires'
- print '-S, --suggests\tPrint Suggests'
- print '-C, --conflicts\tPrint Conflicts'
- print '-O, --obsoletes\tPrint Obsoletes (unused)'
- print '-E, --extras\tPrint Extras '
- exit(1)
- elif o in ('-P', '--provides'):
- Provides = True
- elif o in ('-R', '--requires'):
- Requires = True
- elif o in ('-S', '--suggests'):
- Suggests = True
- elif o in ('-C', '--conflicts'):
- Conflicts = True
- elif o in ('-O', '--obsoletes'):
- Obsoletes = True
- elif o in ('-E', '--extras'):
- Extras = True
-
-if Requires:
- py_abi = True
-else:
- py_abi = False
-py_deps = {}
-if args:
- files = args
-else:
- files = stdin.readlines()
-for f in files:
- f = f.strip()
- lower = f.lower()
- name = 'python(abi)'
- # add dependency based on path, versioned if within versioned python directory
- if py_abi and (lower.endswith('.py') or lower.endswith('.pyc') or lower.endswith('.pyo')):
- if not name in py_deps:
- py_deps[name] = []
- purelib = get_python_lib(standard_lib=1, plat_specific=0).split(version[:3])[0]
- platlib = get_python_lib(standard_lib=1, plat_specific=1).split(version[:3])[0]
- for lib in (purelib, platlib):
- if lib in f:
- spec = ('==',f.split(lib)[1].split(sep)[0])
- if not spec in py_deps[name]:
- py_deps[name].append(spec)
- # Determine provide, requires, conflicts & suggests based on egg metadata
- if lower.endswith('.egg') or \
- lower.endswith('.egg-info') or \
- lower.endswith('.egg-link'):
- dist_name = basename(f)
- if isdir(f):
- path_item = dirname(f)
- metadata = PathMetadata(path_item, f)
- else:
- path_item = f
- metadata = FileMetadata(f)
- dist = Distribution.from_location(path_item, dist_name, metadata)
- if not dist.py_version:
- continue
- py_major = dist.py_version[:1]
- if Provides:
- # If egg metadata says package name is python, we provide python(abi)
- if dist.key == 'python':
- name = 'python(abi)'
- if not name in py_deps:
- py_deps[name] = []
- py_deps[name].append(('==', dist.py_version))
- name = 'pythonegg(%s)(%s)' % (py_major, dist.key)
- if not name in py_deps:
- py_deps[name] = []
- if dist.version:
- spec = ('==', dist.version)
- if not spec in py_deps[name]:
- py_deps[name].append(spec)
- if Requires or (Suggests and dist.extras):
- name = 'python(abi)'
- # If egg metadata says package name is python, we don't add dependency on python(abi)
- if dist.key == 'python':
- py_abi = False
- if name in py_deps:
- py_deps.pop(name)
- elif py_abi and dist.py_version:
- if not name in py_deps:
- py_deps[name] = []
- spec = ('==', dist.py_version)
- if not spec in py_deps[name]:
- py_deps[name].append(spec)
- deps = dist.requires()
- if Suggests:
- depsextras = dist.requires(extras=dist.extras)
- if not Requires:
- for dep in reversed(depsextras):
- if dep in deps:
- depsextras.remove(dep)
- deps = depsextras
- # add requires/suggests based on egg metadata
- for dep in deps:
- name = 'pythonegg(%s)(%s)' % (py_major, dep.key)
- for spec in dep.specs:
- if spec[0] != '!=':
- if not name in py_deps:
- py_deps[name] = []
- if not spec in py_deps[name]:
- py_deps[name].append(spec)
- if not dep.specs:
- py_deps[name] = []
- # Unused, for automatic sub-package generation based on 'extras' from egg metadata
- # TODO: implement in rpm later, or...?
- if Extras:
- deps = dist.requires()
- extras = dist.extras
- print extras
- for extra in extras:
- print '%%package\textras-%s' % extra
- print 'Summary:\t%s extra for %s python egg' % (extra, dist.key)
- print 'Group:\t\tDevelopment/Python'
- depsextras = dist.requires(extras=[extra])
- for dep in reversed(depsextras):
- if dep in deps:
- depsextras.remove(dep)
- deps = depsextras
- for dep in deps:
- for spec in dep.specs:
- if spec[0] == '!=':
- print 'Conflicts:\t%s %s %s' % (dep.key, '==', spec[1])
- else:
- print 'Requires:\t%s %s %s' % (dep.key, spec[0], spec[1])
- print '%%description\t%s' % extra
- print '%s extra for %s python egg' % (extra, dist.key)
- print '%%files\t\textras-%s\n' % extra
- if Conflicts:
- # Should we really add conflicts for extras?
- # Creating a meta package per extra with suggests on, which has
- # the requires/conflicts in stead might be a better solution...
- for dep in dist.requires(extras=dist.extras):
- name = dep.key
- for spec in dep.specs:
- if spec[0] == '!=':
- if not name in py_deps:
- py_deps[name] = []
- spec = ('==', spec[1])
- if not spec in py_deps[name]:
- py_deps[name].append(spec)
-names = py_deps.keys()
-names.sort()
-for name in names:
- if py_deps[name]:
- # Print out versioned provides, requires, suggests, conflicts
- for spec in py_deps[name]:
- print '%s %s %s' % (name, spec[0], spec[1])
- else:
- # Print out unversioned provides, requires, suggests, conflicts
- print name
diff --git a/rubygems.rb b/rubygems.rb
deleted file mode 100755
index a1189af..0000000
--- a/rubygems.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Copyright 2010 Per Øyvind Karlsen <peroyvind@mandriva.org>
-# This program is free software. It may be redistributed and/or modified under
-# the terms of the LGPL version 2.1 (or later).
-#
-# FIXME: Someone with actual ruby skills should really clean up and sanitize
-# this! fugliness obvious...
-#++
-
-require 'optparse'
-require 'rbconfig'
-
-provides = false
-requires = false
-
-opts = OptionParser.new("#{$0} <--provides|--requires>")
-opts.on("-P", "--provides", "Print provides") do |val|
- provides = true
-end
-opts.on("-R", "--requires", "Print requires") do |val|
- requires= true
-end
-
-rest = opts.permute(ARGV)
-
-if rest.size != 0 or (!provides and !requires) or (provides and requires)
- $stderr.puts "Use either --provides OR --requires"
- $stderr.puts opts
- exit(1)
-end
-
-specpatt = "%s/specifications/.*\.gemspec$" % Gem.default_dirs[:system][:gem_dir]
-
-gems = []
-ruby_versioned = false
-abi_provide = false
-
-for path in $stdin.readlines
- # way fugly, but we make the assumption that if the package has
- # this file, the package is the current ruby version, and should
- # therefore provide ruby(abi) = version
- if provides and path.match(RbConfig::CONFIG["archdir"] + "/rbconfig.rb")
- abi_provide = true
- elsif path.match(specpatt)
- ruby_versioned = true
- gems.push(path.chomp)
- # this is quite ugly and lame, but the assumption made is that if any files
- # found in any of these directories specific to this ruby version, the
- # package is dependent on this specific version.
- # FIXME: only supports current ruby version
- elsif not ruby_versioned
- if path.match(RbConfig::CONFIG["rubylibdir"])
- ruby_versioned = true
- elsif path.match(RbConfig::CONFIG["sitelibdir"])
- ruby_versioned = true
- elsif path.match(RbConfig::CONFIG["vendorlibdir"])
- ruby_versioned = true
- end
- end
-end
-
-if requires or abi_provide
- abidep = "ruby(abi)"
- if ruby_versioned and RbConfig::CONFIG["ruby_version"] != ""
- abidep += " = %s" % RbConfig::CONFIG["ruby_version"]
- end
- print abidep + "\n"
-end
-
-if gems.length > 0
- require 'rubygems'
-
- if requires
-
- module Gem
- class Requirement
- def rpm_dependency_transform(name, version)
- pessimistic = ""
- if version == "> 0.0.0" or version == ">= 0"
- version = ""
- else
- if version[0..1] == "~>"
- pessimistic = "rubygem(%s) < %s\n" % [name, Gem::Version.create(version[3..-1]).bump]
- version = version.gsub(/\~>/, '=>')
- end
- version = version.gsub(/^/, ' ')
- end
- version = "rubygem(%s)%s\n%s" % [name, version, pessimistic]
- end
-
- def to_rpm(name)
- result = as_list
- return result.map { |version| rpm_dependency_transform(name, version) }
- end
-
- end
- end
- end
-
- for gem in gems
- data = File.read(gem)
- spec = eval(data)
- if provides
- print "rubygem(%s) = %s\n" % [spec.name, spec.version]
- end
- if requires
- for d in spec.dependencies
- print d.requirement.to_rpm(d.name)[0] unless d.type != :runtime
- end
- for d in spec.required_rubygems_version.to_rpm("rubygems")
- print d.gsub(/(rubygem\()|(\))/, "")
- end
- end
- end
-end