Imported from pacman-2.7.3.tar.gz

This commit is contained in:
Judd Vinet 2004-02-07 20:37:00 +00:00
parent 6d4c666a8e
commit 617b904b26
13 changed files with 3472 additions and 130 deletions

View file

@ -1,5 +1,11 @@
VERSION DESCRIPTION VERSION DESCRIPTION
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
2.7.3 - makepkg not longer strips files with .exe or .dll extensions
- Added Aurelien's patch:
- proxy support (no authentication yet)
- HTTP/1.1 support
- an improved progress bar with transfer rates and ETA
- cleaned up warning output a bit
2.7.2 - Supressed "No such file" messages during stripping 2.7.2 - Supressed "No such file" messages during stripping
- Removed extra newlines in /var/log/pacman.log - Removed extra newlines in /var/log/pacman.log
- Added a --noextract option to makepkg to skip source extraction - Added a --noextract option to makepkg to skip source extraction

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.7.2 PACVER = 2.7.3
TOPDIR = @srcdir@ TOPDIR = @srcdir@
SRCDIR = $(TOPDIR)/src/ SRCDIR = $(TOPDIR)/src/
@ -68,9 +68,9 @@ OBJECTS = $(OBJDIR)pacman.o \
$(OBJDIR)md5driver.o \ $(OBJDIR)md5driver.o \
$(OBJDIR)rpmvercmp.o $(OBJDIR)rpmvercmp.o
all: ftplib pacman vercmp convertdb man all: libftp.a pacman vercmp convertdb man
pacman: $(OBJECTS) pacman: $(OBJECTS) libftp.a
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS) $(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
vercmp: $(OBJDIR)vercmp.o $(OBJDIR)rpmvercmp.o vercmp: $(OBJDIR)vercmp.o $(OBJDIR)rpmvercmp.o
@ -91,7 +91,7 @@ man: $(MANSRC)pacman.8 \
dist: distclean dist: distclean
(cd ..; tar czvf pacman-$(PACVER).tar.gz pacman-$(PACVER)) (cd ..; tar czvf pacman-$(PACVER).tar.gz pacman-$(PACVER))
ftplib: libftp.a:
(cd libftp; make libftp.a) (cd libftp; make libftp.a)
install: pacman vercmp convertdb man install: pacman vercmp convertdb man
@ -112,5 +112,7 @@ clean:
distclean: clean distclean: clean
rm -f pacman convertdb vercmp rm -f pacman convertdb vercmp
rm -f Makefile
rm -f config.h config.status config.log
# End of file # End of file

View file

@ -1,4 +1,4 @@
.TH pacman 8 "September 28, 2003" "pacman #VERSION#" "" .TH pacman 8 "February 6, 2004" "pacman #VERSION#" ""
.SH NAME .SH NAME
pacman \- package manager utility pacman \- package manager utility
.SH SYNOPSIS .SH SYNOPSIS
@ -100,6 +100,10 @@ diskspace, you can remove these packages by using the --clean option.
Display all the members for each package group specified. If no group Display all the members for each package group specified. If no group
names are provided, all groups will be listed. names are provided, all groups will be listed.
.TP .TP
.B "\-l, \-\-list"
List all files in the specified repositories. Multiple repositories can
be specified on the command line.
.TP
.B "\-s, \-\-search <string>" .B "\-s, \-\-search <string>"
This will search each package in the package list for names or descriptions This will search each package in the package list for names or descriptions
that contains <string>. that contains <string>.
@ -185,6 +189,7 @@ NoUpgrade = etc/fstab
[current] [current]
Server = ftp://ftp.archlinux.org/current Server = ftp://ftp.archlinux.org/current
Server = ftp://ftp.mirror.com/archlinux/current Server = ftp://ftp.mirror.com/archlinux/current
Server = http://www.othermirror.com/arch/current
[custom] [custom]
Server = file:///home/pkgs Server = file:///home/pkgs
@ -201,6 +206,12 @@ Overrides the default location of the toplevel database directory. The default
Instructs pacman to ignore any upgrades for this package when performing a Instructs pacman to ignore any upgrades for this package when performing a
\fB--sysupgrade\fP. \fB--sysupgrade\fP.
.TP .TP
.B "ProxyServer = <host | ip>"
If set, pacman will use this proxy server for all ftp/http transfers.
.TP
.B "ProxyPort = <port>"
Use this to set a different port for your proxy server (default is 80).
.TP
.B "NoPassiveFtp" .B "NoPassiveFtp"
Disables passive ftp connections when downloading packages. (aka Active Mode) Disables passive ftp connections when downloading packages. (aka Active Mode)
.TP .TP

View file

@ -1,6 +1,10 @@
# #
# /etc/pacman.conf # /etc/pacman.conf
# #
# NOTE: If you find a mirror that is geographically close to you, please
# move it to the top of the server list, so pacman will choose it
# first.
#
# See the pacman manpage for option directives # See the pacman manpage for option directives
@ -12,6 +16,7 @@ LogFile = /var/log/pacman.log
NoUpgrade = etc/passwd etc/group etc/shadow NoUpgrade = etc/passwd etc/group etc/shadow
NoUpgrade = etc/fstab etc/raidtab NoUpgrade = etc/fstab etc/raidtab
NoUpgrade = etc/rc.conf etc/rc.local NoUpgrade = etc/rc.conf etc/rc.local
NoUpgrade = etc/modprobe.conf etc/modules.conf
NoUpgrade = etc/lilo.conf boot/grub/menu.lst NoUpgrade = etc/lilo.conf boot/grub/menu.lst
#IgnorePkg = lilo kernel #IgnorePkg = lilo kernel
@ -20,6 +25,7 @@ NoUpgrade = etc/lilo.conf boot/grub/menu.lst
# #
[current] [current]
Server = ftp://ftp.archlinux.org/current Server = ftp://ftp.archlinux.org/current
Server = ftp://ftp.archlinux.de/pub/archlinux/current
Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/current Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/current
Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/current Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/current
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/current Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/current
@ -27,23 +33,24 @@ Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/arc
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/current Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/current
Server = ftp://ftp.kegep.tuc.gr/archlinux/current Server = ftp://ftp.kegep.tuc.gr/archlinux/current
Server = http://darkstar.ist.utl.pt/archlinux/current Server = http://darkstar.ist.utl.pt/archlinux/current
Server = ftp://archlinux.creativa.cl/current
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/current Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/current
Server = ftp://saule.mintis.lt/pub/linux/current Server = ftp://saule.mintis.lt/pub/linux/current
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/current Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/current
Server = ftp://ftp.webtrek.com/pub/mirrors/archlinux/current
# Uncomment this block to access the EXTRA package set # Uncomment this block to access the EXTRA package set
# #
[extra] [extra]
Server = ftp://ftp.archlinux.org/extra Server = ftp://ftp.archlinux.org/extra
Server = ftp://ftp.archlinux.de/pub/archlinux/extra
Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/extra Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/extra
Server = ftp://ftp.webtrek.com/pub/mirrors/archlinux/extra
Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/extra Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/extra
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/extra Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/extra
Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/extra Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/extra
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/extra Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/extra
Server = ftp://ftp.kegep.tuc.gr/archlinux/extra Server = ftp://ftp.kegep.tuc.gr/archlinux/extra
Server = http://darkstar.ist.utl.pt/archlinux/extra Server = http://darkstar.ist.utl.pt/archlinux/extra
Server = ftp://archlinux.creativa.cl/extra
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/extra Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/extra
Server = ftp://saule.mintis.lt/pub/linux/extra Server = ftp://saule.mintis.lt/pub/linux/extra
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/extra Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/extra
@ -53,8 +60,8 @@ Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/extra
# #
#[release] #[release]
#Server = ftp://ftp.archlinux.org/release #Server = ftp://ftp.archlinux.org/release
#Server = ftp://ftp.archlinux.de/pub/archlinux/release
#Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/release #Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/release
#Server = ftp://ftp.webtrek.com/pub/mirrors/archlinux/release
#Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/release #Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/release
#Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/release #Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/release
#Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/release #Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/release
@ -69,13 +76,14 @@ Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/extra
# #
#[unstable] #[unstable]
#Server = ftp://ftp.archlinux.org/unstable #Server = ftp://ftp.archlinux.org/unstable
#Server = ftp://ftp.archlinux.de/pub/archlinux/unstable
#Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/unstable #Server = ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/unstable
#Server = ftp://ftp.webtrek.com/pub/mirrors/archlinux/unstable
#Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/unstable #Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/distributions/archlinux/unstable
#Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/unstable #Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/unstable
#Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/unstable #Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/unstable
#Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/unstable #Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/unstable
#Server = http://darkstar.ist.utl.pt/archlinux/unstable #Server = http://darkstar.ist.utl.pt/archlinux/unstable
#Server = ftp://archlinux.creativa.cl/unstable
#Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/unstable #Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/unstable
#Server = ftp://saule.mintis.lt/pub/linux/unstable #Server = ftp://saule.mintis.lt/pub/linux/unstable
#Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unstable #Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unstable

View file

@ -1319,13 +1319,12 @@ GLOBALDEF void FtpQuit(netbuf *nControl)
* *
* return 1 if connected, 0 if not * return 1 if connected, 0 if not
*/ */
GLOBALREF int HttpConnect(const char *host, netbuf **nControl) GLOBALREF int HttpConnect(const char *host, unsigned short port, netbuf **nControl)
{ {
int sControl; int sControl;
struct sockaddr_in sin; struct sockaddr_in sin;
struct hostent *phe; struct hostent *phe;
struct servent *pse; struct servent *pse;
int on=1;
netbuf *ctrl; netbuf *ctrl;
char *lhost; char *lhost;
char *pnum; char *pnum;
@ -1337,14 +1336,18 @@ GLOBALREF int HttpConnect(const char *host, netbuf **nControl)
if (pnum == NULL) if (pnum == NULL)
{ {
#if defined(VMS) #if defined(VMS)
sin.sin_port = htons(21); sin.sin_port = htons(80);
#else #else
/* we pass a port variable instead (for use with proxies)
*
if ((pse = getservbyname("http","tcp")) == NULL) if ((pse = getservbyname("http","tcp")) == NULL)
{ {
perror("getservbyname"); perror("getservbyname");
return 0; return 0;
} }
sin.sin_port = pse->s_port; sin.sin_port = pse->s_port;
*/
sin.sin_port = htons(port);
#endif #endif
} }
else else
@ -1374,13 +1377,6 @@ GLOBALREF int HttpConnect(const char *host, netbuf **nControl)
perror("socket"); perror("socket");
return 0; return 0;
} }
if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR,
SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) == -1)
{
perror("setsockopt");
net_close(sControl);
return 0;
}
if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1) if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1)
{ {
perror("connect"); perror("connect");
@ -1448,13 +1444,14 @@ static int HttpSendCmd(const char *cmd, char expresp, netbuf *nControl)
* *
* return 1 if successful, 0 otherwise * return 1 if successful, 0 otherwise
*/ */
static int HttpXfer(const char *localfile, const char *path, static int HttpXfer(const char *localfile, const char *path, int *size,
netbuf *nControl, int typ, int mode) netbuf *nControl, int typ, int mode)
{ {
int l,c; int l,c;
char *dbuf; char *dbuf;
FILE *local = NULL; FILE *local = NULL;
int rv=1; int rv=1;
int bytes = 0;
if (localfile != NULL) if (localfile != NULL)
{ {
@ -1487,13 +1484,18 @@ static int HttpXfer(const char *localfile, const char *path,
else else
{ {
nControl->dir = FTPLIB_READ; nControl->dir = FTPLIB_READ;
while ((l = FtpRead(dbuf, FTPLIB_BUFSIZ, nControl)) > 0) while ((l = FtpRead(dbuf, FTPLIB_BUFSIZ, nControl)) > 0) {
if (fwrite(dbuf, 1, l, local) <= 0) if (fwrite(dbuf, 1, l, local) <= 0)
{ {
perror("localfile write"); perror("localfile write");
rv = 0; rv = 0;
break; break;
} }
bytes += l;
if(size && bytes >= *size) {
break;
}
}
} }
free(dbuf); free(dbuf);
fflush(local); fflush(local);
@ -1508,12 +1510,15 @@ static int HttpXfer(const char *localfile, const char *path,
* *
* return 1 if successful, 0 otherwise * return 1 if successful, 0 otherwise
*/ */
GLOBALREF int HttpGet(const char *outputfile, const char *path, int *size, GLOBALREF int HttpGet(const char *host, const char *outputfile, const char *path,
netbuf *nControl) int *size, netbuf *nControl, unsigned int offset)
{ {
char buf[256]; char buf[256];
sprintf(buf, "GET %s HTTP/1.0\r\n\r\n\r\n", path); if(offset > 0)
sprintf(buf, "GET %s HTTP/1.1\r\nHost: %s\r\nRange: bytes=%d-\r\n\r\n", path, host, offset);
else
sprintf(buf, "GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", path, host);
if(!HttpSendCmd(buf,'2',nControl)) if(!HttpSendCmd(buf,'2',nControl))
{ {
if (nControl->response[9] == '3') if (nControl->response[9] == '3')
@ -1537,12 +1542,16 @@ GLOBALREF int HttpGet(const char *outputfile, const char *path, int *size,
} }
*buf = 0; *buf = 0;
if (strstr(nControl->response,"Content-Length")) if (strstr(nControl->response,"Content-Length"))
{
sscanf(nControl->response,"Content-Length: %d",size); sscanf(nControl->response,"Content-Length: %d",size);
if(offset > 0)
*size += offset;
}
if (strlen(nControl->response) == 0) if (strlen(nControl->response) == 0)
break; break;
} }
return HttpXfer(outputfile, path, nControl, FTPLIB_FILE_READ, FTPLIB_IMAGE); return HttpXfer(outputfile, path, size, nControl, FTPLIB_FILE_READ, FTPLIB_IMAGE);
} }
/* /*

View file

@ -119,9 +119,9 @@ GLOBALREF int FtpRename(const char *src, const char *dst, netbuf *nControl);
GLOBALREF int FtpDelete(const char *fnm, netbuf *nControl); GLOBALREF int FtpDelete(const char *fnm, netbuf *nControl);
GLOBALREF void FtpQuit(netbuf *nControl); GLOBALREF void FtpQuit(netbuf *nControl);
GLOBALREF int HttpConnect(const char *host, netbuf **nControl); GLOBALREF int HttpConnect(const char *host, unsigned short port, netbuf **nControl);
GLOBALREF int HttpGet(const char *output, const char *path, int *size, GLOBALREF int HttpGet(const char *host, const char *output, const char *path,
netbuf *nControl); int *size, netbuf *nControl, unsigned int offset);
GLOBALREF void HttpQuit(netbuf *nControl); GLOBALREF void HttpQuit(netbuf *nControl);
#ifdef __cplusplus #ifdef __cplusplus

View file

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

View file

@ -20,7 +20,7 @@
# USA. # USA.
# #
myver='2.7.2' myver='2.7.3'
startdir=`pwd` startdir=`pwd`
USE_COLOR="n" USE_COLOR="n"
@ -559,31 +559,33 @@ if [ -d pkg/usr/share ]; then
fi fi
# compress man pages # compress man pages
if [ -d pkg/usr/man ]; then msg "Compressing man pages..."
msg "Compressing man pages..." for i in `find pkg/{usr{,/local},opt/*}/man -type f 2>/dev/null`; do
for i in `find pkg/usr/man -type f`; do ext=${i##*.}
ext=`echo $i | sed 's|.*\.||g'` fn=${i##*/}
fn=`echo $i | sed 's|.*/||g'`
if [ "$ext" != "gz" ]; then if [ "$ext" != "gz" ]; then
# update symlinks to this manpage # update symlinks to this manpage
for ln in `find pkg/usr/man -lname "$fn"`; do for ln in `find pkg/{usr{,/local},opt/*}/man -lname "$fn" 2>/dev/null`; do
rm -f $ln rm -f $ln
ln -sf ${fn}.gz ${ln}.gz ln -sf ${fn}.gz ${ln}.gz
done done
# compress the original # compress the original
gzip -9 $i gzip -9 $i
fi fi
done done
fi
cd $startdir cd $startdir
# strip binaries # strip binaries
if [ "$NOSTRIP" = "0" ]; then if [ "$NOSTRIP" = "0" ]; then
msg "Stripping debugging symbols from libraries..." msg "Stripping debugging symbols from libraries..."
find pkg/{,usr,usr/local,opt/*}/lib -type f -exec /usr/bin/strip --strip-debug '{}' \; 2>&1 | grep -v "No such file" find pkg/{,usr,usr/local,opt/*}/lib -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip --strip-debug '{}' \; 2>&1 \
| grep -v "No such file" | grep -v "format not recognized"
msg "Stripping symbols from binaries..." msg "Stripping symbols from binaries..."
find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -exec /usr/bin/strip '{}' \; 2>&1 | grep -v "No such file" find pkg/{,usr,usr/local,opt/*}/{bin,sbin} -type f -not -name "*.dll" -not -name "*.exe" \
-exec /usr/bin/strip '{}' \; 2>&1 \
| grep -v "No such file" | grep -v "format not recognized"
fi fi
# get some package meta info # get some package meta info

View file

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

View file

@ -78,6 +78,8 @@ unsigned short pmo_group = 0;
/* configuration file options */ /* configuration file options */
char *pmo_dbpath = NULL; char *pmo_dbpath = NULL;
char *pmo_logfile = NULL; char *pmo_logfile = NULL;
char *pmo_proxyhost = NULL;
unsigned short pmo_proxyport = 80;
PMList *pmo_noupgrade = NULL; PMList *pmo_noupgrade = NULL;
PMList *pmo_ignorepkg = NULL; PMList *pmo_ignorepkg = NULL;
unsigned short pmo_usesyslog = 0; unsigned short pmo_usesyslog = 0;
@ -96,6 +98,7 @@ char *lckfile = "/tmp/pacman.lck";
char *workfile = NULL; char *workfile = NULL;
enum {READ_ONLY, READ_WRITE} pm_access; enum {READ_ONLY, READ_WRITE} pm_access;
int maxcols = 80; int maxcols = 80;
int neednl = 0; /* for cleaner message output */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -133,7 +136,7 @@ int main(int argc, char *argv[])
/* check for permission */ /* check for permission */
pm_access = READ_ONLY; pm_access = READ_ONLY;
if(pmo_op != PM_MAIN && pmo_op != PM_QUERY && pmo_op != PM_DEPTEST) { if(pmo_op != PM_MAIN && pmo_op != PM_QUERY && pmo_op != PM_DEPTEST) {
if(pmo_op == PM_SYNC && !pmo_s_sync && (pmo_s_search || pmo_group)) { if(pmo_op == PM_SYNC && !pmo_s_sync && (pmo_s_search || pmo_group || pmo_q_list)) {
/* special case: PM_SYNC can be used w/ pmo_s_search by any user */ /* special case: PM_SYNC can be used w/ pmo_s_search by any user */
} else { } else {
if(geteuid() != 0) { if(geteuid() != 0) {
@ -456,6 +459,37 @@ int pacman_sync(pacdb_t *db, PMList *targets)
FREELIST(pkg); FREELIST(pkg);
} }
FREELIST(groups); FREELIST(groups);
} else if(pmo_q_list) {
PMList *reps = NULL;
int found;
if(targets) {
for(i = targets; i; i = i->next) {
reps = list_add(reps, strdup(i->data));
}
} else {
for(i = pmc_syncs; i; i = i->next) {
reps = list_add(reps, strdup(((sync_t *)i->data)->treename));
}
}
for(i = reps; i; i = i->next) {
found = 0;
for(j = databases; j; j = j->next) {
dbsync_t *dbs = (dbsync_t *)j->data;
if(!strcmp(dbs->sync->treename, i->data)) {
for(k = dbs->pkgcache; k; k = k->next) {
pkginfo_t *pkg = (pkginfo_t*)k->data;
printf("%s %s %s\n", dbs->sync->treename, pkg->name, pkg->version);
}
found = 1;
}
}
if(!found) {
printf("Repository \"%s\" was not found.\n", (char *)i->data);
allgood = 0;
break;
}
}
FREELIST(reps);
} else if(pmo_s_upgrade) { } else if(pmo_s_upgrade) {
int newer = 0; int newer = 0;
int ignore = 0; int ignore = 0;
@ -687,7 +721,7 @@ int pacman_sync(pacdb_t *db, PMList *targets)
} }
} }
if(allgood && !pmo_s_search) { if(allgood && !(pmo_s_search || pmo_q_list)) {
/* check for inter-conflicts and whatnot */ /* check for inter-conflicts and whatnot */
if(!pmo_nodeps && !pmo_s_downloadonly) { if(!pmo_nodeps && !pmo_s_downloadonly) {
int errorout = 0; int errorout = 0;
@ -1132,7 +1166,7 @@ int pacman_add(pacdb_t *db, PMList *targets)
fflush(stdout); fflush(stdout);
for(targ = targets; targ; targ = targ->next) { for(targ = targets; targ; targ = targ->next) {
/* Populate the package struct */ /* Populate the package struct */
vprint("reading %s\n", (char*)targ->data); vprint("reading %s... ", (char*)targ->data);
info = load_pkg((char*)targ->data, 0); info = load_pkg((char*)targ->data, 0);
if(info == NULL) { if(info == NULL) {
return(1); return(1);
@ -1141,11 +1175,28 @@ int pacman_add(pacdb_t *db, PMList *targets)
/* only upgrade/install this package if it is already installed and at a lesser version */ /* only upgrade/install this package if it is already installed and at a lesser version */
pkginfo_t *dummy = db_scan(db, info->name, INFRQ_DESC); pkginfo_t *dummy = db_scan(db, info->name, INFRQ_DESC);
if(dummy == NULL || rpmvercmp(dummy->version, info->version) >= 0) { if(dummy == NULL || rpmvercmp(dummy->version, info->version) >= 0) {
vprint("not installed or lesser version\n");
FREEPKG(info); FREEPKG(info);
FREEPKG(dummy);
continue; continue;
} }
FREEPKG(dummy); FREEPKG(dummy);
} }
/* check if an older version of said package is already in alltargs.
* if so, replace it in the list */
for(j = alltargs, k = filenames; j && j->data && k; j = j->next, k = k->next) {
pkginfo_t *pkg = (pkginfo_t*)j->data;
if(!strcmp(pkg->name, info->name)) {
if(rpmvercmp(pkg->version, info->version) < 0) {
vprint("replacing older version in target list. ");
FREEPKG(j->data);
j->data = info;
FREE(k->data);
k->data = strdup(targ->data);
}
}
}
vprint("done\n");
alltargs = list_add(alltargs, info); alltargs = list_add(alltargs, info);
filenames = list_add(filenames, strdup(targ->data)); filenames = list_add(filenames, strdup(targ->data));
} }
@ -1301,6 +1352,7 @@ int pacman_add(pacdb_t *db, PMList *targets)
int retcode; int retcode;
printf("upgrading %s... ", info->name); printf("upgrading %s... ", info->name);
neednl = 1;
/* we'll need the full record for backup checks later */ /* we'll need the full record for backup checks later */
oldpkg = db_scan(db, info->name, INFRQ_ALL); oldpkg = db_scan(db, info->name, INFRQ_ALL);
@ -1326,6 +1378,7 @@ int pacman_add(pacdb_t *db, PMList *targets)
} }
if(!pmo_upgrade) { if(!pmo_upgrade) {
printf("installing %s... ", info->name); printf("installing %s... ", info->name);
neednl = 1;
} }
fflush(stdout); fflush(stdout);
@ -1711,6 +1764,7 @@ int pacman_remove(pacdb_t *db, PMList *targets)
if(!pmo_upgrade) { if(!pmo_upgrade) {
printf("removing %s... ", info->name); printf("removing %s... ", info->name);
neednl = 1;
fflush(stdout); fflush(stdout);
/* run the pre-remove script if it exists */ /* run the pre-remove script if it exists */
snprintf(pm_install, PATH_MAX, "%s%s/%s/%s-%s/install", pmo_root, pmo_dbpath, db->treename, info->name, info->version); snprintf(pm_install, PATH_MAX, "%s%s/%s/%s-%s/install", pmo_root, pmo_dbpath, db->treename, info->name, info->version);
@ -1764,7 +1818,7 @@ int pacman_remove(pacdb_t *db, PMList *targets)
} }
} }
} else { } else {
vprint(" unlinking %s\n", line); /*vprint(" unlinking %s\n", line);*/
if(unlink(line)) { if(unlink(line)) {
perror("cannot remove file"); perror("cannot remove file");
} }
@ -2845,8 +2899,30 @@ int parseconfig(char *configfile)
strncpy(pmo_dbpath, ptr, PATH_MAX); strncpy(pmo_dbpath, ptr, PATH_MAX);
vprint("config: dbpath: %s\n", pmo_dbpath); vprint("config: dbpath: %s\n", pmo_dbpath);
} else if (!strcmp(key, "LOGFILE")) { } else if (!strcmp(key, "LOGFILE")) {
if(pmo_logfile) {
FREE(pmo_logfile);
}
pmo_logfile = strndup(ptr, PATH_MAX); pmo_logfile = strndup(ptr, PATH_MAX);
vprint("config: log file: %s\n", pmo_logfile); vprint("config: log file: %s\n", pmo_logfile);
} else if (!strcmp(key, "PROXYSERVER")) {
char *p;
if(pmo_proxyhost) {
FREE(pmo_proxyhost);
}
p = strstr(ptr, "://");
if(p) {
p += 3;
if(p == NULL || *p == '\0') {
fprintf(stderr, "config: line %d: bad server location\n", linenum);
return(1);
}
ptr = p;
}
pmo_proxyhost = strndup(ptr, PATH_MAX);
vprint("config: proxyserver: %s\n", pmo_proxyhost);
} else if (!strcmp(key, "PROXYPORT")) {
pmo_proxyport = (unsigned short)atoi(ptr);
vprint("config: proxyport: %u\n", pmo_proxyport);
} else { } else {
fprintf(stderr, "config: line %d: syntax error\n", linenum); fprintf(stderr, "config: line %d: syntax error\n", linenum);
return(1); return(1);
@ -2973,6 +3049,7 @@ void usage(int op, char *myname)
printf(" -d, --nodeps skip dependency checks\n"); printf(" -d, --nodeps skip dependency checks\n");
printf(" -f, --force force install, overwrite conflicting files\n"); printf(" -f, --force force install, overwrite conflicting files\n");
printf(" -g, --groups view all members of a package group\n"); printf(" -g, --groups view all members of a package group\n");
printf(" -l, --list list all packages belonging to the specified repository\n");
printf(" -s, --search search sync database for matching strings\n"); printf(" -s, --search search sync database for matching strings\n");
printf(" -u, --sysupgrade upgrade all packages that are out of date\n"); printf(" -u, --sysupgrade upgrade all packages that are out of date\n");
printf(" -w, --downloadonly download packages, but do not install/upgrade anything\n"); printf(" -w, --downloadonly download packages, but do not install/upgrade anything\n");
@ -3019,6 +3096,10 @@ void logaction(FILE *fp, char *fmt, ...)
vsnprintf(msg, 1024, fmt, args); vsnprintf(msg, 1024, fmt, args);
va_end(args); va_end(args);
if(fp) { if(fp) {
if(neednl) {
fprintf(fp, "\n");
neednl = 0;
}
fprintf(fp, "%s\n", msg); fprintf(fp, "%s\n", msg);
fflush(fp); fflush(fp);
} }
@ -3116,12 +3197,18 @@ void cleanup(int signum)
FREELIST(pmo_ignorepkg); FREELIST(pmo_ignorepkg);
FREE(pmo_root); FREE(pmo_root);
FREE(pmo_dbpath); FREE(pmo_dbpath);
FREE(pmo_logfile);
FREE(pmo_proxyhost);
FREELIST(pm_targets); FREELIST(pm_targets);
/* this is segfaulting... quick fix for now /* this is segfaulting... quick fix for now
FREELISTPKGS(pm_packages);*/ FREELISTPKGS(pm_packages);*/
if(signum) {
printf("\n");
}
exit(signum); exit(signum);
} }

3145
src/pacman.c~ Normal file

File diff suppressed because it is too large Load diff

View file

@ -22,7 +22,7 @@
#define _PAC_PACMAN_H #define _PAC_PACMAN_H
#ifndef PACVER #ifndef PACVER
#define PACVER "2.7.2" #define PACVER "2.7.3"
#endif #endif
#ifndef PKGDIR #ifndef PKGDIR

View file

@ -25,6 +25,7 @@
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <sys/time.h>
#include <ftplib.h> #include <ftplib.h>
/* pacman */ /* pacman */
#include "list.h" #include "list.h"
@ -34,13 +35,21 @@
#include "pacsync.h" #include "pacsync.h"
#include "pacman.h" #include "pacman.h"
/* progress bar */
static int log_progress(netbuf *ctl, int xfered, void *arg); static int log_progress(netbuf *ctl, int xfered, void *arg);
static char sync_fnm[25]; static char sync_fnm[25];
static int offset; static int offset;
static struct timeval t0, t;
static float rate;
static int xfered1;
static unsigned char eta_h, eta_m, eta_s;
/* pacman options */ /* pacman options */
extern char *pmo_root; extern char *pmo_root;
extern char *pmo_dbpath; extern char *pmo_dbpath;
extern char *pmo_proxyhost;
extern unsigned short pmo_proxyport;
extern unsigned short pmo_nopassiveftp; extern unsigned short pmo_nopassiveftp;
/* sync servers */ /* sync servers */
@ -112,8 +121,9 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
for(i = servers; i && !done; i = i->next) { for(i = servers; i && !done; i = i->next) {
server_t *server = (server_t*)i->data; server_t *server = (server_t*)i->data;
if(!strcmp(server->protocol, "ftp")) { if(!strcmp(server->protocol, "ftp") && !pmo_proxyhost) {
FtpInit(); FtpInit();
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;
@ -135,9 +145,15 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
} else { } else {
vprint("FTP passive mode not set\n"); vprint("FTP passive mode not set\n");
} }
} else if(!strcmp(server->protocol, "http")) { /*} else if(!strcmp(server->protocol, "http") || (pmo_proxyhost && !strcmp(server->protocol, "ftp"))) {*/
if(!HttpConnect(server->server, &control)) { } else if(!strcmp(server->protocol, "http") || pmo_proxyhost) {
fprintf(stderr, "error: cannot connect to %s\n", server->server); char *host;
unsigned port;
host = (pmo_proxyhost) ? pmo_proxyhost : server->server;
port = (pmo_proxyhost) ? pmo_proxyport : 80;
vprint("Connecting to %s:%u\n", host, port);
if(!HttpConnect(host, port, &control)) {
fprintf(stderr, "error: cannot connect to %s\n", host);
continue; continue;
} }
} }
@ -155,6 +171,7 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
char output[PATH_MAX]; char output[PATH_MAX];
int j, filedone = 0; int j, filedone = 0;
char *fn = (char*)lp->data; char *fn = (char*)lp->data;
char *ptr;
struct stat st; struct stat st;
if(is_in(fn, complete)) { if(is_in(fn, complete)) {
@ -163,13 +180,31 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn); snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn);
strncpy(sync_fnm, fn, 24); strncpy(sync_fnm, fn, 24);
/* drop filename extension */
ptr = strstr(fn, ".db.tar.gz");
if(ptr && (ptr-fn) < 24) {
sync_fnm[ptr-fn] = '\0';
}
ptr = strstr(fn, ".pkg.tar.gz");
if(ptr && (ptr-fn) < 24) {
sync_fnm[ptr-fn] = '\0';
}
for(j = strlen(sync_fnm); j < 24; j++) { for(j = strlen(sync_fnm); j < 24; j++) {
sync_fnm[j] = ' '; sync_fnm[j] = ' ';
} }
sync_fnm[24] = '\0'; sync_fnm[24] = '\0';
offset = 0; offset = 0;
if(!strcmp(server->protocol, "ftp")) { /* ETA setup */
gettimeofday(&t0, NULL);
t = t0;
rate = 0;
xfered1 = 0;
eta_h = 0;
eta_m = 0;
eta_s = 0;
if(!strcmp(server->protocol, "ftp") && !pmo_proxyhost) {
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);
} }
@ -189,18 +224,21 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
} else { } else {
filedone = 1; filedone = 1;
} }
} else if(!strcmp(server->protocol, "http")) { /*} else if(!strcmp(server->protocol, "http") || (pmo_proxyhost && !strcmp(server->protocol, "ftp"))) {*/
} else if(!strcmp(server->protocol, "http") || pmo_proxyhost) {
char src[PATH_MAX]; char src[PATH_MAX];
if(!stat(output, &st)) { if(!stat(output, &st)) {
/* no resume support yet */ offset = (int)st.st_size;
unlink(output);
} }
if(!pmo_proxyhost) {
snprintf(src, PATH_MAX, "%s%s", server->path, fn); snprintf(src, PATH_MAX, "%s%s", server->path, fn);
if(!HttpGet(output, src, &fsz, control)) { } else {
snprintf(src, PATH_MAX, "%s://%s%s%s", server->protocol, server->server, server->path, fn);
}
if(!HttpGet(server->server, output, src, &fsz, control, offset)) {
fprintf(stderr, "\nfailed downloading %s from %s: %s\n", fprintf(stderr, "\nfailed downloading %s from %s: %s\n",
fn, server->server, FtpLastResponse(control)); fn, server->server, FtpLastResponse(control));
/* no resume support yet */ /* we leave the partially downloaded file in place so it can be resumed later */
unlink(output);
} else { } else {
filedone = 1; filedone = 1;
} }
@ -223,10 +261,10 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
printf(" %s [", sync_fnm); printf(" %s [", sync_fnm);
strncpy(out, server->path, 33); strncpy(out, server->path, 33);
printf("%s", out); printf("%s", out);
for(j = strlen(out); j < maxcols-44; j++) { for(j = strlen(out); j < maxcols-64; j++) {
printf(" "); printf(" ");
} }
fputs("] 100% | LOCAL\n", stdout); fputs("] 100% | LOCAL |", stdout);
} else { } else {
log_progress(control, fsz-offset, &fsz); log_progress(control, fsz-offset, &fsz);
} }
@ -257,13 +295,47 @@ static int log_progress(netbuf *ctl, int xfered, void *arg)
int fsz = *(int*)arg; int fsz = *(int*)arg;
int pct = ((float)(xfered+offset) / fsz) * 100; int pct = ((float)(xfered+offset) / fsz) * 100;
int i, cur; int i, cur;
struct timeval t1;
float timediff;
gettimeofday(&t1, NULL);
if(xfered+offset == fsz) {
t = t0;
}
timediff = t1.tv_sec-t.tv_sec + (float)(t1.tv_usec-t.tv_usec) / 1000000;
if(xfered+offset == fsz) {
/* average download rate */
rate = xfered / (timediff * 1024);
/* total download time */
eta_s = (int)timediff;
eta_h = eta_s / 3600;
eta_s -= eta_h * 3600;
eta_m = eta_s / 60;
eta_s -= eta_m * 60;
} else if(timediff > 1) {
/* we avoid computing the rate & ETA on too small periods of time, so that
results are more significant */
rate = (xfered-xfered1) / (timediff * 1024);
xfered1 = xfered;
gettimeofday(&t, NULL);
eta_s = (fsz-(xfered+offset)) / (rate * 1024);
eta_h = eta_s / 3600;
eta_s -= eta_h * 3600;
eta_m = eta_s / 60;
eta_s -= eta_m * 60;
}
printf(" %s [", sync_fnm); printf(" %s [", sync_fnm);
cur = (int)((maxcols-44)*pct/100); cur = (int)((maxcols-64)*pct/100);
for(i = 0; i < maxcols-44; i++) { for(i = 0; i < maxcols-64; i++) {
(i < cur) ? printf("#") : printf(" "); (i < cur) ? printf("#") : printf(" ");
} }
printf("] %3d%% | %6dK\r", pct, ((xfered+offset)/1024)); if(rate > 1000) {
printf("] %3d%%| %6dK| %6.0fK/s| %02d:%02d:%02d\r", pct, ((xfered+offset) / 1024), rate, eta_h, eta_m, eta_s);
} else {
printf("] %3d%%| %6dK| %6.1fK/s| %02d:%02d:%02d\r", pct, ((xfered+offset) / 1024), rate, eta_h, eta_m, eta_s);
}
fflush(stdout); fflush(stdout);
return(1); return(1);
} }