Imported from pacman-2.9.1.tar.gz

This commit is contained in:
Judd Vinet 2004-09-25 00:15:56 +00:00
parent 4ffc53b339
commit deff79c76c
18 changed files with 211 additions and 136 deletions

View file

@ -1,5 +1,7 @@
VERSION DESCRIPTION VERSION DESCRIPTION
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
2.9.1 - --refresh now only downloads fresh packages lists if they've
been updated (currently only works with FTP)
2.9 - Improved -Rs functionality -- pacman now tracks why a package 2.9 - Improved -Rs functionality -- pacman now tracks why a package
is installed: explicitly, or as a dependency for another is installed: explicitly, or as a dependency for another
package. -Rs will only remove dependencies that were not package. -Rs will only remove dependencies that were not

View file

@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
PACVER = 2.9 PACVER = 2.9.1
TOPDIR = @srcdir@ TOPDIR = @srcdir@
SRCDIR = $(TOPDIR)/src/ SRCDIR = $(TOPDIR)/src/
@ -108,10 +108,6 @@ install: pacman vercmp convertdb man
$(INSTALL) -D -m0644 $(MANSRC)makepkg.8 $(DESTDIR)$(MANDIR)/man8/makepkg.8 $(INSTALL) -D -m0644 $(MANSRC)makepkg.8 $(DESTDIR)$(MANDIR)/man8/makepkg.8
$(INSTALL) -D -m0644 etc/pacman.conf $(DESTDIR)/etc/pacman.conf $(INSTALL) -D -m0644 etc/pacman.conf $(DESTDIR)/etc/pacman.conf
$(INSTALL) -D -m0644 etc/makepkg.conf $(DESTDIR)/etc/makepkg.conf $(INSTALL) -D -m0644 etc/makepkg.conf $(DESTDIR)/etc/makepkg.conf
$(INSTALL) -D -m0644 etc/current $(DESTDIR)/etc/pacman.d/current
$(INSTALL) -D -m0644 etc/release $(DESTDIR)/etc/pacman.d/release
$(INSTALL) -D -m0644 etc/extra $(DESTDIR)/etc/pacman.d/extra
$(INSTALL) -D -m0644 etc/unstable $(DESTDIR)/etc/pacman.d/unstable
clean: clean:
rm -f *~ $(OBJDIR)*.o $(MANSRC)*.8 rm -f *~ $(OBJDIR)*.o $(MANSRC)*.8

View file

@ -219,7 +219,7 @@ global options.
.RS .RS
.nf .nf
[options] [options]
NoUpgrade = etc/passed etc/group etc/shadow NoUpgrade = etc/passwd etc/group etc/shadow
NoUpgrade = etc/fstab NoUpgrade = etc/fstab
Include = /etc/pacman.d/current Include = /etc/pacman.d/current

View file

@ -1,18 +0,0 @@
#
# CURRENT: Arch Linux core repository
#
[current]
Server = ftp://ftp.archlinux.org/current/os/i686
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/current/os/i686
Server = ftp://ftp.archlinux.de/pub/archlinux/current/os/i686
Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/current/os/i686
Server = http://archlinux.antesis.org/current/os/i686
Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/current/os/i686
Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/current/os/i686
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/current/os/i686
Server = ftp://ftp.kegep.tuc.gr/archlinux/current/os/i686
Server = http://darkstar.ist.utl.pt/archlinux/current/os/i686
Server = ftp://archlinux.creativa.cl/current/os/i686
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/current/os/i686
Server = ftp://saule.mintis.lt/pub/linux/current/os/i686
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/current/os/i686

View file

@ -1,18 +0,0 @@
#
# The Extra Repository
#
[extra]
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/extra/os/i686
Server = ftp://ftp.archlinux.de/pub/archlinux/extra/os/i686
Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/extra/os/i686
Server = http://archlinux.antesis.org/extra/os/i686
Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/extra/os/i686
Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/extra/os/i686
Server = ftp://ftp.archlinux.org/extra/os/i686
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/extra/os/i686
Server = ftp://ftp.kegep.tuc.gr/archlinux/extra/os/i686
Server = http://darkstar.ist.utl.pt/archlinux/extra/os/i686
Server = ftp://archlinux.creativa.cl/extra/os/i686
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/extra/os/i686
Server = ftp://saule.mintis.lt/pub/linux/extra/os/i686
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/extra/os/i686

View file

@ -33,6 +33,9 @@ HoldPkg = pacman glibc
# - local/custom mirrors can be added here or in separate files # - local/custom mirrors can be added here or in separate files
# #
#[testing]
#Server = ftp://ftp.archlinux.org/testing/os/i686
[current] [current]
# Add your preferred servers here, they will be used first # Add your preferred servers here, they will be used first
Include = /etc/pacman.d/current Include = /etc/pacman.d/current

View file

@ -1,21 +0,0 @@
#
# The Release tree. This tree is a snapshot view of the Current (core)
# repository as it was when the last ISO was released.
#
# If you use the RELEASE tree, you should disable the CURRENT
# tree to avoid conflicts
#
[release]
Server = ftp://ftp.archlinux.org/release/os/i686
Server = ftp://ftp.archlinux.de/pub/archlinux/release/os/i686
Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/release/os/i686
Server = http://archlinux.antesis.org/release/os/i686
Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/release/os/i686
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/release/os/i686
Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/release/os/i686
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/release/os/i686
Server = ftp://ftp.kegep.tuc.gr/archlinux/release/os/i686
Server = http://darkstar.ist.utl.pt/archlinux/release/os/i686
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/release/os/i686
Server = ftp://saule.mintis.lt/pub/linux/release/os/i686
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/release/os/i686

View file

@ -1,17 +0,0 @@
#
# The Unstable tree. Contains unstable or development versions of packages.
#
[unstable]
Server = ftp://ftp.archlinux.org/unstable/os/i686
Server = ftp://ftp.archlinux.de/pub/archlinux/unstable/os/i686
Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/unstable/os/i686
Server = http://archlinux.antesis.org/unstable/os/i686
Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/unstable/os/i686
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/unstable/os/i686
Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/unstable/os/i686
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/unstable/os/i686
Server = http://darkstar.ist.utl.pt/archlinux/unstable/os/i686
Server = ftp://archlinux.creativa.cl/unstable/os/i686
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/unstable/os/i686
Server = ftp://saule.mintis.lt/pub/linux/unstable/os/i686
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unstable/os/i686

View file

@ -20,7 +20,7 @@
# USA. # USA.
# #
myver='2.9' myver='2.9.1'
usage() { usage() {
echo "gensync $myver" echo "gensync $myver"

View file

@ -20,7 +20,7 @@
# USA. # USA.
# #
myver='2.9' myver='2.9.1'
startdir=`pwd` startdir=`pwd`
PKGDEST=$startdir PKGDEST=$startdir
USE_COLOR="n" USE_COLOR="n"

View file

@ -21,7 +21,7 @@
# #
toplevel=`pwd` toplevel=`pwd`
version="2.9" version="2.9.1"
usage() { usage() {
echo "makeworld version $version" echo "makeworld version $version"

View file

@ -21,7 +21,7 @@
# USA. # USA.
# #
myver='2.9' myver='2.9.1'
usage() { usage() {
echo "updatesync $myver" echo "updatesync $myver"

View file

@ -24,6 +24,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <libgen.h> #include <libgen.h>
#include <unistd.h> #include <unistd.h>
@ -43,7 +44,7 @@ pacdb_t* db_open(char *root, char *pkgdir, char *treename)
if(db->dir == NULL) { if(db->dir == NULL) {
return(NULL); return(NULL);
} }
strncpy(db->treename, treename, sizeof(db->treename)); strncpy(db->treename, treename, sizeof(db->treename)-1);
return(db); return(db);
} }
@ -61,6 +62,52 @@ void db_close(pacdb_t* db)
return; return;
} }
/* reads dbpath/.lastupdate and populates *ts with the contents.
* *ts should be malloc'ed and should be at least 15 bytes.
*
* Returns 0 on success, 1 on error
*
*/
int db_getlastupdate(const char *dbpath, char *ts)
{
FILE *fp;
char path[PATH_MAX];
/* get the last update time, if it's there */
snprintf(path, PATH_MAX, "%s/.lastupdate", dbpath);
if((fp = fopen(path, "r")) == NULL) {
return(1);
} else {
char line[256];
if(fgets(line, sizeof(line), fp)) {
strncpy(ts, line, 15); /* YYYYMMDDHHMMSS */
ts[14] = '\0';
} else {
fclose(fp);
return(1);
}
}
fclose(fp);
return(0);
}
/* writes the db->path/.lastupdate with the contents of *ts
*/
int db_setlastupdate(const char *dbpath, const char *ts)
{
FILE *fp;
char path[PATH_MAX];
snprintf(path, PATH_MAX, "%s/.lastupdate", dbpath);
if((fp = fopen(path, "w")) == NULL) {
return(1);
}
if(fputs(ts, fp) <= 0) {
fclose(fp);
return(1);
}
fclose(fp);
return(0);
}
/* frees pkgcache if necessary and returns a new package /* frees pkgcache if necessary and returns a new package
* cache from db * cache from db
@ -82,6 +129,8 @@ PMList* db_loadpkgs(pacdb_t *db)
pkginfo_t* db_scan(pacdb_t *db, char *target, unsigned int inforeq) pkginfo_t* db_scan(pacdb_t *db, char *target, unsigned int inforeq)
{ {
struct dirent *ent = NULL; struct dirent *ent = NULL;
struct stat sbuf;
char path[PATH_MAX];
char name[256]; char name[256];
char *ptr = NULL; char *ptr = NULL;
int found = 0; int found = 0;
@ -96,6 +145,11 @@ pkginfo_t* db_scan(pacdb_t *db, char *target, unsigned int inforeq)
continue; continue;
} }
strncpy(name, ent->d_name, 255); strncpy(name, ent->d_name, 255);
/* stat the entry, make sure it's a directory */
snprintf(path, PATH_MAX, "%s/%s", db->path, name);
if(stat(path, &sbuf) || !S_ISDIR(sbuf.st_mode)) {
continue;
}
/* truncate the string at the second-to-last hyphen, */ /* truncate the string at the second-to-last hyphen, */
/* which will give us the package name */ /* which will give us the package name */
if((ptr = rindex(name, '-'))) { if((ptr = rindex(name, '-'))) {
@ -115,15 +169,21 @@ pkginfo_t* db_scan(pacdb_t *db, char *target, unsigned int inforeq)
} }
} else { } else {
/* normal iteration */ /* normal iteration */
int isdir = 0;
while(!isdir) {
ent = readdir(db->dir); ent = readdir(db->dir);
if(ent == NULL) { if(ent == NULL) {
return(NULL); return(NULL);
} }
if(!strcmp(ent->d_name, ".")) { /* stat the entry, make sure it's a directory */
ent = readdir(db->dir); snprintf(path, PATH_MAX, "%s/%s", db->path, ent->d_name);
if(!stat(path, &sbuf) && S_ISDIR(sbuf.st_mode)) {
isdir = 1;
}
if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
isdir = 0;
continue;
} }
if(!strcmp(ent->d_name, "..")) {
ent = readdir(db->dir);
} }
} }
return(db_read(db, ent, inforeq)); return(db_read(db, ent, inforeq));
@ -651,7 +711,7 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root)
} }
if(!ok) { if(!ok) {
MALLOC(str, 512); MALLOC(str, 512);
snprintf(str, 512, "%s: exists in filesystem", path); snprintf(str, 512, "%s: %s: exists in filesystem", p->name, path);
conflicts = list_add(conflicts, str); conflicts = list_add(conflicts, str);
} }
} }

View file

@ -37,6 +37,8 @@ typedef struct __pacdb_t {
pacdb_t* db_open(char *root, char *dbpath, char *treename); pacdb_t* db_open(char *root, char *dbpath, char *treename);
void db_close(pacdb_t *db); void db_close(pacdb_t *db);
int db_getlastupdate(const char *dbpath, char *ts);
int db_setlastupdate(const char *dbpath, const char *ts);
PMList* db_loadpkgs(pacdb_t *db); PMList* db_loadpkgs(pacdb_t *db);
pkginfo_t* db_scan(pacdb_t *db, char *target, unsigned int inforeq); pkginfo_t* db_scan(pacdb_t *db, char *target, unsigned int inforeq);
pkginfo_t* db_read(pacdb_t *db, struct dirent *ent, unsigned int inforeq); pkginfo_t* db_read(pacdb_t *db, struct dirent *ent, unsigned int inforeq);

View file

@ -1085,6 +1085,10 @@ int pacman_sync(pacdb_t *db, PMList *targets)
} }
} }
mb = (double)(totalsize / 1048576.0); mb = (double)(totalsize / 1048576.0);
/* round up to 0.1 */
if(mb < 0.1) {
mb = 0.1;
}
printf("\nTargets: "); printf("\nTargets: ");
str = buildstring(list); str = buildstring(list);
indentprint(str, 9); indentprint(str, 9);

View file

@ -22,7 +22,7 @@
#define _PAC_PACMAN_H #define _PAC_PACMAN_H
#ifndef PACVER #ifndef PACVER
#define PACVER "2.9" #define PACVER "2.9.1"
#endif #endif
#ifndef PKGDIR #ifndef PKGDIR

View file

@ -57,29 +57,48 @@ extern unsigned short pmo_nopassiveftp;
extern PMList *pmc_syncs; extern PMList *pmc_syncs;
extern int maxcols; extern int maxcols;
/*
* Download fresh package lists for each repository
*
*/
int sync_synctree() int sync_synctree()
{ {
char ldir[PATH_MAX] = "";
char path[PATH_MAX]; char path[PATH_MAX];
char ldir[PATH_MAX] = "";
mode_t oldmask; mode_t oldmask;
PMList *files = NULL; PMList *files = NULL;
PMList *i; PMList *i;
int success = 0; int success = 0, ret;
for(i = pmc_syncs; i; i = i->next) { for(i = pmc_syncs; i; i = i->next) {
char *mtime = NULL;
char newmtime[16] = "";
char lastupdate[16] = "";
sync_t *sync = (sync_t*)i->data; sync_t *sync = (sync_t*)i->data;
snprintf(ldir, PATH_MAX, "%s%s", pmo_root, pmo_dbpath); snprintf(ldir, PATH_MAX, "%s%s", pmo_root, pmo_dbpath);
/* get the lastupdate time */
snprintf(path, PATH_MAX, "%s/%s", ldir, sync->treename);
if(db_getlastupdate(path, lastupdate)) {
vprint("failed to get lastupdate time for %s (no big deal)\n", sync->treename);
} else {
mtime = lastupdate;
}
/* build a one-element list */ /* build a one-element list */
snprintf(path, PATH_MAX, "%s.db.tar.gz", sync->treename); snprintf(path, PATH_MAX, "%s.db.tar.gz", sync->treename);
files = list_add(files, strdup(path)); files = list_add(files, strdup(path));
success = 1; success = 1;
if(downloadfiles(sync->servers, ldir, files)) { ret = downloadfiles_forreal(sync->servers, ldir, files, mtime, newmtime);
vprint("pacsync: new mtime for %s: %s\n", sync->treename, newmtime);
FREELIST(files);
if(ret > 0) {
fprintf(stderr, "failed to synchronize %s\n", sync->treename); fprintf(stderr, "failed to synchronize %s\n", sync->treename);
success = 0; success = 0;
} } else if(ret < 0) {
FREELIST(files); printf(":: %s is up to date\n", sync->treename);
} else {
snprintf(path, PATH_MAX, "%s/%s.db.tar.gz", ldir, sync->treename); snprintf(path, PATH_MAX, "%s/%s.db.tar.gz", ldir, sync->treename);
if(success) { if(success) {
@ -94,19 +113,54 @@ int sync_synctree()
umask(oldmask); umask(oldmask);
/* uncompress the sync database */ /* uncompress the sync database */
vprint("Unpacking %s...\n", path); vprint("unpacking %s...\n", path);
if(unpack(path, ldir, NULL)) { if(unpack(path, ldir, NULL)) {
return(1); return(1);
} }
if(strlen(newmtime)) {
db_setlastupdate(ldir, newmtime);
}
} }
/* remove the .tar.gz */ /* remove the .tar.gz */
unlink(path); unlink(path);
} }
}
return(!success); return(!success);
} }
/*
* Download a list of files from a list of servers
* - if one server fails, we try the next one in the list
*
* RETURN: 0 for successful download, 1 on error
*/
int downloadfiles(PMList *servers, const char *localpath, PMList *files) int downloadfiles(PMList *servers, const char *localpath, PMList *files)
{
return(!!downloadfiles_forreal(servers, localpath, files, NULL, NULL));
}
/*
* This is the real downloadfiles, used directly by sync_synctree() to check
* modtimes on remote (ftp only) files.
* - if *mtime1 is non-NULL, then only download files
* if they are different than *mtime1. String should be in the form
* "YYYYMMDDHHMMSS" to match the form of ftplib's FtpModDate() function.
* - if *mtime2 is non-NULL, then it will be filled with the mtime
* of the remote FTP file (from MDTM).
*
* NOTE: the *mtime option only works for FTP repositories, and won't work
* if XferCommand is used. We only use it to check mtimes on the
* repo db files.
*
* RETURN: 0 for successful download
* -1 if the mtimes are identical
* 1 on error
*/
int downloadfiles_forreal(PMList *servers, const char *localpath,
PMList *files, const char *mtime1, char *mtime2)
{ {
int fsz; int fsz;
netbuf *control = NULL; netbuf *control = NULL;
@ -125,7 +179,7 @@ int downloadfiles(PMList *servers, const char *localpath, PMList *files)
if(!pmo_xfercommand && strcmp(server->protocol, "file")) { if(!pmo_xfercommand && strcmp(server->protocol, "file")) {
if(!strcmp(server->protocol, "ftp") && !pmo_proxyhost) { if(!strcmp(server->protocol, "ftp") && !pmo_proxyhost) {
FtpInit(); FtpInit();
vprint("Connecting to %s:21\n", server->server); vprint("connecting to %s:21\n", server->server);
if(!FtpConnect(server->server, &control)) { if(!FtpConnect(server->server, &control)) {
fprintf(stderr, "error: cannot connect to %s\n", server->server); fprintf(stderr, "error: cannot connect to %s\n", server->server);
continue; continue;
@ -153,9 +207,9 @@ int downloadfiles(PMList *servers, const char *localpath, PMList *files)
host = (pmo_proxyhost) ? pmo_proxyhost : server->server; host = (pmo_proxyhost) ? pmo_proxyhost : server->server;
port = (pmo_proxyhost) ? pmo_proxyport : 80; port = (pmo_proxyhost) ? pmo_proxyport : 80;
if(strchr(host, ':')) { if(strchr(host, ':')) {
vprint("Connecting to %s\n", host); vprint("connecting to %s\n", host);
} else { } else {
vprint("Connecting to %s:%u\n", host, port); vprint("connecting to %s:%u\n", host, port);
} }
if(!HttpConnect(host, port, &control)) { if(!HttpConnect(host, port, &control)) {
fprintf(stderr, "error: cannot connect to %s\n", host); fprintf(stderr, "error: cannot connect to %s\n", host);
@ -275,6 +329,26 @@ int downloadfiles(PMList *servers, const char *localpath, PMList *files)
if(!FtpSize(fn, &fsz, FTPLIB_IMAGE, control)) { if(!FtpSize(fn, &fsz, FTPLIB_IMAGE, control)) {
fprintf(stderr, "warning: failed to get filesize for %s\n", fn); fprintf(stderr, "warning: failed to get filesize for %s\n", fn);
} }
/* check mtimes */
if(mtime1 || mtime2) {
char fmtime[64];
if(!FtpModDate(fn, fmtime, sizeof(fmtime)-1, control)) {
fprintf(stderr, "warning: failed to get mtime for %s\n", fn);
} else {
trim(fmtime);
if(mtime1 && !strcmp(mtime1, fmtime)) {
/* mtimes are identical, skip this file */
vprint("mtimes are identical, skipping %s\n", fn);
filedone = -1;
complete = list_add(complete, fn);
}
if(mtime2) {
strncpy(mtime2, fmtime, 15); /* YYYYMMDDHHMMSS (=14b) */
mtime2[14] = '\0';
}
}
}
if(!filedone) {
if(!stat(output, &st)) { if(!stat(output, &st)) {
offset = (int)st.st_size; offset = (int)st.st_size;
if(!FtpRestart(offset, control)) { if(!FtpRestart(offset, control)) {
@ -291,6 +365,7 @@ int downloadfiles(PMList *servers, const char *localpath, PMList *files)
} else { } else {
filedone = 1; filedone = 1;
} }
}
} else if(!strcmp(server->protocol, "http") || (pmo_proxyhost && strcmp(server->protocol, "file"))) { } else if(!strcmp(server->protocol, "http") || (pmo_proxyhost && strcmp(server->protocol, "file"))) {
char src[PATH_MAX]; char src[PATH_MAX];
char *host; char *host;
@ -302,9 +377,9 @@ int downloadfiles(PMList *servers, const char *localpath, PMList *files)
host = (pmo_proxyhost) ? pmo_proxyhost : server->server; host = (pmo_proxyhost) ? pmo_proxyhost : server->server;
port = (pmo_proxyhost) ? pmo_proxyport : 80; port = (pmo_proxyhost) ? pmo_proxyport : 80;
if(strchr(host, ':')) { if(strchr(host, ':')) {
vprint("Connecting to %s\n", host); vprint("connecting to %s\n", host);
} else { } else {
vprint("Connecting to %s:%u\n", host, port); vprint("connecting to %s:%u\n", host, port);
} }
if(!HttpConnect(host, port, &control)) { if(!HttpConnect(host, port, &control)) {
fprintf(stderr, "error: cannot connect to %s\n", host); fprintf(stderr, "error: cannot connect to %s\n", host);
@ -346,7 +421,7 @@ int downloadfiles(PMList *servers, const char *localpath, PMList *files)
} }
} }
if(filedone) { if(filedone > 0) {
char completefile[PATH_MAX]; char completefile[PATH_MAX];
if(!strcmp(server->protocol, "file")) { if(!strcmp(server->protocol, "file")) {
char out[56]; char out[56];
@ -364,6 +439,8 @@ int downloadfiles(PMList *servers, const char *localpath, PMList *files)
/* rename "output.part" file to "output" file */ /* rename "output.part" file to "output" file */
snprintf(completefile, PATH_MAX, "%s/%s", localpath, fn); snprintf(completefile, PATH_MAX, "%s/%s", localpath, fn);
rename(output, completefile); rename(output, completefile);
} else if(filedone < 0) {
return(-1);
} }
printf("\n"); printf("\n");
fflush(stdout); fflush(stdout);

View file

@ -31,6 +31,7 @@ typedef struct __server_t {
/* Repositories */ /* Repositories */
typedef struct __sync_t { typedef struct __sync_t {
char* treename; char* treename;
char* lastupdate;
PMList *servers; PMList *servers;
} sync_t; } sync_t;
@ -48,7 +49,11 @@ typedef struct __syncpkg_t {
} syncpkg_t; } syncpkg_t;
int sync_synctree(); int sync_synctree();
int downloadfiles(PMList *servers, const char *localpath, PMList *files); int downloadfiles(PMList *servers, const char *localpath, PMList *files);
int downloadfiles_forreal(PMList *servers, const char *localpath,
PMList *files, const char *mtime1, char *mtime2);
syncpkg_t* find_pkginsync(char *needle, PMList *haystack); syncpkg_t* find_pkginsync(char *needle, PMList *haystack);
PMList* rm_pkginsync(char *needle, PMList *haystack); PMList* rm_pkginsync(char *needle, PMList *haystack);