Imported from pacman-2.6.1.tar.gz

This commit is contained in:
Judd Vinet 2003-09-15 04:58:02 +00:00
parent f8bfe729e4
commit 9d9ffa6cec
16 changed files with 487 additions and 163 deletions

View file

@ -1,5 +1,14 @@
VERSION DESCRIPTION
-----------------------------------------------------------------------------
2.6.1 - Added http download support (Aurelien Foret)
- Improved makepkg's --builddeps behaviour when called via
makeworld
- makepkg's md5 validation now occurs before source extraction
- makepkg delays fakeroot entry until after option parsing
- Fixed an argument-passing bug in fakeroot
- Modified pacman's behaviour wrt provides -- it now allows
multiple packages to be installed, even if they provide the
same thing (they were treated as conflicts before)
2.6 - Added group handling, so one can run 'pacman -S kde' and
install all files from the KDE group
- Fixed a duplication bug in cascade package removal

View file

@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
PACVER = 2.6
PACVER = 2.6.1
TOPDIR = @srcdir@
SRCDIR = $(TOPDIR)/src/

1
TODO
View file

@ -1,5 +1,6 @@
- fix the broken pipe bug
- handle version comparators in makepkg dep resolution (eg, glibc>=2.2.5)
- add post_remove, pre_install, pre_upgrade functions to scriptlets
- record md5sums of all files in a package
? use 'set -e' in makepkg?
x if a package fails, ask before aborting the full operation

View file

@ -1,4 +1,4 @@
.TH makepkg 8 "May 27, 2003" "makepkg #VERSION#" ""
.TH makepkg 8 "September 01, 2003" "makepkg #VERSION#" ""
.SH NAME
makepkg \- package build utility
.SH SYNOPSIS

View file

@ -1,4 +1,4 @@
.TH pacman 8 "May 27, 2003" "pacman #VERSION#" ""
.TH pacman 8 "September 01, 2003" "pacman #VERSION#" ""
.SH NAME
pacman \- package manager utility
.SH SYNOPSIS

View file

@ -2,9 +2,6 @@
# /etc/makepkg.conf
#
# 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"

View file

@ -26,6 +26,7 @@ Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/dist
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/current
Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/current
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/current
Server = http://darkstar.ist.utl.pt/archlinux/current
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/current
Server = ftp://saule.mintis.lt/pub/linux/current
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/current
@ -40,6 +41,7 @@ Server = ftp://ftp.mpi-sb.mpg.de/pub/linux/mirror/ftp.ibiblio.org/pub/Linux/dist
Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/unofficial
Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/unofficial
Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/unofficial
Server = http://darkstar.ist.utl.pt/archlinux/unofficial
Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/unofficial
Server = ftp://saule.mintis.lt/pub/linux/unofficial
Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unofficial
@ -55,6 +57,7 @@ Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unofficial
#Server = ftp://ftp.oit.unc.edu/pub/Linux/distributions/archlinux/stable
#Server = ftp://ftp.tu-chemnitz.de/pub/linux/sunsite.unc-mirror/distributions/archlinux/stable
#Server = ftp://ftp.parrswood.net/Mirrors/ftp.archlinux.org/stable
#Server = http://darkstar.ist.utl.pt/archlinux/stable
#Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/stable
#Server = ftp://saule.mintis.lt/pub/linux/stable
#Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/stable
@ -69,6 +72,7 @@ Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unofficial
#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.parrswood.net/Mirrors/ftp.archlinux.org/unstable
#Server = http://darkstar.ist.utl.pt/archlinux/unstable
#Server = ftp://gd.tuwien.ac.at/opsys/linux/archlinux/unstable
#Server = ftp://saule.mintis.lt/pub/linux/unstable
#Server = ftp://ftp.rez-gif.supelec.fr/pub/Linux/distrib/archlinux/unstable

View file

@ -1309,3 +1309,245 @@ GLOBALDEF void FtpQuit(netbuf *nControl)
free(nControl->buf);
free(nControl);
}
/*
* HttpConnect - connect to remote server
*
* return 1 if connected, 0 if not
*/
GLOBALREF int HttpConnect(const char *host, netbuf **nControl)
{
int sControl;
struct sockaddr_in sin;
struct hostent *phe;
struct servent *pse;
int on=1;
netbuf *ctrl;
char *lhost;
char *pnum;
memset(&sin,0,sizeof(sin));
sin.sin_family = AF_INET;
lhost = strdup(host);
pnum = strchr(lhost,':');
if (pnum == NULL)
{
#if defined(VMS)
sin.sin_port = htons(21);
#else
if ((pse = getservbyname("http","tcp")) == NULL)
{
perror("getservbyname");
return 0;
}
sin.sin_port = pse->s_port;
#endif
}
else
{
*pnum++ = '\0';
if (isdigit(*pnum))
sin.sin_port = htons(atoi(pnum));
else
{
pse = getservbyname(pnum,"tcp");
sin.sin_port = pse->s_port;
}
}
if ((sin.sin_addr.s_addr = inet_addr(lhost)) == -1)
{
if ((phe = gethostbyname(lhost)) == NULL)
{
perror("gethostbyname");
return 0;
}
memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length);
}
free(lhost);
sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sControl == -1)
{
perror("socket");
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)
{
perror("connect");
net_close(sControl);
return 0;
}
ctrl = calloc(1,sizeof(netbuf));
if (ctrl == NULL)
{
perror("calloc");
net_close(sControl);
return 0;
}
ctrl->buf = NULL;
ctrl->handle = sControl;
ctrl->dir = FTPLIB_CONTROL;
ctrl->ctrl = NULL;
ctrl->cmode = FTPLIB_DEFMODE;
ctrl->idlecb = NULL;
ctrl->idletime.tv_sec = ctrl->idletime.tv_usec = 0;
ctrl->idlearg = NULL;
ctrl->xfered = 0;
ctrl->xfered1 = 0;
ctrl->cbbytes = 0;
*nControl = ctrl;
return 1;
}
/*
* HttpSendCmd - send a command
*
* return 1 if proper response received, 0 otherwise
*/
static int HttpSendCmd(const char *cmd, char expresp, netbuf *nControl)
{
int ret = 0;
char *buf = nControl->response;
if (nControl->dir != FTPLIB_CONTROL)
return 0;
if (ftplib_debug > 2)
fprintf(stderr,"%s\n",cmd);
if (net_write(nControl->handle,cmd,strlen(cmd)) <= 0)
{
perror("write");
return 0;
}
while (ret < 256) {
if (socket_wait(nControl) != 1)
return 0;
if (net_read(nControl->handle,buf,1) != 1)
break;
ret++;
if (*buf == '\r') continue;
if (*buf == '\n') break;
buf++;
}
*buf = 0;
if (nControl->response[9] == expresp)
return 1;
return 0;
}
/*
* HttpXfer - issue a command and transfer data
*
* return 1 if successful, 0 otherwise
*/
static int HttpXfer(const char *localfile, const char *path,
netbuf *nControl, int typ, int mode)
{
int l,c;
char *dbuf;
FILE *local = NULL;
int rv=1;
if (localfile != NULL)
{
char ac[4] = "a";
if (typ == FTPLIB_FILE_WRITE)
ac[0] = 'r';
if (mode == FTPLIB_IMAGE)
ac[1] = 'b';
local = fopen(localfile, ac);
if (local == NULL)
{
strncpy(nControl->response, strerror(errno),
sizeof(nControl->response));
return 0;
}
}
if (local == NULL)
local = (typ == FTPLIB_FILE_WRITE) ? stdin : stdout;
dbuf = malloc(FTPLIB_BUFSIZ);
if (typ == FTPLIB_FILE_WRITE)
{
while ((l = fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0)
if ((c = FtpWrite(dbuf, l, nControl)) < l)
{
printf("short write: passed %d, wrote %d\n", l, c);
rv = 0;
break;
}
}
else
{
nControl->dir = FTPLIB_READ;
while ((l = FtpRead(dbuf, FTPLIB_BUFSIZ, nControl)) > 0)
if (fwrite(dbuf, 1, l, local) <= 0)
{
perror("localfile write");
rv = 0;
break;
}
}
free(dbuf);
fflush(local);
if (localfile != NULL)
fclose(local);
free(nControl->data);
return rv;
}
/*
* HttpGet - issue a GET command and write received data to output
*
* return 1 if successful, 0 otherwise
*/
GLOBALREF int HttpGet(const char *outputfile, const char *path, int *size,
netbuf *nControl)
{
char buf[256];
sprintf(buf, "GET %s HTTP/1.0\r\n\r\n\r\n", path);
if(!HttpSendCmd(buf,'2',nControl))
{
if (nControl->response[9] == '3')
printf("redirection not supported\n");
return 0;
}
while (1)
{
int ret = 0;
char *buf = nControl->response;
while (ret < 256) {
if (socket_wait(nControl) != 1)
return 0;
if (net_read(nControl->handle,buf,1) != 1)
break;
ret++;
if (*buf == '\r') continue;
if (*buf == '\n') break;
buf++;
}
*buf = 0;
if (strstr(nControl->response,"Content-Length"))
sscanf(nControl->response,"Content-Length: %d",size);
if (strlen(nControl->response) == 0)
break;
}
return HttpXfer(outputfile, path, nControl, FTPLIB_FILE_READ, FTPLIB_IMAGE);
}
/*
* HttpQuit - disconnect from remote
*
* return 1 if successful, 0 otherwise
*/
GLOBALREF void HttpQuit(netbuf *nControl)
{
net_close(nControl->handle);
free(nControl);
}

View file

@ -119,6 +119,11 @@ GLOBALREF int FtpRename(const char *src, const char *dst, netbuf *nControl);
GLOBALREF int FtpDelete(const char *fnm, netbuf *nControl);
GLOBALREF void FtpQuit(netbuf *nControl);
GLOBALREF int HttpConnect(const char *host, netbuf **nControl);
GLOBALREF int HttpGet(const char *output, const char *path, int *size,
netbuf *nControl);
GLOBALREF void HttpQuit(netbuf *nControl);
#ifdef __cplusplus
};
#endif

View file

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

View file

@ -20,13 +20,13 @@
# USA.
#
myver='2.6'
myver='2.6.1'
startdir=`pwd`
msg() {
echo "$1" >&2
}
# source Arch's abs.conf if it's present
[ -f /etc/abs/abs.conf ] && source /etc/abs/abs.conf
# makepkg configuration
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf
INFAKEROOT=
@ -35,35 +35,16 @@ if [ "$1" = "-F" ]; then
shift
fi
if [ "`id -u`" != "0" ]; then
if [ "$USE_FAKEROOT" = "y" -o "$USE_FAKEROOT" = "Y" ]; then
if [ `type -p fakeroot` ]; then
msg "==> Entering fakeroot environment"
fakeroot -- $0 -F $@
exit $?
else
msg "==> WARNING: Fakeroot is not installed. Building as an unprivileged user"
msg "==> will result in non-root ownership of the packaged files."
msg "==> Install the fakeroot package to correctly build as a non-root"
msg "==> user."
msg ""
sleep 1
fi
else
msg "==> WARNING: Running makepkg as an unprivileged user will result in non-root"
msg "==> ownership of the packaged files. Try using the fakeroot"
msg "==> environment. (USE_FAKEROOT=y in makepkg.conf)"
msg ""
sleep 1
fi
fi
### SUBROUTINES ###
msg() {
echo "$1" >&2
}
strip_url() {
echo $1 | sed 's|^.*://.*/||g'
}
checkdeps() {
local missdep=`pacman -T $*`
local deplist=""
@ -132,6 +113,8 @@ NOSTRIP=0
PKGDEST=$startdir
BUILDSCRIPT="./PKGBUILD"
ARGLIST=$@
while [ "$#" -ne "0" ]; do
case $1 in
--clean) CLEANUP=1 ;;
@ -220,9 +203,40 @@ if [ `echo $pkgrel | grep '-'` ]; then
fi
if [ -f $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz -a "$FORCE" = "0" -a "$GENMD5" = "0" ]; then
if [ "$INSTALL" = "1" ]; then
msg "==> WARNING: a package has already been built, installing existing package."
pacman --upgrade $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
exit $?
else
msg "==> ERROR: a package has already been built. (use -f to overwrite)"
exit 1
fi
fi
# Enter the fakeroot environment if necessary. This will call the makepkg script again
# as the fake root user. We detect this by passing a sentinel option (-F) to makepkg
if [ "`id -u`" != "0" ]; then
if [ "$USE_FAKEROOT" = "y" -o "$USE_FAKEROOT" = "Y" ]; then
if [ `type -p fakeroot` ]; then
msg "==> Entering fakeroot environment"
fakeroot -- $0 -F $ARGLIST
exit $?
else
msg "==> WARNING: Fakeroot is not installed. Building as an unprivileged user"
msg "==> will result in non-root ownership of the packaged files."
msg "==> Install the fakeroot package to correctly build as a non-root"
msg "==> user."
msg ""
sleep 1
fi
else
msg "==> WARNING: Running makepkg as an unprivileged user will result in non-root"
msg "==> ownership of the packaged files. Try using the fakeroot"
msg "==> environment. (USE_FAKEROOT=y in makepkg.conf)"
msg ""
sleep 1
fi
fi
msg "==> Making package: $pkgname (`date`)"
@ -285,7 +299,7 @@ fi
cd $startdir
# extract source
# retrieve sources
msg "==> Retrieving Sources..."
mkdir -p src
cd $startdir/src
@ -329,7 +343,41 @@ for netfile in ${source[@]}; do
cp $file ..
fi
fi
done
if [ "$GENMD5" = "0" ]; then
# MD5 validation
if [ ${#md5sums[@]} -ne ${#source[@]} ]; then
msg "==> WARNING: MD5sums are missing or incomplete. Cannot verify source integrity."
#sleep 1
elif [ `type -p md5sum` ]; then
msg "==> Validating source files with MD5sums"
errors=0
idx=0
for netfile in ${source[@]}; do
file=`strip_url $netfile`
echo -n " |=> $file ... " >&2
echo "${md5sums[$idx]} $file" | md5sum -c - >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "FAILED" >&2
errors=1
else
echo "Passed" >&2
fi
idx=$(($idx+1))
done
if [ $errors -gt 0 ]; then
msg "==> ERROR: One or more files did not pass the validity check!"
exit 1
fi
else
msg "==> WARNING: The md5sum program is missing. Cannot verify source files!"
sleep 1
fi
# extract sources
msg "==> Extracting Sources..."
for netfile in ${source[@]}; do
file=`strip_url $netfile`
unset cmd
case $file in
*.tar.gz|*.tar.Z|*.tgz)
@ -342,6 +390,8 @@ for netfile in ${source[@]}; do
cmd="unzip -qq $file" ;;
*.gz)
cmd="gunzip $file" ;;
*.bz2)
cmd="bunzip2 $file" ;;
esac
if [ "$cmd" != "" ]; then
msg " |=> $cmd"
@ -352,10 +402,9 @@ for netfile in ${source[@]}; do
exit 1
fi
fi
fi
done
if [ "$GENMD5" = "1" ]; then
else
# generate md5 hashes
if [ ! `type -p md5sum` ]; then
msg "==> ERROR: Cannot find the md5sum program."
exit 1
@ -384,34 +433,6 @@ if [ "$GENMD5" = "1" ]; then
exit 0
fi
# MD5 Validation
if [ ${#md5sums[@]} -ne ${#source[@]} ]; then
msg "==> WARNING: MD5sums are missing or incomplete. Cannot verify source integrity."
# sleep 1
elif [ `type -p md5sum` ]; then
msg "==> Validating source files with MD5sums"
errors=0
idx=0
for netfile in ${source[@]}; do
file=`strip_url $netfile`
echo -n " |=> $file ... " >&2
echo "${md5sums[$idx]} $file" | md5sum -c - >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "FAILED" >&2
errors=1
else
echo "Passed" >&2
fi
idx=$(($idx+1))
done
if [ $errors -gt 0 ]; then
msg "==> ERROR: One or more files did not pass the validity check!"
exit 1
fi
else
msg "==> WARNING: The md5sum program is missing. Cannot verify source files!"
sleep 1
fi
if [ "`id -u`" = "0" ]; then
# chown all source files to root.root
@ -481,7 +502,7 @@ if [ "$NOSTRIP" = "0" ]; then
fi
# get some package meta info
builddate=`LC_ALL= ; date -u "+%a %b %d %k:%M:%S %Y"`
builddate=`LC_ALL= ; date -u "+%a %b %e %k:%M:%S %Y"`
if [ "$PACKAGER" != "" ]; then
packager="$PACKAGER"
else
@ -531,9 +552,7 @@ fi
# build a filelist
msg "==> Generating .FILELIST file..."
cd $startdir/pkg
tar cv * >/dev/null 2>.FILELIST.tmp
cat .FILELIST.tmp | sort >.FILELIST
rm -f .FILELIST.tmp
tar cvf /dev/null * | sort >.FILELIST
# tar it up
msg "==> Compressing package..."
@ -555,7 +574,8 @@ msg "==> Finished making: $pkgname (`date`)"
if [ "$INSTALL" = "1" ]; then
msg "==> Running pacman --upgrade"
pacman --upgrade $PKGDEST/$pkgname-$pkgver-$pkgrel.pkg.tar.gz
pacman --upgrade $PKGDEST/${pkgname}-${pkgver}-${pkgrel}.pkg.tar.gz
exit $?
fi
exit 0

View file

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

View file

@ -529,6 +529,7 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root)
return(conflicts);
}
/* return a PMList of packages in "db" that provide "package" */
PMList *whatprovides(pacdb_t *db, char* package)
{
PMList *pkgs, *i = NULL;

View file

@ -66,6 +66,7 @@ unsigned short pmo_d_resolve = 0;
unsigned short pmo_q_isfile = 0;
unsigned short pmo_q_info = 0;
unsigned short pmo_q_list = 0;
unsigned short pmo_q_orphans = 0;
unsigned short pmo_q_owns = 0;
unsigned short pmo_r_cascade = 0;
unsigned short pmo_s_upgrade = 0;
@ -1716,6 +1717,9 @@ int pacman_remove(pacdb_t *db, PMList *targets)
/* look for a provides package */
PMList *provides = whatprovides(db, depend.name);
if(provides) {
/* TODO: should check _all_ packages listed in provides, not just
* the first one.
*/
/* use the first one */
depinfo = db_scan(db, provides->data, INFRQ_ALL);
list_free(provides);
@ -1885,6 +1889,14 @@ int pacman_query(pacdb_t *db, PMList *targets)
printf("%s %s%s\n", info->name, pmo_root, (char*)q->data);
}
freepkg(info);
} else if(pmo_q_orphans) {
info = db_scan(db, tmpp->name, INFRQ_DESC | INFRQ_DEPENDS);
if(info == NULL) {
return(1);
}
if(info->requiredby == NULL) {
printf("%s %s\n", tmpp->name, tmpp->version);
}
} else {
printf("%s %s\n", tmpp->name, tmpp->version);
}
@ -1908,6 +1920,15 @@ int pacman_query(pacdb_t *db, PMList *targets)
for(lp = info->files; lp; lp = lp->next) {
printf("%s %s%s\n", info->name, pmo_root, (char*)lp->data);
}
} else if(pmo_q_orphans) {
info = db_scan(db, package, INFRQ_DESC | INFRQ_DEPENDS);
if(info == NULL) {
fprintf(stderr, "Package \"%s\" was not found.\n", package);
return(2);
}
if(info->requiredby == NULL) {
printf("%s %s\n", info->name, info->version);
}
} else {
info = db_scan(db, package, INFRQ_DESC);
if(info == NULL) {
@ -1953,7 +1974,7 @@ PMList* sortbydeps(PMList *targets)
int clean = 0;
/* count the number of targets */
for(i = targets; i; i = i->next, numtargs++);
numtargs = list_count(targets);
while(change) {
change = 0;
@ -2261,14 +2282,16 @@ PMList* checkdeps(pacdb_t *db, unsigned short op, PMList *targets)
/* PROVIDES -- check to see if another package already provides what
* we offer
*/
/* XXX: disabled -- we allow multiple packages to provide the same thing.
* list packages in conflicts if they really do conflict.
for(j = tp->provides; j; j = j->next) {
PMList *provs = whatprovides(db, j->data);
for(k = provs; k; k = k->next) {
if(!strcmp(tp->name, k->data)) {
/* this is the same package -- skip it */
// this is the same package -- skip it
continue;
}
/* we treat this just like a conflict */
// we treat this just like a conflict
MALLOC(miss, sizeof(depmissing_t));
miss->type = CONFLICT;
miss->depend.mod = DEP_ANY;
@ -2279,7 +2302,7 @@ PMList* checkdeps(pacdb_t *db, unsigned short op, PMList *targets)
baddeps = list_add(baddeps, miss);
}
}
}
}*/
/* DEPENDENCIES -- look for unsatisfied dependencies */
for(j = tp->depends; j; j = j->next) {
@ -2518,6 +2541,7 @@ int parseargs(int op, int argc, char **argv)
{"clean", no_argument, 0, 'c'},
{"force", no_argument, 0, 'f'},
{"nodeps", no_argument, 0, 'd'},
{"orphans", no_argument, 0, 'e'},
{"nosave", no_argument, 0, 'n'},
{"owns", no_argument, 0, 'o'},
{"list", no_argument, 0, 'l'},
@ -2531,7 +2555,7 @@ int parseargs(int op, int argc, char **argv)
{0, 0, 0, 0}
};
while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vhscVfnoldpiuwyg", opts, &option_index))) {
while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vhscVfnoldepiuwyg", opts, &option_index))) {
if(opt < 0) {
break;
}
@ -2548,25 +2572,26 @@ int parseargs(int op, int argc, char **argv)
case 'D': pmo_op = (pmo_op != PM_MAIN ? 0 : PM_DEPTEST); pmo_d_resolve = 1; break;
case 'h': pmo_help = 1; break;
case 'V': pmo_version = 1; break;
case 'v': pmo_verbose = 1; break;
case 'f': pmo_force = 1; break;
case 'd': pmo_nodeps = 1; break;
case 'n': pmo_nosave = 1; break;
case 'l': pmo_q_list = 1; break;
case 'p': pmo_q_isfile = 1; break;
case 'i': pmo_q_info = 1; break;
case 'o': pmo_q_owns = 1; break;
case 'u': pmo_s_upgrade = 1; break;
case 'w': pmo_s_downloadonly = 1; break;
case 'y': pmo_s_sync = 1; break;
case 's': pmo_s_search = 1; break;
case 'b': strcpy(pmo_dbpath, optarg); break;
case 'c': pmo_s_clean = 1; pmo_r_cascade = 1; break;
case 'd': pmo_nodeps = 1; break;
case 'e': pmo_q_orphans = 1; break;
case 'f': pmo_force = 1; break;
case 'g': pmo_group = 1; break;
case 'i': pmo_q_info = 1; break;
case 'l': pmo_q_list = 1; break;
case 'n': pmo_nosave = 1; break;
case 'p': pmo_q_isfile = 1; break;
case 'o': pmo_q_owns = 1; break;
case 'r': if(realpath(optarg, pmo_root) == NULL) {
perror("bad root path");
return(1);
} break;
case 'b': strcpy(pmo_dbpath, optarg); break;
case 's': pmo_s_search = 1; break;
case 'u': pmo_s_upgrade = 1; break;
case 'v': pmo_verbose = 1; break;
case 'w': pmo_s_downloadonly = 1; break;
case 'y': pmo_s_sync = 1; break;
case '?': return(1);
default: return(1);
}
@ -2725,13 +2750,8 @@ int parseconfig(char *configfile)
return(1);
}
server->protocol = strdup(ptr);
if(strcmp(server->protocol, "file")) {
if(!strcmp(server->protocol, "ftp") || !strcmp(server->protocol, "http")) {
char *slash;
/* no http support yet */
if(strcmp(ptr, "ftp")) {
fprintf(stderr, "config: line %d: protocol %s is not supported\n", linenum, ptr);
return(1);
}
/* split the url into domain and path */
slash = strchr(p, '/');
if(slash == NULL) {
@ -2748,7 +2768,7 @@ int parseconfig(char *configfile)
*slash = '\0';
}
server->server = strdup(p);
} else {
} else if(!strcmp(server->protocol, "file")){
/* add a trailing slash if we need to */
if(p[strlen(p)-1] == '/') {
server->path = strdup(p);
@ -2756,9 +2776,12 @@ int parseconfig(char *configfile)
MALLOC(server->path, strlen(p)+2);
sprintf(server->path, "%s/", p);
}
} else {
fprintf(stderr, "config: line %d: protocol %s is not supported\n", linenum, ptr);
return(1);
}
/* add to the list */
vprint("config: %s: server: %s %s\n", section, server->server, server->path);
vprint("config: %s: server: %s %s %s\n", section, server->protocol, server->server, server->path);
sync->servers = list_add(sync->servers, server);
} else {
fprintf(stderr, "config: line %d: syntax error\n", linenum);

View file

@ -22,7 +22,7 @@
#define _PAC_PACMAN_H
#ifndef PACVER
#define PACVER "2.6"
#define PACVER "2.6.1"
#endif
#ifndef PKGDIR

View file

@ -136,12 +136,25 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
} else {
vprint("FTP passive mode not set\n");
}
} else if(!strcmp(server->protocol, "http")) {
if(!HttpConnect(server->server, &control)) {
fprintf(stderr, "error: cannot connect to %s\n", server->server);
continue;
}
}
/* set up our progress bar's callback */
if(strcmp(server->protocol, "file")) {
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);
}
/* get each file in the list */
for(lp = files; lp; lp = lp->next) {
char output[PATH_MAX];
int j;
int j, filedone = 0;
char *fn = (char*)lp->data;
struct stat st;
@ -150,7 +163,7 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
}
snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn);
strncpy(sync_fnm, lp->data, 24);
strncpy(sync_fnm, fn, 24);
for(j = strlen(sync_fnm); j < 24; j++) {
sync_fnm[j] = ' ';
}
@ -170,35 +183,43 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
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);
if(!FtpGet(output, lp->data, FTPLIB_IMAGE, control)) {
if(!FtpGet(output, fn, FTPLIB_IMAGE, control)) {
fprintf(stderr, "\nfailed downloading %s from %s: %s\n",
fn, server->server, FtpLastResponse(control));
/* we leave the partially downloaded file in place so it can be resumed later */
} else {
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);
filedone = 1;
}
} else if(!strcmp(server->protocol, "http")) {
char src[PATH_MAX];
if(!stat(output, &st)) {
/* no resume support yet */
unlink(output);
}
printf("\n");
fflush(stdout);
} else if(!strcmp(server->protocol, "file")) {
/* local repository, just copy the file */
char src[PATH_MAX], dest[PATH_MAX];
snprintf(src, PATH_MAX, "%s%s", server->path, fn);
snprintf(dest, PATH_MAX, "%s/%s", localpath, fn);
vprint("copying %s to %s\n", src, dest);
if(copyfile(src, dest)) {
if(!HttpGet(output, src, &fsz, control)) {
fprintf(stderr, "\nfailed downloading %s from %s: %s\n",
fn, server->server, FtpLastResponse(control));
/* no resume support yet */
unlink(output);
} else {
filedone = 1;
}
} else if(!strcmp(server->protocol, "file")) {
char src[PATH_MAX];
snprintf(src, PATH_MAX, "%s%s", server->path, fn);
vprint("copying %s to %s/%s\n", src, localpath, fn);
/* local repository, just copy the file */
if(copyfile(src, output)) {
fprintf(stderr, "failed copying %s\n", src);
} else {
filedone = 1;
}
}
if(filedone) {
char completefile[PATH_MAX];
if(!strcmp(server->protocol, "file")) {
char out[56];
printf(" %s [", sync_fnm);
strncpy(out, server->path, 33);
@ -207,11 +228,16 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
printf(" ");
}
fputs("] 100% | LOCAL\n", stdout);
fflush(stdout);
} else {
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);
}
}
printf("\n");
fflush(stdout);
}
if(list_count(complete) == list_count(files)) {
done = 1;
@ -219,6 +245,8 @@ int downloadfiles(PMList *servers, char *localpath, PMList *files)
if(!strcmp(server->protocol, "ftp")) {
FtpQuit(control);
} else if(!strcmp(server->protocol, "http")) {
HttpQuit(control);
}
}
@ -230,12 +258,6 @@ static int log_progress(netbuf *ctl, int xfered, void *arg)
int fsz = *(int*)arg;
int pct = ((float)(xfered+offset) / fsz) * 100;
int i, cur;
char *cenv = NULL;
cenv = getenv("COLUMNS");
if(cenv) {
maxcols = atoi(cenv);
}
printf(" %s [", sync_fnm);
cur = (int)((maxcols-44)*pct/100);