apt-move/0000700000175000017500000000000010535430240014036 5ustar herbertgreathan00000000000000apt-move/getdist.awk0000600000175000017500000000113007640015425016211 0ustar herbertgreathan00000000000000# getdist --- Get Debian component name from a section string. # # Copyright (c) 2002 Herbert Xu # $Id: getdist.awk,v 1.4 2003/03/25 09:02:13 herbert Exp $ function getdist(section, dist, a) { if (section in _getdist) { return _getdist[section] } dist = section ldist = tolower(dist) if (match(ldist, /^non-us\/[^\/]*/)) { dist = "non-US" substr(dist, 7, RLENGTH - 6) } else if (ldist == "non-us") { dist = "non-US/main" } else if (match(dist, /^[^\/]*\//)) { dist = substr(dist, 1, RLENGTH - 1) } else { dist = "main" } return _getdist[section] = dist } apt-move/herbert.binary.local0000600000175000017500000000266507640262457020023 0ustar herbertgreathan00000000000000# SAMPLE .local file # # This file creates a suite called herbert with the latest versions of # the following packages in it. I do this so that they are kept in the # archive even before they hit unstable. apt-move optional admin apt-move ash optional shells dash cramfsprogs - - cramfs dash optional shells dash dash-udeb - - dash dosemu optional contrib/otherosfs dosemu gettyps - non-free/comm gettyps idecrypt - - pidentd initrd-tools optional utils initrd-tools kernel-doc-2.2.22 - - kernel-source-2.2.22 kernel-doc-2.4.19 - - kernel-source-2.4.19 kernel-source-2.2.22 - - kernel-source-2.2.22 kernel-source-2.4.19 - - kernel-source-2.4.19 lesstif-bin - - lesstif1-1 lesstif-dev - - lesstif1-1 lesstif-doc - - lesstif1-1 lesstif1 - - lesstif1-1 lesstif2 - - lesstif1-1 lesstif2-dev - - lesstif1-1 nfs-user-server extra net nfs-user-server nntpcache optional non-free/news nntpcache nntpcache-dev-doc extra non-free/news nntpcache newsgate - non-free/news newsgate pidentd - - pidentd pidentd-des - - pidentd pump - - pump pump-udeb - - pump rdate - - rdate rdist - - rdist rsh-client - - netkit-rsh rsh-server - - netkit-rsh rwho - - netkit-rwho rwhod - - netkit-rwho telnet standard net netkit-telnet telnetd optional net netkit-telnet traceroute optinoal net traceroute ugidd optional net nfs-user-server xfonts-dosemu optional contrib/x11 dosemu apt-move/get30000600000175000017500000000207007551536634014646 0ustar herbertgreathan00000000000000# $Id: get3,v 1.4 2002/10/11 12:01:32 herbert Exp $ BEGIN { type = ARGV[1] ARGC = 1 map["package"] = "" map["priority"] = "" map["section"] = "" map["version"] = "" map["source"] = "" map["task"] = "-" } { dist = $1 file = $2 while ((val = getline < file) > 0) { if (/^$/) { section = map["section"] if (dist == "-") { key = getdist(section) } else { key = dist } package = map["package"] if (type == "binary") { source = map["source"] map["source"] = "" if (source == "") { source = package } key = key "_" source "_" package task = map["task"] " " map["task"] = "-" } else { key = key "_" package } print \ key " " \ map["priority"] " " section " " \ task map["version"] continue } if (/^[ \t]/) { continue } x = index($0, ":") if (!x) { continue } field = tolower(substr($0, 1, x - 1)) if (field in map) { split(substr($0, x + 1), a, " ") map[field] = a[1] } } if (val < 0) { print "Failed to read " file > "/dev/stderr" exit 1 } } apt-move/ChangeLog.O0000600000175000017500000004670110341757725016036 0ustar herbertgreathan00000000000000apt-move (4.2.24) unstable; urgency=low * Added -a option (closes: #242272). * Allow get with no index files if -f is used. * Use APTMOVE_SCRIPTS instead of SCRIPTS. -- Herbert Xu Mon, 23 May 2005 20:16:41 +1000 apt-move (4.2.22) unstable; urgency=low * Removed remaining rsync references (closes: #232927). * Fixed typo in apt-move(8) manual (Martin Koeppe). * Removed ARCHS references in apt-move(8) manual (Martin Koeppe). * Fixed code name symlink in apt-move(8) manual (Martin Koeppe). * Check list* errors in runmirror/runsync (Daniel Haude). * Canonicalise DIST at start-up (Daniel Haude). * Do not move files under a subdirectory of FILECACHE (closes: #240328). * fetch: Use iostream instead of iostream.h. -- Herbert Xu Sat, 27 Mar 2004 09:54:05 +1100 apt-move (4.2.21) unstable; urgency=low * Implemented new value /all/ for APTSITES. * Set default APTSITES to /all/ (closes: #227292). * Make sure that ocmd is open in move4 (closes: #227095). * Added .udeb to all checks for the .deb suffix. -- Herbert Xu Sat, 14 Feb 2004 10:13:10 +1100 apt-move (4.2.20) unstable; urgency=low * Added note about suite name changes in README (closes: #218263). * Added note on apt-move.conf syntax in manual. * Trap errors in apt-move.conf (closes: #220720). * Return a sensible error if MOVE3 fails in movefiles. -- Herbert Xu Sat, 13 Dec 2003 19:28:26 +1100 apt-move (4.2.19) unstable; urgency=low * Set LC_NUMERIC to C (closes: #205275). * Documented incorrect Section header problem in README. -- Herbert Xu Sat, 11 Oct 2003 21:55:55 +1000 apt-move (4.2.18) unstable; urgency=low * Fixed orig.tar.gz symlink bug where there are no files (closes: #203172). * Removed references to gz in make_pkg_files message (closes: #203587). -- Herbert Xu Sat, 20 Sep 2003 16:30:02 +1000 apt-move (4.2.17) unstable; urgency=low * Delete old symlinks in source downloading directory (closes: #196880). * Fixed typo in del1 (Gerard MacNeil, closes: #200362). * Clarified meaning of skipping in apt-move(8) (closes: #202832). * Added warning if APTSITES entry does not exist (closes: #202558). * Create orig.tar.gz symlinks when mirroring source (closes: #201641). -- Herbert Xu Sun, 27 Jul 2003 14:18:33 +1000 apt-move (4.2.16) unstable; urgency=low * Clarified meaning of DIST in apt-move(8). * Sort keys after filling in blanks in make_pkg_list (Dub Spencer, closes: #189335). -- Herbert Xu Sat, 31 May 2003 22:16:23 +1000 apt-move (4.2.15) unstable; urgency=low * Bail if nothing in APTSITES exists. * Documented that move will copy obsolete packages (closes: #191223). * Documented that delete will delete dangling index files (closes: #188583). * Removed gcc-2.95 setting (closes: #192412). -- Herbert Xu Sat, 17 May 2003 10:34:42 +1000 apt-move (4.2.14) unstable; urgency=low * Added example binary.local file. * Documented inadequecy of the DIST setting when mirroring. * Delete index files with no or missing package files. * Use normal g++ on hppa. -- Herbert Xu Mon, 31 Mar 2003 22:06:57 +1000 apt-move (4.2.13) unstable; urgency=low * Fixed regexp in getdist.awk that broke contrib/non-free (closes: #185645). * Force old gcc until apt is updated (closes: #182203). -- Herbert Xu Tue, 25 Mar 2003 20:31:17 +1100 apt-move (4.2.12) unstable; urgency=low * Added missing existence test in make_release (closes: #182378). * Work around some broken package section headers. -- Herbert Xu Sat, 1 Mar 2003 11:55:26 +1100 apt-move (4.2.11) unstable; urgency=low * Fixed source package breakage with CONTENTS. -- Herbert Xu Sun, 23 Feb 2003 17:39:30 +1100 apt-move (4.2.10) unstable; urgency=low * Improved manual entry of PKGCOMP. * Accept empty master files in checklist. * Fixed handling of non-US packages in foo-updates. * Do not generate Release files for debian-installer. * Generate overall Release files. * Added optional support for Contents files (closes: #129961). -- Herbert Xu Sat, 22 Feb 2003 21:56:59 +1100 apt-move (4.2.9) unstable; urgency=low * Use readlink -f instead of realpath. * Dropped compatibility dependencies due to stat -L (closes: #174461). * Fixed broken exclude function (Chuan-kai Lin, closes: #174457). -- Herbert Xu Tue, 31 Dec 2002 07:38:31 +1100 apt-move (4.2.8) unstable; urgency=low * Remove duplicate entries from *.arch.* files. * Call stat with -L. -- Herbert Xu Fri, 8 Nov 2002 20:24:58 +1100 apt-move (4.2.7) unstable; urgency=low * Unset LC_ALL and replace it with individual LC macros (closes: #163931). * Added support for suite aliases. * Made updates components closer to the real thing. * Added support for udebs. * Updated short description to mention package pools. * Added option q to synopsis in usage. * Added option d to override DIST. * Added missing dependency on bc (closes: #166485). * Fixed sort order of letters vs. non-letters in version numbers. -- Herbert Xu Tue, 29 Oct 2002 19:01:01 +1100 apt-move (4.2.6) unstable; urgency=low * Fsck now works properly on new archives. * Fixed off-by-one bug when fscking sources (closes: #164729). * Set LC_COLLATE to C (closes: #163931). * Calculate best versions for architectures individually in move6. -- Herbert Xu Sat, 19 Oct 2002 19:18:29 +1000 apt-move (4.2.5) unstable; urgency=low * Ignore symlinks when converting old archives (closes: #163931). -- Herbert Xu Sun, 13 Oct 2002 22:05:16 +1000 apt-move (4.2.4) unstable; urgency=low * Clarified documentation of DIST variable. * Do not create version file if dists or pool exists. * Do not uniq in createidx since this preempts get2 later on (closes: #164311). * Removed empty version check from get2. * Put mirrored source files in .apt-move/archive. * Made move3 succeed when source is missing but destination exists (closes: #164361). -- Herbert Xu Sat, 12 Oct 2002 22:31:16 +1000 apt-move (4.2.3) unstable; urgency=low * Attempt to diagnose buggy shells that bombs out on EINTR. * Handle non-existant Release files. * Use dash until #164134 is fixed. * Fixed default LISTSTATE in manual page (Jochen Voss, closes: #164294). -- Herbert Xu Fri, 11 Oct 2002 22:11:37 +1000 apt-move (4.2.2) unstable; urgency=low * Mirror commands now bail out if DIST is set incorrectly. * Fixed key calculation for local source file. * Fixed binkey expression in proc_idx_diff. * Deal with GPG headers in dsc files. * Work around bash bugs with background jobs (closes: #164001). * Chop result of realpath in move3 (closes: #163786). -- Herbert Xu Thu, 10 Oct 2002 21:54:11 +1000 apt-move (4.2.1) unstable; urgency=low * Removed dependency on textutils since we no longer use paste -f. * Added stat as alternative to fileutils for woody compatibility. * Handle empty directories in .apt-move/dists. * Allow deletion index files even when there are no package files. * Dropped unnecessary fifo from domove (closes: #163756). * Use realpath to resolve links in move3 (closes: #163786). -- Herbert Xu Tue, 8 Oct 2002 22:18:36 +1000 apt-move (4.2.0) unstable; urgency=low * Store files in package pools (closes: #80191, #106633, #116966). * Optionally Generate uncompressed and bzipped Packages and Sources files (closes: #81513). * Added COPYONLY (closes: #96556). * Generate our own index files (closes: #130485). * Check whether mirroring is neccesary ourselves (closes: #147920). * Only preserve timestamps when calling cp in move3 (closes: #155667). * Call getout when configuration file is missing (closes: #152663). * Only create directories that have packages in them (closes: #80464, #80466). * Generate Release files (closes: #100623). -- Herbert Xu Mon, 7 Oct 2002 19:12:22 +1000 apt-move (4.1.22) unstable; urgency=low * Call cp with -p when falling back to it (closes: #143283). * Expand LOCALDIR inside the trap (closes: #143494). -- Herbert Xu Sun, 28 Apr 2002 12:06:35 +1000 apt-move (4.1.21) unstable; urgency=low * Unset CDPATH (closes: #140119). * Fixed exclusion processing when mirroring. * Added exclusion processing when deleting. -- Herbert Xu Sun, 14 Apr 2002 17:23:07 +1000 apt-move (4.1.20) unstable; urgency=low * Ignore blank lines in exclude file (closes: #136089). * Fixed path names in apt-move manual (closes: #80467). * Only chown files if chowning .archive succeeds (closes: #129122). -- Herbert Xu Sat, 2 Mar 2002 18:56:42 +1100 apt-move (4.1.19) unstable; urgency=low * Added pathnames in expanddsc so that files are deleted (closes: #117014). * Make everything owned by root if possible (closes: #117015). * Fixed typos (Eric Van Buggenhaut, me, closes: #120331). -- Herbert Xu Sat, 1 Dec 2001 23:20:09 +1100 apt-move (4.1.18) unstable; urgency=low * Fixed gcc-3.0 compilation errors (closes: #115305) -- Herbert Xu Sat, 13 Oct 2001 10:45:01 +1000 apt-move (4.1.17) unstable; urgency=low * Recompiled with new apt (closes: #109554) * Fixed expanddsc for weird dsc files (closes: #104180). -- Herbert Xu Tue, 28 Aug 2001 19:52:52 +1000 apt-move (4.1.16) unstable; urgency=low * Get the highest available version instead of the candidate version (closes: #96072). -- Herbert Xu Thu, 3 May 2001 21:50:48 +1000 apt-move (4.1.15) unstable; urgency=low * Rebuilt with apt 0.5.2. -- Herbert Xu Tue, 6 Mar 2001 22:16:34 +1100 apt-move (4.1.14) unstable; urgency=low * Fixed build problem with apt 5 (loic.lefort, #87008). -- Herbert Xu Fri, 23 Feb 2001 20:06:03 +1100 apt-move (4.1.13) unstable; urgency=low * Make fsck delete any {Packages, Sources}[.gz] files (closes: #76288). * Added -c option to use an alternative configuration file. * Added the commands listbin, listsrc, mirrorbin and mirrorsrc (closes: #78675). -- Herbert Xu Sun, 17 Dec 2000 16:52:34 +1100 apt-move (4.1.12) unstable; urgency=low * Added more pointers for the need to list apt-move in /etc/sources.list, per suggestions from Jochen Pawletta. * Debian control file field names are case-insensitive. Thanks to Petr Vandrovec for reporting it, though Brandon had something to do with it as well. -- Herbert Xu Wed, 1 Nov 2000 22:20:54 +1100 apt-move (4.1.11) unstable; urgency=low * Fixed a typo in procsrc() where the wrong directory is used. This broke the mirroring of source packages. * Work around parser bug in bash. -- Herbert Xu Sun, 15 Oct 2000 07:37:53 +1100 apt-move (4.1.10) unstable; urgency=low * Fixed typo that broke the source field (closes: #72986). -- Herbert Xu Thu, 5 Oct 2000 19:29:28 +1100 apt-move (4.1.9) unstable; urgency=low * Use local temporary files instead of global ones (closes: #67413). * Documented the need to list apt-move in /etc/sources.list. -- Herbert Xu Wed, 19 Jul 2000 13:01:33 +1000 apt-move (4.1.8) unstable; urgency=low * Treat multiline fields correctly. -- Herbert Xu Mon, 17 Jul 2000 18:54:38 +1000 apt-move (4.1.7) unstable; urgency=high * Replaced $DIST in dodelete() by $dist. This caused all files to be deleted if they are not available in the current distribution. * Use getopt(3) instead of GetOpt from libg++ (closes: #66646). -- Herbert Xu Mon, 3 Jul 2000 21:15:26 +1000 apt-move (4.1.6) unstable; urgency=high * Replaced $DIST in dopackages() by $dist. * Fixed incorrect invocation of xargs (introduced in 4.1.5) which caused files to be deleted rather than moved. -- Herbert Xu Sun, 2 Jul 2000 21:19:26 +1000 apt-move (4.1.5) unstable; urgency=low * Fixed boundary cases with move1 and dpkg-scan*. * Added build-time dependency on libg++-dev (closes: #66515). * Fixed a bug in getfile() where local packages weren't being added to $DIST.binary.$ARCH, which will cause them to be deleted later on. -- Herbert Xu Sat, 1 Jul 2000 23:11:06 +1000 apt-move (4.1.4) unstable; urgency=low * Added a stderr redirection for tee in dodeleteobsoleteind() as join may exit early. * Fixed runsync() so that it only fetches packages marked "install" (closes: #66444). * Use fetch -t and apt-get --print-uris in runsync() and runmirror() when -t is used. This will show what is really going to be fetched. -- Herbert Xu Thu, 29 Jun 2000 21:09:05 +1000 apt-move (4.1.3) unstable; urgency=low * The removal of .archive needed a -f since it may not exist. * When moving files fetched by apt-get -d source, skip all symbolic links as they will be ignored later on anyway. -- Herbert Xu Tue, 27 Jun 2000 22:02:55 +1000 apt-move (4.1.2) unstable; urgency=low * Remove .archive before trying to create it (closes: #66262, #66282). -- Herbert Xu Mon, 26 Jun 2000 22:03:33 +1000 apt-move (4.1.1) unstable; urgency=low * Added build-time dependency on debhelper (closes: #65879). * Fixed runmirror() and runsync() when there is no exlucde file. Spotted by Brian Moore. * Fix bad filenames in dofsck() as well (closes: #65931). * Added STRICTMOVE which when set causes packages whose version differs from the value in the master file to be skipped when moving. * Use readlink instead of realpath. * Don't complain if index files don't exist in dodeleteobsoletepkg() (closes: #65970). * No longer complains about missing Source files when PKGTYPE is set to binary in getfiles() (closes: #65972, #66128). * Document how local files should be treated (closes: #66011). * Check for empty dirlist in dodelete(). * No longer complains about missing source master file when PKGTYPE is set to binary in checklist() (closes: #66047). * Fixed incorrect test in dodeleteobsoletepkg(). * Made paths absolute in procsrc(). Both of these were spotted and fixed by Petr Vandrovec. * Fixed typo in manual page, spotted by Jarkko Niemi. -- Herbert Xu Sun, 25 Jun 2000 19:25:32 +1000 apt-move (4.1) unstable; urgency=low * Packages in binary-all are now removed at the same time as when all symbolic links to them disappear. * Added dependency on dwww. * Fixed a syntax error in dofsck() (closes: #65846). * Fixed an error in checklist(). * Replaced character classes from all awk scripts to work with mawk. * Fixed ancient file creation in postinst (closes: #65821). -- Herbert Xu Mon, 19 Jun 2000 09:31:34 +1000 apt-move (4.0) unstable; urgency=low * New maintainer. * Completely rewritten. Changes too numerous to list here, read /usr/share/doc/apt-move/README[.gz] for details (closes: #53656, #55838, #61798, #63452, #48044, #52076, #55993, #56246, #57337, #57823, #62973, #65775). -- Herbert Xu Sat, 17 Jun 2000 21:26:20 +1000 apt-move (3.0-13) unstable; urgency=low * Fixed a typo which caused the removal of obsolete source packages to fail. closes: Bug#54684 -- Gregory T. Norris Tue, 11 Jan 2000 15:11:04 -0600 apt-move (3.0-12) unstable; urgency=low * In certain circumstances the MAXDELETE option was handled incorrectly, and would effectively double the specified threshold. Fixed. * The original author's ``cleandebs'' script has been merged. closes: Bug#50073 -- Gregory T. Norris Mon, 27 Dec 1999 18:07:11 -0600 apt-move (3.0-11) unstable; urgency=low * Cleanup of empty directories within the local mirror will be restricted to $LOCALDIR/dists/$DIST/ and below. closes: Bug#52636 * Debfiles within the apt cache are no longer renamed using dpkg-name. Instead the new names are determined using a sed pattern, and the files are only renamed when being moved to the local mirror. closes: Bug#51506, Bug#51606 -- Gregory T. Norris Sun, 26 Dec 1999 17:53:46 -0600 apt-move (3.0-10) unstable; urgency=low * If a section named ``local'' exists within the local mirror (i.e. dists/unstable/local), it will be silently ignored. closes: Bug#51550 * Fixed a bug in which tracking a distribution by name (i.e. ``potato'' rather than ``unstable'') would generate an error stating that the requested DIST did not exist. closes: Bug#52152 * Fixed a bug which could cause apt-move to attempt to remove $LOCALDIR, if it contained no visible files. -- Gregory T. Norris Mon, 6 Dec 1999 17:19:45 -0600 apt-move (3.0-9) unstable; urgency=low * Fixed a nasty bug which could cause entire architectures to be removed when multiple systems of different architectures shared the same local mirror. closes: Bug#50900 * Some mirrors integrate the non-US tree under /debian rather than /debian-non-US, which is the usual location. Both cases are handled now. closes: Bug#50699 * Tempfiles should always be cleaned up properly now. closes: Bug#51215 -- Gregory T. Norris Tue, 23 Nov 1999 04:44:35 -0600 apt-move (3.0-8) unstable; urgency=low * rsync updates. closes: Bug#49815 * Updates to the ``rsync optional'' handling. closes: Bug#49733 * Added information on using proxies to ``README.Debian''. closes: Bug#48578 * Miscellaneous list-generation fixes. closes Bug#49760, Bug#49861 -- Gregory T. Norris Wed, 17 Nov 1999 17:44:52 -0600 apt-move (3.0-7) unstable; urgency=low * Added support for local ``Packages'' files downloaded by apt(8). -- Gregory T. Norris Wed, 3 Nov 1999 16:51:26 -0600 apt-move (3.0-6) unstable; urgency=low * Updates to the SIGINT (^C) handling -- Gregory T. Norris Sun, 31 Oct 1999 10:22:22 -0600 apt-move (3.0-5) unstable; urgency=low * Added SIGINT (^C) handling. closes: Bug#43357 -- Gregory T. Norris Mon, 25 Oct 1999 17:33:02 -0500 apt-move (3.0-4) unstable; urgency=high * Corrected error in relative pathnames, which caused empty directories below the cwd to be deleted. closes: Bug#46956 * Added clarification of rsync version requirement to ``README.Debian''. closes: 46829 -- Gregory T. Norris Fri, 8 Oct 1999 19:52:20 -0500 apt-move (3.0-3) unstable; urgency=low * /etc/cron.weekly/apt-move wasn't registered as a conffile... oopsie. closes: Bug#46323 -- Gregory T. Norris Thu, 30 Sep 1999 17:02:29 -0500 apt-move (3.0-2) unstable; urgency=low * Added sanity checking to the cron script, to allow for a graceful exit if the package has been removed. * Downgraded the Standards Version from 3.0.1 to 2.5.1, since it should be using `logrotate' instead of `savelog' for the higher designation. -- Gregory T. Norris Mon, 30 Aug 1999 05:59:44 -0500 apt-move (3.0-1) unstable; urgency=low * Initial Release. -- Gregory T. Norris Fri, 20 Aug 1999 19:17:35 -0500 apt-move/ChangeLog0000600000175000017500000000124010535427720015620 0ustar herbertgreathan000000000000002006-12-06 Herbert Xu * Release 4.2.27. 2006-12-06 Petr Vandrovec * Handle tildes in version numbers. 2006-01-14 Petr Vandrovec * Added gpg signature support. 2005-11-30 Herbert Xu * Fixed dash reexec bug. * Release 4.2.26. 2005-11-26 Herbert Xu * Removed Debian packaging. * Replace stat(1) with perl(1). * Release 4.2.25. 2005-11-26 Petr Vandrovec * When merging source package indices always use the latest package version. For older ChangeLogs see ChangeLog.O. ChangeLog ends here apt-move/apt-move0000700000175000017500000011014410362074203015516 0ustar herbertgreathan00000000000000#!/bin/sh # # Copyright (c) 1999 Michael Merten # Copyright (c) 1999-2000 Gregory T. Norris # Copyright (c) 2000-2003 Herbert Xu # # License: This script is distributed under the terms of version 2 # of the GNU GPL. See the LICENSE file included with the package. # # $Id: apt-move,v 1.115 2006/01/14 04:05:23 herbert Exp $ # # The apt-move(8) manpage contains the most up-to-date documentation # for this script. Also, see the README file. # # Configuration for this script can be found in /etc/apt-move.conf # # Requires GNU sed. # set -e if [ -z "$APT_MOVE_REEXEC" ] && [ -n "$BASH" ]; then export APT_MOVE_REEXEC=1 if type dash > /dev/null 2>&1; then exec dash $0 "$@" else exec ash $0 "$@" fi fi [ ${CDPATH+1} ] && unset CDPATH if [ ${LC_ALL+1} ]; then export LC_MONETARY="$LC_ALL" export LC_RESPONSE="$LC_ALL" export LC_TIME="$LC_ALL" export LC_MESSAGES="$LC_ALL" unset LC_ALL fi export LC_CTYPE=C export LC_COLLATE=C export LC_NUMERIC=C # set some defaults for conffile items, just in case someone tries to # "clean up" the file ARCH=`dpkg --print-installation-architecture` LOCALDIR=/mirrors/debian DIST=stable PKGTYPE=binary APTSITES= FILECACHE=/var/cache/apt/archives LISTSTATE=/var/lib/apt/lists DELETE=no MAXDELETE=20 COPYONLY=no PKGCOMP=gzip CONTENTS=no GPGKEY= LISTALL= # Remember where we came from. ORIGDIR=$PWD # Global variables. TEST= # test run flag (-t) FORCE= # force delete flag (-f) QUIET= # quite (-q) # GET_BINARY= # binary distribution flag GET_SOURCE= # source distribution flag VERSION=0 FETCH=/usr/lib/apt-move/fetch # crappy replacement for apt-get SCRIPTS=$APTMOVE_SCRIPTS : ${SCRIPTS:=/usr/share/apt-move} awk="awk -f $SCRIPTS/cmpbignum.awk -f $SCRIPTS/cmpversion.awk -f" awk="$awk $SCRIPTS/getdist.awk -f" MOVE3=$SCRIPTS/move3 MOVE4="$awk $SCRIPTS/move4" MOVE5="$awk $SCRIPTS/move5" MOVE6="$awk $SCRIPTS/move6" MOVE7="$awk $SCRIPTS/move7" GET2="$awk $SCRIPTS/get2" GET3="$awk $SCRIPTS/get3" DEL1=$SCRIPTS/del1 PKG1=$SCRIPTS/pkg1 unset awk # End Globals --------------------------------------------------------------- info() { printf "%b\n" "$*" >&3 } showusage() { revision='$Id: apt-move,v 1.115 2006/01/14 04:05:23 herbert Exp $' # display a 'usage' message. cat >&2 <<- EOF $revision Usage: apt-move [-c conffile] [-d dist] [-afqt] COMMAND Commands: get - update your master files from local apt. getlocal - alias of get. fsck - fix broken repositories, use with caution. move - move cache files into mirror tree. movefile - move files specified on the command line. delete - delete obsolete packages. packages - create new local Packages files. update - alias for 'get move delete packages'. local - alias for 'move delete packages'. localupdate - alias for 'getlocal move delete packages'. mirror - update your local mirror from remote site. sync - same as mirror, but only gets packages that you currently have installed on your system. exclude - prints a list of all packages EXCLUDED from the mirror by the .exclude file (ignores -t). listbin - prints lists of packages which can serve as the input to mirrorbin. Takes the arguments mirror, sync, or repo. listsrc - same as listbin, but lists source packages. mirrorbin - same as mirror, but gets the packages specified on stdin. mirrorsrc - same as mirrorbin, but gets source packages. Options: -a Process all packages including those that are unchanged. -c Specify an alternative configuration file. -d Override the DIST setting. -f Override the MAXDELETE setting (use with caution). -q Be quiet; suppress normal output. -t Show what apt-move would do, but do not actually do anything. See the apt-move(8) manpage for further details. EOF exit 64 } apt_move_stat() { perl -lpe '$_ = (stat)[7];' } checklist() { [ -d .apt-move ] || return 24 if [ $GET_BINARY ]; then [ -f .apt-move/binary ] || return 24 fi if [ $GET_SOURCE ]; then [ -f .apt-move/source ] || return 24 fi } checkconf() { local i [ -z "$DIST" ] && getout apt-move 6 case "$PKGTYPE" in binary) GET_BINARY=yes ;; source) GET_SOURCE=yes ;; both) GET_BINARY=yes GET_SOURCE=yes ;; *) getout apt-move 18 esac set -f set +f $PKGCOMP for i in $PKGCOMP; do case "$i" in none | gzip | bzip2) ;; *) getout apt-move 29 ;; esac done case $CONTENTS in [yY]*) CONTENTS=yes ;; *) CONTENTS=no ;; esac case $APTSITES in /all/) APTSITES=[!_]* ;; esac GPGKEY=${GPGKEY:-$SIGNINKEY} } waitall() { for i in $CHILDREN $!; do set +e wait $i status=$? set -e case $status in 0 | 141) ;; *) exit $status ;; esac done unset CHILDREN } sortind() { awk ' { file = $1 n = split(file, a, /[_\/]/) m = 5 dist = a[3] if (n == 10) { dist = dist "/" a[4] m++ } src = a[m] bin = a[m + 2] ver = a[m + 3] arch = a[m + 4] name = dist "_" src (arch == "source" ? "" : "_" bin) print name " " ver " " arch " " $0 } ' | sort } createidx() { local pf pf=$TMPHOME/createidx $GET3 $1 > $pf-tmp < $pf-tmp sort } make_idx_local() { local dir i dist pf type pf=$TMPHOME/make_idx_local dir=$1 type=$2 set *.$type.local if [ $# -eq 1 ] && [ ! -e "$1" ]; then return fi if [ $type = binary ]; then cat <<- \EOF /^#/ || NF == 0 { next } { printf "%s_%s_%s %s %s %s %s\n", getdist($3), $4, $1, $2, $3, $6 != "" ? $6 : "-", $5 != "" ? $5 : "-" } EOF else cat <<- \EOF /^#/ || NF == 0 { next } { printf "%s_%s %s %s %s\n", getdist($3), $1, $2, $3, $4 != "" ? $4 : "-" } EOF fi > $pf-awk for i; do dist=${i%%.*} [ -d $dir/$dist ] || mkdir $dir/$dist awk -f $SCRIPTS/getdist.awk -f $pf-awk $i > $pf-tmp1 < $pf-tmp1 sort -k 1,1 > $dir/$dist/local done } make_pkg_list() { local pf i type pf=$TMPHOME/make_pkg_list type=$1 cd "$LISTSTATE" set -f set +f -- $APTSITES for i; do set -- ${i}_*_$type [ $# -eq 1 ] && [ ! -e "$1" ] && { info "APTSITES: $i does not exist" continue } printf '%s\n' "$@" done | sed 's:^\(.*\)_'$type'$:\1 &:' | sort -k 1,1 > $pf-tmp1 if [ -z "$FORCE" ] && ! [ -s $pf-tmp1 ]; then return 32 fi for i; do if [ $type = Packages ]; then set ${i}_*_binary-*_Release else set ${i}_*_source_Release fi [ $# -eq 1 ] && [ ! -e "$1" ] && continue printf '%s\n' "$@" done | xargs -r awk ' function process() { if (name == "") return if (dist ~ /^updates\//) { rel = rel "-updates" dist = "-" } else if (dist ~ /\/debian-installer$/) { rel = rel "-debian-installer" dist = substr(dist, 1, length(dist) - 17) } if (arch == "") arch = "-" if (rel == "") rel = "-" if (dist == "") dist = "-" print name " " arch " " rel " " dist arch = rel = dist = "" } FNR == 1 { process() # Remove _Release suffix. name = substr(FILENAME, 1, length(FILENAME) - 8) } /^Architecture:/ { arch = $2 } /^Archive:/ { rel = $2 } /^Component:/ { dist = $2 } END { process() } ' > $pf-tmp2 || return 27 cd $OLDPWD < $pf-tmp2 sort -k 3,3 | join -a 1 -o 1.1,1.2,1.4,2.2,1.3 - $TMPHOME/code-alias | awk '{print $1 " " $2 " " $4 " " $3}' | sort -k 1,1 | join -a 1 -e - -o 2.2,2.3,2.4,1.2 $pf-tmp1 - | awk ' $1 == "-" { $1 = "'$ARCH'" } $2 == "-" { $2 = "'$DIST'" } { print } ' | sort -k 1,2 | awk ' { key = $2 "." $1 } file != key { if (file && close(file)) { print "Failed to close " file \ > "/dev/stderr" exit 1; } file = key } { print $3 " '"$LISTSTATE"'/" $4 > file } ' } make_bin_arch() { local dir pf i arch dist home dir=$1 pf=$TMPHOME/make_bin_arch rm -rf $pf mkdir $pf home=$PWD cd $pf make_pkg_list Packages set * if [ $# -eq 1 ] && [ ! -e "$1" ]; then cd "$home" return fi for i; do dist=${i%.*} arch=${i##*.} [ -d $dir/$dist ] || mkdir $dir/$dist < $i createidx binary > $dir/$dist/arch.$arch > "$LOCALDIR"/.apt-move/$dist.arch.$arch done cd "$home" } make_src_debian() { local dir pf i dist home dir=$1 pf=$TMPHOME/make_src_debian rm -rf $pf mkdir $pf home=$PWD cd $pf make_pkg_list Sources set * if [ $# -eq 1 ] && [ ! -e "$1" ]; then cd "$home" return fi for i; do dist=${i%.*} [ -d $dir/$dist ] || mkdir $dir/$dist < $i createidx source > $dir/$dist/debian done cd "$home" } getonebin() { local dir dist pf i dir=$1 dist=${dir##*/} pf=$TMPHOME/getonebin [ -f $dir/local ] || > $dir/local set $dist.arch.* if [ $# -eq 1 ] && [ ! -e "$1" ]; then rm -f $dist.binary return fi if [ -f $dist.binary ]; then sort -um $dist.arch.* | join - $dist.binary else > $dist.binary fi > $pf-old set $dir/arch.* if [ $# -gt 1 ] || [ -e "$1" ]; then for i; do cut -d ' ' -f 1 $i | uniq > $dist.arch.${i##*/arch.} done else set -- fi sort -k 1,1 -m $pf-old "$@" | $GET2 | sort -k 1,1 -sum $dir/local - | awk '{ printf "%-30s\t%-9s\t%-15s\t%-9s\t%s\n", $1, $2, $3, $4, $5 }' | unexpand -a > $dist.binary } getonesrc() { local dir dist pf i dir=$1 dist=${dir##*/} pf=$TMPHOME/getonesrc [ -f $dir/local ] || > $dir/local [ -f $dir/debian ] || > $dir/debian < $dir/debian $GET2 | sort -k 1,1 -sum $dir/local - | awk '{ printf "%-30s\t%-9s\t%-15s\t%s\n", $1, $2, $3, $4 }' | unexpand -a > $dist.source } make_index() { local pf i pf=$TMPHOME/make_index for i in binary source; do set *.$i if [ $# -gt 1 ] || [ -e "$1" ]; then printf '%s\n' "$@" | awk ' { f = $0 d = substr(f, 1, length(f) - 7) while ((val = getline < f) > 0) { print $1 " " d " " $NF } if (val < 0) { print "Failed to read" f > \ "/dev/stderr" exit 1 } close(f) } ' | sort fi > $i.new done { set *.arch.* if [ $# -gt 1 ] || [ -e "$1" ]; then for i; do IFS=. set $i unset IFS echo $1 binary-$3 done fi set *.source if [ $# -gt 1 ] || [ -e "$1" ]; then printf '%s\n' "$@" | tr . ' ' fi } | sort > arch.new } proc_idx_diff() { local pf i readlink binkey pf=$TMPHOME/proc_idx_diff rm -f $pf-fifo1 $pf-fifo2 mkfifo $pf-fifo1 $pf-fifo2 [ -f arch ] || > arch [ -f binary ] || > binary [ -f source ] || > source join -v 1 -o 1.1 arch arch.new | uniq | tee $pf-archold | { cd ../dists xargs -r rm -rf } cd dists < $pf-archold xargs -r rm -rf cd .. IFS=' ' set -- $(join -v 2 $pf-archold arch | comm -23 - arch.new) unset IFS for i; do set $i [ -d dists/$1 ] && find dists/$1 -type d -name $2 [ -d ../dists/$1 ] && find ../dists/$1 -type d -name $2 done | xargs -r rm -r IFS=' ' set -- $( join -v 2 -o 2.1 arch arch.new | uniq | join -v 2 - arch.new | comm -13 arch - | tee $pf-new ) unset IFS for i; do set $i [ -d dists/$1 ] || continue [ $2 = source ] && continue find dists/$1 -type d -name binary-all \ -printf "[ -d %h/$2 ] || cp -a %p %h/$2;" done | sh mv arch.new arch if ! [ -s $pf-new ] && cmp -s binary.new binary && cmp -s source.new source then rm binary.new source.new return fi < $pf-new cut -d ' ' -f 1 | awk ' { rel[$0] = 1 } END { file = "binary" while ((err = getline < file) > 0) { if (!($2 in rel)) { print } } } ' | comm -13 - binary.new > $pf-diff comm -13 source source.new > $pf-srcdiff cd .. readlink='while (<>) { chop; print "$_ " . readlink() . "\n"; }' binkey='s%^\(.apt-move/dists/\([^/]*\)/\(.*\)/binary-.*/' binkey="$binkey"'\.index/\(.*\)\) .*/\(.*\)/\.index/.*$%' binkey="$binkey"'\3_\5_\4 \2 \1%p' nice find .apt-move/dists -type l | perl -e "$readlink" | tee $pf-lnk | sed -n "$binkey" | sort > $pf-old cut -d ' ' -f -2 .apt-move/binary > $pf-fifo1& cut -d ' ' -f -2 .apt-move/binary.new | comm -23 $pf-fifo1 - | join -t ' ' -o 2.2 - $pf-old | xargs -r rm waitall binkey='s%^\(.apt-move/dists/\([^/]*\)/\(.*\)/source/\.index/\(.*\)\)' binkey="$binkey"' .*%\3_\4 \2 \1%p' < $pf-lnk sed -n "$binkey" | sort > $pf-old cut -d ' ' -f -2 .apt-move/source > $pf-fifo1& cut -d ' ' -f -2 .apt-move/source.new | comm -23 $pf-fifo1 - | join -t ' ' -o 2.2 - $pf-old | xargs -r rm waitall binkey='s%^\(.apt-move/dists/\([^/]*\)/.*/\([^/]*\)/.index/\(.*\)\)' binkey="$binkey"' [^_]*_\(.*\)_.*%\4/\3/\2 \1 \5%' < $pf-lnk sed "$binkey" | sort > $pf-old { nice find .apt-move/pool -path '*/.index/*' -type f \ \( -name '*_source' -fprint $pf-src -o -print \) | sortind | $MOVE6 $pf-diff .apt-move/arch /dev/null < $pf-src sortind | $MOVE6 $pf-srcdiff .apt-move/arch /dev/null } > $pf-new < $pf-new sort | $MOVE7 $pf-old /dev/null /dev/null > $pf-cmd < $pf-cmd sort -u | cut -f 2- | $MOVE3 cd .apt-move mv binary.new binary mv source.new source } getbin() { [ $GET_BINARY ] || return 0 local pf dist pf=$TMPHOME/getbin rm -rf $pf mkdir $pf make_idx_local $pf binary make_bin_arch $pf set $pf/* if [ $# -gt 1 ] || [ -e "$1" ]; then for dist do getonebin $dist done fi } getsrc() ( [ $GET_SOURCE ] || return 0 local pf dist pf=$TMPHOME/getsrc rm -rf $pf mkdir $pf make_idx_local $pf source make_src_debian $pf set $pf/* if [ $# -gt 1 ] || [ -e "$1" ]; then for dist do getonesrc $dist done fi ) pkgdir() { sed ' s:^non-us :non-US/main :I s:^non-us\(/.*\) :non-US\1/ :I s:^[^/]* :main/&: s:\(non-US/.*\|.*/\)\(.*\) \(.*\):dists/'$DIST'/\1\3/\2: s:/$:: ' } getfiles() ( info '\nUpdating from local Packages files...' [ $TEST ] && return mkdir -p .apt-move/dists .apt-move/pool dists pool || return 5 cd .apt-move getbin getsrc make_index proc_idx_diff cd .. ) link_new_files() { local readlink readlink='while (<>) { chop; m%^.apt-move/dists/([^/]*)/.*/([^/]*)/.index/(.*)%; print "$3/$2/$1 $_"; $_ = readlink; s/[^_]*_//; s/_.*//; print " $_\n"; }' nice find .apt-move/dists -type l | perl -e "$readlink" | sort > $pf-old { if [ -f $pf-pkg ]; then < $pf-pkg sortind | $MOVE6 \ .apt-move/binary .apt-move/arch \ $pf-skip5 fi if [ -f $pf-src ]; then < $pf-src sortind | $MOVE6 \ .apt-move/source .apt-move/arch \ $pf-skip7 fi } | sort | $MOVE7 $pf-old $pf-skip6 $pf-move1 > $pf-lnk } movefiles() { checklist info '\nMoving files...' local pf i bif pf=$TMPHOME/movefiles rm -f $pf-fifo1 $pf-fifo2 mkfifo $pf-fifo1 $pf-fifo2 rm -rf $pf mkdir $pf bif=' s/.* // p ' if [ $GET_BINARY ]; then bif=' /\.u\?deb$/ { w '$pf-deb' b } '"$bif" fi if [ $GET_SOURCE ]; then bif=' /\.dsc$/ { w '$pf-dsc' b } '"$bif" fi sed -n "$bif" > $pf-skip3 mkdir $pf/deb $pf/dsc if [ $GET_BINARY ]; then < $pf-deb apt_move_stat > $pf-fifo1& < $pf-deb xargs -r md5sum | $MOVE4 $pf/deb $pf-fifo1 $pf-skip1 $pf-pkg $CONTENTS waitall fi > $pf-mvdeb if [ $GET_SOURCE ]; then < $pf-dsc apt_move_stat > $pf-fifo1& < $pf-dsc xargs -r md5sum | $MOVE4 $pf/dsc $pf-fifo1 $pf-skip2 > $pf-dsc1 waitall sort -t _ -k 2 .apt-move/source > $pf-sdist sort -k 1,1 $pf-dsc1 | $MOVE5 $pf-sdist $pf-skip4 $pf-src fi > $pf-mvdsc link_new_files info 'Skipping files:' cat $pf-skip* - $pf-move* <<- EOF >&3 Moving Files: EOF [ $TEST ] && return { for i in $pf-mvd?? $pf-lnk; do < $i sort -u done } | cut -f 2- | $MOVE3 || return 34 if [ $COPYONLY = no ]; then sort -u $pf-move* | xargs -r rm -f || return 28 fi return } domove() { local pf pf=$TMPHOME/domove rm -f $pf-fifo1 mkfifo $pf-fifo1 find $FILECACHE/ -maxdepth 1 -name '*.deb' -o -name '*.udeb' | movefiles } upgrade0() { [ -d backup ] && return 30 mkdir backup || return 5 for i in .apt-move dists pool; do [ -e $i ] && mv $i backup done info "Your old repository is now in $LOCALDIR/backup." mkdir -p .apt-move/dists .apt-move/pool dists pool || return 5 echo $VERSION > .apt-move/version mkdir $pf/deb $pf/dsc find backup -type f \( \ -name '*.udeb' -fprint $pf-deb -o \ -name '*.deb' -fprint $pf-deb -o \ -name '*.dsc' -fprint $pf-dsc \ \) < $pf-deb apt_move_stat > $pf-fifo1& < $pf-deb xargs -r md5sum | $MOVE4 $pf/deb $pf-fifo1 $pf-skip1 $pf-pkg $CONTENTS \ > $pf-mvdeb waitall < $pf-dsc apt_move_stat > $pf-fifo1& < $pf-dsc xargs -r md5sum | $MOVE4 $pf/dsc $pf-fifo1 $pf-skip2 > $pf-dsc1 waitall cd .apt-move < $pf-pkg sortind | awk ' { name = $1 ver = $2 arch = $3 n = split($5, a, /\//) rel = "unknown" if ($5 ~ /^backup.dists/) { rel = a[3] } if (arch == "all") { arch = "'$ARCH'" } print name | "uniq > " rel ".arch." arch print name " - - - " ver | "'"$GET2"' > " rel ".binary" } ' < $pf-dsc1 awk ' { src = $1 ver = $2 n = split($4, a, /\//) rel = "unknown" m = 3 if ($4 ~ /^backup.dists/) { rel = a[3] m++ } dist = a[m] if (n == 7) { dist = dist "/" a[m + 1] } cmd = "sort | '"$GET2"' > " rel ".source" print dist "_" src " - - " ver | cmd } ' make_index mv arch.new arch mv binary.new binary mv source.new source cd .. sort -t _ -k 2 .apt-move/source > $pf-sdist sort -k 1,1 $pf-dsc1 | $MOVE5 $pf-sdist $pf-skip4 $pf-src > $pf-mvdsc link_new_files { for i in $pf-mvd?? $pf-lnk; do < $i sort -u done } | cut -f 2- | $MOVE3 > /dev/null cat - $pf-skip* <<- EOF | tee .apt-move/backup.list >&3 The following files need to be archived manually: EOF info "It is available in $LOCALDIR/.apt-move/backup.list" info "if you missed it." } dofsck() { local pf fifos i readlink bif overawk pf=$TMPHOME/dofsck rm -f $pf-fifo1 $pf-fifo2 mkfifo $pf-fifo1 $pf-fifo2 rm -rf $pf mkdir $pf info info "Rebuilding repository..." [ $TEST ] && return 0 set .apt-move/version if [ ! -f $1 ] || [ $(cat $1) != $VERSION ]; then upgrade0 return fi cd .apt-move find dists -type l | xargs -r rm if [ -f binary ]; then mv binary binary.new else > binary.new fi if [ -f source ]; then mv source source.new else > source.new fi cp arch arch.new proc_idx_diff cd .. } check_del_count() { # I do this just because a bug caused there to be a total of 0 files # in the distribution, and bc had a heart-attack. [ $loccount -eq 0 ] && return 0 delcount=$(cat $pf-delcount) # check the results case `echo "scale=2; (($delcount/$loccount)*100) <= $MAXDELETE" | bc` in 0) [ -z "$FORCE" ] && return 13 info info "Too many files, but FORCE used... deleting anyway!" ;; 1) ;; *) return 12 ;; esac } dodeletes() { checklist local pf readlink expand sedp pf=$TMPHOME/dodeletes info if [ "$DELETE" != "yes" ]; then info "File deletes disabled, skipping." return 0 fi info "Removing obsolete packages..." readlink='while (<>) { chop; $lnk = readlink(); $lnk =~ s%^[./]*%%; print ".apt-move/$lnk\t$_\n"; }' sedp='s%.*%& &%' if [ $CONTENTS != no ]; then sedp='s%\(.*/\.\)content\(/.*\)%\1index\2 &%;t;'$sedp fi loccount=$(nice find pool -type f | sort | tee $pf-files | wc -l) nice find .apt-move/dists -path '*/.index/*' -type l | perl -e "$readlink" | sort | tee $pf-dists-map | cut -f 1 | uniq | $DEL1 | sort -u > $pf-idx-map join -v 2 -o 2.2 $pf-files $pf-idx-map | sort -u > $pf-idx-tmp nice find .apt-move/pool -type f | sed "$sedp" | sort | tee $pf-contents-map | cut -f 2 | sort -u > $pf-idx-list comm -23 $pf-idx-list $pf-idx-tmp | join -v 2 -o 2.2 - $pf-dists-map | sort > $pf-dists-del sort -k 2,2 $pf-dists-map | join -v 2 -2 2 -o 2.1 $pf-dists-del - | sort -u | join -v 2 -o 2.2 - $pf-contents-map > $pf-idx-del sort -k 2,2 $pf-idx-map | join -v 2 -2 2 -o 2.1 $pf-idx-del - | sort | comm -13 - $pf-files | tee $pf-files-del | wc -l > $pf-delcount check_del_count # we are either ok, or forced... sed 's/^/removing: /' $pf-files-del >&3 [ $TEST ] && return cat $pf-*-del | xargs -r rm find .apt-move/pool pool -type d -empty | xargs -r rmdir -p --ignore-fail-on-non-empty } listbin() { [ -f .apt-move/$DIST.arch.$ARCH ] || return 0 local pf readlink pf=$TMPHOME/listbin readlink='while (<>) { chop; m%^.apt-move/dists/[^/]*/(.*)/.*/.index/(.*)%; $dist = $1; $bin = $2; $_ = readlink; s%^[./]*%%; m%^pool/.*/(.*)/.index/[^_]*_(.*)_%; print "${dist}_$1_$bin $2\n"; }' if [ -d .apt-move/dists/$DIST ]; then nice find .apt-move/dists/$DIST \ -path "*/binary-$ARCH/*" -type l | perl -e "$readlink" | sort fi > $pf-old local changed if ! [ $LISTALL ]; then changed='$3 != $4' fi join -o 2.1,2.3,2.5 .apt-move/$DIST.arch.$ARCH - | join -a 1 - $pf-old | awk "$changed"' { print $1 " " $2 }' | tee $pf-tmp1 | sed 's/^[^ ]*_\([^ ]*\) .*/\1_*/' > $pf-tmp2 sed 's/.* \(.*\)$/\1 binary-'$ARCH'/' $pf-tmp1 | pkgdir | paste -d / - $pf-tmp2 } listsrc() { local pf readlink pf=$TMPHOME/listbin readlink='while (<>) { chop; m%^.apt-move/dists/[^/]*/(.*)/.*/.index/(.*)%; print "$1_$2"; $_ = readlink; s/[^_]*_//; s/_.*//; print " $_\n"; }' if [ -d .apt-move/dists/$DIST ]; then nice find .apt-move/dists/$DIST -path "*/source/*" -type l | perl -e "$readlink" | sort > $pf-old fi local changed if ! [ $LISTALL ]; then changed='$3 != $4' fi join -o 1.1,1.3,1.4,2.2 -a 1 - $pf-old | awk "$changed"' { print $1 " " $2 }' | tee $pf-tmp1 | sed 's/^[^ ]*_\([^ ]*\) .*/\1_*/' > $pf-tmp2 sed 's/.* \(.*\)/\1 source/' $pf-tmp1 | pkgdir | paste -d / - $pf-tmp2 } excluded() { checklist local pf pf=$TMPHOME/excluded # print list of excluded files info "The following files are EXCLUDED from the mirror:" # if a $LOCALDIR/.exclude file exists, also find the files that # match one of the exclude patterns in that file. if [ -f $LOCALDIR/.exclude ]; then makeexcl { if [ $GET_BINARY ]; then < .apt-move/$DIST.binary listbin fi if [ $GET_SOURCE ]; then < .apt-move/$DIST.source listsrc fi } | grep -f $TMPHOME/makeexcl | sort fi } make_pkg_files() { local pf i dist sect suffix rel compo arch type lbl odist conj norel \ contents pf=$TMPHOME/make_pkg_files rm -f $pf-fifo1 $pf-fifo2 $pf-fifogz $pf-fifobz mkfifo $pf-fifo1 $pf-fifo2 $pf-fifogz $pf-fifobz type=$1 info "Creating $type files..." set -- $( cd .apt-move/dists if [ $type = Packages ]; then nice find . \ -type d -name binary-\* \ ! -name binary-all else nice find . -type d -name source fi ) for i; do i=${i#./} odist=${i%%/*} compo=${i#*/} compo=${compo%/*} lbl=APT-Move arch=${i##*/} conj= norel= contents= case $odist in *-updates) case $compo in (non-US/*) continue esac conj=.apt-move/dists/$odist/non-US/$compo/$arch/.index dist=${odist%-updates} compo=updates/$compo lbl=$lbl-Security sect=dists/$dist/$compo/$arch ;; *-debian-installer) dist=${odist%-debian-installer} compo=main/debian-installer sect=dists/$dist/$compo/$arch norel=yes ;; *) dist=$odist sect=dists/$i if [ $type = Packages ] && [ $CONTENTS != no ]; then contents=$pf-contents/$i mkdir -p ${contents%/*} > $contents fi ;; esac [ -h dists/$dist ] && continue info "Building: $dist $sect $type" [ $TEST ] && continue mkdir -p $sect || return 5 rm -f $sect/$type* if [ -n "$conj" ] && [ -d $conj ]; then find $conj -type l -printf '%f %h/%l\n' | sort > $pf-non-US fi if [ $type = Packages ]; then sed 's%^[^[:blank:]]*_%%' .apt-move/$odist.binary else sed 's%^[^[:blank:]]*_%%' .apt-move/$odist.source fi | sort | $GET2 > $pf-fifo1& CHILDREN=$! find .apt-move/dists/$i/.index -type l -printf '%f %h/%l\n' | if [ -n "$conj" ] && [ -s $pf-non-US ]; then sort -u - $pf-non-US else sort fi | $PKG1 $pf-fifo1 $contents > $pf-fifo2& if [ $dogz ]; then CHILDREN="$CHILDREN $!" < $pf-fifogz gzip > $sect/$type.gz& fi if [ $dobz ]; then CHILDREN="$CHILDREN $!" < $pf-fifobz nice bzip2 -f \ > $sect/$type.bz2& fi < $pf-fifo2 tee \ ${donone:+$sect/$type} \ ${dogz:+$pf-fifogz} \ ${dobz:+$pf-fifobz} > /dev/null waitall [ $norel ] && continue { echo "Archive: $dist" echo "Component: $compo" echo "Origin: APT-Move" echo "Label: $lbl" echo "Architecture: ${arch#binary-}" } > $sect/Release done } get_checksum() { for l; do [ -f $l ] || continue size=$(perl -le 'print ((stat($ARGV[0]))[7]);' $l) printf ' %32s%.s %16d %s\n' \ $(md5sum $l) $size $j/$k/$l printf ' %40s%.s %16d %s\n' \ $(sha1sum $l) $size $j/$k/$l >&3 done } make_release() { local pf dir suite j dogz dobz donone codename origin label compo \ nonus k arch l size desc prev pf=$TMPHOME/make_release dir=$1 case $dir in */non-US) suite=${dir%/*} nonus=non-US/ ;; *) suite=$dir nonus= ;; esac codename=unknown desc=unknown origin=APT-Move label=APT-Move for j in codename desc origin label; do if [ -f .$j ]; then eval "$j=\$(cat .$j)" fi done compo= arch= for j in main contrib non-free main/debian-installer; do [ -d $j ] || continue if [ $j != main/debian-installer ]; then compo="$compo $nonus$j" prev=.. else prev=../.. fi cd $j for k in binary-*; do [ -d $k ] || continue arch="$arch ${k#*-}" cd $k get_checksum Packages Packages.gz Packages.bz2 Release cd .. done k=source if [ -d $k ]; then cd $k get_checksum Sources Sources.gz Sources.bz2 Release cd .. fi cd $prev done > $pf-md5sum 3> $pf-sha1sum [ -n "$compo" ] || return 0 info "Building: $dir Release" [ $TEST ] && return exec > Release.new echo Origin: $origin echo Label: $label echo Suite: $suite echo Codename: $codename echo Date: $(TZ=UTC date '+%a, %d %b %Y %T %Z') echo Architectures: $(printf '%s\n' $arch | sort -u) echo Components:$compo echo Description: $desc echo MD5Sum: cat $pf-md5sum echo SHA1: cat $pf-sha1sum exec >&- if [ -n "$GPGKEY" ]; then gpg --detach-sign -ao Release.gpg --default-key "$GPGKEY" \ --batch --yes --sign Release.new fi mv Release.new Release } make_contents() { local pf dir j k path pf=$TMPHOME/make_release dir=$1 [ $CONTENTS != no ] || { [ $TEST ] || rm -f Contents-* return 0 } info "Building: $dir Contents" [ $TEST ] && return rm -f Contents-* for j in main contrib non-free; do path=$TMPHOME/make_pkg_files-contents/$dir/$j [ -d $path ] || continue set -- "$path"/* [ $# -eq 1 ] && [ ! -e "$1" ] && continue for k; do cat $k >> Contents-${k##*-} done done set Contents-* [ $# -eq 1 ] && [ ! -e "$1" ] && return for j; do sort $j | awk ' prev != $1 { if (prev != "") { printf "%-59s %s\n", prev, pkg } prev = $1 pkg = $2 next } { pkg = pkg "," $2 } END { if (prev != "") { printf "%-59s %s\n", prev, pkg } } ' | unexpand -a | cat $SCRIPTS/Contents.head - | gzip > $j.gz rm $j done } dopackages() { checklist local i dogz dobz donone dogz= dobz= donone= for i in $PKGCOMP; do case $i in gzip) dogz=yes ;; bzip2) dobz=yes ;; *) donone=yes ;; esac done info # build our own local Packages.gz files # paths stored in packages files are relative to debian/ if [ $GET_BINARY ]; then make_pkg_files Packages fi if [ $GET_SOURCE ]; then make_pkg_files Sources fi info "Creating Release files..." cd dists for i in *; do [ ! -h $i ] && [ -d $i ] || continue cd $i make_release $i make_contents $i [ -d non-US ] || { cd .. continue } cd non-US make_release $i/non-US make_contents $i/non-US cd ../.. done } procbin() { sed 's:.*/\(.*\)_\*$:\1:' | { if [ $TEST ]; then xargs -r $FETCH -t return 0 fi xargs -r $FETCH } domove } procsrc() { sed 's:.*/\(.*\)_\*$:\1:' | { if [ $TEST ]; then xargs -r apt-get --print-uris source return 0 fi if [ -d .apt-move/archive ]; then find .apt-move/archive -type l | xargs -r rm else mkdir .apt-move/archive || exit 5 fi cd .apt-move/archive find ../../pool -name '*.orig.tar.gz' | xargs -r ln -s --target-directory=. xargs -r apt-get -d source cd ../.. } find .apt-move/archive -name '*.dsc' | movefiles } runmirror() { # grab copy of all non-excluded files for the configured distribution. info info "Updating mirror..." local pf pf=$TMPHOME/runmirror rm -f $pf-fifo mkfifo $pf-fifo makeexcl listbinmirror > $pf-fifo& < $pf-fifo procbin waitall listsrcmirror > $pf-fifo& < $pf-fifo procsrc waitall } runsync() { # grab copy of all the packages you currently have installed info info "Syncing mirror..." local pf pf=$TMPHOME/runsync rm -f $pf-fifo mkfifo $pf-fifo makeexcl makeselect listbinsync > $pf-fifo& < $pf-fifo procbin waitall listsrcsync > $pf-fifo& < $pf-fifo procsrc waitall } listbinmirror() { [ $GET_BINARY ] || return 0 [ -f .apt-move/$DIST.binary ] || return 31 < .apt-move/$DIST.binary listbin | grep -v -f $TMPHOME/makeexcl | sed 's:.*/\(.*\)_\*$:\1:' } listsrcmirror() { [ $GET_SOURCE ] || return 0 [ -f .apt-move/$DIST.source ] || return 31 < .apt-move/$DIST.source listsrc | grep -v -f $TMPHOME/makeexcl | sed 's:.*/\(.*\)_\*$:\1:' } listbinsync() { [ $GET_BINARY ] || return 0 [ -f .apt-move/$DIST.binary ] || return 31 < .apt-move/$DIST.binary listbin | grep -v -f $TMPHOME/makeexcl | sed 's:.*/\(.*\)_\*$:\1:' | sort | comm -12 $TMPHOME/makeselect - } listsrcsync() { [ $GET_SOURCE ] || return 0 [ -f .apt-move/$DIST.source ] || return 31 < .apt-move/$DIST.source listsrc | grep -v -f $TMPHOME/makeexcl | sed 's:.*/\(.*\)_\*$:\1:' | sort | comm -12 $TMPHOME/makeselect-src - } listbinrepo() { [ $GET_BINARY ] || return 0 [ -f .apt-move/$DIST.binary ] || return 31 local pf pf=$TMPHOME/listbinrepo nice find pool -name '*.deb' -o -name '*.udeb' | sed 's%.*/%%; s/_.*//' | sort -u > $pf-old < .apt-move/$DIST.binary listbin | grep -v -f $TMPHOME/makeexcl | sed 's:.*/\(.*\)_\*$:\1:' | sort | comm -12 $pf-old - } listsrcrepo() { [ $GET_SOURCE ] || return 0 [ -f .apt-move/$DIST.source ] || return 31 local pf pf=$TMPHOME/listsrcrepo nice find .apt-move/pool -name '*_source' | sed 's%.*/%%; s/_.*//' | sort -u > $pf-old < .apt-move/$DIST.source listsrc | grep -v -f $TMPHOME/makeexcl | sed 's:.*/\(.*\)_\*$:\1:' | sort | comm -12 $pf-old - } makeexcl() { local f=$TMPHOME/makeexcl [ -f $f ] && return if [ -f .exclude ]; then sed '/^[#;]/d; /^$/d; s/\*//g' .exclude fi > $f } makeselect() { local f=$TMPHOME/makeselect pf [ -f $f ] && return pf=$TMPHOME/makeselect dpkg --get-selections | sort -sb -k 2,2 > $pf-tmp1 echo install | join -j2 2 -o 2.1 - $pf-tmp1 > $f if [ -f .apt-move/$DIST.binary ]; then awk -F '[ \t_]' '{ print $3 " " $2 }' .apt-move/$DIST.binary | sort | join -o 1.2 - $f | sort -u fi > $f-src } printerr() { # print error message and exit with appropriate status case "$2" in 0) ;; 5) echo "Error: $1: Could not create directory. Aborting script." ;; 6) echo "Error: $1: You failed to select a distribution. Check" echo " the DIST setting in /etc/apt-move.conf. Aborting" echo " script." ;; 12) echo "Error: $1: bc calculation returned invalid result" ;; 13) echo "Error: $1: too many files to delete! Your current limit" echo " is set to $MAXDELETE%. To change that, see the" echo " MAXDELETE setting in /etc/apt-move.conf. You can" echo " override this safety using the 'force' parameter," echo " but be careful! Aborting script." ;; 18) echo "Error: $1: You specified an invalid package type." echo " See the PKGTYPE setting in /etc/apt-move.conf." echo " Your current setting is:" echo " PKGTYPE=$PKGTYPE" echo " Aborting script." ;; 20) echo "Terminated by SIGINT (^C)..." ;; 21) echo "Terminated by SIGTERM..." ;; 22) echo "Terminated by SIGHUP..." ;; 23) echo "Error: $1: Your current mirror directory is incompatible" echo " with this version of apt-move. Please read" echo " /usr/share/doc/apt-move/README[.gz] for" echo " instructions on updating your mirror directory." ;; 24) echo "Error: $1: No master files exist!" echo " You need to run apt-move get." ;; 25) echo "Error: $1: Could not read configuration. Aborting." ;; 27) echo "Error: $1: Could not read Release files." ;; 28) echo "Error: $1: Failed to remove original files." ;; 29) echo "\ Error: $1: You specified an invalid Packages file compression list. See the PKGCOMP setting in /etc/apt-move.conf. Your current setting is: PKGCOMP='$PKGCOMP' Aborting script." ;; 30) echo "Error: $1: Please remove $LOCALDIR/backup." ;; 31) echo "Error: $1: Unknown DIST setting." echo " Value must match Archive field in Release file." ;; 32) echo "Error: $1: Cannot find index files for APTSITES." echo " Make sure that apt-get update has been run." ;; 33) echo "Error: $1: Configuration file has errors. Aborting." ;; 34) echo "Error: $1: Failed to move files." ;; 64) # this is used by the 'usage' function... should get none of # these here. ;; 255 | *) echo "Unknown error: $1: $2." ;; esac } # called when one of the main functions returns an error. # display the appropriate message # $1 should be the function name, and $2 should be the error code getout() { [ $GETOUT ] || printerr $1 $2 >&2 GETOUT=yes exit $2 } # START main program logic ----------------------------------------------- umask 022 CONFFILE=/etc/apt-move.conf unset dist # read the options while getopts "ac:d:fqt" flag; do case $flag in a) LISTALL=yes ;; c) CONFFILE="$OPTARG" [ -n "${CONFFILE##/*}" ] && CONFFILE="$ORIGDIR/$CONFFILE" ;; d) dist="$OPTARG" ;; t) TEST=yes ;; f) FORCE=yes ;; q) QUIET=yes ;; *) showusage ;; esac done shift $(($OPTIND - 1)) # if nothing on command line, [ $# -eq 0 ] && showusage # source the conffile [ -f "$CONFFILE" ] || getout apt-move 25 trap 'getout apt-move 33' EXIT . "$CONFFILE" trap - EXIT if [ ${dist+1} ]; then DIST=$dist unset dist fi checkconf # set the working directory - create it if required [ -d $LOCALDIR ] || install -d $LOCALDIR || getout apt-move 5 cd $LOCALDIR if [ -d .apt-move ] || [ -d dists ] || [ -d pool ]; then if [ "$1" != fsck ]; then [ -f .apt-move/version ] || getout apt-move 23 [ $(cat .apt-move/version) = $VERSION ] || getout apt-move 23 fi else mkdir .apt-move || get-out apt-move 5 echo $VERSION > .apt-move/version fi trap "SIG=INT; getout apt-move 20" INT trap "SIG=TERM; getout apt-move 21" TERM trap "SIG=HUP; getout apt-move 22" HUP # make sure that tempfile always get cleaned up trap ' err=$? set +e CHILDREN="$CHILDREN${!:+ $!}" [ -n "$CHILDREN" ] && kill $CHILDREN 2> /dev/null wait rm -rf $TMPHOME if [ $SIG ]; then trap - $SIG kill -$SIG $$ else getout ${PROGNAME:-apt-move} $err fi ' EXIT TMPHOME=$( d=`mktemp -u ${TMPDIR:-/tmp}/MOVE_XXXXXX` && mkdir -m 700 $d && echo $d ) || getout apt-move 5 if [ $QUIET ]; then exec 3> /dev/null else exec 3>&1 fi if [ -d dists ]; then find dists -maxdepth 1 -type l -printf '%f %l\n' | sort fi > $TMPHOME/code-alias if [ -h $DIST ]; then DIST=$(echo $DIST | join -o 2.2 - $TMPHOME/code-alias) fi # Put together the basic functions for each option case "$1" in get | getlocal) FUNCT="getfiles" shift if [ $# -gt 0 ]; then LISTSTATE=$1 [ -n "${LISTSTATE##/*}" ] && LISTSTATE="$ORIGDIR/$LISTSTATE" fi ;; move) FUNCT="domove" ;; delete) FUNCT="dodeletes" ;; packages) FUNCT="dopackages" ;; update | localupdate) FUNCT="getfiles domove dodeletes dopackages" ;; local) FUNCT="domove dodeletes dopackages" ;; mirror) FUNCT="getfiles runmirror dodeletes dopackages" ;; sync) FUNCT="getfiles runsync dodeletes dopackages" ;; exclude) FUNCT="excluded" ;; fsck) FUNCT="dofsck" ;; mirrorbin) FUNCT="getfiles procbin dodeletes dopackages" ;; mirrorsrc) FUNCT="getfiles procsrc dodeletes dopackages" ;; movefile) shift if [ -z "$*" ]; then showusage fi PROGNAME=movefile echo $* | tr " " "\n" | sed "/^[^/]/s:^:$ORIGDIR/:" | movefiles ;; listbin | listsrc) case "$2" in mirror | repo) ;; sync) makeselect ;; *) showusage ;; esac makeexcl $1$2 ;; *) showusage ;; esac if [ -n "$FUNCT" ]; then if [ $# -gt 1 ]; then showusage fi for PROGNAME in $FUNCT; do $PROGNAME done fi # # normal exit # done (I think) info "\nAll done, exiting." exit 0 apt-move/README0000600000175000017500000000713007751131023014724 0ustar herbertgreathan00000000000000apt-move for Debian ---------------------- As of version 4.2 we now store packages in pools. apt-move 4 differs drastically from previous versions. We no longer store and use Package files in .apt-move. In its place, we use files similar to the override files to keep track of available packages. These files are generated from Packages (and Sources) files retrieved by apt. As a result of this, deleting obsolete packages has become a lot easier to handle. This has also made it possible to remove the need for setting ``DELETE'' to ``duplicate'' as packages won't be removed unless they disappear from the upstream Packages file, or there is a new version currently in the repository. In order to cut down the time consumed by ``apt-move packages'', index files are now created when a package enters the repository. This means that the Packages (and Sources for source packages) entry is only computed once, when the package is first moved into the repository. Another major change is the removal of all references to rsync. The reason for this is that all retrievals should be done through apt in order to minimise the duplication of code. As a consequence this, you can now mirror all (or a subset) of your ``sources.list'' sites. The result will be merged under a single dist tree as if they originated from one site. Architecture all packages are now handled properly. There are a number of changes in the command-line interface of apt-move. In particular, only one command is accepted for each invocation apt-move and -b and the assorted functionality has been removed since they can be easily achieved by existing tools such as screen or even tee. Upgrading to 4.2 ---------------------- Since we now use pools to store packages, you can not use apt-move 4.2 directly on a repository maintained by an older version of apt-move. In order to upgrade your existing repository, you need to: 1. Update ``/etc/apt-move.conf''. 2. Execute ``apt-move fsck''. 3. Insert entries for your apt-move mirror at the top of ``/etc/apt/sources.list''. Please note that the default suite names are now chosen according to Debian Release files. If your apt-move archive refers to code names such as ``woody'' or ``sid'', you will need to create aliases for them. Please refer to the note about code names in the apt-move(8) manual page. Local Files ---------------------- If you have any local files (files under $dist/local where $dist is a distribution, e.g., potato) in your repository, you need to move them out of the way before you do this. Consult the manual page as to how you can move them back using $dist.{binary, source}.local files. non-US/contrib ---------------------- You may notice that apt-move does not create this section automatically. This is because the only way for apt-move to enumerate sections it by looking at the packages. Since this section is currently empty, apt-move won't know anything about it. If you need it to exist, simply create the appropriate .index directories for it and apt-move will generate empty Packages/Sources files for it correctly. Skipping Files ---------------------- Sometimes apt-move will refuse to move a package into an archive. This is often caused by certain packages in contrib/non-free/non-US which contain incorrect Section headers. Because apt-move needs to deduce the pool directory of package prior to looking up the Packages files, the Section header must be set correctly for packages that are outside main. The solution in this case is to report this to the maintainers of those packages. Herbert Xu, $Id: README,v 1.8 2003/11/02 07:28:19 herbert Exp $ apt-move/apt-move.80000600000175000017500000003714110362074203015670 0ustar herbertgreathan00000000000000.\" Copyright (c) 1999 Michael Merten .\" Copyright (c) 2000-2003 Herbert Xu .\" May be distributed under the terms of version 2 of the .\" GNU GPL. See the LICENSE file included with this package. .\" $Id: apt-move.8,v 1.35 2006/01/14 04:05:23 herbert Exp $ .TH APT\-MOVE 8 "2002 Oct 7th" "APT-MOVE" .SH NAME apt\-move \- move cache of Debian packages into a mirror hierarchy. .SH SYNOPSIS .B apt\-move .RB [ \-c .IR conffile ] .RB [ \-d .IR dist ] .RB [ \-afqt ] .I command .SH DESCRIPTION The .B apt\-move script is used to move a collection of Debian package files into a proper archive hierarchy of the form .B $LOCALDIR/pool/... where .B LOCALDIR is specified in the configuration file. It is intended as a tool to help manage the .BR apt\-get (8) file cache, but could be configured to work with any collection of Debian packages. .PP Additionally, using the .I sync and .I mirror commands, you can build your own local mirror of portions of a selected binary and/or source distribution. .PP Running .B apt\-move periodically will assist in managing the resulting partial mirror by (optionally) removing obsolete packages and creating valid local Packages.gz and Sources.gz. .SS "Commands" The following commands are accepted by .BR apt\-move : .TP .B get \fR[ \fIdir \fR] This generates the master files using Packages and Sources files from the .BR apt (8) cache. The master files are used to keep track of what packages are available, and where packages should be installed. If .I dir is specified, it will be used in lieu of the .B LISTSTATE variable. .TP .B getlocal \fR[ \fIdir \fR] This is an alias of get. It may be removed in future releases. .TP .B move Moves a collection of packages into the local mirror tree. Uses existing master files (see .IR get ) to repair any mangling done to the package names. Any packages that aren't listed in the master files or are obsolete will be left in the file cache directory. Obsolete packages will also be copied into the archive but they will be removed after the next delete operation. In the these two cases, the package is considered to have been skipped. .TP .B delete Delete obsolete package files. Configurable through the .I DELETE and .I MAXDELETE settings in the .B /etc/apt\-move.conf file (see the .I CONFIGURATION section below). It also deletes any index files of packages that are no longer in the archive. This means that you can simply delete packages from the archive without affecting its consistency as long as you run the .B delete command afterwards. .TP .B packages Builds new local versions of Packages.gz and Sources.gz files. .TP .B fsck Rebuilds all index files used to make Packages and Sources files and reprocess all packages in the archive by calling .B movefile on them. Use this if you are upgrading from an old version (<< 4.2) of .BR apt-move . .TP .B update This is an alias, equivalent to .RI ' get .I move .I delete .IR packages '. This is the preferred method for moving package files from your cache into a local mirror. .TP .B local This is an alias, equivalent to .RI ' move .I delete .IR packages '. .TP .B localupdate This is an alias for update. It may be removed in future releases. .TP .B mirror This command automatically runs .IR get , then uses .B /usr/lib/apt-move/fetch and .BR apt-get (8) to download any packages missing from your mirror. The downloaded files will be installed into the repository using .IR move . Finally, it runs .I packages and exits. See the .I DIST and .I PKGTYPE settings in .BR /etc/apt\-move.conf . Before using this command, you need to set up a .B $LOCALDIR/.exclude file containing patterns to exclude unwanted files from your mirror. See the .B SAMPLE.exclude file for an example. See also the .I "Exclude file" section of .I NOTES below. Note that this command will only mirror packages for the architecture that you are running on. It will, however, mirror all source packages. .TP .B sync Similar to the .I mirror function, but only gets the packages that are currently installed on your system. It uses .BR dpkg (8) .I \-\-get\-selections to find out what files to download. It will skip any files that match one of the patterns in the .B $LOCALDIR/.exclude file (if it exists). .B sync will get the latest versions of the packages, regardless of the version currently installed on your system (think about it). .TP .B exclude This command is used to test your .B $LOCALDIR/.exclude pattern file. It will go through the master lists and print any file that matches one of the patters in .BR $LOCALDIR/.exclude . This will show you exactly what files you have EXCLUDED from your mirror. The .B \-t (test) flag has no affect on this command. This uses your existing master files, and does not require an internet connection. .TP .BI movefile \ files... This command is similar to move. Instead of moving files from .IR FILECACHE , it will move the files specified on the command line. .TP \fBlistbin \fR[ \fBmirror \fR| \fBsync \fR| \fBrepo \fR] This command prints a list of packages which may serve as the input to mirrorbin or mirrorsrc. If the argument is .B mirror or .BR sync , it will produce the same lists that the .B mirror and .B sync commands use. If the argument is .BR repo , the list produced will contain the packages that are currently in the apt-move repository. .TP .B mirrorbin This command will fetch the list of packages specified on the standard input, and place them into the archive in the same way as .B mirror does. .TP .B mirrorsrc This commands acts like .BR mirrorbin , except that it fetches source packages instead of binary ones. .SS Options The following options are available from the command line: .TP .B \-a Process all packages. By default, commands like .B listbin and .B mirrorbin only process packages that differ in version between the apt-move repository and the archive being mirrored. This option causes all packages to be considered even if the apt-move repository already contains the latest version. .TP \fB\-c \fIconffile Use .I conffile as the configuration file instead of .BR /etc/apt\-move.conf . .TP \fB\-d \fIdist Use .I dist as the default suite instead of the value of .I DIST from the configuration file. .TP .B \-f Forces deletion of files even when the percentage of files to delete exceeds the .I MAXDELETE setting. This is useful if .B apt\-move aborts with an error saying that too many files would be deleted, and you want to delete the files anyway. (Use with caution.) If you get this error, using .B \-ft will show you the complete list of files, so you can verify them before you use .BR \-f. .TP .B \-q Suppresses normal output. This option is useful when .B apt\-move is used in a non-interactive script. .TP .B \-t Makes a 'test run' and reports what WOULD be done for .B option but does not modify any of the cache or mirror files. .SH CONFIGURATION Before using .BR apt\-move , edit the .B /etc/apt\-move.conf file to match your local setup. Always remember to use the .I test parameter after any change in your configuration to make sure it will work like you want it to. You may also want to set the .I DELETE option to .I no to turn off file deletes until everything else is working successfully. .PP The file is read as a Bourne shell script. So you must obey the syntactical rules of .BR sh(1) . In particular, values with spaces in them must be quoted with single or double quotes. .PP The following settings are recognized by .B apt-move (shown here with their defaults): .TP .BR APTSITES= """debian.midco.net non-us.debian.org""" Set this to the names of sites in your .B /etc/apt/sources.list that you wish to mirror. The value .B /all/ refers to all non-file URIs. .TP .BR LOCALDIR= /mirrors/debian This is the full (absolute) path to your debian directory (the top of your local mirror). .TP .BR DIST= stable This is the default suite assigned to packages when the .I Release file is missing. It does not have any effect on whether a suite is stored in the archive. .TP .BR PKGTYPE= binary Set this to your choice of: .IR binary , .I source or .I both to tell the .IR mirror , .I sync and .I movefile which type(s) of files to get. .TP .BR FILECACHE= /var/cache/apt/archives The directory where your local cache of packages are. The default will work for the .BR apt-get (8) packages, unless you've changed the configuration in .BR /etc/apt/apt.conf . .TP .BR LISTSTATE= /var/lib/apt/lists The directory to your local cache of Packages files. The default will work for the .BR apt-get (8) packages, unless you've changed the configuration in .BR /etc/apt/apt.conf . .TP .BR DELETE= no Determines whether obsolete packages (packages not listed in the master file, or packages that have been superceded in the repository) are to be removed. .TP .BR MAXDELETE= 20 Maximum percentage of files .B apt\-move is allowed to delete during a normal run. Anything exceeding this will produce an error and abort the script. I added this as a precaution so that you won't lose your entire mirror when a new distribution is released. You can override this (with caution) using the .I \-f parameter with .BR apt\-move . .TP .BR COPYONLY= no If this is set to yes, then .B move and .B movefile will copy instead of move. That is, the originals will be left alone. .TP .BR PKGCOMP= gzip This should be set to a space-separated list of compression formats that apt-move should provide when generating Packages and Sources files. The possible values are .BR none , .B gzip and .BR bzip2 . With the current .B apt package you should include at least .BR none , as otherwise .B apt will complain about missing files. .TP .BR CONTENTS= no If this is set to yes, then .B packages will generate Contents files. .TP .BR GPGKEY= "" If this is set to non-empty string, then .B packages will sign generated Release files with the specified key. You must install .B gnupg before enabling this option. .PP For the .I sync and .I mirror commands to function correctly, you need to list your .B apt\-move repository at the top of .BR /etc/apt/sources.list as a .BR file\ URI . .SH FILES .TP .B /usr/bin/apt\-move The script. .TP .B /etc/apt\-move.conf Configuration file for the script. .TP .B /usr/share/man/man8/apt\-move.8.gz The manpage. .TP .B /tmp/MOVE_* The temporary files created at runtime. .TP .B /usr/lib/apt-move/fetch Utility to fetch files just like .IR "apt-get install -d" . Except that no dependency analysis is done. .TP .B .apt-move/*.{binary, source}.local Put entries of local packages here. The fields are ``package priority section source version task'' for the binary file, and ``package priority section version'' for the source file. The .B version field may be set to a single dash to refer to the latest version in the archive. Blank lines and lines beginning with a hash are ignored. .SH "SEE ALSO" .BR dpkg (8), .BR apt\-get (8) .SH NOTES .SS "Exclude file" The .I mirror command uses a file in the .B $LOCALDIR/ directory called '.exclude' which contains exclude patterns that are applied against the files to be mirrored. These patterns were created with the following limitation: they must work the same with with .BR grep (1), after any '*' characters are removed. Unless you're careful setting this up, you'll get unexpected results. Run .RB "'" apt-move .B \-t .BR mirror "'" first, to make sure you're getting the results you intended. Another way to verify your exclude file is the use the .I exclude command for .B apt\-move to print a list of files your are excluding from your mirror. See the sample .exclude file (SAMPLE.exclude) for an example of an .exclude file. .SS Mirroring The .B apt\-move .B mirror and .B sync commands do not test for available disk space. The current potato (main binary) distribution is over 1Gb in size. Add the sources to that and it can eat up the space on a partition really fast. I would advise you to put your mirror somewhere other than the root partition. Set up your exclude file and run .B "apt\-move -t mirror" and examine the result. .SS "Code names" Since .B apt\-move gets the suite names from .I Release files, which usually use the names .IR stable , .I testing and .IR unstable , the suites in the repository are named accordingly. You can simulate the code names by creating symbolic links in the .I dists directory. For example, in order to make .I testing equivalent to .IR sarge , you could run .BR "ln -s testing $LOCALDIR/dists/sarge" . Alternatively, you could delete the .I testing subdirectory and run .BR "ln -s sarge $LOCALDIR/dists/testing" . This will cause future executions of the .I get operation to use .I sarge whenever it sees .I testing in the .I Release file. .SH DIAGNOSTICS .B apt\-move may exit with one of the following error messages: .TP .B "Could not read configuration." .B apt\-move could not find the .B /etc/apt-move.conf file. Run the install script. .TP .B "Could not create directory." For some reason, a necessary directory could not be created. .TP .B "You failed to select a distribution." You did not configure a .I DIST setting in /etc/apt-move.conf. .TP .B "You specified an invalid package type." You can only use .IR binary , .I source or .I both for the PKGTYPE setting. .TP .B "No master files exist!" You need to run .B apt-\move with the .B get command at least once in order to create the master files which determine where packages are to be installed. .TP .B "bc calculation returned invalid result" .B apt\-move uses the .BR bc (1) program to determine when the number of files to delete will exceed the .I MAXDELETE setting in .BR apt\-move.conf . If you get this error, make sure that .I MAXDELETE is set to a number in the range of 1 to 100, without the % sign. Otherwise you need to report this as a bug. .TP .B "Too many files to delete!" .B apt\-move will report this error if the number of files to be deleted exceeds the .I MAXDELETE setting in .BR apt\-move.conf . You need to study the output to determine if this is normal (in which case you can override this using the .I force parameter), or if its due to some drastic change on the mirror site (like a new release) or possibly due to a partial download of the master Packages.gz or Sources.gz file. .TP .B "Your current mirror directory is incompatible..." You have just upgraded from an old version of apt-move. Update your configuration, then run .I apt-move fsck and finally remove .BR .apt-move/ancient . .TP .B "Could not read Release files." .B apt\-move could not read the release files needed to build the master files. Make sure you have run .I apt-get update and try again. .TP .B "Failed to remove original files." .B apt\-move could not remove the original copies of files that have just entered the .B apt\-move archive. Make sure that you have permission to delete those files. .TP .B "Please remove $LOCALDIR/backup." You must remove .B LOCALDIR/backup before running the .B fsck command. .TP .B "Unknown DIST setting." The value of .I DIST must match the .B Archive field in the .B Release file of the distribution that you are trying to mirror. .TP .B "Cannot find index files for APTSITES." .B apt\-move could not find any index files for the .B get operation. You should either run .IR "apt-get update" , or run .B apt\-move with .B -f if only the .I *.local files have been changed. .SH BUGS The exclusion system was designed prior to the introduction to the package pools. Hence its content still relates to the old structure of the Debian archive. This is confusing and it should be replaced with a new exclusion system. .PP The .I DIST variable does not control what is actually downloaded by the .B fetch utility. It should have a similar effect to that of .BR "apt-get -t" . .SH AUTHOR Michael Merten Herbert Xu apt-move/changelog.ancient0000600000175000017500000002527407122661554017360 0ustar herbertgreathan00000000000000revision 3.0 apt-move: * Changed defaults in apt-move.conf to something a bit more reasonable for the average system. * Removed checks for installed packages. * Added support for mirroring the source as well as the binary packages ('use the source, Luke!') * Clarified (I think) the license for package. * Found a situation where the MAXDELETE percentage calculation would end up dividing by zero, so I added a bypass if that occurs. * added -v switch for more verbose rsync output. install: * Added install for apt-move.cron script provided by Greg Norris . * Added checks for installed packages. * changed so that the manpage that comes with the distribution is not gzipped until after it is installed in the MANDIR. (so my patches will work on it as well) -- Michael Merten 1999/08/17 13:55:43 UTC revision 2.7 apt-move: * changed uses of install(1) -D to -d and -m to work with older versions of install(1) * use install(1) to create destination directory before running rsync. * changed all functions to silently ignore the .exclude file if none exists. install: * changed uses of install(1) -D to -d and -m to work with older versions of install(1) * fixed syntax error in the for loop for obsolete files. -- Michael Merten 1999/08/15 16:55:91 UTC revision 2.6 apt-move: * fixed a few more typos in the startup code. * added new exclude option to print list of files excluded from the mirror. * added -b operation, and removed the runmirror script and runsync link. Also removed their manpages. * added stop option to kill -b scripts. install: * added code to read old config file, if it exists, and build a new one from the old settings, while saving a backup. -- Michael Merten 1999/08/12 14:09:06 revision 2.5 apt-move: * found bug where I used the wrong exclude file for the sync option. * Fixed bug where I misspelled the include file for the sync option. -- Michael Merten 1999/08/12 17:20:50 revision 2.4 apt-move: * Fixed bug (reported by Wim Kerkhoff) where I misstyped the dpkg --get-selections command in sync funct. -- Michael Merten 1999/08/12 16:59:43 revision 2.3 * Updated all documentation files. * moved info from README.* files into manpages. * moved INSTALL file to README file. * removed CHANGELOG.* files and added changelog file. apt-move: * Added creation of temp files using tempfile. Moved them from /var/tmp to /tmp. * Added logic to determine current distribution names from a listing of the remote debian/dists directory obtained by rsync. Removed DEB* settings from config file. * Updated usage message. * Added logic to allow command line switches (-f & -t) instead of the force and test words. * Added logic to allow multiple options to be specified on the command line, with semi-intelligent parsing. * Added options to directly access the getfiles and domove functions, and modified the delete and packages functions to refer only to their respective functions. * Modified usage function to exit with 1 instead of returning 0. * Simplified logic in the getfiles, runmirror and runsync functions. * Changed return code for .kill from 1 to 16. * Moved the 'remove excluded files' part of runmirror function into the dodeletes function. Removed --delete option from all rsync invocations. * Added execution of dpkg-name to fix package files before moving them. * moved creation of temp excl file to the makelist function. * Added excluded files to list of obsolete files before making the MAXDELETE calculation. * niced all find and dpkg-scanpackages calls. * removed nested double quotes from the MAXDELETE case statement. * removed references to .stop file. * added runsync function, and sync option. * modified error message (#2) to apply only to non-us site config. * added error message (#4) for now mandatory us site config. * Changed error message (#7) to indicate invalid DIST config. * added error message (#15) for missing master ls file. runmirror: * Added runsync link, and logic for the sync option. * moved usage message to a function and updated new syntax. * added logic to read switches -ft and pass them on to apt-move * changed LOGFILE and MONITOR to /dev/null if not configured. * changed kill option to stop. * added manpages for runmirror and runsync. install: * added logic to detect existing files and prompt for delete. * added logic to detect -f switch and force deletes. * added support for new manpages. -- Michael Merten 1999/08/12 14:32:57 revision 2.2 apt-move: * Rewrote all mkdirhier function calls to use the /usr/bin/install program instead. * Removed the mkdirhier function. * Removed error code 4 (used by mkdirhier). runmirror: * bumped revision to match apt-move. * changed script name from mirror to runmirror. Suggested by Oliver Elphick. * fixed config file test to exit with 1 on error. * added test and additional logic for LOGFILE and MONITOR settings. * removed header function (it was only used in one place). * removed stop option and modified usage message. install: * initial version -- Michael Merten 1999/08/10 13:36:24 revision 2.1 apt-move: * Fixed bug where I tested for '' instead of '.' as the output of the dirname command when executed for a pathname without a path (i.e. a base filename). Reported by Wim Kerkhoff. * Added display of current config settings when printing error messages. -- Michael Merten 1999/08/10 03:56:10 revision 2.0 apt-move: * Major rewrite of code (so much changed that rcsdiff gave up and started quoting entire sections) * Major changes in error detection, handling, and reporting. * Simplified code in a lot of places. * Reorganized and added code to verify some of the config options. * Added code and usage for the force parameter. * Renamed 'rsync' option to 'mirror'. * Removed silly comments from several places. * Removed several unnecessary variables. * Removed dists loop from all functions... now only supports ONE dist at a time. * Simplified slink/non-US code. * removed makedirs function completely. * rearranged and simplified runmirror function. * Added getout and printerr functions. * added test for the bc package * removed dodeletes function call from the mirror option. * bumped revision to 2.0 mirror: * cleaned up comments and output messages. * changed rsync option to mirror. -- Michael Merten 1999/08/09 15:11:19 revision 1.4 apt-move: * moved all configuration to the /etc/apt-move.conf file. * changed variables NODEL to DELETE, and DOIT to TEST, and reversed the logic for them. Makes more sense when reading the code. * completely rewrote the getfiles function. Now, instead of trying to get every combination of packages and override files, it only retrieves the ones for the sections you mirror (per config file). Also now correctly handles non-standard stable/non-US directory. * completely rewrote the runmirror function. Now can mirror any portion of the debian mirror site. It will retrieve the files for every section you have configured in /etc/apt-move.conf. * added better error checking, error reporting, and .kill/.stop handling in every function. * added getout() error function that correctly differentiates between a manual script .kill and an actual function error. * completely rewrote the main program logic so that the return code from every function is checked, and the script will now abort properly when an error occurs. * cleaned up code in all sections. * tested mirror run for unstable/main (this is all I mirror). Will have to rely on someone else to test the other distros/sections. mirror: * moved all config options to the apt-move.conf file. * changed MIRRORDIR references to LOCALDIR -- Michael Merten 1999/08/08 16:03:59 revision 1.3 apt-move: * cleaned up code and comments in various places. * added notation about manpage in the file header comments. * removed comments about not using '.' in LOCALDIR configuration. * changed APTCACHE variable name to FILECACHE. * removed unused APTLISTS variable. * rewrote all uses of the debian/indices directory to instead use the debian/.apt-move directory. * removed apt-get package dependancy. * rewrote showusage function to mention the manpage. * forced creation of the .apt-move directory in the getfiles function. * added ftp site config check and bypass logic to the runmirror and getfiles functions. * added safety check to prevent dodeletes and dopackages functions from working if the master packages and override files don't exist. * added verbose flag to rsync options for runmirror function. * added quiet flag to rsync options for getfiles function. mirror: * added copyright and license statement. -- Michael Merten 1999/08/08 02:53:16 revision 1.2 apt-move: * cleaned up code in several places. * added a mkdirhier function and removed dependancy on xlib6g-dev package. * modified rsync function to obey the NODEL config variable. -- Michael Merten 1999/08/07 02:38:57 revision 1.1 apt-move: Initial revision mirror: Initial revision -- Michael Merten 1999/08/07 00:15:01 ============================================================================= apt-move/move30000700000175000017500000000444007563115305015030 0ustar herbertgreathan00000000000000#!/usr/bin/perl # $Id: move3,v 1.17 2002/11/09 05:19:01 herbert Exp $ # stole this from dinstall sub cleansymlink { my($old, $new) = @_; my($olddir, $newdir, $oldfile, $newfile, @olddir, @newdir); ($olddir, $oldfile) = ($old =~ m:((.*)/)?([^/]*):)[1,2]; ($newdir, $newfile) = ($new =~ m:((.*)/)?([^/]*):)[1,2]; @olddir = split("/", $olddir); @newdir = split("/", $newdir); while (@olddir && $olddir[0] eq $newdir[0]) { shift @olddir; shift @newdir; } for (@newdir) { unshift(@olddir, ".."); } symlink(join("/", @olddir, $oldfile), $new); } sub move { my $new = "$_[1].new"; $_ = $_[0]; if (!-e) { die "Could not move $_: no such file" unless -e $_[1]; return; } if (-l) { $_ = `readlink -f $_` or die "readlink failed"; chop; } unlink($new); link($_, $new) or !system("cp --preserve=timestamps $_ $new") or die "Could not copy $_ to $new"; chmod(0644, $new); chown(0, 0, $new) unless $>; rename($new, $_[1]) or die "Could not rename $new to $_[1]: $!"; unlink($new); } while (<>) { split; if ($_[0] eq "D") { if (fileno(MKDIR) == undef) { open(MKDIR, '| xargs -r mkdir -p'); } print MKDIR "$_[1]\n"; next; } else { if (fileno(MKDIR) != undef) { close(MKDIR) or die "Could not make directories: $!"; } } if ($_[0] eq "d") { system(substr($_, 2)) and exit 0; } elsif ($_[0] eq "h") { unlink($_[2]); link($_[1], $_[2]) or die "Could not link $_[1] to $_[2]: $!"; } elsif ($_[0] eq "H") { link($_[1], $_[2]) or die "Could not link $_[1] to $_[2]: $!"; } elsif ($_[0] eq "l") { unlink($_[2]); cleansymlink($_[1], $_[2]) or die "Could not cleansymlink $_[1] to $_[2]: $!"; } elsif ($_[0] eq "r") { unlink($_[2]); rename($_[1], $_[2]) or die "Could not rename $_[1] to $_[2]: $!"; } elsif ($_[0] eq "s") { unlink($_[2]); symlink($_[1], $_[2]) or die "Could not symlink $_[1] to $_[2]: $!"; } elsif ($_[0] eq "i") { open(IN, "<$_[1]") or die "Could not open $_[1]: $!"; open(OUT, ">$_[2]") or die "Could not open $_[2]: $!"; while () { s/^Directory:.*/Directory: $_[3]/; print OUT $_; } close(IN); close(OUT) or die "Could not close $_[2]: $!"; } elsif ($_[0] eq "u") { unlink($_[1]) or "Could not unlink $_[1]: $!"; } elsif ($_[0] eq "m") { move($_[1], $_[2]); } } apt-move/move70000600000175000017500000000252207550253073015033 0ustar herbertgreathan00000000000000# $Id: move7,v 1.5 2002/10/07 09:39:07 herbert Exp $ function read(file) { err = getline < file if (err < 0) { print "getline failed on " file > "/dev/stderr" exit 1 } else if (err == 0) { eof = 1 return } curname = $1 curfile = $2 curver = $3 } function process(dir, i, a) { if (best == "") { return } if (!eof && curname == name) { print "1 u " curfile } dir = bestlink sub(/\/[^\/]*$/, "", dir) print "2\tD " dir print "3\tl " bestfile " " bestlink split(besttail, a) for (i in a) { usecnt[a[i]] = 1 } } function moveskip(i) { for (i in usecnt) { if (usecnt[i]) { print i > movef } else { print i > skipf } } } BEGIN { curf = ARGV[1] skipf = ARGV[2] movef = ARGV[3] ARGC = 1 read(curf) printf "" > skipf printf "" > movef } { name = $1 split($1, a, /\//) key = a[1] } prevname != name { process() best = "" } prevkey != key { moveskip() split("", usecnt) prevkey = key } { link = $2 ver = $3 file = $4 tail = "" for (i = 5; i <= NF; i++) { tail = tail " " $i usecnt[$i] += 0 } } prevname != name { while (!eof && curname < name) { read(curf) } prevname = name } !eof && curname == name && cmpversion(ver, curver) <= 0 { next } best == "" || cmpversion(ver, best) > 0 { best = ver bestlink = link bestfile = file besttail = tail } END { process() moveskip() } apt-move/COPYING0000600000175000017500000004312710341757725015121 0ustar herbertgreathan00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. apt-move/move40000600000175000017500000001345610005547667015044 0ustar herbertgreathan00000000000000# $Id: move4,v 1.15 2004/01/27 20:53:11 herbert Exp $ function record(field, name, value) { if (field == "") { return } i = index(field, ":") name = tolower(substr(field, 1, i - 1)) value = substr(field, i + 1) if (name in kmap) { name = kmap[name] } tv[name] = value } function ucfirst(s) { return toupper(substr(s, 1, 1)) substr(s, 2) } function readsize(sizef, size) { err = getline size < sizef if (err < 0) { print "getline failed on " sizef > "/dev/stderr" exit 1 } else if (err == 0) { return -1 } return size } BEGIN { pref = ARGV[1] sizef = ARGV[2] skipf = ARGV[3] pkgf = ARGV[4] contents = ARGV[5] == "yes" ARGC = 1 isbin = pref ~ /deb$/ if (isbin) { kmap["optional"] = "suggests" kmap["recommended"] = "recommends" kmap["class"] = "priority" kmap["package_revision"] = "revision" } else { kmap["source"] = "package" } i = 0 # This order is taken from apt which in turn comes from dpkg. # Fields specific to the status file have been removed. if (isbin) { pri[++i] = "Package" pri[++i] = "Essential" pri[++i] = "Priority" pri[++i] = "Section" pri[++i] = "Installed-Size" pri[++i] = "Maintainer" pri[++i] = "Architecture" pri[++i] = "Source" pri[++i] = "Version" pri[++i] = "Replaces" pri[++i] = "Provides" pri[++i] = "Depends" pri[++i] = "Pre-Depends" pri[++i] = "Recommends" pri[++i] = "Suggests" pri[++i] = "Conflicts" pri[++i] = "Filename" pri[++i] = "Size" pri[++i] = "MD5sum" pri[++i] = "SHA1sum" pri[++i] = "Description" } else { pri[++i] = "Package" pri[++i] = "Binary" pri[++i] = "Version" pri[++i] = "Priority" pri[++i] = "Section" pri[++i] = "Maintainer" pri[++i] = "Build-Depends" pri[++i] = "Build-Depends-Indep" pri[++i] = "Build-Conflicts" pri[++i] = "Build-Conflicts-Indep" pri[++i] = "Architecture" pri[++i] = "Standards-Version" pri[++i] = "Format" pri[++i] = "Directory" pri[++i] = "Files" } prilen = i nextsize = readsize(sizef) printf "" > skipf if (isbin) { printf "" > pkgf } } nextsize < 0 { print "unexpected eof encountered on " sizef > "/dev/stderr" exit 1 } { size = nextsize nextsize = readsize(sizef) } isbin { suffix = substr($2, length($2) - 3) if (suffix == "udeb") { suffix = ".udeb" } cmd = "dpkg-deb -I " $2 " control" while ((val = (cmd | getline line)) > 0 && line == "") { } if (val <= 0) { print "dpkg-deb returned nothing on " $2 > "/dev/stderr" print $2 > skipf close(cmd) next } field = "" split("", tv) do { if (line ~ /^[ \t]/) { field = field "\n" line continue } record(field) field = line } while ((val = (cmd | getline line)) > 0 && line != "") val += close(cmd) if (val < 0) { print "dpkg-deb failed on " $2 > "/dev/stderr" print $2 > skipf next } record(field) tv["md5sum"] = " " $1 tv["size"] = " " size if ("revision" in tv) { tv["version"] = tv["version"] "-" tv["revision"] delete tv["revision"] } } !isbin { while ((val = (getline line < $2)) > 0) { if (line == "") { continue } if (line ~ /^-----BEGIN PGP SIGNED MESSAGE-----/) { while ((val = (getline line < $2)) > 0) { if (line != "") { continue } break } if (val > 0) { continue } } break } if (val <= 0) { if (val < 0) { print "Failed to read " $2 > "/dev/stderr" } else { print "Invalid dsc file " $2 > "/dev/stderr" } print $2 > skipf close($2) next } field = "" split("", tv) do { if (line ~ /^-----BEGIN PGP SIGNATURE-----/) { break } if (line ~ /^[ \t]/) { field = field "\n" line continue } record(field) field = line } while ((val = (getline line < $2)) > 0 && line != "") close($2) if (val < 0) { print "Failed to read " $2 > "/dev/stderr" print $2 > skipf next } record(field) dir = $2 file = $2 sub(/\/[^\/]*$/, "", dir) sub(/.*\//, "", file) n = split(tv["files"], a) files = dir " " file for (i = 3; i <= n; i += 3) { files = files " " a[i] } tv["files"] = "\n " $1 " " size " " file tv["files"] tv["section"] = tv["section"] tv["priority"] = tv["priority"] tv["directory"] = tv["directory"] } { split(tv["package"], a) src = bin = a[1] if ("source" in tv) { split(tv["source"], a) src = a[1] } else { src = bin } split(tv["version"], a) ver = a[1] } isbin { ever = ver sub(/.*:/, "", ever) key = substr(src, 1, 1) if (key == "l" && substr(src, 1, 3) == "lib") { key = substr(src, 1, 4) } split(tv["architecture"], a) arch = a[1] split(tv["section"], a) dist = getdist(a[1]) dir = "pool/" dist "/" key "/" src filename = dir "/" bin "_" ever "_" arch suffix tv["filename"] = " " filename ifname = ".apt-move/" dir "/.index/" bin "_" ver "_" arch cfname = ".apt-move/" dir "/.content/" bin "_" ver "_" arch } { ifn = src "_" bin cnt = ++count[ifn] cfn = pref "/" ifn "_content_" cnt ifn = pref "/" ifn "_" cnt for (i = 1; i <= prilen; i++) { name = tolower(pri[i]) if (name in tv) { print pri[i] ":" tv[name] > ifn delete tv[name] } } for (name in tv) { print ucfirst(name) ":" tv[name] > ifn } print "" > ifn if (close(ifn)) { print "Error closing " ifn > "/dev/stderr" exit 1 } } contents { cmd = "dpkg-deb -c " $2 ocmd = "sort > " cfn printf "" | ocmd while ((val = (cmd | getline line)) > 0) { if (line ~ /^d/) { continue } sub(/.* \.\//, "", line) print line | ocmd } if (close(ocmd)) { close(cmd) print "Error closing " ocmd > "/dev/stderr" exit 1 } val += close(cmd) if (val < 0) { print "dpkg-deb failed on " $2 > "/dev/stderr" print $2 > skipf next } printf "1\tD .apt-move/%s/.content\n", dir printf "3\tm %s %s\n", cfn, cfname } isbin { printf "1\tD %s\n", dir printf "1\tD .apt-move/%s/.index\n", dir printf "2\tm %s %s\n", $2, filename printf "3\tm %s %s\n", ifn, ifname print ifname " " $2 > pkgf } !isbin { print src " " ver " " ifn " " files } apt-move/cmpbignum.awk0000600000175000017500000000117207424215634016541 0ustar herbertgreathan00000000000000# cmpbignum --- compare two arbitrarily long integers. # The function returns: # < 0 if a < b # == 0 if a == b # > 0 if a > b # The idea came from Anthony Towns in http://bugs.debian.org/92839. # # Copyright (c) 2001 Herbert Xu # $Id: cmpbignum.awk,v 1.1 2002/01/25 08:47:24 herbert Exp $ function cmpbignum(a, b, i, j, k, l, d) { i = match(a, /[^0]/) j = match(b, /[^0]/) if (!i || !j) { return !!i - !!j } k = length(a) l = length(b) d = (k - i) - (l - j) if (d) { return d } do { d = substr(a, i, 1) - substr(b, j, 1) if (d) { return d } i++ j++ } while (i <= k) return 0 } apt-move/fetch.cc0000600000175000017500000000570010031132637015442 0ustar herbertgreathan00000000000000#include #include #include #include #include #include #include #include #include #include #include using std::cerr; using std::cout; using std::endl; typedef pkgCache::VerIterator VerIterator; typedef pkgCache::VerFileIterator VerFileIterator; #define NotSource pkgCache::Flag::NotSource #define NotAutomatic pkgCache::Flag::NotAutomatic VerIterator getHighestVersion(pkgCache &cache, pkgCache::PkgIterator pkg) { VerIterator last(cache, 0); for (VerIterator i = pkg.VersionList(); !i.end(); i++) { for (VerFileIterator j = i.FileList(); !j.end(); j++) { if ((j.File()->Flags & NotSource) != 0) { continue; } if ((j.File()->Flags & NotAutomatic) != 0) { if (last.end()) { last = i; } continue; } return i; } } return last; } bool downloadPackages(int test, int argc, char **argv) { pkgCacheFile cache; OpTextProgress prog(*_config); if (!cache.Open(prog, false)) return false; pkgRecords rec(cache); if (_error->PendingError()) return false; FileFd Lock; if (!_config->FindB("Debug::NoLocking",false)) { Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock")); if (_error->PendingError()) return _error->Error( "Unable to lock the download directory"); } pkgAcquire fetcher; pkgSourceList list; if (!list.ReadMainList()) return _error->Error("The list of sources could not be read."); string *filenames = new string[argc]; for (int i = 0; i < argc; i++) { pkgCache::PkgIterator pkg = cache->FindPkg(argv[i]); if (pkg.end()) { cerr << "Couldn't find package " << argv[i] << endl; continue; } VerIterator candidateVer = getHighestVersion(cache, pkg); if (candidateVer == 0) { cerr << "Couldn't find package " << argv[i] << endl; continue; } new pkgAcqArchive(&fetcher, &list, &rec, candidateVer, filenames[i]); } if (test) { pkgAcquire::UriIterator i = fetcher.UriBegin(); for (; i != fetcher.UriEnd(); i++) { cout << i->URI << endl; } return true; } if (fetcher.Run() == pkgAcquire::Failed) return false; return true; } static void usage(const char *name) { cerr << "usage: " << name << " [-t] pkg..." << endl; exit(1); } int main(int argc, char **argv) { int test = 0; const char *progname = argv[0]; int c; while ((c = getopt(argc, argv, "t")) != -1) { switch (c) { case 't': test = 1; break; default: usage(progname); } } argc -= optind; argv += optind; if (!*argv) { usage(progname); } pkgInitConfig(*_config); pkgInitSystem(*_config, _system); if (ttyname(STDOUT_FILENO) == 0 && _config->FindI("quiet",0) < 1) _config->Set("quiet","1"); downloadPackages(test, argc, argv); if (!_error->empty()) { bool Errors = _error->PendingError(); _error->DumpErrors(); return Errors ? 100 : 0; } return 0; } apt-move/apt-move.conf0000600000175000017500000000327110362074203016443 0ustar herbertgreathan00000000000000# Configuration file for the apt-move script. # # You should modify the following configuration to suit your system. # See the apt-move(8) manpage for information about these settings. # # The defaults for this file are simply the settings I currently use. # Configuration for apt-move script -------------------------------------- # The sites in ``/etc/apt/sources.list'' that you wish to mirror. APTSITES="/all/" # The absolute path to your debian directory (top of your local mirror). # This MUST appear as the first entry of your sources.list if you use # sync or mirror. LOCALDIR=/mirrors/debian # The default distribution (see the apt-move(8) manpage for details) DIST=stable # The package types you want to mirror. # Possible values are: binary, source, and both (use only one). PKGTYPE=binary # The full (absolute) path to your local cache of package files. The default # will work for the apt-get packages, unless you've reconfigured apt. FILECACHE=/var/cache/apt/archives # The full (absolute) path to your local cache of Packages files. The # default will work for the apt-get Packages, unless you've reconfigured apt. LISTSTATE=/var/lib/apt/lists # Do you want apt-move to delete obsolete files from your mirror? (yes/no) DELETE=no # Maximum percentage of files to delete during a normal run. MAXDELETE=20 # Set this to yes if you wish to keep the originals for move/movefile. COPYONLY=no # Set this to 'none gzip' to get uncompressed Packages/Sources files. PKGCOMP=gzip # Set this to yes to make apt-move generate Contents files. CONTENTS=no # Set this to key name to be used for signing Release files. GPGKEY= # End Configuration ------------------------------------------------------ apt-move/del10000700000175000017500000000134207702511004014611 0ustar herbertgreathan00000000000000#!/usr/bin/awk -f BEGIN { err = "/dev/stderr" } { idx = $0 filefield = 0 split("", files) while ((val = getline < idx) > 0) { if (filefield) { if (substr($0, 1, 1) == " ") { files[$3] = 1 continue } else { filefield = 0 } } x = index($0, ":") if (!x) { continue } key = tolower(substr($0, 1, x - 1)) if (key == "directory") { dir = substr($0, x + 1) sub(/ */, "", dir) } else if (key == "filename") { file = substr($0, x + 1) sub(/ */, "", file) print file "\t" idx close(idx) next } else if (key == "files") { filefield = 1 } } if (val < 0) { print "Failed to read " idx > err exit 1 } close(idx) for (i in files) { print dir "/" i "\t" idx } } apt-move/move60000600000175000017500000000436607554156621015047 0ustar herbertgreathan00000000000000# $Id: move6,v 1.10 2002/10/19 04:20:33 herbert Exp $ function read(file, err) { err = getline < file if (err < 0) { print "getline failed on " file > "/dev/stderr" exit 1 } else if (err == 0) { eof = 1 return } binname = $1 binrel = $2 binver = $3 } function process(i, j, a, rel, arch) { for (i in best) { split(i, a, SUBSEP) rel = a[1] arch = a[2] print ones[i] arch twos[i] arch threes[i] tails[i] split(tails[i], a) for (j in a) { usecnt[a[j]] = 1 } if (arch != "binary-all") { continue } for (j in relarches) { split(j, a, SUBSEP) if (a[1] != rel || a[2] == "source") { continue } print ones[i] a[2] twos[i] a[2] threes[i] tails[i] } } for (i in usecnt) { if (!usecnt[i]) { print i > skipf } } } function check() { if (((rel, arch) in best) && cmpversion(best[rel, arch], ver) > 0) { return } best[rel, arch] = ver ones[rel, arch] = zero twos[rel, arch] = "/" rel one rel two threes[rel, arch] = three tails[rel, arch] = tail } BEGIN { binf = ARGV[1] archf = ARGV[2] skipf = ARGV[3] ARGC = 1 while ((val = getline < archf) > 0) { relarches[$1, $2] = 1 } if (val < 0) { print "getline failed on " archf > "/dev/stderr" exit 1 } read(binf) printf "" > skipf } { name = $1 } prevname != name { process() split("", rels) split("", vers) split("", best) split("", arches) split("", ones) split("", twos) split("", threes) split("", tails) split("", usecnt) } { split($1, a, /_/) dist = a[1] src = a[2] bin = a[3] ver = $2 arch = $3 file = $4 if (arch == "source") { bin = src } else { arch = "binary-" arch } tail = "" for (i = 5; i <= NF; i++) { tail = tail " " $i usecnt[$i] += 0 } } prevname != name { while (!eof && binname < name) { read(binf) } count = 0 while (!eof && binname == name) { count++ rels[count] = binrel vers[count] = binver read(binf) } prevname = name } !count { next } { zero = bin "/" one = " .apt-move/dists/" two = "/" dist "/" three = "/.index/" bin " " ver " " file for (i = 1; i <= count; i++) { rel = rels[i] bver = vers[i] if (arch != "binary-all" && !((rel, arch) in relarches)) { continue } if (cmpversion(ver, bver) > 0) { continue } check() } } END { process() } apt-move/Makefile0000600000175000017500000000116207625653533015522 0ustar herbertgreathan00000000000000# Debian makefile for apt-move CXXFLAGS = -g -O2 -Wall LDLIBS = -lapt-pkg DESTDIR = PREFIX = $(DESTDIR)/usr BINDIR = $(PREFIX)/bin MANDIR = $(PREFIX)/share/man/man8 CONFDIR = $(DESTDIR)/etc LIBDIR = $(PREFIX)/lib/apt-move SHAREDIR = $(PREFIX)/share/apt-move all: fetch fetch: fetch.o $(CXX) -o $@ $(LDFLAGS) $^ $(LOADLIBS) $(LDLIBS) clean: rm -f fetch *.o install: fetch install -p apt-move $(BINDIR) install fetch $(LIBDIR) install del1 move3 pkg1 $(SHAREDIR) install -m 644 get[23] move[4-7] *.awk Contents.head $(SHAREDIR) cp -p apt-move.conf $(CONFDIR) cp -p apt-move.8 $(MANDIR) .PHONY: all clean install apt-move/Contents.head0000600000175000017500000000262207625653533016504 0ustar herbertgreathan00000000000000This file maps each file available in the Debian GNU/Linux system to the package from which it originates. It includes packages from the DIST distribution for the ARCH architecture. You can use this list to determine which package contains a specific file, or whether or not a specific file is available. The list is updated weekly, each architecture on a different day. When a file is contained in more than one package, all packages are listed. When a directory is contained in more than one package, only the first is listed. The best way to search quickly for a file is with the Unix `grep' utility, as in `grep CONTENTS': $ grep nose Contents etc/nosendfile net/sendfile usr/X11R6/bin/noseguy x11/xscreensaver usr/X11R6/man/man1/noseguy.1x.gz x11/xscreensaver usr/doc/examples/ucbmpeg/mpeg_encode/nosearch.param graphics/ucbmpeg usr/lib/cfengine/bin/noseyparker admin/cfengine This list contains files in all packages, even though not all of the packages are installed on an actual system at once. If you want to find out which packages on an installed Debian system provide a particular file, you can use `dpkg --search ': $ dpkg --search /usr/bin/dselect dpkg: /usr/bin/dselect FILE LOCATION apt-move/move50000600000175000017500000000315307550253073015032 0ustar herbertgreathan00000000000000# $Id: move5,v 1.7 2002/10/07 09:39:07 herbert Exp $ function read(file, err, a) { err = getline < file if (err < 0) { print "getline failed on " file > "/dev/stderr" exit 1 } else if (err == 0) { eof = 1 return } split($1, a, /_/) ddist = a[1] dname = a[2] dver = $3 } function pskip(i) { for (i in files) { print i > skipf } } BEGIN { distf = ARGV[1] skipf = ARGV[2] srcf = ARGV[3] ARGC = 1 printf "" > srcf printf "" > skipf read(distf) } { name = $1 ver = $2 ifn = $3 sdir = $4 split("", files) for (i = 5; i <= NF; i++) { files[$i] = 1 } } sname != name { sname = name while (!eof && dname < name) { read(distf) } if (eof || dname != name) { pskip() next } split("", sdist) split("", sver) i = 1 do { sver[i] = dver sdist[i] = ddist i++ read(distf) } while (!eof && name == dname) } { low = "" for (i in sver) { if (sver[i] == ver) { low = ver dist = sdist[i] break } if (cmpversion(sver[i], ver) < 0) { continue } if (low == "" || cmpversion(sver[i], low) < 0) { low = sver[i] dist = sdist[i] } } } low == "" { pskip() next } { src = name ever = ver sub(/.*:/, "", ever) key = substr(src, 1, 1) if (key == "l" && substr(src, 1, 3) == "lib") { key = substr(src, 1, 4) } dir = "pool/" dist "/" key "/" src ifname = ".apt-move/" dir "/.index/" src "_" ver "_source" printf "1\tD %s\n", dir printf "1\tD .apt-move/%s/.index\n", dir printf ifname > srcf for (i in files) { printf "2\tm %s/%s %s/%s\n", sdir, i, dir, i printf " " sdir "/" i > srcf } printf "3\ti %s %s %s\n", ifn, ifname, dir print "" > srcf } apt-move/AUTHORS0000600000175000017500000000034410341757725015130 0ustar herbertgreathan00000000000000Copyright (c) 1999 Michael Merten Copyright (c) 1999-2000 Gregory T. Norris Copyright (c) 2000-2005 Herbert Xu $Id: AUTHORS,v 1.1 2005/11/26 04:08:53 herbert Exp $ apt-move/cmpversion.awk0000600000175000017500000000420610535427671016751 0ustar herbertgreathan00000000000000# cmpversion --- compare versions of Debian packages. # The function returns: # < 0 if a < b # == 0 if a == b # > 0 if a > b # This function depends on cmpbignum. # # Copyright (c) 2001 Herbert Xu # $Id: cmpversion.awk,v 1.3 2006/12/06 02:49:29 herbert Exp $ function _cmpversion_segment(a, b, i, j, k, l, m, n, p, q, d) { k = length(a) l = length(b) while (k > 0 && l > 0) { i = match(a, /[0-9]/) if (!i) { i = k + 1 } j = match(b, /[0-9]/) if (!j) { j = l + 1 } m = 1 n = 1 while (m < i && n < j) { p = substr(a, m, 1) if (p == "~") { p = "!" } q = substr(b, n, 1) if (q == "~") { q = "!"; } d = (p ~ /[A-Za-z]/) - (q ~ /[A-Za-z]/) if (d) { return d } if (p != q) { return p < q ? -1 : 1 } m++ n++ } d = (m < i) - (n < j) if (d) { return d } a = substr(a, i) b = substr(b, j) k -= i - 1 l -= j - 1 if (k <= 0 || l <= 0) { break } i = match(a, /[^0-9]/) if (!i) { i = k + 1 } j = match(b, /[^0-9]/) if (!j) { j = l + 1 } d = cmpbignum(substr(a, 1, i - 1), substr(b, 1, j - 1)) if (d) { return d } a = substr(a, i) b = substr(b, j) k -= i - 1 l -= j - 1 } if (k <= 0) { a = "0"; } if (l <= 0) { b = "0"; } a = substr(a, 1, 1); b = substr(b, 1, 1); d = (b ~ /~/) - (a ~ /~/); if (d) { return d; } return (k > 0) - (l > 0) } function cmpversion(a, b, i, j, k, l, d) { if (a == b) { return 0 } else if (a == "-") { return 1 } else if (b == "-") { return -1 } i = index(a, ":") j = index(b, ":") if (i > 1 || j > 1) { d = (i > 1) - (j > 1) if (d) { return d } d = cmpbignum(substr(a, 1, i - 1), substr(b, 1, j - 1)) if (d) { return d } i++ j++ } else { i = 1 j = 1 } a = substr(a, i) b = substr(b, j) k = match(a, /.*-/) if (k) { k = RLENGTH - 1 i = k + 2 } else { k = length(a) i = k + 1 } l = match(b, /.*-/) if (l) { l = RLENGTH - 1 j = l + 2 } else { l = length(b) j = l + 1 } d = _cmpversion_segment(substr(a, 1, k), substr(b, 1, l)) if (d) { return d } return _cmpversion_segment(substr(a, i), substr(b, j)) } apt-move/pkg10000700000175000017500000000234407625653541014652 0ustar herbertgreathan00000000000000#!/usr/bin/awk -f # $Id: pkg1,v 1.5 2003/02/22 10:56:33 herbert Exp $ function read(err) { err = getline < overf if (err < 0) { print "getline failed on " overf > "/dev/stderr" exit 1 } else if (err == 0) { eof = 1 return } opkg = $1 oprio = $2 != "-" ? $2 : "" osect = $3 != "-" ? $3 : "" if (NF >= 5) { otask = $4 != "-" ? $4 : "" } } BEGIN { overf = ARGV[1] contents = ARGV[2] ARGC = 1 read() } { pkg = $1 file = $2 while (!eof && opkg < pkg) { read() } task = sect = prio = "" if (!eof && opkg == pkg) { prio = oprio sect = osect task = otask } while ((err = getline < file) > 0) { if (/^Section:/) { if (sect != "") { print "Section: " sect } else { print sect = substr($0, 8) gsub(/ */, "", sect) } continue } if (prio != "" && /^Priority:/) { print "Priority: " prio continue } if (task != "" && /^$/) { print "Task: " task } print } if (err < 0) { print "getline failed on " file > "/dev/stderr" exit 1 } close(file) } contents { cnt = split(file, a, "/") file = substr(file, 1, length(file) - length(a[cnt]) - 8) file = file "/.content/" a[cnt] while (getline < file > 0) { print $0 " " sect "/" pkg > contents } close(file) } apt-move/SAMPLE.exclude0000600000175000017500000000500110013772563016400 0ustar herbertgreathan00000000000000# SAMPLE .exclude file for apt-move # # The following is a copy of my debian/.exclude file. # See the apt-move(8) manpage for additional details about how to set this up. # ----------------------------------------------------------------------------- # # Exclude file for Debian unstable mirror using apt-move # # You'll notice a lot of **/xxxx names. Its the easiest way for me # to indicate the start of a file name, and still be able to use # the same pattern with grep (minus the *s, of course) # # Packages I NEVER use and don't want to waste space on # ----------------------------------------------------------------- # # I make my own local Packages file Packages* # # this is HUGE **/tetex-src_* # # I'm not a ham... hamradio/ # # I'm refusing all kernel stuff except for 2.0.36 and 2.2.10 **/kernel-image-2.0.35_* **/kernel-headers-2.0.35_* **/kernel-source-2.0.3* **/kernel-doc-2.0.35_* **/kernel-image-2.1.* **/kernel-headers-2.1.* **/kernel-source-2.1.* **/kernel-doc-2.1.* **/kernel-image-2.2.[1579]_* **/kernel-headers-2.2.[1579]_* **/kernel-source-2.2.[1579]_* **/kernel-doc-2.2.[1579]_* **/kernel-patch-* **/pcmcia-modules-2.0.35_* **/pcmcia-modules-2.1.* **/pcmcia-modules-2.2.[1579]_* # # lots of foreign language stuff I don't need *kanji* *-es_* *-fr_* *-hr_* *-it_* *-ja_* *-ja-dev_* *-ko_* *-pl_* *-pl-dev_* *-pl-html_* *-sv_* *-zh_* *-de_* *-de-dev_* *-fi_* *-hu_* *japanese* *arabic* *asian* *chinese* *european* *brazilian* *british* *czech* *danish* *dutch* *french* *german* *italian* *norwegian* *polish* *portuguese* *spanish* *swedish* *cyrillic* *greek* *wnn* *canna* *big5* *-cjk_* **/kakasi-dic* # # magazines **/pj-9* **/lg-base* **/lg-issue* # # devel type stuff I don't need *m68k* *-dbg_* *-pic_* *-prof_* **/binutils-multiarch* # # Packages excluded because I don't have room #---------------------------------------------------------------------- **/ddd_* *prolog* **/icon[-ctx]* **/lapac-d* **/mercury_* **/mico-* **/pact[-_]* **/rscheme_* **/tabi-tsi_* **/wordnet* **/a4c.* *-static_* **/anarchism* **/9fonts* **/ada-rm_* **/aegis* **/asiya* **/bb_* **/bible-kjv* **/bigloo[-_]* **/bioperl_* **/clips[-_]* **/crossfire* **/cvs[-_]* **/doc-rfc_* **/docbook* **/dstool* **/elisp* **/epic4[-_]* **/epic_3* **/fidogate* **/fml_* **/gimp-manual* **/hbf-* **/libace* **/libsane* **/sane* **/xsane* **/ncbi-tools* **/scalapack* **/slatec[-_]* **/sml-nj* **/tochnog-doc* **/xfntil2* *-biznet-* *-altdev_* **/xbooks* *emacs* *quake* **/picon* **/timidity* **/abuse* **/scilab* **/networker* **/gnat* **/libroxen* **/roxen* apt-move/get20000600000175000017500000000041307551674401014637 0ustar herbertgreathan00000000000000# $Id: get2,v 1.3 2002/10/12 01:21:05 herbert Exp $ last != $1 { if (last) { print bestline } last = $1 bestline = $0 bestver = $NF next } { if (cmpversion($NF, bestver) > 0) { bestline = $0 bestver = $NF } } END { if (last) { print bestline } }