Imported from pacman-1.21.tar.gz
This commit is contained in:
parent
931506031b
commit
b656d1fe59
10 changed files with 101 additions and 52 deletions
|
@ -1,10 +1,14 @@
|
|||
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
|
||||
- Added better handling of configuration files and the like.
|
||||
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
|
||||
1.0 - Initial Release
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -27,7 +27,7 @@ BINDIR = /usr/bin
|
|||
MANDIR = /usr/man
|
||||
ETCDIR = /etc
|
||||
|
||||
VERSION = 1.2
|
||||
VERSION = 1.21
|
||||
LIBTAR_VERSION = 1.2.4
|
||||
|
||||
CXX = gcc
|
||||
|
|
2
makepkg
2
makepkg
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
me=`basename $0`
|
||||
myver='1.2'
|
||||
myver='1.21'
|
||||
startdir=`pwd`
|
||||
|
||||
[ -f /etc/makepkg.conf ] && . /etc/makepkg.conf
|
||||
|
|
7
makepkg.8.in
Executable file → Normal file
7
makepkg.8.in
Executable file → Normal 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
|
||||
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
|
||||
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
|
||||
.TP
|
||||
.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
|
||||
pacman. This will designate all files listed there to be backed up if this
|
||||
package is ever removed from a system.
|
||||
|
@ -92,7 +93,7 @@ by wget.
|
|||
.B install
|
||||
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
|
||||
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.
|
||||
This will be run by pacman whenever it installs the package.
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
toplevel=`pwd`
|
||||
version="1.2"
|
||||
version="1.21"
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "makepkg version $version"
|
||||
echo "usage: $0 <destdir> <category> [category] ..."
|
||||
echo " where <category> is base, opt, etc."
|
||||
echo " eg: makeworld /packages base opt extra"
|
||||
echo " where <category> is one or more of base, opt, contrib"
|
||||
echo " eg: makeworld /packages base opt"
|
||||
echo
|
||||
echo " this should be run from the toplevel directory of ABS (usually /usr/abs)"
|
||||
exit 1
|
||||
|
|
|
@ -65,10 +65,13 @@ This option should be used with care, preferably not at all.
|
|||
.TP
|
||||
.B "\-n, \-\-nosave"
|
||||
Instructs pacman to ignore file backup designations. Normally, when
|
||||
a file is about to be removed from the system, the database is first
|
||||
checked to see if the file should be renamed to a .save extension
|
||||
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 .pacsave extension
|
||||
(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
|
||||
.B "\-r, \-\-root <path>"
|
||||
Specify alternative installation root (default is "/"). This
|
||||
|
|
87
pacman.c
87
pacman.c
|
@ -174,12 +174,11 @@ int main(int argc, char* argv[])
|
|||
if(ret == 1) {
|
||||
fprintf(stderr, "error: Could not open package database file!\n");
|
||||
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);
|
||||
}
|
||||
if(ret == 2) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -188,6 +187,15 @@ int main(int argc, char* argv[])
|
|||
for(i = 0; i < pm_targct; i++) {
|
||||
if(op_func(pm_targets[i])) {
|
||||
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) {
|
||||
|
@ -210,11 +218,11 @@ int main(int argc, char* argv[])
|
|||
|
||||
int pacman_add(char* pkgfile)
|
||||
{
|
||||
int i, errors = 0;
|
||||
int i, ret = 0, errors = 0;
|
||||
TAR* tar;
|
||||
char* errmsg = NULL;
|
||||
char* expath = NULL;
|
||||
char* newpath = NULL;
|
||||
/*char* newpath = NULL;*/
|
||||
fileset_t files = NULL;
|
||||
unsigned int filecount = 0, nb = 0;
|
||||
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 */
|
||||
if(pmo_upgrade) {
|
||||
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");
|
||||
return(1);
|
||||
} else if(ret == 2) {
|
||||
fprintf(stderr, "%s is not installed. skipping...\n", pkgname);
|
||||
return(0);
|
||||
}
|
||||
if(db_update(NULL, 0)) {
|
||||
fprintf(stderr, "\nError updating database. Upgrade aborted.\n");
|
||||
|
@ -281,11 +298,16 @@ int pacman_add(char* pkgfile)
|
|||
vprint(" %s\n", expath);
|
||||
if(!pmo_nosave && nb && !stat(expath, &buf)) {
|
||||
/* backup this file */
|
||||
newpath = (char*)realloc(newpath, strlen(expath)+6);
|
||||
/*newpath = (char*)realloc(newpath, strlen(expath)+6);
|
||||
strcpy(newpath, expath);
|
||||
strcat(newpath, ".save");
|
||||
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)) {
|
||||
errmsg = strerror(errno);
|
||||
|
@ -350,8 +372,13 @@ int pacman_remove(char* pkgfile)
|
|||
}
|
||||
}
|
||||
if(!found) {
|
||||
fprintf(stderr, "Cannot remove %s: Package was not found.\n", pkgfile);
|
||||
return(1);
|
||||
if(pmo_upgrade) {
|
||||
/* special handling */
|
||||
return(2);
|
||||
} else {
|
||||
fprintf(stderr, "Cannot remove %s: Package was not found.\n", pkgfile);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
while(!done) {
|
||||
|
@ -388,13 +415,22 @@ int pacman_remove(char* pkgfile)
|
|||
/* perror("cannot remove directory"); */
|
||||
}
|
||||
} else {
|
||||
/* if the file is flagged, back it up to .save */
|
||||
if(!pmo_nosave && nb) {
|
||||
newpath = (char*)realloc(newpath, strlen(file)+6);
|
||||
strcpy(newpath, file);
|
||||
strcat(newpath, ".save");
|
||||
rename(file, newpath);
|
||||
fprintf(stderr, "%s renamed to %s\n", file, newpath);
|
||||
/* if the file is flagged, back it up to .pacsave */
|
||||
if(nb) {
|
||||
if(!pmo_upgrade && !pmo_nosave) {
|
||||
newpath = (char*)realloc(newpath, strlen(file)+strlen(".pacsave")+1);
|
||||
strcpy(newpath, file);
|
||||
strcat(newpath, ".pacsave");
|
||||
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 {
|
||||
vprint(" unlinking %s\n", file);
|
||||
if(unlink(file)) {
|
||||
|
@ -1025,31 +1061,32 @@ void usage(int op, char* myname)
|
|||
printf("usage: %s {-A --add} [options] <file>\n", myname);
|
||||
printf("options:\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(" -r, --root <path> set an alternative installation root\n");
|
||||
printf(" -r, --root <path> set an alternate installation root\n");
|
||||
} else if(op == PM_REMOVE) {
|
||||
printf("usage: %s {-R --remove} [options] <package>\n", myname);
|
||||
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(" -r, --root <path> set an alternative installation root\n");
|
||||
printf(" -r, --root <path> set an alternate installation root\n");
|
||||
} else if(op == PM_UPGRADE) {
|
||||
printf("usage: %s {-U --upgrade} [options] <file>\n", myname);
|
||||
printf("options:\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(" -r, --root <path> set an alternative installation root\n");
|
||||
printf(" -r, --root <path> set an alternate installation root\n");
|
||||
} else if(op == PM_QUERY) {
|
||||
printf("usage: %s {-Q --query} [options] [package]\n", myname);
|
||||
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(" -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(" 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
pacman.h
2
pacman.h
|
@ -21,7 +21,7 @@
|
|||
#ifndef PACMAN_H
|
||||
#define PACMAN_H
|
||||
|
||||
#define VERSION "1.2"
|
||||
#define VERSION "1.21"
|
||||
|
||||
#define PKGEXT ".tar.gz"
|
||||
#define PKGDB "/var/lib/pacman/pacman.db"
|
||||
|
|
20
pacsync
20
pacsync
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
version="1.2"
|
||||
version="1.21"
|
||||
tanpath="/var/lib/pacman"
|
||||
tandb="pacsync.db"
|
||||
errors=0
|
||||
|
@ -49,7 +49,7 @@ download() {
|
|||
|
||||
dosync() {
|
||||
cd /tmp
|
||||
download "package list" $tandb
|
||||
download "package list" pacsync/$tandb
|
||||
if [ $? -gt 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
@ -62,7 +62,7 @@ doinstall() {
|
|||
pkg2dl=
|
||||
pkg2inst=
|
||||
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
|
||||
message "package $pkgname not found"
|
||||
exit 1
|
||||
|
@ -75,7 +75,7 @@ doinstall() {
|
|||
filename=`echo $line | sed 's|^[a-z]*/||g'`
|
||||
pkg2inst="$pkg2inst $filename"
|
||||
if [ ! -f /var/cache/pacman/pkg/$filename ]; then
|
||||
pkg2dl="$pkg2dl arch/$filename"
|
||||
pkg2dl="$pkg2dl $filename"
|
||||
fi
|
||||
done
|
||||
|
||||
|
@ -88,7 +88,7 @@ doinstall() {
|
|||
if [ `pwd` != "/var/cache/pacman/pkg" ]; then
|
||||
# move downloaded files into cache
|
||||
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
|
||||
|
||||
|
@ -109,7 +109,7 @@ doupgrade() {
|
|||
pkg2dl=
|
||||
pkg2up=
|
||||
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
|
||||
message "package $pkgname not found"
|
||||
exit 1
|
||||
|
@ -129,7 +129,7 @@ doupgrade() {
|
|||
else
|
||||
pkg2up="$pkg2up $filename"
|
||||
if [ ! -f /var/cache/pacman/pkg/$filename ]; then
|
||||
pkg2dl="$pkg2dl arch/$filename"
|
||||
pkg2dl="$pkg2dl $filename"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
@ -143,7 +143,7 @@ doupgrade() {
|
|||
if [ `pwd` != "/var/cache/pacman/pkg" ]; then
|
||||
# move downloaded files into cache
|
||||
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
|
||||
|
||||
|
@ -166,7 +166,7 @@ doreport() {
|
|||
headers=0
|
||||
pkg2up=
|
||||
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`
|
||||
if [ $? -gt 0 ]; then
|
||||
# skip this one, it's not installed
|
||||
|
@ -174,7 +174,7 @@ doreport() {
|
|||
fi
|
||||
pkgver=`echo $pacman | awk '{print $2}'`
|
||||
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
|
||||
if [ "$locfile" = "$remfile" ]; then
|
||||
# this package is up to date
|
||||
|
|
10
pacsync.conf
10
pacsync.conf
|
@ -2,7 +2,11 @@
|
|||
# /etc/pacsync.conf
|
||||
#
|
||||
|
||||
#
|
||||
# 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"
|
||||
|
|
Loading…
Add table
Reference in a new issue