Selaa lähdekoodia

completely work-off the URPMI packaging based on hints from contribution

Ralf S. Engelschall 19 vuotta sitten
vanhempi
commit
5eefa9a36e
2 muutettua tiedostoa jossa 151 lisäystä ja 26 poistoa
  1. 37 0
      urpmi/urpmi.patch
  2. 114 26
      urpmi/urpmi.spec

+ 37 - 0
urpmi/urpmi.patch

@@ -88,3 +88,40 @@ Index: URPM-1.47/URPM.xs
  
  #undef Fflush
  #undef Mkdir
+
+--- urpmi-4.8.29/Makefile.PL.bla	2006-03-21 18:28:24.000000000 +0100
++++ urpmi-4.8.29/Makefile.PL	2006-11-12 00:39:36.000000000 +0100
+@@ -64,6 +64,7 @@
+     my $po = $with_po ? ' installpo' : '';
+     my $gui = $with_gui ? ' installgurpmi2' : '';
+     $inherited =~ s/^install ::/$& installconfigfiles installstatedir$po$gui/gm;
++    $inherited =~ s/^pure_install ::/$& installconfigfiles installstatedir$po$gui/gm;
+     $inherited;
+ }
+ 
+@@ -104,10 +105,10 @@
+ 	install -m 644 inst.list skip.list \$(SYSCONFDIR)/urpmi
+ 
+ installstatedir:
+-	install -d \$(LOCALSTATEDIR)/urpmi
+-	install -d \$(DESTDIR)/var/cache/urpmi/partial
+-	install -d \$(DESTDIR)/var/cache/urpmi/headers
+-	install -d \$(DESTDIR)/var/cache/urpmi/rpms
++	install -d \$(LOCALSTATEDIR)/urpmi/lib
++	install -d \$(DESTDIR)/\$(PREFIX)/var/urpmi/cache/partial
++	install -d \$(DESTDIR)/\$(PREFIX)/var/urpmi/cache/headers
++	install -d \$(DESTDIR)/\$(PREFIX)/var/urpmi/cache/rpms
+ 
+ installgurpmi2: pure_install
+ 	ln -s -f consolehelper \$(DESTINSTALLSCRIPT)/gurpmi2
+@@ -151,8 +152,8 @@
+ 	INST_MAN5DIR		=> 'blib/man5',
+ 	INST_MAN8DIR		=> 'blib/man8',
+ 	# We could read those values from rpm macros.
+-	SYSCONFDIR		=> '$(DESTDIR)/etc',
+-	LOCALSTATEDIR		=> '$(DESTDIR)/var/lib',
++	SYSCONFDIR		=> '$(DESTDIR)$(PREFIX)/etc',
++	LOCALSTATEDIR		=> '$(DESTDIR)$(PREFIX)/var',
+     },
+     EXE_FILES		=> [ @bin_scripts, @sbin_scripts ],
+     PMLIBDIRS		=> [ qw(urpm) ],

+ 114 - 26
urpmi/urpmi.spec

@@ -22,13 +22,15 @@
 ##  SUCH DAMAGE.
 ##
 
-#   FIXME: rse: blindly packaged, still not tested at all under run-time
-
 #   package version
-%define       V_urpmi           4.8.18
-%define       V_urpm            1.47
-%define       V_mdv_packdrakeng 1.01
-%define       V_mdv_distribconf 1.01
+%define       V_urpmi               4.8.29
+%define       V_urpmi_rpm           4.8.29-1mdv2007.1
+%define       V_urpm                1.47
+%define       V_urpm_rpm            1.47-1mdv2007.1
+%define       V_mdv_distribconf     3.06
+%define       V_mdv_distribconf_rpm 3.06-1mdv2007.0
+%define       V_mdv_packdrakeng     1.01
+%define       V_mdv_packdrakeng_rpm 1.01-2mdk
 
 #   package information
 Name:         urpmi
@@ -41,53 +43,74 @@ Class:        EVAL
 Group:        Bootstrapping
 License:      GPL
 Version:      %{V_urpmi}
-Release:      20061017
+Release:      20061114
+
+#   package options
+%option       with_wget      no
+%option       with_ssh       no
+%option       with_rsync     no
 
 #   list of sources
-Source0:      http://www.cpan.org/authors/id/R/RG/RGARCIA/urpmi-%{V_urpmi}.tar.gz
-Source1:      http://www.cpan.org/authors/id/R/RG/RGARCIA/URPM-%{V_urpm}.tar.gz
-Source2:      http://www.cpan.org/authors/id/R/RG/RGARCIA/MDV-Packdrakeng-%{V_mdv_packdrakeng}.tar.gz
-Source3:      http://www.cpan.org/authors/id/R/RG/RGARCIA/MDV-Distribconf-%{V_mdv_distribconf}.tar.gz
+Source0:      ftp://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/devel/cooker/SRPMS/main/release/urpmi-%{V_urpmi_rpm}.src.rpm
+Source1:      ftp://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/devel/cooker/SRPMS/main/release/perl-URPM-%{V_urpm_rpm}.src.rpm
+Source2:      ftp://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/devel/cooker/SRPMS/main/release/perl-MDV-Distribconf-%{V_mdv_distribconf_rpm}.src.rpm
+Source3:      ftp://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/devel/cooker/SRPMS/main/release/perl-MDV-Packdrakeng-%{V_mdv_packdrakeng_rpm}.src.rpm
 Patch0:       urpmi.patch
 
 #   build information
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
-BuildPreReq:  OpenPKG, openpkg >= 20040130, perl, perl-openpkg
-PreReq:       OpenPKG, openpkg >= 20040130, perl, perl-locale
+BuildPreReq:  OpenPKG, openpkg >= 20040130, perl, perl-openpkg, cpio
+PreReq:       OpenPKG, openpkg >= 20040130, perl, coreutils
+PreReq:       perl-parse, perl-crypto, perl-locale
+%if "%{with_wget}" == "yes"
+PreReq:       wget
+%endif
+%if "%{with_ssh}" == "yes"
+PreReq:       openssh
+%endif
+%if "%{with_rsync}" == "yes"
+PreReq:       rsync
+%endif
 AutoReq:      no
 AutoReqProv:  no
 
 %description
     URPMI is a frontend for the RedHat Package Manager (RPM).
+    It was originally developed for Mandriva Linux.
 
 %track
     prog urpmi:urpmi = {
         version   = %{V_urpmi}
-        url       = http://www.cpan.org/authors/id/R/RG/RGARCIA/
-        regex     = urpmi-(__VER__)\.tar\.gz
+        url       = ftp://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/devel/cooker/SRPMS/main/release/
+        regex     = urpmi-(__VER__)\.src\.gmz
     }
     prog urpmi:URPM = {
         version   = %{V_urpm}
-        url       = http://www.cpan.org/authors/id/R/RG/RGARCIA/
-        regex     = URPM-(__VER__)\.tar\.gz
+        url       = ftp://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/devel/cooker/SRPMS/main/release/
+        regex     = perl-URPM-(__VER__)\.src\.rpm
     }
     prog urpmi:MDV-Packdrakeng = {
         version   = %{V_mdv_packdrakeng}
-        url       = http://www.cpan.org/authors/id/R/RG/RGARCIA/
-        regex     = MDV-Packdrakeng-(__VER__)\.tar\.gz
+        url       = ftp://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/devel/cooker/SRPMS/main/release/
+        regex     = perl-MDV-Packdrakeng-(__VER__)\.src\.rpm
     }
     prog urpmi:MDV-Distribconf = {
         version   = %{V_mdv_distribconf}
-        url       = http://www.cpan.org/authors/id/R/RG/RGARCIA/
-        regex     = MDV-Distribconf-(__VER__)\.tar\.gz
+        url       = ftp://ftp.free.fr/pub/Distributions_Linux/MandrivaLinux/devel/cooker/SRPMS/main/release/
+        regex     = perl-MDV-Distribconf-(__VER__)\.src\.rpm
     }
 
 %prep
-    %setup -q -c
-    %setup -q -D -T -a 1
-    %setup -q -D -T -a 2
-    %setup -q -D -T -a 3
+    %setup -q -T -c
+    %{l_rpm2cpio} %{SOURCE urpmi-%{V_urpmi_rpm}.src.rpm}                          | cpio -idvmu
+    %{l_rpm2cpio} %{SOURCE perl-URPM-%{V_urpm_rpm}.src.rpm}                       | cpio -idvmu
+    %{l_rpm2cpio} %{SOURCE perl-MDV-Distribconf-%{V_mdv_distribconf_rpm}.src.rpm} | cpio -idvmu
+    %{l_rpm2cpio} %{SOURCE perl-MDV-Packdrakeng-%{V_mdv_packdrakeng_rpm}.src.rpm} | cpio -idvmu
+    %{l_bzip2} -d -c       urpmi-%{V_urpmi}.tar.bz2                               | %{l_tar} xf -
+    %{l_bzip2} -d -c       URPM-%{V_urpm}.tar.bz2                                 | %{l_tar} xf -
+    %{l_bzip2} -d -c       MDV-Packdrakeng-%{V_mdv_packdrakeng}.tar.bz2           | %{l_tar} xf -
+    %{l_gzip}  -d -c       MDV-Distribconf-%{V_mdv_distribconf}.tar.gz            | %{l_tar} xf -
     %patch -p0
 
 %build
@@ -95,21 +118,86 @@ AutoReqProv:  no
 %install
     rm -rf $RPM_BUILD_ROOT
     ( cd urpmi-%{V_urpmi}
+      #   adjust path to configuration files
       %{l_shtool} subst \
           -e "s;/etc/urpmi;%{l_prefix}/etc/urpmi;" \
           urpmq urpm/cfg.pm urpm.pm
+
+      #   adjust cache and hdlist paths
+       %{l_shtool} subst \
+           -e "s;/var/lib/urpmi;%{l_prefix}/var/urpmi/lib;" \
+           -e "s;/var/cache/urpmi;%{l_prefix}/var/urpmi/cache;" \
+           urpm.pm
+
+      #   fix superuser message (l_muid)
+      %{l_shtool} subst \
+          -e "s;$< != 0;$< != %{l_muid};" \
+          urpmi.addmedia urpmi.update urpmi.removemedia rurpmi urpmi urpmq
+      %{l_shtool} subst \
+          -e "s;$<;($< != %{l_muid});" \
+          urpme urpmi.recover urpm.pm
+
+      #   fix common tool paths (coreutils)
+      %{l_shtool} subst \
+          -e "s;/bin/cp;%{l_prefix}/bin/cp;" \
+          -e "s;/bin/mv;%{l_prefix}/bin/mv;" \
+          -e "s;/usr/bin/md5sum;%{l_prefix}/bin/md5sum;" \
+          urpm/util.pm
+      %{l_shtool} subst \
+          -e "s;/usr/bin/curl;%{l_prefix}/lib/openpkg/curl;" \
+%if "%{with_wget}" == "yes"
+          -e "s;/usr/bin/wget;%{l_prefix}/bin/wget;" \
+%endif
+%if "%{with_rsync}" == "yes"
+          -e "s;/usr/bin/rsync;%{l_prefix}/bin/rsync;" \
+%endif
+%if "%{with_ssh}" == "yes"
+          -e "s;/usr/bin/ssh;%{l_prefix}/bin/ssh;" \
+%endif
+          urpm/download.pm
     ) || exit $?
+
+    #   install addon Perl modules
     %{l_prefix}/bin/perl-openpkg prepare
     %{l_prefix}/bin/perl-openpkg -d MDV-Distribconf-%{V_mdv_distribconf} configure build install
     %{l_prefix}/bin/perl-openpkg -d MDV-Packdrakeng-%{V_mdv_packdrakeng} configure build install
     %{l_prefix}/bin/perl-openpkg -d URPM-%{V_urpm} configure build install
     %{l_prefix}/bin/perl-openpkg -d urpmi-%{V_urpmi} configure build install
     %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
+
+    #   determine installation files
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
-        %{l_files_std} `cat perl-openpkg-files`
+        %{l_files_std} `cat perl-openpkg-files` \
+        '%dir %{l_prefix}/var/urpmi/*' \
+        '%not %dir %{l_prefix}/etc/urpmi' \
+        '%config %{l_prefix}/etc/urpmi/inst.list' \
+        '%config %{l_prefix}/etc/urpmi/skip.list'
 
 %files -f files
 
 %clean
     rm -rf $RPM_BUILD_ROOT
 
+%post
+    #   update media information
+    $RPM_INSTALL_PREFIX/bin/perl -Murpm -e '
+        if (-e "$ARGV[0]/etc/urpmi/urpmi.cfg") {
+            $urpm = new urpm;
+            $urpm->read_config;
+            $urpm->update_media(nolock => 1, nopubkey => 1);
+        }
+    ' $RPM_INSTALL_PREFIX
+    exit 0
+
+%preun
+    #   remove database files on deinstallation
+    if [ ".$1" = .0 ]; then
+        ( cd $RPM_INSTALL_PREFIX/var/urpmi/lib || exit $?
+          rm -f compss provides depslist* descriptions.* *.cache hdlist.* synthesis.hdlist.* list.* >/dev/null 2>&1 || true
+        ) || exit $?
+        ( cd $RPM_INSTALL_PREFIX/var/urpmi/cache || exit $?
+          rm -rf partial/* headers/* rpms/* >/dev/null 2>&1 || true
+        ) || exit $?
+    fi
+    exit 0
+