Package: reprepro Version: 3.5.2-3 Severity: wishlist Tags: patch Hi,
we have a limited bandwidth at work so we run reprepo late at nicht when nobody is using it. But sometimes it takes too long and it is still running in the morning and blocks our internet. The attached patch adds a -t, --timelimit <x> options that makes reprepro stop fetching new files after x seconds. The current file (and maybe one or two more?) will finish downloading so a clean shutdown and export is possible but lists should not be marked done so the next run will continue where it left of. I hope that works right in the patch. MfG Goswin -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable'), (400, 'unstable-i386') Architecture: amd64 (x86_64) Kernel: Linux 2.6.25-kvm-nofb (SMP w/2 CPU cores) Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C) Shell: /bin/sh linked to /bin/bash Versions of packages reprepro depends on: ii libarchive1 2.4.17-2 Single library to read/write tar, ii libbz2-1.0 1.0.5-1 high-quality block-sorting file co ii libc6 2.7-13 GNU C Library: Shared libraries ii libdb4.3 4.3.29-11 Berkeley v4.3 Database Libraries [ ii libgpg-error0 1.4-2 library for common error values an ii libgpgme11 1.1.6-2 GPGME - GnuPG Made Easy ii zlib1g 1:1.2.3.3.dfsg-12 compression library - runtime Versions of packages reprepro recommends: ii apt 0.7.14+b1 Advanced front-end for dpkg Versions of packages reprepro suggests: ii gnupg-agent 2.0.9-3 GNU privacy guard - password agent pn inoticoming <none> (no description available) -- no debconf information
diff -u reprepro-3.5.2/main.c reprepro-3.5.2/main.c --- reprepro-3.5.2/main.c +++ reprepro-3.5.2/main.c @@ -2787,6 +2787,7 @@ " -C, --component <component>: Add,list or delete only in component.\n" " -A, --architecture <architecture>: Add,list or delete only to architecture.\n" " -T, --type <type>: Add,list or delete only type (dsc,deb,udeb).\n" +" -t, --timelimit <seconds: Set a time limit for downloading packages.\n" "\n" "actions (selection, for more see manpage):\n" " dumpreferences: Print all saved references\n" @@ -3029,6 +3030,9 @@ } CONFIGDUP(x_priority, optarg); break; + case 't': + time_limit = time(0) + atoi(optarg); + break; case '?': /* getopt_long should have already given an error msg */ exit(EXIT_FAILURE); @@ -3117,6 +3121,7 @@ {"spacecheck", required_argument, &longoption, LO_SPACECHECK}, {"safetymargin", required_argument, &longoption, LO_SAFETYMARGIN}, {"dbsafetymargin", required_argument, &longoption, LO_DBSAFETYMARGIN}, + {"timelimit", required_argument, &longoption, 't'}, {NULL, 0, NULL, 0} }; const struct action *a; @@ -3149,7 +3154,7 @@ if( interrupted() ) exit(EXIT_RET(RET_ERROR_INTERRUPTED)); - while( (c = getopt_long(argc,argv,"+fVvshb:P:i:A:C:S:T:",longopts,NULL)) != -1 ) { + while( (c = getopt_long(argc,argv,"+fVvshb:P:i:A:C:S:T:t:",longopts,NULL)) != -1 ) { handle_option(c,optarg); } if( optind >= argc ) { diff -u reprepro-3.5.2/debian/changelog reprepro-3.5.2/debian/changelog --- reprepro-3.5.2/debian/changelog +++ reprepro-3.5.2/debian/changelog @@ -1,3 +1,10 @@ +reprepro (3.5.2-3a0.mrvn.1) unstable; urgency=low + + [ Goswin von Brederlow ] + * Add time limit + + -- Goswin von Brederlow <[EMAIL PROTECTED]> Mon, 22 Sep 2008 14:39:38 +0200 + reprepro (3.5.2-3) unstable; urgency=low * backport some bugfixes of 3.6.1 to 3.5.2: diff -u reprepro-3.5.2/debian/rules reprepro-3.5.2/debian/rules --- reprepro-3.5.2.orig/updates.c +++ reprepro-3.5.2/updates.c @@ -78,6 +78,7 @@ #include "configparser.h" #include "filecntl.h" +time_t time_limit = 0; extern int verbose; /* The data structures of this one: ("u_" is short for "update_") @@ -1762,12 +1763,17 @@ break; } - for( d=distributions ; d != NULL ; d=d->next) { - struct update_target *u; + if( time_limit == 0 || time_limit > time(0) ) { + for( d=distributions ; d != NULL ; d=d->next) { + struct update_target *u; - for( u=d->targets ; u != NULL ; u=u->next ) { - markdone(u); + for( u=d->targets ; u != NULL ; u=u->next ) { + markdone(u); + } } + } else { + if( verbose >= 0 ) + printf("Warning: Time limit exceeded, not marking lists as done!\n"); } logger_wait(); only in patch2: unchanged: --- reprepro-3.5.2.orig/updates.h +++ reprepro-3.5.2/updates.h @@ -18,7 +18,9 @@ #include "freespace.h" #endif +#include <time.h> +extern time_t time_limit; struct update_pattern; struct update_origin; struct update_target; only in patch2: unchanged: --- reprepro-3.5.2.orig/aptmethod.c +++ reprepro-3.5.2/aptmethod.c @@ -27,6 +27,7 @@ #include <assert.h> #include <string.h> #include <ctype.h> +#include <time.h> #include "error.h" #include "mprintf.h" #include "strlist.h" @@ -39,7 +40,7 @@ #include "filecntl.h" extern int verbose; - +extern time_t time_limit; struct aptmethod { /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/ @@ -1166,7 +1167,7 @@ r = readwrite(run, &workleft, database); RET_UPDATE(result,r); // TODO: check interrupted here... - } while( workleft > 0 ); + } while( workleft > 0 && (time_limit == 0 || time_limit > time(0))); return result; }