From: ianmdlvl Date: Sun, 7 Oct 2001 19:00:58 +0000 (+0000) Subject: Working on debianisation and packaging. X-Git-Tag: debian_version_2_0_0~10 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=chiark-utils.git;a=commitdiff_plain;h=460e29f1c9232dafbdc161bf67d3e956d23eeb6b;ds=sidebyside Working on debianisation and packaging. --- diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.cvsignore @@ -0,0 +1 @@ +build diff --git a/backup/.cvsignore b/backup/.cvsignore new file mode 100644 index 0000000..cf6c95c --- /dev/null +++ b/backup/.cvsignore @@ -0,0 +1,2 @@ +readbuffer +writebuffer diff --git a/backup/Makefile b/backup/Makefile index 59a3c11..59cdfa1 100644 --- a/backup/Makefile +++ b/backup/Makefile @@ -21,5 +21,43 @@ # 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) diff --git a/backup/checkallused b/backup/checkallused index ab2dcd6..fac60a9 100755 --- a/backup/checkallused +++ b/backup/checkallused @@ -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'; } diff --git a/backup/driver b/backup/driver index c143bd8..a114a18 100755 --- a/backup/driver +++ b/backup/driver @@ -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 diff --git a/backup/full b/backup/full index dddb343..c25acc0 100755 --- a/backup/full +++ b/backup/full @@ -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'; } diff --git a/backup/increm b/backup/increm index fc20b3a..b3c1f70 100755 --- a/backup/increm +++ b/backup/increm @@ -28,7 +28,7 @@ # includes ID and function). BEGIN { - $etc= '/etc/backup'; + $etc= '/etc/chiark-backup'; require "$etc/settings.pl"; require 'backuplib.pl'; } diff --git a/backup/iwjbackup.txt b/backup/iwjbackup.txt index 9866f09..3b09433 100644 --- a/backup/iwjbackup.txt +++ b/backup/iwjbackup.txt @@ -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 diff --git a/backup/loaded b/backup/loaded index 69adcb4..ed47752 100755 --- a/backup/loaded +++ b/backup/loaded @@ -23,13 +23,14 @@ # 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 diff --git a/backup/readbuffer.c b/backup/readbuffer.c index ec03c6a..f389a77 100644 --- a/backup/readbuffer.c +++ b/backup/readbuffer.c @@ -29,13 +29,18 @@ #include #include +#include #include #include #include #include #include -#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; } diff --git a/backup/settings.pl b/backup/settings.pl index b503f91..0c3752f 100644 --- a/backup/settings.pl +++ b/backup/settings.pl @@ -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 diff --git a/backup/takedown b/backup/takedown index 76f68b4..8372ffa 100755 --- a/backup/takedown +++ b/backup/takedown @@ -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 diff --git a/backup/whatsthis b/backup/whatsthis index d631869..f006b7a 100755 --- a/backup/whatsthis +++ b/backup/whatsthis @@ -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. diff --git a/backup/writebuffer.c b/backup/writebuffer.c index bb1d26f..aaff8d7 100644 --- a/backup/writebuffer.c +++ b/backup/writebuffer.c @@ -34,7 +34,11 @@ #include #include -#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 index 0000000..21910a2 --- /dev/null +++ b/debian/control @@ -0,0 +1,24 @@ +Source: chiark-utils +Section: admin +Priority: extra +Maintainer: Ian and others +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 index 0000000..5c5ea51 --- /dev/null +++ b/debian/rules @@ -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