Date: Saturday, June 9, 2012 @ 18:30:24
  Author: dreisner
Revision: 161334

upgpkg: squid 3.1.20-2

- cleanup cron job to avoid use of pidof
- cleanup rc.d script to use pidfile
- move pidfile to /run
- add systemd service
- remove empty /usr/include dir

Added:
  squid/trunk/squid.service
Modified:
  squid/trunk/PKGBUILD
  squid/trunk/squid
  squid/trunk/squid.cron

---------------+
 PKGBUILD      |   82 ++++++++++++++++++++++++++++++++++++--------------------
 squid         |   28 ++++++++-----------
 squid.cron    |   11 +++++--
 squid.service |   13 ++++++++
 4 files changed, 87 insertions(+), 47 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2012-06-09 19:56:32 UTC (rev 161333)
+++ PKGBUILD    2012-06-09 22:30:24 UTC (rev 161334)
@@ -4,25 +4,32 @@
 
 pkgname=squid
 pkgver=3.1.20
-pkgrel=1
+pkgrel=2
 pkgdesc="A full-featured Web proxy cache server."
 arch=('i686' 'x86_64')
 url="http://www.squid-cache.org";
 depends=('openssl' 'pam' 'cron' 'perl' 'libltdl')
 makedepends=('libcap')
 license=('GPL')
-backup=('etc/squid/squid.conf' 'etc/squid/mime.conf' 'etc/conf.d/squid')
+backup=('etc/squid/squid.conf'
+        'etc/squid/mime.conf'
+        'etc/conf.d/squid')
 install=squid.install
-source=("http://www.squid-cache.org/Versions/v3/3.1/${pkgname}-${pkgver}.tar.bz2";
-        'squid' 'squid.conf.d' 'squid.pam' 'squid.cron')
+source=("http://www.squid-cache.org/Versions/v3/3.1/$pkgname-$pkgver.tar.bz2";
+        'squid'
+        'squid.conf.d'
+        'squid.pam'
+        'squid.cron'
+        'squid.service')
 md5sums=('c4d733a383c0508fd0746d64a2d7278a'
-         'd213b0cc1db72b749bb8c88716fdab39'
+         '02f7b5bd793f778e40834fd6457d2199'
          '2383772ef94efddc7b920628bc7ac5b0'
          '270977cdd9b47ef44c0c427ab9034777'
-         '5e17df989e2a74e869790c066f61225b')
+         'b499c2b725aefd7bd60bec2f1a9de392'
+         '20e00e1aa1198786795f3da32db3c1d8')
 
 build() {
-  cd "${srcdir}"/${pkgname}-${pkgver}
+  cd "$pkgname-$pkgver"
 
   # gcc 4.6 doesn't support -fhuge-objects.
   sed '/^    HUGE_OBJECT_FLAG=/ s/"-fhuge-objects"//' -i configure
@@ -32,37 +39,56 @@
   sed '/^#cache_dir/ s/100/256/
        /^NAME: cache_effective_group/ {n;n;s/none/proxy/}' -i src/cf.data.pre
 
-  ./configure --prefix=/usr --datadir=/usr/share/squid \
-      --sysconfdir=/etc/squid --libexecdir=/usr/lib/squid \
-      --localstatedir=/var --with-logdir=/var/log/squid \
-      --enable-auth="basic,digest,ntlm" --enable-removal-policies="lru,heap" \
-      --enable-digest-auth-helpers="password" 
--enable-storeio="aufs,ufs,diskd" \
+  ./configure \
+      --prefix=/usr \
+      --datadir=/usr/share/squid \
+      --sysconfdir=/etc/squid \
+      --libexecdir=/usr/lib/squid \
+      --localstatedir=/var \
+      --with-logdir=/var/log/squid \
+      --with-pidfile=/run/squid.pid \
+      --enable-auth="basic,digest,ntlm" \
+      --enable-removal-policies="lru,heap" \
+      --enable-digest-auth-helpers="password" \
+      --enable-storeio="aufs,ufs,diskd" \
       
--enable-basic-auth-helpers="getpwnam,YP,NCSA,SMB,MSNT,PAM,multi-domain-NTLM" \
       --enable-external-acl-helpers="ip_user,unix_group,wbinfo_group" \
       --enable-ntlm-auth-helpers="smb_lm,fakeauth,no_check" \
-      --enable-delay-pools --enable-arp-acl --enable-ssl --enable-snmp \
-      --enable-linux-netfilter --enable-ident-lookups \
-      --enable-useragent-log --enable-cache-digests --enable-referer-log \
-      --enable-arp-acl --enable-htcp --enable-carp --enable-epoll \
-      --with-filedescriptors=4096 --with-large-files --enable-arp-acl \
+      --enable-delay-pools \
+      --enable-arp-acl \
+      --enable-ssl \
+      --enable-snmp \
+      --enable-linux-netfilter \
+      --enable-ident-lookups \
+      --enable-useragent-log \
+      --enable-cache-digests \
+      --enable-referer-log \
+      --enable-arp-acl \
+      --enable-htcp \
+      --enable-carp \
+      --enable-epoll \
+      --with-filedescriptors=4096 \
+      --with-large-files \
+      --enable-arp-acl \
       --with-default-user=proxy \
-      --enable-async-io --enable-truncate
-#some versions have build problems with both async and truncate enabled:
-#      --enable-async-io
+      --enable-async-io \
+      --enable-truncate
 
   make
 }
 
 package() {
-  cd "${srcdir}"/${pkgname}-${pkgver}
-  make DESTDIR="${pkgdir}" install
+  make -C "$pkgname-$pkgver" DESTDIR="$pkgdir" install
 
-  install -D -m755 "${srcdir}"/squid "${pkgdir}"/etc/rc.d/squid
-  install -D -m755 "${srcdir}"/squid.cron "${pkgdir}"/etc/cron.weekly/squid
-  install -D -m644 "${srcdir}"/squid.conf.d "${pkgdir}"/etc/conf.d/squid
-  install -D -m644 "${srcdir}"/squid.pam "${pkgdir}"/etc/pam.d/squid
+  install -Dm755 "$srcdir"/squid "$pkgdir"/etc/rc.d/squid
+  install -Dm755 "$srcdir"/squid.cron "$pkgdir"/etc/cron.weekly/squid
+  install -Dm644 "$srcdir"/squid.conf.d "$pkgdir"/etc/conf.d/squid
+  install -Dm644 "$srcdir"/squid.pam "$pkgdir"/etc/pam.d/squid
 
-  # avoid conflict with filesystem>=2012.06
-  rmdir "$pkgdir/var/run"
+  install -Dm644 "$srcdir/squid.service" 
"$pkgdir/usr/lib/systemd/system/squid.service"
+
+  # random unneeded empty dir...
+  rmdir "$pkgdir/usr/include"
 }
+
 # vim: ts=2 sw=2 et ft=sh

Modified: squid
===================================================================
--- squid       2012-06-09 19:56:32 UTC (rev 161333)
+++ squid       2012-06-09 22:30:24 UTC (rev 161334)
@@ -1,23 +1,21 @@
 #!/bin/bash
 
 # source application-specific settings
-SQUID_ARGS=
-[ -f /etc/conf.d/squid ] && . /etc/conf.d/squid
+[[ -f /etc/conf.d/squid ]] && . /etc/conf.d/squid
 
 . /etc/rc.conf
 . /etc/rc.d/functions
 
-PID=`pidof -o %PPID /usr/sbin/squid`
-case "$1" in
+pidfile=/run/squid.pid
+{ read -r PID </run/squid.pid; } 2>/dev/null
+if [[ $pid && ! /proc/$pid/exe -ef /usr/sbin/squid ]]; then
+  rm /run/squid.pid
+fi
 
+case $1 in
   start)
-    if [ ! -f /var/cache/squid/swap.state ]; then
-      stat_busy "Creating squid's swap directories"
-      /usr/sbin/squid -z
-    fi
     stat_busy "Starting squid"
-    [ -z "$PID" ] && /usr/sbin/squid ${SQUID_ARGS}
-    if [ $? -gt 0 ]; then
+    if [[ $PID ]] || ! squid $SQUID_ARGS; then
       stat_fail
     else
       add_daemon squid
@@ -27,12 +25,11 @@
 
   stop)
     stat_busy "Stopping squid"
-    [ ! -z "$PID" ]  && /usr/sbin/squid -k shutdown &> /dev/null
-    if [ $? -gt 0 ]; then
+    if [[ -z $PID ]] || ! squid -k shutdown &>/dev/null; then
       stat_fail
     else
-      # wait for squid to shutdown so we can safely do a restart
-      while [ ! -z "`pidof -o %PPID /usr/sbin/squid`" ]; do
+      # squid takes forever to shutdown all its listening FDs
+      while [[ /proc/$PID/exe -ef /usr/sbin/squid ]]; do
         stat_append "."
         sleep 3
       done
@@ -43,10 +40,9 @@
 
   restart)
     $0 stop
-    sleep 5
     $0 start
     ;;
   *)
-    echo "usage: $0 {start|stop|restart}"  
+    echo "usage: $0 {start|stop|restart}"
 esac
 exit 0

Modified: squid.cron
===================================================================
--- squid.cron  2012-06-09 19:56:32 UTC (rev 161333)
+++ squid.cron  2012-06-09 22:30:24 UTC (rev 161334)
@@ -1,4 +1,9 @@
-#!/bin/bash
+#!/bin/sh
 
-PID=`pidof -o %PPID /usr/sbin/squid`
-[ -n "$PID" ] && /usr/sbin/squid -k rotate
+# exit without error if no pidfile exists
+{ read pid </run/squid.pid; } 2>/dev/null || exit 0
+
+# make sure found PID really is a squid process
+if [ /proc/$pid/exec -ef /usr/sbin/squid ]; then
+  /usr/sbin/squid -k rotate
+fi

Added: squid.service
===================================================================
--- squid.service                               (rev 0)
+++ squid.service       2012-06-09 22:30:24 UTC (rev 161334)
@@ -0,0 +1,13 @@
+[Unit]
+Description=Web Proxy Cache Server
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/squid.pid
+ExecStart=/usr/sbin/squid -sYC
+ExecStop=/usr/sbin/squid -k shutdown
+ExecReload=/usr/sbin/squid -k reconfigure
+
+[Install]
+WantedBy=multi-user.target

Reply via email to