Imported from pacman-2.8.4.tar.gz

This commit is contained in:
Judd Vinet 2004-08-23 06:52:47 +00:00
parent ad87360a71
commit afc0d9a3c4
16 changed files with 309 additions and 58 deletions

View file

@ -1,5 +1,13 @@
VERSION DESCRIPTION
-----------------------------------------------------------------------------
2.8.4 - Added updatesync script from Jason Chu
- Changed the pacman binary to be dynamically linked
- Included a pacman.static binary as well
- Added fakeroot checks when seeing if we're root
- Fixed makepkg to use 'tail -n 1' instead of 'tail -1'
- Added patch from Kevin Piche:
- Cleanup db_loadpkgs(), add list_add_sorted()
- Fixed a memory leak in db_find_conflicts()
2.8.3 - Fixed a little makepkg bug with bash 3.0
- Fixed resolvedeps to always prefer literals over provisios
- Added --config option to specify an alternate config file

View file

@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
PACVER = 2.8.3
PACVER = 2.8.4
TOPDIR = @srcdir@
SRCDIR = $(TOPDIR)/src/
@ -45,7 +45,7 @@ SCRDIR = $(TOPDIR)/scripts/
CXX = @CC@
CXXFLAGS += @CFLAGS@ -g -Wall -pedantic -fno-exceptions \
-D_GNU_SOURCE -DPACVER=\"$(PACVER)\" -I. -Ilibftp
LDFLAGS += @LDFLAGS@ -static -Llibftp -lftp -ltar -lz
LDFLAGS += @LDFLAGS@ -Llibftp -lftp -ltar -lz
SRCS = $(SRCDIR)pacman.c \
$(SRCDIR)db.c \
@ -72,6 +72,7 @@ all: libftp.a pacman vercmp convertdb man
pacman: $(OBJECTS) libftp.a
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
$(CXX) $(OBJECTS) -o $@.static -static $(LDFLAGS)
vercmp: $(OBJDIR)vercmp.o $(OBJDIR)rpmvercmp.o
$(CXX) $(OBJDIR)vercmp.o $(OBJDIR)rpmvercmp.o $(CXXFLAGS) -o $@
@ -96,11 +97,13 @@ libftp.a:
install: pacman vercmp convertdb man
$(INSTALL) -D -m0755 pacman $(DESTDIR)$(BINDIR)/pacman
$(INSTALL) -D -m0755 pacman.static $(DESTDIR)$(BINDIR)/pacman.static
$(INSTALL) -D -m0755 vercmp $(DESTDIR)$(BINDIR)/vercmp
$(INSTALL) -D -m0755 convertdb $(DESTDIR)$(BINDIR)/convertdb
$(INSTALL) -D -m0755 $(SCRDIR)makepkg $(DESTDIR)$(BINDIR)/makepkg
$(INSTALL) -D -m0755 $(SCRDIR)makeworld $(DESTDIR)$(BINDIR)/makeworld
$(INSTALL) -D -m0755 $(SCRDIR)gensync $(DESTDIR)$(BINDIR)/gensync
$(INSTALL) -D -m0755 $(SCRDIR)updatesync $(DESTDIR)$(BINDIR)/updatesync
$(INSTALL) -D -m0644 $(MANSRC)pacman.8 $(DESTDIR)$(MANDIR)/man8/pacman.8
$(INSTALL) -D -m0644 $(MANSRC)makepkg.8 $(DESTDIR)$(MANDIR)/man8/makepkg.8
$(INSTALL) -D -m0644 etc/pacman.conf $(DESTDIR)/etc/pacman.conf
@ -115,7 +118,7 @@ clean:
(cd libftp; make clobber)
distclean: clean
rm -f pacman convertdb vercmp
rm -f pacman pacman.static convertdb vercmp
rm -f Makefile
rm -f config.h config.status config.log

8
TODO
View file

@ -1,8 +0,0 @@
- think about consolidating the -A/-U/-S options into one smart
install operation
- replaces code doesn't run with -U or -A
- when performing replaces, pacman should not remove old packages until
the conflict checks are passed
- handle version comparators in makepkg dep resolution (eg, glibc>=2.2.5)
- check $PACCONF env var
- add a --pretend option

View file

@ -30,12 +30,15 @@ HoldPkg = pacman glibc
# REPOSITORIES
# - can be defined here or included from another file
# - pacman will search repositories in the order defined here.
# - local/custom mirrors can be added here, above the respective Include
# for that repository
# - local/custom mirrors can be added here or in separate files
#
[current]
# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/current
[extra]
# Add your preferred servers here, they will be used first
Include = /etc/pacman.d/extra
#Include = /etc/pacman.d/unstable

View file

@ -20,7 +20,7 @@
# USA.
#
myver='2.8.3'
myver='2.8.4'
usage() {
echo "gensync $myver"
@ -30,8 +30,8 @@ usage() {
echo "from <root>. gensync builds the database in a temporary directory"
echo "and then compresses it to <destfile>."
echo
echo "gensync will calculate md5sums of packages in <destdir>, unless an"
echo "alternate [package_directory] is specified."
echo "gensync will calculate md5sums of packages in the same directory as"
echo "<destfile>, unless an alternate [package_directory] is specified."
echo
echo "note: The <destfile> name is important. It must be of the form"
echo " {treename}.db.tar.gz where {treename} is the name of the custom"
@ -67,7 +67,7 @@ db_write_entry()
unset groups replaces provides depends conflicts
source $1 || return 1
cd $gstmpdir
mkdir $pkgname-$pkgver-$pkgrel
mkdir $pkgname-$pkgver-$pkgrel || return 1
cd $pkgname-$pkgver-$pkgrel
# desc
: >desc

View file

@ -20,7 +20,7 @@
# USA.
#
myver='2.8.3'
myver='2.8.4'
startdir=`pwd`
PKGDEST=$startdir
USE_COLOR="n"
@ -611,7 +611,7 @@ if [ "$PACKAGER" != "" ]; then
else
packager="Arch Linux (http://www.archlinux.org)"
fi
size=`du -cb $startdir/pkg | tail -1 | awk '{print $1}'`
size=`du -cb $startdir/pkg | tail -n 1 | awk '{print $1}'`
# write the .PKGINFO file
msg "Generating .PKGINFO file..."

View file

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

221
scripts/updatesync Executable file
View file

@ -0,0 +1,221 @@
#!/bin/bash
#
# updatesync
#
# Copyright (c) 2004 by Jason Chu <jason@archlinux.org>
# Derived from gensync (c) 2002-2004 Judd Vinet <jvinet@zeroflux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
myver='2.8.4'
usage() {
echo "updatesync $myver"
echo "usage: $0 <action> <destfile> <option> [package_directory]"
echo
echo "updatesync will update a sync database by reading a PKGBUILD and"
echo "modifying the destfile. updatesync updates the database in a temporary"
echo "directory and then compresses it to <destfile>."
echo
echo "There are two types of actions:"
echo
echo "upd - Will update a package's entry or create it if it doesn't exist."
echo " It takes the package's PKGBUILD as an option."
echo "del - Will remove a package's entry from the db."
echo " It takes the package's name as an option."
echo
echo "updatesync will calculate md5sums of packages in the same directory as"
echo "<destfile>, unless an alternate [package_directory] is specified."
echo
echo "example: updatesync upd /home/mypkgs/custom.db.tar.gz PKGBUILD"
echo
echo
exit 0
}
die()
{
echo "updatesync: $*" >&2
rm -rf $ustmpdir
exit 1
}
get_md5checksum()
{
source $1 || return 1
if [ "$pkgdir" != "" ]; then
pkgfile="$pkgdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz"
else
pkgfile="$destdir/$pkgname-$pkgver-$pkgrel.pkg.tar.gz"
fi
if [ -f $pkgfile ]; then
md5line=`md5sum $pkgfile`
[ ! -z "$md5line" ] && pkgmd5sum=${md5line% *}
echo $pkgmd5sum
fi
return 0
}
db_write_entry()
{
unset pkgname pkgver pkgrel pkgdesc force
unset groups replaces provides depends conflicts
source $1 || return 1
cd $ustmpdir
mkdir $pkgname-$pkgver-$pkgrel || return 1
cd $pkgname-$pkgver-$pkgrel
# desc
: >desc
echo "%NAME%" >>desc
echo "$pkgname" >>desc
echo "" >>desc
echo "%VERSION%" >>desc
echo "$pkgver-$pkgrel" >>desc
echo "" >>desc
echo "%DESC%" >>desc
echo "$pkgdesc" >>desc
echo "" >>desc
if [ ! -z $pkgmd5sum ]; then
echo "%MD5SUM%" >>desc
echo "$pkgmd5sum" >>desc
echo "" >>desc
fi
if [ ${#groups[*]} -gt 0 ]; then
echo "%GROUPS%" >>desc
for it in "${groups[@]}"; do
echo "$it" >>desc
done
echo "" >>desc
fi
if [ ${#replaces[*]} -gt 0 ]; then
echo "%REPLACES%" >>desc
for it in "${replaces[@]}"; do
echo "$it" >>desc
done
echo "" >>desc
fi
if [ "$force" = "y" -o "$force" = "Y" ]; then
echo "%FORCE%" >>desc
echo "" >>desc
fi
# depends
: >depends
if [ ${#depends[*]} -gt 0 ]; then
echo "%DEPENDS%" >>depends
for it in "${depends[@]}"; do
echo "$it" >>depends
done
echo "" >>depends
fi
if [ ${#conflicts[*]} -gt 0 ]; then
echo "%CONFLICTS%" >>depends
for it in "${conflicts[@]}"; do
echo "$it" >>depends
done
echo "" >>depends
fi
if [ ${#provides[*]} -gt 0 ]; then
echo "%PROVIDES%" >>depends
for it in "${provides[@]}"; do
echo "$it" >>depends
done
echo "" >>depends
fi
}
delete_entry()
{
echo $1 | grep PKGBUILD 2>&1 >/dev/null
if [ $? -eq 0 ]; then
source $1
else
pkgname=$1
fi
for i in *; do
if [ "${i%-*-*}" = "$pkgname" ]; then
echo "updatesync: deleting $i" >&2
rm -rf $i
fi
done
}
if [ $# -lt 3 ]; then
usage
exit 0
fi
if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
exit 0
fi
action=$1
pkgdb=$2
option=$3
curdir="`pwd`"
pkgdir=$curdir
if [ "$4" != "" ]; then
pkgdir=$4
fi
if [ "$action" != "upd" -a "$action" != "del" ]; then
usage
exit 1
fi
ustmpdir=$(mktemp -dt updatesync.XXXXXXXXXX) || exit 1
cd $ustmpdir
if [ ! -f $pkgdb ]; then
if [ ! -f $curdir/$pkgdb ]; then
echo "updatesync: $pkgdb not found"
exit 1
fi
pkgdb=$curdir/$pkgdb
fi
if [ "$action" = "upd" -a ! -f $option ]; then
if [ ! -f $curdir/$option ]; then
echo "updatesync: $option not found"
exit 1
fi
option=$curdir/$option
fi
echo "updatesync: uncompressing to $ustmpdir..." >&2
tar -xzf $pkgdb || die "error uncompressing $pkgdb"
if [ "$action" = "upd" ]; then
# INSERT / UPDATE
delete_entry $option
pkgmd5sum=`get_md5checksum $option`
[ -z $pkgmd5sum ] && die "error generating checksum for $option"
echo "updatesync: creating entry for $option" >&2
db_write_entry $option || die "error writing entry for $option"
else
# DELETE
delete_entry $option
fi
echo "updatesync: compressing to $pkgdb..." >&2
cd $ustmpdir
tar c * | gzip -9 >$pkgdb || die "error writing to $pkgdb"
cd $curdir
rm -rf $ustmpdir
exit 0

View file

@ -61,43 +61,20 @@ void db_close(pacdb_t* db)
return;
}
/* frees pkgcache if necessary and returns a new package
* cache from db
*/
PMList* db_loadpkgs(pacdb_t *db)
{
pkginfo_t *info;
pkginfo_t **arr = NULL;
unsigned int arrct = 0;
int i;
PMList *cache = NULL;
rewinddir(db->dir);
while((info = db_scan(db, NULL, INFRQ_DESC | INFRQ_DEPENDS)) != NULL) {
/* add to the collective */
/* we load all package names into a linear array first, so qsort can handle it */
if(arr == NULL) {
arr = (pkginfo_t**)malloc(sizeof(pkginfo_t*));
arrct++;
} else {
arr = (pkginfo_t**)realloc(arr, (++arrct)*sizeof(pkginfo_t*));
cache = list_add_sorted(cache, info, pkgcmp);
}
if(arr == NULL) {
fprintf(stderr, "error: out of memory\n");
exit(1);
}
arr[arrct-1] = info;
}
/* sort the package list */
qsort(arr, (size_t)arrct, sizeof(pkginfo_t*), pkgcmp);
/* now load them into the proper PMList */
for(i = 0; i < arrct; i++) {
cache = list_add(cache, arr[i]);
}
FREE(arr);
return(cache);
}
@ -645,7 +622,7 @@ PMList* db_find_conflicts(pacdb_t *db, PMList *targets, char *root)
if(dbpkg2 && !is_in(filestr, p1->files) && is_in(filestr, dbpkg2->files)) {
ok = 1;
}
FREE(dbpkg2);
FREEPKG(dbpkg2);
}
}
}

View file

@ -223,4 +223,37 @@ void list_display(const char *title, PMList *list)
}
}
/* Add items to a list in sorted order. Use the given
* comparision func to determine order.
*/
PMList* list_add_sorted(PMList *list, void *data, cmp_fn sortfunc)
{
PMList *add;
PMList *prev = NULL;
PMList *iter = list;
add = list_new();
add->data = data;
/* Find insertion point. */
while(iter) {
if(sortfunc(add->data, iter->data) <= 0) break;
prev = iter;
iter = iter->next;
}
/* Insert node before insertion point. */
add->prev = prev;
add->next = iter;
if(iter != NULL) iter->prev = add; /* Not at end. */
if(prev != NULL) {
prev->next = add; /* In middle. */
} else {
list = add; /* Start or empty, new list head. */
}
return(list);
}
/* vim: set ts=2 sw=2 noet: */

View file

@ -30,6 +30,11 @@ typedef struct __pmlist_t {
struct __pmlist_t* next;
} PMList;
/* Sort comparison callback function declaration. */
typedef int (*cmp_fn) (const void *, const void *);
PMList* list_new();
void list_free(PMList* list);
PMList* list_add(PMList* list, void* data);
@ -42,6 +47,8 @@ int list_strcmp(const void *s1, const void *s2);
PMList *list_sort(PMList *list);
void list_display(const char *title, PMList *list);
PMList* list_add_sorted(PMList *list, void *data, cmp_fn sortfunc);
#endif
/* vim: set ts=2 sw=2 noet: */

View file

@ -284,10 +284,10 @@ void freepkg(pkginfo_t *pkg)
*/
int pkgcmp(const void *p1, const void *p2)
{
pkginfo_t **pkg1 = (pkginfo_t**)p1;
pkginfo_t **pkg2 = (pkginfo_t**)p2;
pkginfo_t *pkg1 = (pkginfo_t*)p1;
pkginfo_t *pkg2 = (pkginfo_t*)p2;
return(strcmp(pkg1[0]->name, pkg2[0]->name));
return(strcmp(pkg1->name, pkg2->name));
}
/* Test for existence of a package in a PMList*

View file

@ -115,6 +115,7 @@ int main(int argc, char *argv[])
char *ptr = NULL;
pacdb_t *db_local = NULL;
char *cenv = NULL;
uid_t myuid;
cenv = getenv("COLUMNS");
if(cenv) {
@ -144,6 +145,13 @@ int main(int argc, char *argv[])
return(ret);
}
/* see if we're root or not */
myuid = geteuid();
if(!myuid && getenv("FAKEROOTKEY")) {
/* fakeroot doesn't count, we're non-root */
myuid = 99;
}
/* check for permission */
pm_access = READ_ONLY;
if(pmo_op != PM_MAIN && pmo_op != PM_QUERY && pmo_op != PM_DEPTEST) {
@ -151,7 +159,7 @@ int main(int argc, char *argv[])
(pmo_s_search || pmo_s_printuris || pmo_group || pmo_q_list || pmo_q_info)) {
/* special case: PM_SYNC can be used w/ pmo_s_search by any user */
} else {
if(geteuid() != 0) {
if(myuid) {
fprintf(stderr, "error: you cannot perform this operation unless you are root.\n");
return(1);
}
@ -178,7 +186,7 @@ int main(int argc, char *argv[])
if(pmo_usesyslog) {
openlog("pacman", 0, LOG_USER);
}
if(pmo_logfile && geteuid() == 0) {
if(pmo_logfile && myuid == 0) {
/* open the log file */
logfd = fopen(pmo_logfile, "a");
if(logfd == NULL) {
@ -1664,7 +1672,6 @@ int pacman_add(pacdb_t *db, PMList *targets)
/* see if this is an upgrade. if so, remove the old package first */
if(pmo_upgrade) {
if(is_pkgin(info, pm_packages)) {
PMList* tmp = list_new();
int retcode;
printf("upgrading %s... ", info->name);
@ -1701,10 +1708,10 @@ int pacman_add(pacdb_t *db, PMList *targets)
}
if(oldpkg) {
list_add(tmp, strdup(info->name));
PMList* tmp = list_add(NULL, strdup(info->name));
vprint("removing old package first...\n");
retcode = pacman_remove(db, tmp);
list_free(tmp);
FREELIST(tmp);
if(retcode == 1) {
fprintf(stderr, "\nupgrade aborted.\n");
return(1);

View file

@ -22,7 +22,7 @@
#define _PAC_PACMAN_H
#ifndef PACVER
#define PACVER "2.8.3"
#define PACVER "2.8.4"
#endif
#ifndef PKGDIR

View file

@ -33,7 +33,7 @@
#include "util.h"
/* borrowed and modified from Per Liden's pkgutils (http://crux.nu) */
int gzopen_frontend(char *pathname, int oflags, int mode)
long gzopen_frontend(char *pathname, int oflags, int mode)
{
char* gzoflags;
int fd;
@ -63,7 +63,7 @@ int gzopen_frontend(char *pathname, int oflags, int mode)
return -1;
}
return (int)gzf;
return (long)gzf;
}
int unpack(char *archive, const char *prefix, const char *fn)

View file

@ -28,7 +28,7 @@
#define FREE(p) { if (p) { free(p); (p)= NULL; }}
int gzopen_frontend(char *pathname, int oflags, int mode);
long gzopen_frontend(char *pathname, int oflags, int mode);
int unpack(char *archive, const char *prefix, const char *fn);
int copyfile(char *src, char *dest);
int makepath(char *path);