Imported from pacman-1.21.tar.gz

This commit is contained in:
Judd Vinet 2002-04-03 08:40:12 +00:00
parent 931506031b
commit b656d1fe59
10 changed files with 101 additions and 52 deletions

View file

@ -1,10 +1,14 @@
VERSION DESCRIPTION VERSION DESCRIPTION
------------------------------------------------------------------ ------------------------------------------------------------------
- 1.21 - Added better backup control -- upgrade/add and remove
do different things with the -n switch
1.2 - Added wildcard handling
- Added man pages for makepkg and pacsync
- Added the pacsync utility for remote file fetching/sync
1.1 - Fixed some string-handling bugs 1.1 - Fixed some string-handling bugs
- Added better handling of configuration files and the like. - Added better handling of configuration files and the like.
If "file" is about to be removed, but it is designated to If "file" is about to be removed, but it is designated to
be backed up, then it will be copied to "file.save" backed up, then it will be copied to "file.save"
- Changed db_find_conflicts() to ignore directories - Changed db_find_conflicts() to ignore directories
1.0 - Initial Release 1.0 - Initial Release

View file

@ -27,7 +27,7 @@ BINDIR = /usr/bin
MANDIR = /usr/man MANDIR = /usr/man
ETCDIR = /etc ETCDIR = /etc
VERSION = 1.2 VERSION = 1.21
LIBTAR_VERSION = 1.2.4 LIBTAR_VERSION = 1.2.4
CXX = gcc CXX = gcc

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
me=`basename $0` me=`basename $0`
myver='1.2' myver='1.21'
startdir=`pwd` startdir=`pwd`
[ -f /etc/makepkg.conf ] && . /etc/makepkg.conf [ -f /etc/makepkg.conf ] && . /etc/makepkg.conf

7
makepkg.8.in Executable file → Normal file
View file

@ -70,12 +70,13 @@ Notice that the "/usr" portion should be present with "prefix", but not "DESTDIR
Once the package is successfully installed into the package root, \fImakepkg\fP Once the package is successfully installed into the package root, \fImakepkg\fP
will remove some directories (as per Arch Linux package guidelines; if you use will remove some directories (as per Arch Linux package guidelines; if you use
this elsewhere, feel free to change it) like /usr/doc and /usr/info. It will this elsewhere, feel free to change it) like /usr/doc and /usr/info. It will
then strip debugging info from libraries and binaries and compress then strip debugging info from libraries and binaries and compress everything
into a .pkg.tar.gz file in the directory you ran \fBmakepkg\fP from.
.SH PKGBUILD Directives .SH PKGBUILD Directives
.TP .TP
.B backup .B backup
A space-delimited array of filenames (without a preceiding slash). The A space-delimited array of filenames (without a preceding slash). The
\fIbackup\fP line will be propagated to the package meta-info file for \fIbackup\fP line will be propagated to the package meta-info file for
pacman. This will designate all files listed there to be backed up if this pacman. This will designate all files listed there to be backed up if this
package is ever removed from a system. package is ever removed from a system.
@ -92,7 +93,7 @@ by wget.
.B install .B install
There is also an \fIinstall\fP directive that is not used in the example There is also an \fIinstall\fP directive that is not used in the example
above. If \fIinstall\fP is set to the name of a file in the package build above. If \fIinstall\fP is set to the name of a file in the package build
directory (but \fBnot\fP listed in the source line), then it will be directory, then it will be
copied to the package meta-info file and designated as a post-install script. copied to the package meta-info file and designated as a post-install script.
This will be run by pacman whenever it installs the package. This will be run by pacman whenever it installs the package.

View file

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
toplevel=`pwd` toplevel=`pwd`
version="1.2" version="1.21"
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
echo "makepkg version $version" echo "makepkg version $version"
echo "usage: $0 <destdir> <category> [category] ..." echo "usage: $0 <destdir> <category> [category] ..."
echo " where <category> is base, opt, etc." echo " where <category> is one or more of base, opt, contrib"
echo " eg: makeworld /packages base opt extra" echo " eg: makeworld /packages base opt"
echo echo
echo " this should be run from the toplevel directory of ABS (usually /usr/abs)" echo " this should be run from the toplevel directory of ABS (usually /usr/abs)"
exit 1 exit 1

View file

@ -65,10 +65,13 @@ This option should be used with care, preferably not at all.
.TP .TP
.B "\-n, \-\-nosave" .B "\-n, \-\-nosave"
Instructs pacman to ignore file backup designations. Normally, when Instructs pacman to ignore file backup designations. Normally, when
a file is about to be removed from the system, the database is first a file is about to be \fIremoved\fP from the system the database is first
checked to see if the file should be renamed to a .save extension checked to see if the file should be renamed to a .pacsave extension
(indicated by a '\fB*\fP' prefix in the pacman database). The \fB--nosave\fP (indicated by a '\fB*\fP' prefix in the pacman database). The \fB--nosave\fP
will turn off all file backups. will turn off these file backups. Normally, when a file is about to be \fIadded\fP
or \fIupgraded\fP and a starred file already exists, pacman will write
the new file to a .pacnew extension and keep the old one in place. In this
case, \fB--nosave\fP instructs pacman to overwrite the existing file.
.TP .TP
.B "\-r, \-\-root <path>" .B "\-r, \-\-root <path>"
Specify alternative installation root (default is "/"). This Specify alternative installation root (default is "/"). This

View file

@ -174,12 +174,11 @@ int main(int argc, char* argv[])
if(ret == 1) { if(ret == 1) {
fprintf(stderr, "error: Could not open package database file!\n"); fprintf(stderr, "error: Could not open package database file!\n");
fprintf(stderr, " Check to see that %s exists.\n", dbpath); fprintf(stderr, " Check to see that %s exists.\n", dbpath);
fprintf(stderr, " If not, you may simply create it by \"touch\"-ing it.\n"); fprintf(stderr, " If not, you can create it by \"touch\"-ing it.\n");
return(1); return(1);
} }
if(ret == 2) { if(ret == 2) {
fprintf(stderr, "error: Database is corrupt! You may need to use the backup database.\n"); fprintf(stderr, "error: Database is corrupt! You may need to use the backup database.\n");
fprintf(stderr, " I hope you like tweaking... ;-)\n");
return(1); return(1);
} }
@ -188,6 +187,15 @@ int main(int argc, char* argv[])
for(i = 0; i < pm_targct; i++) { for(i = 0; i < pm_targct; i++) {
if(op_func(pm_targets[i])) { if(op_func(pm_targets[i])) {
ret = 1; ret = 1;
/*
if(op_func == pacman_add) {
printf("Failed to add %s\n", pkgname != NULL ? pkgname : pm_targets[i]);
} else if(op_func == pacman_remove) {
printf("Failed to remove %s\n", pkgname != NULL ? pkgname : pm_targets[i]);
} else if(op_func == pacman_upgrade) {
printf("Failed to upgrade %s\n", pkgname != NULL ? pkgname : pm_targets[i]);
}
*/
} }
} }
if(op_func == pacman_query && pm_targct == 0) { if(op_func == pacman_query && pm_targct == 0) {
@ -210,11 +218,11 @@ int main(int argc, char* argv[])
int pacman_add(char* pkgfile) int pacman_add(char* pkgfile)
{ {
int i, errors = 0; int i, ret = 0, errors = 0;
TAR* tar; TAR* tar;
char* errmsg = NULL; char* errmsg = NULL;
char* expath = NULL; char* expath = NULL;
char* newpath = NULL; /*char* newpath = NULL;*/
fileset_t files = NULL; fileset_t files = NULL;
unsigned int filecount = 0, nb = 0; unsigned int filecount = 0, nb = 0;
struct stat buf; struct stat buf;
@ -248,9 +256,18 @@ int pacman_add(char* pkgfile)
/* see if this is an upgrade. if so, remove the old package first */ /* see if this is an upgrade. if so, remove the old package first */
if(pmo_upgrade) { if(pmo_upgrade) {
vprint("Removing old package first...\n"); vprint("Removing old package first...\n");
if(pacman_remove(pkgname)) { /* save the old nosave option and disable it for the package remove */
i = pmo_nosave;
pmo_nosave = 0;
ret = pacman_remove(pkgname);
/* restore nosave */
pmo_nosave = i;
if(ret == 1) {
fprintf(stderr, "\nUpgrade aborted.\n"); fprintf(stderr, "\nUpgrade aborted.\n");
return(1); return(1);
} else if(ret == 2) {
fprintf(stderr, "%s is not installed. skipping...\n", pkgname);
return(0);
} }
if(db_update(NULL, 0)) { if(db_update(NULL, 0)) {
fprintf(stderr, "\nError updating database. Upgrade aborted.\n"); fprintf(stderr, "\nError updating database. Upgrade aborted.\n");
@ -281,11 +298,16 @@ int pacman_add(char* pkgfile)
vprint(" %s\n", expath); vprint(" %s\n", expath);
if(!pmo_nosave && nb && !stat(expath, &buf)) { if(!pmo_nosave && nb && !stat(expath, &buf)) {
/* backup this file */ /* backup this file */
newpath = (char*)realloc(newpath, strlen(expath)+6); /*newpath = (char*)realloc(newpath, strlen(expath)+6);
strcpy(newpath, expath); strcpy(newpath, expath);
strcat(newpath, ".save"); strcat(newpath, ".save");
rename(expath, newpath); rename(expath, newpath);
fprintf(stderr, "%s renamed to %s\n", expath, newpath); fprintf(stderr, "%s renamed to %s\n", expath, newpath);*/
/* keep the old file and write the new one to a .pacnew extension */
fprintf(stderr, "%s already exists, extracting to %s.pacnew\n", expath, expath);
expath = (char*)realloc(expath, strlen(expath)+strlen(".pacnew")+1);
strcat(expath, ".pacnew");
} }
if(tar_extract_file(tar, expath)) { if(tar_extract_file(tar, expath)) {
errmsg = strerror(errno); errmsg = strerror(errno);
@ -350,8 +372,13 @@ int pacman_remove(char* pkgfile)
} }
} }
if(!found) { if(!found) {
fprintf(stderr, "Cannot remove %s: Package was not found.\n", pkgfile); if(pmo_upgrade) {
return(1); /* special handling */
return(2);
} else {
fprintf(stderr, "Cannot remove %s: Package was not found.\n", pkgfile);
return(1);
}
} }
while(!done) { while(!done) {
@ -388,13 +415,22 @@ int pacman_remove(char* pkgfile)
/* perror("cannot remove directory"); */ /* perror("cannot remove directory"); */
} }
} else { } else {
/* if the file is flagged, back it up to .save */ /* if the file is flagged, back it up to .pacsave */
if(!pmo_nosave && nb) { if(nb) {
newpath = (char*)realloc(newpath, strlen(file)+6); if(!pmo_upgrade && !pmo_nosave) {
strcpy(newpath, file); newpath = (char*)realloc(newpath, strlen(file)+strlen(".pacsave")+1);
strcat(newpath, ".save"); strcpy(newpath, file);
rename(file, newpath); strcat(newpath, ".pacsave");
fprintf(stderr, "%s renamed to %s\n", file, newpath); rename(file, newpath);
fprintf(stderr, "%s renamed to %s\n", file, newpath);
} else if(!pmo_upgrade && pmo_nosave) {
vprint(" unlinking %s\n", file);
if(unlink(file)) {
perror("cannot remove file");
}
} else {
/* skip */
}
} else { } else {
vprint(" unlinking %s\n", file); vprint(" unlinking %s\n", file);
if(unlink(file)) { if(unlink(file)) {
@ -1025,31 +1061,32 @@ void usage(int op, char* myname)
printf("usage: %s {-A --add} [options] <file>\n", myname); printf("usage: %s {-A --add} [options] <file>\n", myname);
printf("options:\n"); printf("options:\n");
printf(" -f, --force force install, overwrite conflicting files\n"); printf(" -f, --force force install, overwrite conflicting files\n");
printf(" -n, --nosave do not save configuration files\n"); printf(" -n, --nosave overwrite configuration files as well\n");
printf(" -v, --verbose be verbose\n"); printf(" -v, --verbose be verbose\n");
printf(" -r, --root <path> set an alternative installation root\n"); printf(" -r, --root <path> set an alternate installation root\n");
} else if(op == PM_REMOVE) { } else if(op == PM_REMOVE) {
printf("usage: %s {-R --remove} [options] <package>\n", myname); printf("usage: %s {-R --remove} [options] <package>\n", myname);
printf("options:\n"); printf("options:\n");
printf(" -n, --nosave do not save configuration files\n"); printf(" -n, --nosave do not save configuration files as .pacsave\n");
printf(" -v, --verbose be verbose\n"); printf(" -v, --verbose be verbose\n");
printf(" -r, --root <path> set an alternative installation root\n"); printf(" -r, --root <path> set an alternate installation root\n");
} else if(op == PM_UPGRADE) { } else if(op == PM_UPGRADE) {
printf("usage: %s {-U --upgrade} [options] <file>\n", myname); printf("usage: %s {-U --upgrade} [options] <file>\n", myname);
printf("options:\n"); printf("options:\n");
printf(" -f, --force force install, overwrite conflicting files\n"); printf(" -f, --force force install, overwrite conflicting files\n");
printf(" -n, --nosave do not save configuration files\n"); printf(" -n, --nosave upgrade configuration files as well (old one is deleted)\n");
printf(" -v, --verbose be verbose\n"); printf(" -v, --verbose be verbose\n");
printf(" -r, --root <path> set an alternative installation root\n"); printf(" -r, --root <path> set an alternate installation root\n");
} else if(op == PM_QUERY) { } else if(op == PM_QUERY) {
printf("usage: %s {-Q --query} [options] [package]\n", myname); printf("usage: %s {-Q --query} [options] [package]\n", myname);
printf("options:\n"); printf("options:\n");
printf(" -r, --root <path> set an alternative installation root\n");
printf(" -o, --owns <file> query the package that owns <file>\n"); printf(" -o, --owns <file> query the package that owns <file>\n");
printf(" -l, --list list the contents of the queried package\n"); printf(" -l, --list list the contents of the queried package\n");
printf(" -i, --info output the .PKGINFO file (only used with -p)\n"); printf(" -i, --info view the package info file (only used with -p)\n");
printf(" -p, --file if used, then [package] will be the path\n"); printf(" -p, --file if used, then [package] will be the path\n");
printf(" to an (uninstalled) package to query\n"); printf(" to a .tar.gz package file to query\n");
printf(" -v, --verbose be verbose\n");
printf(" -r, --root <path> set an alternate installation root\n");
} }
} }

View file

@ -21,7 +21,7 @@
#ifndef PACMAN_H #ifndef PACMAN_H
#define PACMAN_H #define PACMAN_H
#define VERSION "1.2" #define VERSION "1.21"
#define PKGEXT ".tar.gz" #define PKGEXT ".tar.gz"
#define PKGDB "/var/lib/pacman/pacman.db" #define PKGDB "/var/lib/pacman/pacman.db"

20
pacsync
View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
version="1.2" version="1.21"
tanpath="/var/lib/pacman" tanpath="/var/lib/pacman"
tandb="pacsync.db" tandb="pacsync.db"
errors=0 errors=0
@ -49,7 +49,7 @@ download() {
dosync() { dosync() {
cd /tmp cd /tmp
download "package list" $tandb download "package list" pacsync/$tandb
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
exit 1 exit 1
fi fi
@ -62,7 +62,7 @@ doinstall() {
pkg2dl= pkg2dl=
pkg2inst= pkg2inst=
for pkgname in $*; do for pkgname in $*; do
line=`egrep "^[a-z]+/$pkgname-[a-z0-9\.]+-[0-9]+\.pkg\.tar\.gz$" $tanpath/$tandb` line=`egrep "^[a-z]+/$pkgname-[a-zA-Z0-9\.]+-[0-9]+\.pkg\.tar\.gz$" $tanpath/$tandb`
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
message "package $pkgname not found" message "package $pkgname not found"
exit 1 exit 1
@ -75,7 +75,7 @@ doinstall() {
filename=`echo $line | sed 's|^[a-z]*/||g'` filename=`echo $line | sed 's|^[a-z]*/||g'`
pkg2inst="$pkg2inst $filename" pkg2inst="$pkg2inst $filename"
if [ ! -f /var/cache/pacman/pkg/$filename ]; then if [ ! -f /var/cache/pacman/pkg/$filename ]; then
pkg2dl="$pkg2dl arch/$filename" pkg2dl="$pkg2dl $filename"
fi fi
done done
@ -88,7 +88,7 @@ doinstall() {
if [ `pwd` != "/var/cache/pacman/pkg" ]; then if [ `pwd` != "/var/cache/pacman/pkg" ]; then
# move downloaded files into cache # move downloaded files into cache
mkdir -p /var/cache/pacman/pkg mkdir -p /var/cache/pacman/pkg
mv `echo $pkg2dl | sed 's|arch/||g'` /var/cache/pacman/pkg/ mv $pkg2dl /var/cache/pacman/pkg/
fi fi
fi fi
@ -109,7 +109,7 @@ doupgrade() {
pkg2dl= pkg2dl=
pkg2up= pkg2up=
for pkgname in $*; do for pkgname in $*; do
line=`egrep "^[a-z]+/$pkgname-[a-z0-9\.]+-[0-9]+\.pkg\.tar\.gz$" $tanpath/$tandb` line=`egrep "^[a-z]+/$pkgname-[a-zA-Z0-9\.]+-[0-9]+\.pkg\.tar\.gz$" $tanpath/$tandb`
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
message "package $pkgname not found" message "package $pkgname not found"
exit 1 exit 1
@ -129,7 +129,7 @@ doupgrade() {
else else
pkg2up="$pkg2up $filename" pkg2up="$pkg2up $filename"
if [ ! -f /var/cache/pacman/pkg/$filename ]; then if [ ! -f /var/cache/pacman/pkg/$filename ]; then
pkg2dl="$pkg2dl arch/$filename" pkg2dl="$pkg2dl $filename"
fi fi
fi fi
done done
@ -143,7 +143,7 @@ doupgrade() {
if [ `pwd` != "/var/cache/pacman/pkg" ]; then if [ `pwd` != "/var/cache/pacman/pkg" ]; then
# move downloaded files into cache # move downloaded files into cache
mkdir -p /var/cache/pacman/pkg mkdir -p /var/cache/pacman/pkg
mv `echo $pkg2dl | sed 's|arch/||g'` /var/cache/pacman/pkg/ mv $pkg2dl /var/cache/pacman/pkg/
fi fi
fi fi
@ -166,7 +166,7 @@ doreport() {
headers=0 headers=0
pkg2up= pkg2up=
for pkgfile in `cat $tanpath/$tandb | sed "s|^[a-z]*/||g"`; do for pkgfile in `cat $tanpath/$tandb | sed "s|^[a-z]*/||g"`; do
pkgname=`echo $pkgfile | sed 's|-[a-z0-9\.]*-[0-9]*\.pkg\.tar\.gz||g'` pkgname=`echo $pkgfile | sed 's|-[a-zA-Z0-9\.]*-[0-9]*\.pkg\.tar\.gz||g'`
pacman=`pacman -Q $pkgname 2>/dev/null` pacman=`pacman -Q $pkgname 2>/dev/null`
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
# skip this one, it's not installed # skip this one, it's not installed
@ -174,7 +174,7 @@ doreport() {
fi fi
pkgver=`echo $pacman | awk '{print $2}'` pkgver=`echo $pacman | awk '{print $2}'`
locfile="$pkgname-$pkgver" locfile="$pkgname-$pkgver"
remfile=`echo $pkgfile | sed 's|^[a-z]*/||g' | sed 's|\.pkg\.tar\.gz||g'` remfile=`echo $pkgfile | sed 's|^[a-zA-Z]*/||g' | sed 's|\.pkg\.tar\.gz||g'`
# compare locfile and remfile # compare locfile and remfile
if [ "$locfile" = "$remfile" ]; then if [ "$locfile" = "$remfile" ]; then
# this package is up to date # this package is up to date

View file

@ -2,7 +2,11 @@
# /etc/pacsync.conf # /etc/pacsync.conf
# #
#
# the full URL of the server (up to the /arch package directory) # the full URL of the server (up to the /arch package directory)
SYNC_SERVER="ftp://ftp.archlinux.org" #
#SYNC_SERVER="http://www.archlinux.org/pub" # (note: ibiblio.org will be fastest; please use it)
#
SYNC_SERVER="ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/arch"
#SYNC_SERVER="http://www.ibiblio.org/pub/linux/distributions/archlinux/arch"
#SYNC_SERVER="ftp://ftp.archlinux.org/arch"