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 59a3c11185d34041b854036f3c0aa9d13d93c96a..59cdfa1e4b135b9a99c078a52eab9c49878830c5 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 ab2dcd63d8de5999461b174284f3549892bdd776..fac60a9c0159e4ba401bdd85da0ceb5a55b3e555 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 c143bd897c141453c602ef58c53f9f141be43a73..a114a183c9631784b5454f11f27dd66d76b773d5 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 dddb343be2b12ed0fc5b520f62d4b8ecefd56b57..c25acc0861762e5c81c4e84784a0cf6c009538e4 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 fc20b3a32b85e6ef49114cabdd337d2c8db70099..b3c1f7019d57e2dd42feeb1fea506ecab926c2c0 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 9866f0969d1aea147b1a90d70ba9b4ce802690fd..3b09433d185b84440c2eb3f35d57f6818553590b 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 69adcb4dfa2f9c1034f1b6d6c4a792c7c7eb17f6..ed47752956dc68c51e038a7c6609d9d9a8872283 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 ec03c6a390a08022529e12d3727b287e3327718b..f389a77c3fce8bf6319bc4a2c6698dfe28e68dc9 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 b503f917ce5915abb916bcd9d4f36305b39267f6..0c3752f88f5a28c4abe0cbb618d6e6d5524a508f 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 76f68b43e18eb9a354dcd65e45ed2e0aba696389..8372ffab0f20845da086714d04ffc1bcabe87656 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 d631869aecac90c45262ea47b677269c2ea615ab..f006b7a2e912454c4336cce3ca098eb76a4016eb 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 bb1d26f71e358e0d4c369435bdd956fb97f4bdb3..aaff8d7859d48a30899fa93d21a3cf3158591597 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