From 185ce5454e4afd11b1f90d7fe487b0ec3cb840c7 Mon Sep 17 00:00:00 2001 From: Judd Vinet Date: Mon, 17 Mar 2003 19:36:48 +0000 Subject: Imported from pacman-2.3.2.tar.gz --- ChangeLog | 5 +++++ Makefile.in | 2 +- TODO | 1 - etc/makepkg.conf | 6 ++++++ etc/pacman.conf | 13 ++++++++--- libftp/ftplib.c | 18 +++++++++++++++- libftp/ftplib.h | 1 + scripts/gensync | 2 +- scripts/makepkg | 50 ++++++++++++++++++++++++++++--------------- scripts/makeworld | 2 +- src/.pacman.c.swp | Bin 0 -> 24576 bytes src/pacman.c | 10 ++++++++- src/pacman.h | 2 +- src/pacsync.c | 63 ++++++++++++++++++++++++++++++------------------------ src/util.c | 13 +++++++++++ 15 files changed, 133 insertions(+), 55 deletions(-) create mode 100644 src/.pacman.c.swp diff --git a/ChangeLog b/ChangeLog index d9469ea1..707826b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ VERSION DESCRIPTION ------------------------------------------------------------------ +2.3.2 - Added patches from Aurelien Foret: + - FTP resume feature + - IgnorePkg option in pacman.conf + - FTPAGENT setting in makepkg.conf + - Added --cleancache option to makepkg 2.3.1 - Fixed the progress bar overflow - Pacman does not ask "Are you sure" when you use --downloadonly - Switched up a couple makepkg options to be more consistent diff --git a/Makefile.in b/Makefile.in index b5479d6d..c5f89922 100644 --- a/Makefile.in +++ b/Makefile.in @@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ -PACVER = 2.3.1 +PACVER = 2.3.2 LIBTAR_VERSION = 1.2.5 TOPDIR = @srcdir@ diff --git a/TODO b/TODO index 7b1d6f07..add6b4be 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,6 @@ - add some logging mechanism (/var/log/pacman.log) - handle version comparators in makepkg dep resolution (eg, glibc>=2.2.5) - have "group" designations -- IgnorePkg option/switch in pacman.conf to ignore updates from the sync repo - record md5sums of all files in a package - add a way to clean /var/cache/pacman/src - duplicate dep checks occur with sync (one in sync, one in add) diff --git a/etc/makepkg.conf b/etc/makepkg.conf index c73d9889..b2d8a893 100644 --- a/etc/makepkg.conf +++ b/etc/makepkg.conf @@ -5,6 +5,11 @@ # the top-level directory of all your PKGBUILDs export ABSROOT="/usr/abs" +# The FTP/HTTP download utility that makepkg should use to acquire sources +export FTPAGENT="/usr/bin/wget --continue --passive-ftp --tries=3 --waitretry=3" +#export FTPAGENT="/usr/bin/snarf" +#export FTPAGENT="/usr/bin/lftpget -c" + # Pentium Pro/Pentium II/Pentium III+/Pentium 4/Athlon optimized (but binaries # will run on any x86 system) #export CHOST="i686-pc-linux-gnu" @@ -22,3 +27,4 @@ export CXXFLAGS="-march=i686 -O2 -pipe" # if you want your name to show up in the packages you build, set this. #export PACKAGER="John Doe " + diff --git a/etc/pacman.conf b/etc/pacman.conf index ad77cfec..8262aad3 100644 --- a/etc/pacman.conf +++ b/etc/pacman.conf @@ -2,14 +2,21 @@ # /etc/pacman.conf # -# Currently the only option directive is NoUpgrade. Use this with a -# space-delimited list of files that should never be touched by pacman -# during an install/upgrade. (note: do not include the leading slash) +# GENERAL OPTIONS +# NoUpgrade: a space-delimited list of files that should never +# be touched by pacman during an install/upgrade. +# (note: do not include the leading slash) +# IgnorePkg: a space-delimited list of packages that pacman should NOT +# upgrade when doing a --sysupgrade [options] NoUpgrade = etc/passwd etc/group etc/shadow NoUpgrade = etc/fstab etc/rc.conf etc/rc.local NoUpgrade = etc/lilo.conf etc/raidtab +#IgnorePkg = lilo gcc +# +# REPOSITORIES +# [current] Server = ftp://ftp.archlinux.org/current Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/current diff --git a/libftp/ftplib.c b/libftp/ftplib.c index 9089a5b3..d8c25f58 100644 --- a/libftp/ftplib.c +++ b/libftp/ftplib.c @@ -1104,7 +1104,7 @@ static int FtpXfer(const char *localfile, const char *path, if (localfile != NULL) { - char ac[4] = "w"; + char ac[4] = "a"; if (typ == FTPLIB_FILE_WRITE) ac[0] = 'r'; if (mode == FTPLIB_IMAGE) @@ -1199,6 +1199,22 @@ GLOBALDEF int FtpSize(const char *path, int *size, char mode, netbuf *nControl) return rv; } +/* + * FtpRestart - issue a REST command + * + * return 1 if successful, 0 otherwise + */ +GLOBALDEF int FtpRestart(int offset, netbuf *nControl) +{ + char cmd[256]; + int rv=1; + + sprintf(cmd,"REST %d",offset); + if (!FtpSendCmd(cmd,'3',nControl)) + rv = 0; + return rv; +} + /* * FtpModDate - determine the modification date of a remote file * diff --git a/libftp/ftplib.h b/libftp/ftplib.h index c281b723..05bdf9e1 100644 --- a/libftp/ftplib.h +++ b/libftp/ftplib.h @@ -109,6 +109,7 @@ GLOBALREF int FtpPwd(char *path, int max, netbuf *nControl); GLOBALREF int FtpNlst(const char *output, const char *path, netbuf *nControl); GLOBALREF int FtpDir(const char *output, const char *path, netbuf *nControl); GLOBALREF int FtpSize(const char *path, int *size, char mode, netbuf *nControl); +GLOBALREF int FtpRestart(int offset, netbuf *nControl); GLOBALREF int FtpModDate(const char *path, char *dt, int max, netbuf *nControl); GLOBALREF int FtpGet(const char *output, const char *path, char mode, netbuf *nControl); diff --git a/scripts/gensync b/scripts/gensync index cc825f3b..e73ba3c1 100755 --- a/scripts/gensync +++ b/scripts/gensync @@ -1,6 +1,6 @@ #!/bin/bash -myver='2.3.1' +myver='2.3.2' usage() { echo "gensync $myver" diff --git a/scripts/makepkg b/scripts/makepkg index 5f39a832..890ec22f 100755 --- a/scripts/makepkg +++ b/scripts/makepkg @@ -1,6 +1,6 @@ #!/bin/bash -myver='2.3.1' +myver='2.3.2' startdir=`pwd` [ -f /etc/makepkg.conf ] && source /etc/makepkg.conf @@ -52,6 +52,7 @@ if [ "$1" = "--help" -o "$1" = "-h" ]; then echo "usage: $0 [options] [build_script]" echo "options:" echo " -c, --clean Clean up work files after build" + echo " -C, --cleancache Clean up source files from the cache" echo " -s, --syncdeps Install missing dependencies with pacman" echo " -b, --builddeps Build missing dependencies from source" echo " -d, --nodeps Skip all dependency checks" @@ -67,6 +68,7 @@ fi # Options CLEANUP=0 +CLEANCACHE=0 INSTALL=0 DEP_BIN=0 DEP_SRC=0 @@ -79,6 +81,9 @@ for arg in $*; do -c|--clean) CLEANUP=1 ;; + -C|--cleancache) + CLEANCACHE=1 + ;; -s|--syncdeps) DEP_BIN=1 ;; @@ -100,22 +105,16 @@ for arg in $*; do esac done +if [ "$CLEANCACHE" = "1" ]; then + msg "==> Cleaning up source files from the cache" + rm -rf /var/cache/pacman/src/* + exit 0 +fi + unset pkgname pkgver pkgrel pkgdesc unset depends conflicts backup source install build umask 0022 -# check for a download utility -if [ -x /usr/bin/wget ]; then - ftpagent="/usr/bin/wget --passive-ftp --tries=3 --waitretry=3" -elif [ -x /usr/bin/snarf ]; then - ftpagent="/usr/bin/snarf" -elif [ -x /usr/bin/lftpget -a "$proto" = "ftp" ]; then - ftpagent="/usr/bin/lftpget" -else - msg "==> ERROR: You need an ftp client installed (snarf/lftp/wget) in /usr/bin" - exit 1 -fi - if [ ! -f $BUILDSCRIPT ]; then msg "==> ERROR: $BUILDSCRIPT does not exist." exit 1 @@ -151,7 +150,7 @@ if [ `type -p pacman` -a "$NODEPS" = "0" ]; then msg "==> ERROR: Failed to install missing dependencies." exit 1 fi - # TODO: check deps again to make sure they were resolved + # TODO: check deps again to make sure they were resolved elif [ "$DEP_SRC" = "1" ]; then # install missing deps by building them from source. # we look for each package name in $ABSROOT and build it. @@ -183,7 +182,7 @@ if [ `type -p pacman` -a "$NODEPS" = "0" ]; then exit 1 fi done - # TODO: check deps again to make sure they were resolved + # TODO: check deps again to make sure they were resolved else exit 1 fi @@ -211,6 +210,18 @@ for netfile in ${source[@]}; do msg "==> Using local copy of $file" cp /var/cache/pacman/src/$file . else + # check for a download utility + if [ -z "$FTPAGENT" ]; then + msg "==> ERROR: FTPAGENT is not configured. Check the /etc/makepkg.conf file." + msg "==> Aborting..." + exit 1 + fi + ftpclient=`echo $FTPAGENT | awk {'print $1'}` + if [ ! -x $ftpclient ]; then + msg "==> ERROR: ftpclient `basename $ftpclient` is not installed." + msg "==> Aborting..." + exit 1 + fi proto=`echo $netfile | sed 's|://.*||'` if [ "$proto" != "ftp" -a "$proto" != "http" ]; then msg "==> ERROR: $netfile was not found in the build directory and is not a proper URL." @@ -218,7 +229,7 @@ for netfile in ${source[@]}; do exit 1 fi msg "==> Downloading $file" - $ftpagent $netfile 2>&1 + $FTPAGENT $netfile 2>&1 if [ ! -f $file ]; then msg "==> ERROR: Failed to download $file" msg "==> Aborting..." @@ -242,6 +253,11 @@ for netfile in ${source[@]}; do if [ "$cmd" != "" ]; then msg "==> $cmd" $cmd + if [ $? -ne 0 ]; then + msg "==> ERROR: Failed to extract $file" + msg "==> Aborting..." + exit 1 + fi fi done @@ -348,7 +364,7 @@ fi cd $startdir if [ "$CLEANUP" = "1" ]; then msg "==> Cleaning up" - rm -rf src pkg + rm -rf src pkg filelist fi d=`date` diff --git a/scripts/makeworld b/scripts/makeworld index 3c523f9c..9b5e46cd 100755 --- a/scripts/makeworld +++ b/scripts/makeworld @@ -1,7 +1,7 @@ #!/bin/bash toplevel=`pwd` -version="2.3.1" +version="2.3.2" usage() { echo "makeworld version $version" diff --git a/src/.pacman.c.swp b/src/.pacman.c.swp new file mode 100644 index 00000000..e318408d Binary files /dev/null and b/src/.pacman.c.swp differ diff --git a/src/pacman.c b/src/pacman.c index 5ea0c1a7..779fc581 100644 --- a/src/pacman.c +++ b/src/pacman.c @@ -76,6 +76,7 @@ unsigned short pmo_s_sync = 0; unsigned short pmo_s_search = 0; unsigned short pmo_s_clean = 0; PMList *pmo_noupgrade = NULL; +PMList *pmo_ignorepkg = NULL; /* list of sync_t structs for sync locations */ @@ -379,6 +380,7 @@ int pacman_sync(pacdb_t *db, PMList *targets) } } else if(pmo_s_upgrade) { int newer = 0; + int ignore = 0; for(i = pm_packages; i && allgood; i = i->next) { int cmp, found = 0; pkginfo_t *local = (pkginfo_t*)i->data; @@ -400,6 +402,12 @@ int pacman_sync(pacdb_t *db, PMList *targets) /*fprintf(stderr, "%s: not found in sync db. skipping.", local->name);*/ continue; } + /* check if package should be ignored */ + if(is_in((char*)i->data, pmo_ignorepkg)) { + fprintf(stderr, ":: %s: ignoring package upgrade\n", (char*)i->data); + ignore = 1; + continue; + } /* compare versions and see if we need to upgrade */ cmp = rpmvercmp(local->version, sync->pkg->version); if(cmp > 0) { @@ -438,7 +446,7 @@ int pacman_sync(pacdb_t *db, PMList *targets) } } } - if(newer && allgood) { + if((newer || ignore) && allgood) { fprintf(stderr, ":: Above packages will be skipped. To manually upgrade use 'pacman -S '\n"); } } else { diff --git a/src/pacman.h b/src/pacman.h index 2c9b19a4..e248a8bf 100644 --- a/src/pacman.h +++ b/src/pacman.h @@ -22,7 +22,7 @@ #define _PAC_PACMAN_H #ifndef PACVER -#define PACVER "2.3.1" +#define PACVER "2.3.2" #endif #ifndef PKGDIR diff --git a/src/pacsync.c b/src/pacsync.c index f61a61e0..72b0a0d4 100644 --- a/src/pacsync.c +++ b/src/pacsync.c @@ -38,6 +38,7 @@ static int log_progress(netbuf *ctl, int xfered, void *arg); static char sync_fnm[25]; +static int offset; /* pacman options */ extern char *pmo_root; @@ -104,7 +105,6 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files) int done = 0; PMList *complete = NULL; PMList *i; - extern char* workfile; if(files == NULL) { return(0); @@ -136,12 +136,13 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files) char output[PATH_MAX]; int j; char *fn = (char*)lp->data; + struct stat st; if(is_in(fn, complete)) { continue; } - snprintf(output, PATH_MAX, "%s/%s", localpath, fn); + snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn); strncpy(sync_fnm, lp->data, 24); for(j = strlen(sync_fnm); j < 24; j++) { sync_fnm[j] = ' '; @@ -157,30 +158,36 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files) if(!FtpSize(fn, &fsz, FTPLIB_IMAGE, control)) { fprintf(stderr, "warning: failed to get filesize for %s\n", fn); } + offset = 0; + if(!stat(output, &st)) { + offset = (int)st.st_size; + } + if(offset) { + if(!FtpRestart(offset, control)) { + fprintf(stderr, "warning: failed to resume download -- restarting\n"); + /* can't resume: */ + /* unlink the file in order to restart download from scratch */ + unlink(output); + } + } /* set up our progress bar's callback */ FtpOptions(FTPLIB_CALLBACK, (long)log_progress, control); FtpOptions(FTPLIB_IDLETIME, (long)1000, control); FtpOptions(FTPLIB_CALLBACKARG, (long)&fsz, control); FtpOptions(FTPLIB_CALLBACKBYTES, (10*1024), control); - /* declare our working file so it can be removed it on interrupt */ - /* by the cleanup() function */ - if(workfile) { - FREE(workfile); - } - MALLOC(workfile, PATH_MAX); - strcpy(workfile, output); - if(!FtpGet(output, lp->data, FTPLIB_IMAGE, control)) { fprintf(stderr, "\nfailed downloading %s from %s: %s\n", fn, server->server, FtpLastResponse(control)); - /* unlink the file */ - unlink(output); + /* we leave the partially downloaded file in place so it can be resumed later */ } else { - log_progress(control, fsz, &fsz); + char completefile[PATH_MAX]; + log_progress(control, fsz-offset, &fsz); complete = list_add(complete, fn); + /* rename "output.part" file to "output" file */ + snprintf(completefile, PATH_MAX, "%s/%s", localpath, fn); + rename(output, completefile); } - FREE(workfile); printf("\n"); fflush(stdout); } else { @@ -220,20 +227,20 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files) static int log_progress(netbuf *ctl, int xfered, void *arg) { - int fsz = *(int*)arg; - int pct = ((float)xfered / fsz) * 100; - int i; - - printf("%s [", sync_fnm); - for(i = 0; i < (int)(pct/3); i++) { - printf("#"); - } - for(i = (int)(pct/3); i < (int)(100/3); i++) { - printf(" "); - } - printf("] %3d%% | %6dK\r", pct, (xfered/1024)); - fflush(stdout); - return(1); + int fsz = *(int*)arg; + int pct = ((float)(xfered+offset) / fsz) * 100; + int i; + + printf("%s [", sync_fnm); + for(i = 0; i < (int)(pct/3); i++) { + printf("#"); + } + for(i = (int)(pct/3); i < (int)(100/3); i++) { + printf(" "); + } + printf("] %3d%% | %6dK\r ", pct, ((xfered+offset)/1024)); + fflush(stdout); + return(1); } /* vim: set ts=2 sw=2 noet: */ diff --git a/src/util.c b/src/util.c index cba4a050..96a91371 100644 --- a/src/util.c +++ b/src/util.c @@ -59,6 +59,7 @@ extern unsigned short pmo_s_clean; extern unsigned short pmo_s_upgrade; extern unsigned short pmo_s_downloadonly; extern PMList *pmo_noupgrade; +extern PMList *pmo_ignorepkg; extern PMList *pmc_syncs; extern PMList *pm_targets; @@ -305,6 +306,18 @@ int parseconfig(char *configfile) } pmo_noupgrade = list_add(pmo_noupgrade, strdup(p)); vprint("config: noupgrade: %s\n", p); + } else if(!strcmp(key, "IGNOREPKG")) { + char *p = ptr; + char *q; + while((q = strchr(p, ' '))) { + *q = '\0'; + pmo_ignorepkg = list_add(pmo_ignorepkg, strdup(p)); + vprint("config: ignorepkg: %s\n", p); + p = q; + p++; + } + pmo_ignorepkg = list_add(pmo_ignorepkg, strdup(p)); + vprint("config: ignorepkg: %s\n", p); } else { fprintf(stderr, "config: line %d: syntax error\n", linenum); return(1); -- cgit v1.2.3-24-g4f1b