chiark / gitweb /
Working on debianisation and packaging.
authorianmdlvl <ianmdlvl>
Sun, 7 Oct 2001 19:00:58 +0000 (19:00 +0000)
committerianmdlvl <ianmdlvl>
Sun, 7 Oct 2001 19:00:58 +0000 (19:00 +0000)
16 files changed:
.cvsignore [new file with mode: 0644]
backup/.cvsignore [new file with mode: 0644]
backup/Makefile
backup/checkallused
backup/driver
backup/full
backup/increm
backup/iwjbackup.txt
backup/loaded
backup/readbuffer.c
backup/settings.pl
backup/takedown
backup/whatsthis
backup/writebuffer.c
debian/control [new file with mode: 0644]
debian/rules [new file with mode: 0755]

diff --git a/.cvsignore b/.cvsignore
new file mode 100644 (file)
index 0000000..378eac2
--- /dev/null
@@ -0,0 +1 @@
+build
diff --git a/backup/.cvsignore b/backup/.cvsignore
new file mode 100644 (file)
index 0000000..cf6c95c
--- /dev/null
@@ -0,0 +1,2 @@
+readbuffer
+writebuffer
index 59a3c11..59cdfa1 100644 (file)
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-CC=gcc
-CFLAGS=-Wall -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -O2 -g
+CC=            gcc
+CFLAGS=                $(WARNINGS) $(OPTIMISE) $(DEBUG)
+CPPFLAGS=      -DRWBUFFER_SIZE_MB=$(RWBUFFER_SIZE_MB)
+
+WARNINGS=      -Wall -Wwrite-strings -Wmissing-prototypes \
+               -Wstrict-prototypes -Wpointer-arith
+OPTIMISE=      -O2
+DEBUG=         -g
+RWBUFFER_SIZE_MB=16
+
+prefix=/usr/local
+etcdir=/etc/chiark-backup
+bindir=$(prefix)/bin
+sharedir=$(prefix)/share/chiark-backup
+
+INSTALL=               install
+INSTALL_SHARE=         $(INSTALL) -m 644 -o root -g root
+INSTALL_SCRIPT=                $(INSTALL) -m 755 -o root -g root
+INSTALL_PROGRAM=       $(INSTALL_SCRIPT) -s
+INSTALL_DIRECTORY=     $(INSTALL) -m 2755 -o root -g root -d
+
+CTARGETS=      readbuffer writebuffer
+BINSCRIPTS=    checkallused loaded driver takedown whatsthis
+SHARESCRIPTS=  bringup full increm
+SHAREFILES=    backuplib.pl
+
+all:           $(CTARGETS)
+
+install:               all
+               $(INSTALL_DIRECTORY) $(etcdir) $(bindir) $(sharedir)
+               $(INSTALL_PROGRAM) $(CTARGETS) $(bindir)
+               set -e; for s in $(BINSCRIPTS); do \
+                       $(INSTALL_SCRIPT) $$s $(bindir)/backup-$$s; done
+               $(INSTALL_SHARE) $(SHAREFILES) $(sharedir)
+
+clean:
+               rm -f *~ ./#*#
+
+distclean realclean:   clean
+               rm -f $(CTARGETS)
index ab2dcd6..fac60a9 100755 (executable)
@@ -26,7 +26,7 @@
 # incremental dumps or listed as exceptions.
 
 BEGIN {
-    $etc= '/etc/backup';
+    $etc= '/etc/chiark-backup';
     require "$etc/settings.pl";
     require 'backuplib.pl';
 }
index c143bd8..a114a18 100755 (executable)
@@ -22,8 +22,8 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-cd /var/local/backup
-PATH=/usr/local/lib/backup:$PATH export PATH
+cd /var/lib/chiark-backup
+PATH=/usr/lib/chiark-backup:$PATH export PATH
 
 if [ "x$1" != test ]; then
        stty sane
index dddb343..c25acc0 100755 (executable)
@@ -23,7 +23,7 @@
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 BEGIN {
-    $etc= '/etc/backup';
+    $etc= '/etc/chiark-backup';
     require "$etc/settings.pl";
     require 'backuplib.pl';
 }
index fc20b3a..b3c1f70 100755 (executable)
@@ -28,7 +28,7 @@
 # includes ID and function).
 
 BEGIN {
-    $etc= '/etc/backup';
+    $etc= '/etc/chiark-backup';
     require "$etc/settings.pl";
     require 'backuplib.pl';
 }
index 9866f09..3b09433 100644 (file)
@@ -34,9 +34,9 @@ The three tarfiles in this directory should go in the following
 places (the paths can probably be configured/hacked, but this is
 where they are on my system and on chiark):
 
-etc.tgz : /etc/backup/
+etc.tgz : /etc/chiark-backup/
 lib.tgz : /usr/local/lib/backup/
-var.tgz : /var/local/backup/
+var.tgz : /var/lib/chiark-backup/
 
 NOTE: these versions are not those used on chiark; they
 are somewhat modified by me (couple of extra features and
@@ -48,7 +48,7 @@ them except maybe last-tape (which you want to change anyway).
 You'll also need to recompile readbuffer and writebuffer unless
 you're using SPARClinux :->
 
-Contents of /etc/backup/:
+Contents of /etc/chiark-backup/:
 warnings.*  : files defining how many warnings you get as the
 system is brought down to do backups. The defaults are fine.
 settings.pl : generic config file: in particular, the name of 
index 69adcb4..ed47752 100755 (executable)
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 set -e
-cd /var/local/backup
+cd /var/lib/chiark-backup
 
-if test -f "/etc/backup/tape.$1"
+if test -f "/etc/chiark-backup/tape.$1"
 then
        echo "$1" >really-TAPEID
        echo "Will assume tape is $1 unless I discover otherwise."
 else
+       if [ "x$1" != x ]; then echo "Tape $1 not found."; fi
        echo "Will only use tape if it has a TAPEID."
        rm -f really-TAPEID
 fi
index ec03c6a..f389a77 100644 (file)
 
 #include <sys/time.h>
 #include <sys/types.h>
+#include <sys/mman.h>
 #include <assert.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
 
-#define BUFFER 16*1024*1024
+#ifndef RWBUFFER_SIZE_MB
+#define RWBUFFER_SIZE_MB 16
+#endif
+
+#define BUFFER (RWBUFFER_SIZE_MB*1024*1024)
 #define WAITEMPTY ((BUFFER*1)/4)
 
 static inline int min(int a, int b) { return a<=b ? a : b; }
index b503f91..0c3752f 100644 (file)
@@ -1,9 +1,9 @@
-# configuration, for putting in /etc/backup
+# configuration, for putting in /etc/chiark-backup
 
-chdir '/var/local/backup' or die $!;
-push(@INC,'/usr/local/lib/backup');
-$ENV{'PATH'} =~ s,^/usr/local/lib/backup:/usr/local/bin:,,;
-$ENV{'PATH'}= '/usr/local/lib/backup:/usr/local/bin:'.$ENV{'PATH'};
+chdir '/var/lib/chiark-backup' or die $!;
+push(@INC,'/usr/lib/chiark-backup');
+$ENV{'PATH'} =~ s,^/usr/lib/chiark-backup,,;
+$ENV{'PATH'}= '/usr/lib/chiark-backup:'.$ENV{'PATH'};
 
 # This sets both blocksizes to 512b. Note that both must be the
 # same if using the zftape floppy tape driver, since that requires
index 76f68b4..8372ffa 100755 (executable)
@@ -23,7 +23,7 @@
 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 # Expects a single (possibly empty) argument X which is used to select
-# a file /etc/backup/warnings.X. This file will contain lines like:
+# a file /etc/chiark-backup/warnings.X. This file will contain lines like:
 # T 300 "in 10 minutes"
 # T 240 "in 5 minutes"
 # T 45 "in 1 minute"
@@ -36,7 +36,7 @@
 #   takedown now                 no warning at all
 
 set -e
-cd /etc/backup
+cd /etc/chiark-backup
 
 host="`hostname`" || true
 
index d631869..f006b7a 100755 (executable)
@@ -32,7 +32,7 @@
 sub rewind();
 sub stopandsay(@);
 
-$etc='/etc/backup';
+$etc='/etc/chiark-backup';
 require "$etc/settings.pl";
 require 'backuplib.pl';
 
@@ -118,7 +118,7 @@ if ($ftype =~ /POSIX tar/) {
 # Now back up so we can read the file again properly
 #system "mt -f $ntape bsf 1"; $? and stopandsay "couldn't backspace tape: $?";
 
-system "dd if=$ntape ibs=$blocksizebytes | /usr/local/lib/backup/readbuffer | $reader";
+system "dd if=$ntape ibs=$blocksizebytes | readbuffer | $reader";
 $? and stopandsay "listing failed: $?";
 
 # All's well, stop here.
index bb1d26f..aaff8d7 100644 (file)
 #include <errno.h>
 #include <unistd.h>
 
-#define BUFFER 16*1024*1024
+#ifndef RWBUFFER_SIZE_MB
+#define RWBUFFER_SIZE_MB 16
+#endif
+
+#define BUFFER (RWBUFFER_SIZE_MB*1024*1024)
 #define WAITFILL ((BUFFER*3)/4)
 
 static inline int min(int a, int b) { return a<=b ? a : b; }
@@ -49,16 +53,16 @@ static void nonblock(int fd) {
 int main(int argc, const char *const *argv) {
   static unsigned char buf[BUFFER];
   
-  if (argv[1]) {
-    fputs("readbuffer: no arguments allowed\n", stderr);
-    exit(-1);
-  }
-
   unsigned char *wp, *rp;
   int used,r,writing,seeneof;
   fd_set readfds;
   fd_set writefds;
 
+  if (argv[1]) {
+    fputs("readbuffer: no arguments allowed\n", stderr);
+    exit(-1);
+  }
+
   used=0; wp=rp=buf; writing=0; seeneof=0;
   nonblock(0); nonblock(1);
   while (!seeneof || used) {
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..21910a2
--- /dev/null
@@ -0,0 +1,24 @@
+Source: chiark-utils
+Section: admin
+Priority: extra
+Maintainer: Ian and others <chiark-utils-maint@davenant.greenend.org.uk>
+Standards-Version: 2.1.1.0
+
+Package: chiark-backup
+Architecture: all
+Depends: chiark-rwbuffer
+Description: backup system for small systems and networks
+ These are the backup scripts used by chiark.greenend.org.uk and other
+ systems belonging to the Sinister Greenend Organisation.  Features:
+  * Suitable for single systems and small networks.
+  * Reasonably simple; they do what you tell it to.
+  * Hard failures when individual systems fail, to encourage fixing !
+ If you have a larger site you may wish to look at Amanda.
+
+Package: chiark-rwbuffer
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: readbuffer/writebuffer: prevents tape drive seesawing, etc.
+ readbuffer and writebuffer: programs for reading input from devices,
+ and writing output to, which don't like constant stopping and
+ starting, such as tape drives and audio playback devices.
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..5c5ea51
--- /dev/null
@@ -0,0 +1,97 @@
+#!/usr/bin/make -f
+
+package=       chiark-utils
+packages_indep=        chiark-backup chiark-rwbuffer
+packages_arch= chiark-backup chiark-rwbuffer
+packages=      $(packages_indep) $(packages_arch)
+
+cwd=   $(shell pwd)
+d=     $(cwd)/debian
+t=     $d/tmp
+
+build:
+       $(checkdir)
+       $(MAKE) -C backup all
+       touch build
+
+clean:
+       $(checkdir)
+       -rm -f build
+       -$(MAKE) -i distclean || $(MAKE) -f Makefile.in distclean
+       -rm -rf *~ debian/tmp debian/*~ debian/files* debian/substvars*
+
+binary-prep:
+       $(checkdir)
+       -rm -rf debian/tmp*
+       -#
+       set -e; for p in $(packages); do \
+               install -d $t/$$p/DEBIAN $t/usr/share/doc/$$p; \
+               cp debian/copyright debian/changelog \
+                       $t/$$p/usr/share/doc/$$p; \
+               ln -s changelog.gz $t/usr/share/doc/$$p/changelog.Debian.gz; \
+               gzip -9v $t/usr/share/doc/$$p/changelog; \
+               done
+       -#
+       $(MAKE) -C backup install prefix=$t/chiark-backup
+       -#
+       install -d $t/chiark-rwbuffer/usr/bin
+       cd $t/chiark-backup/usr/bin && \
+        mv readbuffer writebuffer $t/chiark-rwbuffer/usr/bin
+
+binary-hook-chiark-backup:
+binary-hook-chiark-rwbuffer:
+
+binary-one:
+       dpkg-gencontrol -p$p -O$t/$p -Tdebian/sv-$p
+       chown -R root.root debian/tmp
+       chmod -R g-ws debian/tmp
+       debian/rules binary-hook-$p
+       dpkg --build $t/$p ..
+
+binary-indep:  checkroot build binary-prep
+       install -d debian/tmp/var/run/$(package)/
+       cp debian/{postinst,prerm,postrm,conffiles} debian/tmp/DEBIAN/.
+       cp debian/initd debian/tmp/etc/init.d/userv
+       chmod +x debian/tmp/DEBIAN/{postinst,prerm,postrm}
+       chmod +x debian/tmp/etc/init.d/userv
+       $(MAKE) LDFLAGS=-s INSTALL_PROGRAM='install -c -s' \
+               prefix=debian/tmp/usr etcdir=debian/tmp/etc \
+               docdir=debian/tmp/usr/doc/userv \
+               install install-doc
+       cp debian/copyright debian/tmp/usr/doc/$(package)/.
+       cp debian/changelog debian/tmp/usr/doc/$(package)/changelog
+       cp README debian/tmp/usr/doc/$(package)/README.upstream
+       cp system.default system.override debian/tmp/usr/doc/$(package)/examples
+       ln -s changelog.gz debian/tmp/usr/doc/$(package)/changelog.Debian.gz
+       gzip -9v debian/tmp/usr/doc/$(package)/changelog debian/tmp/usr/man/man1/*.1
+       rm debian/tmp/usr/doc/userv/*.ps
+       dpkg-shlibdeps daemon client
+       dpkg-gencontrol
+       chown -R root.root debian/tmp
+       chmod -R g-ws debian/tmp
+       chmod 700 debian/tmp/var/run/userv
+       dpkg --build debian/tmp ..
+       $(checkdir)
+
+binary-arch:   checkroot build binary-prep
+       $(checkdir)
+       rm debian/tmp/usr/doc/userv/*.ps
+       dpkg-shlibdeps -Tdebian/sv-chiark-backup $t/chiark-backup/usr/bin/*
+       set -e; for p $(packages_arch); do debian/rules binary-one p=$$p; done
+
+define checkdir
+       test -f backup/writebuffer.c
+endef
+
+# Below here is fairly generic really
+
+binary:                binary-indep binary-arch
+
+source diff:
+       @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+checkroot:
+       $(checkdir)
+       test root = "`whoami`"
+
+.PHONY: binary binary-arch binary-indep clean checkroot