Pārlūkot izejas kodu

Polished the package and made it fun again. Index data is now to be fetched on a weekly basis. BTW I don't see a reason for %update_config_scripts in this package hence I removed it.

Christoph Schug 23 gadi atpakaļ
vecāks
revīzija
e94ddccff2
2 mainītis faili ar 52 papildinājumiem un 11 dzēšanām
  1. 28 11
      heise/heise.spec
  2. 24 0
      heise/rc.heise

+ 28 - 11
heise/heise.spec

@@ -37,18 +37,18 @@ Distribution: OpenPKG [EVAL]
 Group:        Misc
 License:      GPL
 Version:      %{V_vl}
-Release:      20020826
+Release:      20021211
 
 #   list of sources
 Source0:      ftp://ftp.heise.de/pub/ct/register/regpl%{V_vs}.zip
-Source1:      ftp://ftp.heise.de/pub/ct/register/register.zip
+Source1:      rc.heise
 Source2:      heise.conf
 
 #   build information
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
 BuildPreReq:  OpenPKG, openpkg >= 20020206, infozip
-PreReq:       OpenPKG, openpkg >= 20020206, perl
+PreReq:       OpenPKG, openpkg >= 20020206, infozip, perl, curl, shtool
 AutoReq:      no
 AutoReqProv:  no
 
@@ -57,28 +57,35 @@ AutoReqProv:  no
 
 %prep
     %setup -T -c
-    %update_config_scripts
     %{l_prefix}/bin/unzip -x %{SOURCE regpl%{V_vs}.zip}
-    %{l_prefix}/bin/unzip -x %{SOURCE register.zip}
 
 %build
     ( echo "#!%{l_prefix}/bin/perl"
       sed \
           -e '1,15d' \
-          -e "s;~/heise/inhalt.frm;%{l_prefix}/share/heise/inhalt.frm;" \
+          -e "s;~/heise/inhalt.frm;%{l_prefix}/var/heise/inhalt.frm;" \
           -e "s;^\(\$frmfilefmt = \).*$;\1\"%{l_prefix}/etc/heise/heise.conf\"\;;" \
           <reg.pl
-#          -e "s;^\(\$frmfilefmt = \).*$;\1%{l_prefix}/etc/heise/heise.conf;" \
     ) >heise
 
 %install
     rm -rf $RPM_BUILD_ROOT
     %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/bin
     %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/heise
-    %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/share/heise
-    %{l_shtool} install -c -m 755 heise $RPM_BUILD_ROOT%{l_prefix}/bin/
-    %{l_shtool} install -c -m 644 INHALT.FRM $RPM_BUILD_ROOT%{l_prefix}/share/heise/inhalt.frm
-    %{l_shtool} install -c -m 644 %{SOURCE heise.conf} $RPM_BUILD_ROOT%{l_prefix}/etc/heise/
+    %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
+    %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/var/heise
+    %{l_shtool} install -c -m 755 \
+        heise \
+        $RPM_BUILD_ROOT%{l_prefix}/bin/
+    %{l_shtool} install -c -m 644 \
+        %{SOURCE heise.conf} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/heise/
+    %{l_shtool} install -c -m 755 \
+        -e 's;@l_prefix@;%{l_prefix};g' \
+        -e 's;@l_musr@;%{l_musr};g' \
+        -e 's;@l_mgrp@;%{l_mgrp};g' \
+        %{SOURCE rc.heise} \
+        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
 
 %files -f files
@@ -86,3 +93,13 @@ AutoReqProv:  no
 %clean
     rm -rf $RPM_BUILD_ROOT
 
+%post
+    if [ "$1" -eq 1 ]; then
+        $RPM_INSTALL_PREFIX/etc/rc.d/rc.heise weekly || true
+    fi
+
+%preun
+    if [ "$1" -eq 0 ]; then
+        rm -rf $RPM_INSTALL_PREFIX/var/heise/* 2>/dev/null || true
+    fi
+

+ 24 - 0
heise/rc.heise

@@ -0,0 +1,24 @@
+#!@l_prefix@/lib/openpkg/bash @l_prefix@/etc/rc
+##
+##  rc.heise -- Run-Commands for heise
+##
+
+%config
+    heise_enable="yes"
+    heise_idx_numfiles="10"
+    heise_idx_complevel="9"
+    heise_url="ftp://ftp.heise.de/pub/ct/register/register.zip"
+
+%weekly -u @l_musr@
+    opServiceEnabled heise || exit 0
+
+    #   fetch new index data
+    ( cd @l_prefix@/var/heise \
+          && @l_prefix@/bin/curl -s -o register.zip ${heise_url} \
+          && @l_prefix@/bin/shtool rotate -f \
+              -n${heise_idx_numfiles} -s0 \
+              -z${heise_idx_complevel} -o@l_musr@ -g@l_mgrp@ -m644 \
+              inhalt.frm \
+          && @l_prefix@/bin/unzip -jop register.zip INHALT.FRM > inhalt.frm
+    )
+