Просмотр исходного кода

Before deploying this beast once again, tweak this fairly complex package in the hope that this reduces its complexity a little bit ;-) - add a bunch of code comments to document the parts a little bit more - simplify packaging by compacting commands - reorder Perl module installation to better satisfy their dependencies - split %post hint into initial and upgrade messages - require latest perl-openpkg which has the -p option only - strip down installation files even more

Ralf S. Engelschall 22 лет назад
Родитель
Сommit
a0a789e9b9
2 измененных файлов с 105 добавлено и 111 удалено
  1. 1 0
      rt/rc.rt
  2. 104 111
      rt/rt.spec

+ 1 - 0
rt/rc.rt

@@ -57,3 +57,4 @@
 %hourly -u @l_rusr@
     opServiceEnabled rt || exit 0
     find $rt_sessiondir -type f -amin +600 -exec rm '{}' \;
+

+ 104 - 111
rt/rt.spec

@@ -49,7 +49,7 @@ Distribution: OpenPKG [EVAL]
 Group:        Database
 License:      GPL
 Version:      %{V_here}
-Release:      20030516
+Release:      20030517
 
 #   package options
 %option       with_color_primary  336699
@@ -92,7 +92,7 @@ Patch0:       rt.patch
 #   build information
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
-BuildPreReq:  OpenPKG, openpkg >= 20020206, perl, perl-openpkg
+BuildPreReq:  OpenPKG, openpkg >= 20020206, perl, perl-openpkg >= 20030515
 BuildPreReq:  perl-sys, perl-util, perl-ds, perl-text, perl-apache
 BuildPreReq:  perl-dbi, perl-dbix, perl-mail, perl-www
 BuildPreReq:  apache, apache::with_mod_perl = yes
@@ -121,6 +121,7 @@ AutoReqProv:  no
     over a thousand sites around the world.
 
 %prep
+    #   unpack distribution tarballs
     %setup -q -c
     %setup -q -T -D -a 1
     %setup -q -T -D -a 2
@@ -132,29 +133,31 @@ AutoReqProv:  no
     %setup -q -T -D -a 8
     %setup -q -T -D -a 9
     %setup -q -T -D -a 10
-    ( cd rt-%{V_real}
-      %patch0 -p0
-    ) || exit $?
+
+    #   patch RT distribution
+    cd rt-%{V_real}
+    %patch0 -p0
     %{l_shtool} install -c -m 0644 \
         -e 's;@l_prefix@;%{l_prefix};' \
-        %{SOURCE config.layout} rt-%{V_real}/.
+        %{SOURCE config.layout} .
     %{l_shtool} subst \
-      -e 's;chown;true;g' \
-      -e 's;chgrp;true;g' \
-      -e 's;chmod;true;g' \
-      -e 's;mkdir -p;%{l_shtool} mkdir -p;g' \
-      rt-%{V_real}/Makefile.in
+        -e 's;chown;true;g' \
+        -e 's;chgrp;true;g' \
+        -e 's;chmod;true;g' \
+        -e 's;mkdir -p;%{l_shtool} mkdir -p;g' \
+        Makefile.in
+    %{l_shtool} subst \
+        -e 's;Locale::Maketext 1\.04;Locale::Maketext 1.03;' \
+        lib/RT/I18N.pm
     %{l_shtool} subst \
-      -e 's;Locale::Maketext 1\.04;Locale::Maketext 1.03;' \
-      rt-%{V_real}/lib/RT/I18N.pm
-
-%build
-    ( cd rt-%{V_real}
-      %{l_shtool} subst \
         -e 's;/usr/sbin/sendmail;%{l_prefix}/sbin/sendmail;g' \
         etc/RT_Config.pm.in
-      PERL=%{l_prefix}/bin/perl
-      ./configure \
+
+%build
+    #   configure RT part
+    cd rt-%{V_real}
+    PERL=%{l_prefix}/bin/perl
+    ./configure \
         --enable-layout=OPKG \
         --with-db-type=mysql \
         --with-db-host=localhost \
@@ -183,26 +186,29 @@ AutoReqProv:  no
         --with-customhtmldir=%{l_prefix}/etc/rt/local/html \
         --with-customlibdir=%{l_prefix}/etc/rt/local/lib \
         --with-customlexdir=%{l_prefix}/etc/rt/local/po
-    ) || exit $?
 
 %install
     rm -rf $RPM_BUILD_ROOT
 
-    #   perform common prolog operations
+    #   perform common Perl prolog operations
     rt=%{l_prefix}/libexec/rt
     %{l_shtool} mkdir -f -p -m 755 ${RPM_BUILD_ROOT}$rt
-
     %{l_prefix}/bin/perl-openpkg prolog
 
+    #   install remaining prerequisite Perl modules which
+    #   are not part of the OpenPKG perl-xxx packages.
     %{l_prefix}/bin/perl-openpkg install \
-        -d Log-Dispatch-%{V_log_dispatch} \
+        -d Regexp-Common-%{V_regexp_common} \
         -p ${RPM_BUILD_ROOT}$rt
     %{l_prefix}/bin/perl-openpkg install \
-        -d HTML-Mason-%{V_html_mason} \
+        -d Log-Dispatch-%{V_log_dispatch} \
         -p ${RPM_BUILD_ROOT}$rt
     %{l_prefix}/bin/perl-openpkg install \
         -d libapreq-%{V_libapreq} \
         -p ${RPM_BUILD_ROOT}$rt
+    %{l_prefix}/bin/perl-openpkg install \
+        -d HTML-Mason-%{V_html_mason} \
+        -p ${RPM_BUILD_ROOT}$rt
     %{l_prefix}/bin/perl-openpkg install \
         -d WWW-Mechanize-%{V_www_mechanize} \
         -p ${RPM_BUILD_ROOT}$rt
@@ -221,13 +227,11 @@ AutoReqProv:  no
     %{l_prefix}/bin/perl-openpkg install \
         -d Locale-Maketext-Fuzzy-%{V_locale_maketext_fuzzy} \
         -p ${RPM_BUILD_ROOT}$rt
-    %{l_prefix}/bin/perl-openpkg install \
-        -d Regexp-Common-%{V_regexp_common} \
-        -p ${RPM_BUILD_ROOT}$rt
 
-    #   perform common epilog operations
+    #   perform common Perl epilog operations
     %{l_prefix}/bin/perl-openpkg epilog
 
+    #   create installation file hierarchy
     %{l_shtool} mkdir -f -p -m 0755 \
         $RPM_BUILD_ROOT%{l_prefix}/sbin \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rt \
@@ -241,52 +245,61 @@ AutoReqProv:  no
         $RPM_BUILD_ROOT%{l_prefix}/var/rt/log \
         $RPM_BUILD_ROOT%{l_prefix}/var/rt/run
 
+    #   perform RT installation procedure
     ( cd rt-%{V_real}
-      %{l_make} \
-        config-install \
-        dirs \
-        libs-install \
-        etc-install \
-        bin-install \
-        sbin-install \
-        html-install \
-        doc-install \
-        DESTDIR=$RPM_BUILD_ROOT
+      %{l_make} %{l_mflags} \
+          config-install dirs libs-install etc-install bin-install \
+          sbin-install html-install doc-install \
+          DESTDIR=$RPM_BUILD_ROOT
       %{l_shtool} install -c -m 0644 \
-        etc/upgrade/* \
-        $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/etc/upgrade/
+          etc/upgrade/* \
+          $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/etc/upgrade/
       %{l_shtool} install -c -m 0644 \
-        -e '/Set($WebBaseURL/s;"[^"]*";"";' \
-        etc/RT_Config.pm \
-        $RPM_BUILD_ROOT%{l_prefix}/etc/rt/RT_SiteConfig.pm
-      rm -f \
-        $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/etc/RT_SiteConfig.pm
-      ln -s \
-        %{l_prefix}/etc/rt/RT_SiteConfig.pm \
+          -e '/Set($WebBaseURL/s;"[^"]*";"";' \
+          etc/RT_Config.pm \
+          $RPM_BUILD_ROOT%{l_prefix}/etc/rt/RT_SiteConfig.pm
+    ) || exit $?
+
+    #   post-adjust installation hierarchy
+    %{l_shtool} mkln -f -s \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rt/RT_SiteConfig.pm \
         $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/etc/RT_SiteConfig.pm
-      mv \
+    mv \
         $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/WebRT/html/NoAuth/webrt.css \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rt/webrt.css
-      ln -s \
-        %{l_prefix}/etc/rt/webrt.css \
+    %{l_shtool} mkln -f -s \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rt/webrt.css \
         $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/WebRT/html/NoAuth/webrt.css
-      mv \
+    mv \
         $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/local \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rt/local
-      ln -s \
-        %{l_prefix}/etc/rt/local \
+    %{l_shtool} mkln -f -s \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rt/local \
         $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/local
-    ) || exit $?
+    mv \
+        $RPM_BUILD_ROOT%{l_prefix}/bin/webmux.pl \
+        $RPM_BUILD_ROOT%{l_prefix}/bin/mason_handler.fcgi \
+        $RPM_BUILD_ROOT%{l_prefix}/cgi/rt/
+    mv \
+        $RPM_BUILD_ROOT%{l_prefix}/bin/rt-crontool \
+        $RPM_BUILD_ROOT%{l_prefix}/bin/rt-mailgate \
+        $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/tools/
+    %{l_shtool} install -c -m 755 \
+        -e 's;@l_prefix@;%{l_prefix};g' \
+        %{SOURCE rt-mailgate.sh} \
+        $RPM_BUILD_ROOT%{l_prefix}/bin/rt-mailgate
 
-    #   cleanup installation area
-    rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*.svc
-    rm -f $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/tools/rt-test-dependencies
+    #   strip installation hierarchy
+    rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/*.svc
+    rm -f  $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/tools/rt-test-dependencies
     rm -rf $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/t
-    rm -f $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/RT.pm.in
-    rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/xgettext.pl
-    rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/pod2test
+    rm -f  $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/RT.pm.in
+    rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/xgettext.pl
+    rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/pod2test
+    rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man3
+    rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/rt
 
-    #   setup/cleanup/upgrade script
+    #   install own setup/cleanup/upgrade script
 %if "%{with_db_mysql}" == "yes"
     rt_db_dba=root
 %endif
@@ -299,20 +312,10 @@ AutoReqProv:  no
     %{l_shtool} install -c -m 755 \
         -e 's;@l_prefix@;%{l_prefix};g' \
         -e "s;@rt_db_dba@;$rt_db_dba;g" \
-        %{SOURCE rtsetup} \
-        $RPM_BUILD_ROOT%{l_prefix}/sbin/
-    %{l_shtool} install -c -m 755 \
-        -e 's;@l_prefix@;%{l_prefix};g' \
-        -e "s;@rt_db_dba@;$rt_db_dba;g" \
-        %{SOURCE rtcleanup} \
-        $RPM_BUILD_ROOT%{l_prefix}/sbin/
-    %{l_shtool} install -c -m 755 \
-        -e 's;@l_prefix@;%{l_prefix};g' \
-        -e "s;@rt_db_dba@;$rt_db_dba;g" \
-        %{SOURCE rtupgrade} \
+        %{SOURCE rtsetup} %{SOURCE rtcleanup} %{SOURCE rtupgrade} \
         $RPM_BUILD_ROOT%{l_prefix}/sbin/
 
-    #   startup script
+    #   install OpenPKG run-command script
     %{l_shtool} install -c -m 755 \
         -e 's;@l_prefix@;%{l_prefix};g' \
         -e 's;@l_rusr@;%{l_rusr};g' \
@@ -320,13 +323,13 @@ AutoReqProv:  no
         %{SOURCE rc.rt} \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
 
-    #   apachectl wrapper
+    #   install Apache "apachectl" wrapper
     %{l_shtool} install -c -m 755 \
         -e 's;@l_prefix@;%{l_prefix};g' \
         %{SOURCE rtapachectl} \
         $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/tools/
 
-    #   apache config
+    #   install Apache configuration
     l_hostname=`%{l_shtool} echo -e %h`
     l_domainname=`%{l_shtool} echo -e %d | cut -c2-`
     %{l_shtool} install -c -m 755 \
@@ -338,24 +341,11 @@ AutoReqProv:  no
         %{SOURCE rtapache.conf} \
         $RPM_BUILD_ROOT%{l_prefix}/etc/rt/
 
-    #   better places
-    mv \
-        $RPM_BUILD_ROOT%{l_prefix}/bin/webmux.pl \
-        $RPM_BUILD_ROOT%{l_prefix}/bin/mason_handler.fcgi \
-        $RPM_BUILD_ROOT%{l_prefix}/cgi/rt/
-    mv \
-        $RPM_BUILD_ROOT%{l_prefix}/bin/rt-crontool \
-        $RPM_BUILD_ROOT%{l_prefix}/bin/rt-mailgate \
-        $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/tools/
-    %{l_shtool} install -c -m 755 \
-        -e 's;@l_prefix@;%{l_prefix};g' \
-        %{SOURCE rt-mailgate.sh} \
-        $RPM_BUILD_ROOT%{l_prefix}/bin/rt-mailgate
-
-    #   post-adjustments
+    #   final post-adjustments to installation hierarchy
     %{l_shtool} subst \
         -e 's;#336699;#%{with_color_primary};g' \
-        `find $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/WebRT -type f -print | grep -v gif | grep -v jpg`
+        `find $RPM_BUILD_ROOT%{l_prefix}/libexec/rt/WebRT \
+              -type f -print | grep -v gif | grep -v jpg`
 
     #   determine installation files
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
@@ -383,28 +373,29 @@ AutoReqProv:  no
         mta_aliases_file=`%{l_prefix}/etc/rc --query mta_aliases_file`
         mta_aliases_update=`%{l_prefix}/etc/rc --query mta_aliases_update`
         if [ ".$mta_aliases_file" != . ]; then
-            (
-              echo "rt:              \"|%{l_prefix}/bin/rt-mailgate --action correspond --queue general --url http://127.0.0.1:8380/\""
-              echo "rt-comment:      \"|%{l_prefix}/bin/rt-mailgate --action comment --queue general --url http://127.0.0.1:8380/\""
+            ( echo "rt:         \"|%{l_prefix}/bin/rt-mailgate --action correspond --queue general --url http://127.0.0.1:8380/\""
+              echo "rt-comment: \"|%{l_prefix}/bin/rt-mailgate --action comment    --queue general --url http://127.0.0.1:8380/\""
             ) | %{l_rpmtool} config -a -i "%{l_prefix}:%{name}" $mta_aliases_file
         fi
         if [ ".$mta_aliases_update" != . ]; then
             eval $mta_aliases_update
         fi
+
+        #   display final hint after initial installation
+        ( echo "To complete installation of the RT package please check the"
+          echo "file $RPM_INSTALL_PREFIX/etc/rt/RT_SiteConfig.pm. In particular,"
+          echo "you have to assign a password to the RT database user."
+          echo "Then you have to create the RT database in the RDBMS with:"
+          echo "\$ $RPM_INSTALL_PREFIX/sbin/rtsetup"
+        ) | %{l_rpmtool} msg -b -t notice
+    elif [ $1 -gt 1 ]; then
+        #   display final hint after upgrading
+        ( echo "If you have an old RT database you can erase it with:"
+          echo "\$ $RPM_INSTALL_PREFIX/sbin/rtcleanup"
+          echo "Upgrading from an earlier RT 3.x database you can with:"
+          echo "\$ $RPM_INSTALL_PREFIX/sbin/rtupgrade <old-rt-version>"
+        ) | %{l_rpmtool} msg -b -t notice
     fi
-    ( echo "To complete installation of the RT package please check the"
-      echo "file '$RPM_INSTALL_PREFIX/etc/rt/RT_SiteConfig.pm'. In particular"
-      echo "you have to assign a password to the RT database user."
-      echo "If you have an old RT database you can erase it with:"
-      echo "$RPM_INSTALL_PREFIX/sbin/rtcleanup"
-      echo "If you start with a new installation of RT then run the command:"
-      echo "$RPM_INSTALL_PREFIX/sbin/rtsetup"
-      echo "DON'T FORGET TO SET A ADMINISTRATOR PASSWORD"
-      echo "Default settings are: user 'root', password 'password'"
-      echo "If you upgrade from an earlier 3.x-RT-Version then run:"
-      echo "$RPM_INSTALL_PREFIX/sbin/rtupgrade old-rt-version"
-      echo "to update RTs system tables"
-    ) | %{l_rpmtool} msg -b -t notice
 
 %preun
     if [ $1 -eq 0 ]; then
@@ -421,9 +412,11 @@ AutoReqProv:  no
             eval $mta_aliases_update
         fi
 
-        rm -f $RPM_INSTALL_PREFIX/var/rt/mason-session/*
+        #   remove generated files
+        rm -f  $RPM_INSTALL_PREFIX/var/rt/mason-session/*
         rm -rf $RPM_INSTALL_PREFIX/var/rt/mason-data/*/*
-        rm -f $RPM_INSTALL_PREFIX/var/rt/log/*
-        rm -f $RPM_INSTALL_PREFIX/var/rt/run/apache.pid
-        rm -f $RPM_INSTALL_PREFIX/var/rt/run/ssl_scache
+        rm -f  $RPM_INSTALL_PREFIX/var/rt/log/*
+        rm -f  $RPM_INSTALL_PREFIX/var/rt/run/apache.pid
+        rm -f  $RPM_INSTALL_PREFIX/var/rt/run/ssl_scache
     fi
+