Imported from pacman-1.23.tar.gz

This commit is contained in:
Judd Vinet 2002-04-30 18:53:55 +00:00
parent 4c3842d42b
commit 20b7462293
10 changed files with 220 additions and 70 deletions

View file

@ -1,11 +1,12 @@
VERSION DESCRIPTION
------------------------------------------------------------------
1.23 - Added install/upgrade/remove scripting control
1.22 - Some manpage typo fixes
- Added --root switch to pacsync
- Added --help and ability to specify a PKGBUILD to makepkg
- Switched default downloader to snarf
- Added --help and ability to specify a PKGBUILD to makepkg
- Switched default downloader to snarf
1.21 - Added better backup control -- upgrade/add and remove
do different things with the -n switch
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

View file

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

View file

@ -1,6 +1,6 @@
#!/bin/bash
myver='1.22'
myver='1.23'
startdir=`pwd`
[ -f /etc/makepkg.conf ] && . /etc/makepkg.conf
@ -114,12 +114,6 @@ echo "pkgver = $pkgver-$pkgrel" >>.PKGINFO
for bakfile in "${backup[@]}"; do
echo "backup = $bakfile" >>.PKGINFO
done
if [ "$install" != "" ]; then
cat $startdir/$install | egrep '^[^$]' | sed 's/^/install = /g' >>.PKGINFO
fi
if [ "$remove" != "" ]; then
cat $startdir/$remove | egrep '^[^$]' | sed 's/^/remove = /g' >>.PKGINFO
fi
# remove info/doc files
cd $startdir

View file

@ -73,7 +73,84 @@ 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 everything
into a .pkg.tar.gz file in the directory you ran \fBmakepkg\fP from.
At this point you should have a package file in the current directory, named
something like name-version-release.pkg.tar.gz. Done!
.SH Install/Upgrade/Remove Scripting
Pacman has the ability to store and execute a package-specific script when it
installs, removes, or upgrades a package. This allows a package to "configure
itself" after installation and do the opposite right before it is removed.
The exact time the script is run varies with each operation:
.TP
.B post_install
script is run right after files are installed.
.TP
.B post_upgrade
script is run after all files have been upgraded.
.TP
.B pre_remove
script is run right before files are removed.
.RE
In order to use this feature, your build function should put the script in
$startdir/pkg/var/lib/pacman/scripts and it must be named exactly the same
as the \fI$pkgname\fP variable in the PKGBUILD script. For example, an
install script for grep will be $startdir/pkg/var/lib/pacman/scripts/grep.
Note that the scripts should be 644, not 755 (we don't need execute permission).
.TP
.TP
.SH Install scripts must follow this format:
.RS
.nf
# arg 1: the new package version
post_install() {
#
# do post-install stuff here
#
}
# arg 1: the new package version
# arg 2: the old package version
post_upgrade() {
#
# do post-upgrade stuff here
#
}
# arg 1: the old package version
pre_remove() {
#
# do pre-remove stuff here
#
}
op=$1
shift
$op $*
.fi
.RE
This template is also available in your ABS tree (/usr/abs/install.proto).
.SH PKGBUILD Directives
.TP
.B pkgname
The name of the package. This has be a unix-friendly name as it will be
used in the package filename.
.TP
.B pkgver
This is the version of the software as released from the author (eg, 2.7.1).
.TP
.B pkgrel
This is the release number specific to Arch Linux packages.
.TP
.B backup
A space-delimited array of filenames (without a preceding slash). The
@ -89,14 +166,6 @@ file, unless they have a fully-qualified URL. Then if the source file
does not already exist in /var/cache/pacman/src, the file is downloaded
by wget.
.TP
.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, 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.
.SH CONFIGURATION
Configuration options are stored in /etc/makepkg.conf. This file is parsed
as a bash script, so you can export any special compiler flags you wish

View file

@ -1,7 +1,7 @@
#!/bin/bash
toplevel=`pwd`
version="1.22"
version="1.23"
if [ $# -lt 2 ]; then
echo "makepkg version $version"

View file

@ -17,12 +17,12 @@ into the installation root and the database will be updated.
.B "\-R, \-\-remove"
Remove a package from the system. Files belonging to the
specified package will be deleted, and the database will
be updated. Note that files with \fI.conf\fP extensions will
be renamed with \fI.conf.save\fP extensions.
be updated. Note that most configuration files will be
be renamed with \fI.pacsave\fP extensions.
.TP
.B "\-U, \-\-upgrade"
Upgrade a package. This is essentially a "remove-then-install"
process. Files with \fI.conf\fP extensions will be saved.
process. Most configuration files will be not be overwritten.
.TP
.B "\-Q, \-\-query"
Query the package database. This operation allows you to

View file

@ -79,10 +79,11 @@ static tartype_t gztype = {
* GLOBALS
*
*/
FILE* dbfp = NULL;
char* dbpath = PKGDB;
char* pkgname = NULL;
char* pkgver = NULL;
FILE* dbfp = NULL;
char* dbpath = NULL;
char* pkgname = NULL;
char* pkgver = NULL;
char oldpkgver[65];
char* pmo_root = NULL;
unsigned short pmo_verbose = 0;
@ -90,6 +91,7 @@ unsigned short pmo_force = 0;
unsigned short pmo_upgrade = 0;
unsigned short pmo_nosave = 0;
unsigned short pmo_nofunc = 0;
unsigned short pmo_haveinst = 0;
unsigned short pmo_q_isfile = 0;
unsigned short pmo_q_info = 0;
unsigned short pmo_q_list = 0;
@ -103,9 +105,6 @@ unsigned int pm_pkgcount = 0;
fileset_t pm_targets = NULL;
unsigned int pm_targct = 0;
/* path to post-install script, if any */
char* pm_install = NULL;
int main(int argc, char* argv[])
{
pm_opfunc_t op_func;
@ -115,6 +114,10 @@ int main(int argc, char* argv[])
pmo_root = (char*)malloc(2);
strcpy(pmo_root, "/");
/* db location */
dbpath = (char*)malloc(strlen(PKGDIR)+strlen(PKGDB)+1);
sprintf(dbpath, "%s/%s", PKGDIR, PKGDB);
if(argc < 2) {
usage(PM_MAIN, (char*)basename(argv[0]));
return(0);
@ -158,15 +161,14 @@ int main(int argc, char* argv[])
}
/* check for db existence */
if(pmo_root != NULL) {
if(pmo_root != NULL && strcmp(pmo_root, "/")) {
/* trim the trailing '/' if there is one */
if((int)rindex(pmo_root, '/') == ((int)pmo_root)+strlen(pmo_root)-1) {
pmo_root[strlen(pmo_root)-1] = '\0';
}
free(dbpath);
dbpath = (char*)malloc(strlen(pmo_root) + strlen(PKGDB) + 1);
strcpy(dbpath, pmo_root);
dbpath = (char*)strcat(dbpath, PKGDB);
dbpath = (char*)malloc(strlen(pmo_root)+strlen(PKGDIR)+strlen(PKGDB)+1);
sprintf(dbpath, "%s%s/%s", pmo_root, PKGDIR, PKGDB);
}
vprint("Using package DB: %s\n", dbpath);
@ -185,6 +187,7 @@ int main(int argc, char* argv[])
/* start the requested operation */
if(!pmo_nofunc) {
for(i = 0; i < pm_targct; i++) {
pmo_haveinst = 0;
if(op_func(pm_targets[i])) {
ret = 1;
/*
@ -205,7 +208,7 @@ int main(int argc, char* argv[])
if(op_func == pacman_remove) {
/* the remove function no longer updates the db itself. we do it here
* instead, in an effort to save some expensive file rewrites. note that we
* instead in an effort to save some expensive file rewrites. note that we
* can't do this for pacman_add() yet, as he's gotta call db_find_conflicts
* for each package.
*/
@ -219,9 +222,11 @@ int main(int argc, char* argv[])
int pacman_add(char* pkgfile)
{
int i, ret = 0, errors = 0;
TAR* tar;
TAR* tar = NULL;
char* errmsg = NULL;
char* expath = NULL;
char pm_install[PATH_MAX+1];
char cmdline[PATH_MAX+1];
/*char* newpath = NULL;*/
fileset_t files = NULL;
unsigned int filecount = 0, nb = 0;
@ -331,15 +336,19 @@ int pacman_add(char* pkgfile)
vprint("Done.\n");
}
/* run the script in pm_install */
if(pm_install != NULL) {
/* run the post-install script if it exists */
snprintf(pm_install, PATH_MAX, "%s%s/scripts/%s", pmo_root, PKGDIR, pkgname);
if(!stat(pm_install, &buf)) {
strcpy(oldpkgver, "");
for(i = 0; i < pm_pkgcount; i++) {
if(!strcmp(pm_packages[i]->name, pkgname)) {
strcpy(oldpkgver, pm_packages[i]->version);
}
}
vprint("Executing post-install script...\n");
expath = (char*)malloc(256);
snprintf(expath, 255, "/bin/bash %s", pm_install);
system(expath);
free(expath);
unlink(pm_install);
free(pm_install);
snprintf(cmdline, PATH_MAX, "cd %s && /bin/sh %s post_%s %s %s", pmo_root, pm_install,
(pmo_upgrade ? "upgrade" : "install"), pkgver, (pmo_upgrade ? oldpkgver : ""));
system(cmdline);
}
return(0);
@ -350,6 +359,7 @@ int pacman_remove(char* pkgfile)
int found = 0, done = 0;
int i;
char line[PATH_MAX+1];
char pm_install[PATH_MAX+1];
fileset_t files = NULL;
unsigned int filecount = 0, nb = 0;
struct stat buf;
@ -367,7 +377,7 @@ int pacman_remove(char* pkgfile)
strcpy(line, trim(line));
if(!strcmp(line, pkgfile)) {
/* read the version */
fgets(line, 63, dbfp);
fgets(oldpkgver, 63, dbfp);
found = 1;
}
}
@ -381,6 +391,18 @@ int pacman_remove(char* pkgfile)
}
}
if(!pmo_upgrade) {
/* run the pre-remove script if it exists */
snprintf(pm_install, PATH_MAX, "%s%s/scripts/%s", pmo_root, PKGDIR, pkgfile);
if(!stat(pm_install, &buf)) {
vprint("Executing pre-remove script...\n");
snprintf(line, PATH_MAX, "cd %s && /bin/sh %s pre_remove %s", pmo_root,
pm_install, oldpkgver);
system(line);
}
}
while(!done) {
fgets(line, PATH_MAX, dbfp);
strcpy(line, trim(line));
@ -921,19 +943,6 @@ int parse_descfile(char* descfile, unsigned short output, fileset_t *bakptr,
strcpy(pkgver, ptr);
} else if(!strcmp(key, "PKGDESC")) {
/* Not used yet */
} else if(!strcmp(key, "INSTALL")) {
if(inst == NULL) {
pm_install = (char*)malloc(strlen("/tmp/pacman_XXXXXX")+1);
strcpy(pm_install, "/tmp/pacman_XXXXXX");
mkstemp(pm_install);
inst = fopen(pm_install, "w");
if(inst == NULL) {
perror("fopen");
return(1);
}
}
fputs(ptr, inst);
fputc('\n', inst);
} else if(!strcmp(key, "BACKUP")) {
backup = (fileset_t)realloc(backup, (++count) * sizeof(char*));
backup[count-1] = (char*)malloc(strlen(ptr)+1);
@ -1016,6 +1025,8 @@ int parseargs(int op, int argc, char** argv)
pmo_nofunc = 1;
return(1);
}
/* trim off the leading slash */
pmo_q_owns++;
} else if(!strcmp(argv[i], "-l") || !strcmp(argv[i], "--list")) {
/* PM_QUERY only */
pmo_q_list = 1;

View file

@ -21,10 +21,11 @@
#ifndef PACMAN_H
#define PACMAN_H
#define VERSION "1.22"
#define VERSION "1.23"
#define PKGEXT ".tar.gz"
#define PKGDB "/var/lib/pacman/pacman.db"
#define PKGDIR "/var/lib/pacman"
#define PKGDB "pacman.db"
/* Operations */
#define PM_MAIN 0

38
pacsync
View file

@ -1,11 +1,12 @@
#!/bin/bash
version="1.22"
version="1.23"
tanpath="/var/lib/pacman"
tandb="pacsync.db"
errors=0
upgrade=0
INSTALL_ROOT="/"
IGNORE_PKG=
message() {
echo "==> $1" >&2
@ -13,7 +14,7 @@ message() {
usage() {
echo "pacsync version $version"
echo "usage: $0 [--root <root>] <operation> [package]"
echo "usage: $0 [--root <root>] [--ignore <pkg>] <operation> [package]"
echo ""
echo "operations:"
echo " sync Download a fresh package list from the server"
@ -23,6 +24,11 @@ usage() {
echo " sysupgrade Same as \"report\", but actually do the upgrades"
echo " clean Removes all files from package cache to clear up diskspace"
echo ""
echo "options:"
echo " --root <root> Set installation root to <root>"
echo " --ignore <pkg> Ignore packages that have <pkg> in their names when doing"
echo " sysupgrades. (--ignore can be used multiple times)"
echo ""
}
checkdb() {
@ -37,6 +43,10 @@ download() {
shift
cl=
for file in $*; do
# snarf returns a nonzero error code when the file already exists, which
# confuses pacsync, so for now, no resume action...
rm -f $file
cl="$cl $SYNC_SERVER/$file"
done
message "Downloading $targ"
@ -49,13 +59,12 @@ download() {
}
dosync() {
cd /tmp
download "package list" pacsync/$tandb
if [ $? -gt 0 ]; then
exit 1
fi
rm -f $INSTALL_ROOT/$tanpath/$tandb
mv /tmp/$tandb $INSTALL_ROOT/$tanpath/$tandb
mv $tandb $INSTALL_ROOT/$tanpath/$tandb
message "Done."
}
@ -167,7 +176,7 @@ doreport() {
headers=0
newkernel=0
pkg2up=
for pkgfile in `cat $INTALL_ROOT/$tanpath/$tandb | sed "s|^[a-z]*/||g"`; do
for pkgfile in `cat $INSTALL_ROOT/$tanpath/$tandb | sed "s|^[a-z]*/||g"`; do
pkgname=`echo $pkgfile | sed 's|-[a-zA-Z0-9\.]*-[0-9]*\.pkg\.tar\.gz||g'`
pacman=`pacman -Q -r $INSTALL_ROOT $pkgname 2>/dev/null`
if [ $? -gt 0 ]; then
@ -183,9 +192,16 @@ doreport() {
continue
else
if [ `echo "$locfile" | egrep '^kernel-[a-zA-Z0-9\.]+-[0-9]+$'` ]; then
# this is the kernel pacakge -- we handle this one specially
newkernel=1
continue
fi
if [ "$IGNORE_PKG" != "" ]; then
if [ `echo "$locfile" | egrep "$IGNORE_PKG"` ]; then
# ignore this package as per user's request
continue
fi
fi
if [ "$headers" = "0" ]; then
echo "+--------------------------------------+--------------------------------------+"
echo "| LOCAL | REMOTE |"
@ -227,6 +243,8 @@ doreport() {
exit 0
}
cd /tmp
if [ $# -lt 1 ]; then
usage
exit 0
@ -238,6 +256,16 @@ if [ "$1" = "--root" ]; then
shift
fi
while [ "$1" = "--ignore" ]; do
shift
if [ "$IGNORE_PKG" = "" ]; then
IGNORE_PKG="$1"
else
IGNORE_PKG="$IGNORE_PKG|$1"
fi
shift
done
if [ -f /etc/pacsync.conf ]; then
. /etc/pacsync.conf
else

View file

@ -1,12 +1,58 @@
#
# /etc/pacsync.conf
#
#
# From here you can configure pacsync to follow a certain package tree.
# Typically this is either 'stable' or 'current', but you can pick
# specific versions as well (eg, '0.2'). Read below for the structure.
#
# Arch Linux servers follow this directory structure:
#
# 0.1
# |- iso
# | |- i686
# |- os
# | |- i686
# 0.2
# |- iso
# | |- i686
# |- os
# | |- i686
# 0.3
# |- iso
# | |- i686
# |- os
# | |- i686
# current -> 0.3/os/i686
# stable -> 0.2/os/i686
#
#
# Set your SYNC_SERVER according to the version you wish to follow. For
# example, if you simply wish to follow the stable branch (whatever version
# it may be), then you can set SYNC_SERVER as follows:
#
# SYNC_SERVER="ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/stable"
#
# Other examples:
# SYNC_SERVER="ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/0.2/os/i686"
# SYNC_SERVER="ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/0.3/os/i686"
# SYNC_SERVER="ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/current"
#
#
# the full URL of the server (up to the /arch package directory)
# SYNC_SERVER: the full location of the package repository (ftp or http)
#
# (note: ibiblio.org will be fastest; please use it)
SYNC_SERVER="ftp://ftp.ibiblio.org/pub/linux/distributions/archlinux/current"
#
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"
# OTHER LOCATIONS (MIRRORS)
#
# Note: ibiblio.org will typically be fastest. Please stick with them unless
# you've got a good reason to change.
#
#SYNC_SERVER="http://www.ibiblio.org/pub/linux/distributions/archlinux/current"
#SYNC_SERVER="ftp://ftp2.archlinux.org/current"
#SYNC_SERVER="ftp://ftp.archlinux.org/current"