summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/.pacman.c.swpbin0 -> 24576 bytes
-rw-r--r--src/pacman.c10
-rw-r--r--src/pacman.h2
-rw-r--r--src/pacsync.c63
-rw-r--r--src/util.c13
5 files changed, 58 insertions, 30 deletions
diff --git a/src/.pacman.c.swp b/src/.pacman.c.swp
new file mode 100644
index 00000000..e318408d
--- /dev/null
+++ b/src/.pacman.c.swp
Binary files 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 <pkg>'\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);