Imported from pacman-2.8.4.tar.gz
This commit is contained in:
parent
ad87360a71
commit
afc0d9a3c4
16 changed files with 309 additions and 58 deletions
|
@ -1,5 +1,13 @@
|
||||||
VERSION DESCRIPTION
|
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
|
2.8.3 - Fixed a little makepkg bug with bash 3.0
|
||||||
- Fixed resolvedeps to always prefer literals over provisios
|
- Fixed resolvedeps to always prefer literals over provisios
|
||||||
- Added --config option to specify an alternate config file
|
- Added --config option to specify an alternate config file
|
||||||
|
|
|
@ -34,7 +34,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||||
INSTALL_DATA = @INSTALL_DATA@
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||||
|
|
||||||
PACVER = 2.8.3
|
PACVER = 2.8.4
|
||||||
|
|
||||||
TOPDIR = @srcdir@
|
TOPDIR = @srcdir@
|
||||||
SRCDIR = $(TOPDIR)/src/
|
SRCDIR = $(TOPDIR)/src/
|
||||||
|
@ -45,7 +45,7 @@ SCRDIR = $(TOPDIR)/scripts/
|
||||||
CXX = @CC@
|
CXX = @CC@
|
||||||
CXXFLAGS += @CFLAGS@ -g -Wall -pedantic -fno-exceptions \
|
CXXFLAGS += @CFLAGS@ -g -Wall -pedantic -fno-exceptions \
|
||||||
-D_GNU_SOURCE -DPACVER=\"$(PACVER)\" -I. -Ilibftp
|
-D_GNU_SOURCE -DPACVER=\"$(PACVER)\" -I. -Ilibftp
|
||||||
LDFLAGS += @LDFLAGS@ -static -Llibftp -lftp -ltar -lz
|
LDFLAGS += @LDFLAGS@ -Llibftp -lftp -ltar -lz
|
||||||
|
|
||||||
SRCS = $(SRCDIR)pacman.c \
|
SRCS = $(SRCDIR)pacman.c \
|
||||||
$(SRCDIR)db.c \
|
$(SRCDIR)db.c \
|
||||||
|
@ -72,6 +72,7 @@ all: libftp.a pacman vercmp convertdb man
|
||||||
|
|
||||||
pacman: $(OBJECTS) libftp.a
|
pacman: $(OBJECTS) libftp.a
|
||||||
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
|
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
|
||||||
|
$(CXX) $(OBJECTS) -o $@.static -static $(LDFLAGS)
|
||||||
|
|
||||||
vercmp: $(OBJDIR)vercmp.o $(OBJDIR)rpmvercmp.o
|
vercmp: $(OBJDIR)vercmp.o $(OBJDIR)rpmvercmp.o
|
||||||
$(CXX) $(OBJDIR)vercmp.o $(OBJDIR)rpmvercmp.o $(CXXFLAGS) -o $@
|
$(CXX) $(OBJDIR)vercmp.o $(OBJDIR)rpmvercmp.o $(CXXFLAGS) -o $@
|
||||||
|
@ -96,11 +97,13 @@ libftp.a:
|
||||||
|
|
||||||
install: pacman vercmp convertdb man
|
install: pacman vercmp convertdb man
|
||||||
$(INSTALL) -D -m0755 pacman $(DESTDIR)$(BINDIR)/pacman
|
$(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 vercmp $(DESTDIR)$(BINDIR)/vercmp
|
||||||
$(INSTALL) -D -m0755 convertdb $(DESTDIR)$(BINDIR)/convertdb
|
$(INSTALL) -D -m0755 convertdb $(DESTDIR)$(BINDIR)/convertdb
|
||||||
$(INSTALL) -D -m0755 $(SCRDIR)makepkg $(DESTDIR)$(BINDIR)/makepkg
|
$(INSTALL) -D -m0755 $(SCRDIR)makepkg $(DESTDIR)$(BINDIR)/makepkg
|
||||||
$(INSTALL) -D -m0755 $(SCRDIR)makeworld $(DESTDIR)$(BINDIR)/makeworld
|
$(INSTALL) -D -m0755 $(SCRDIR)makeworld $(DESTDIR)$(BINDIR)/makeworld
|
||||||
$(INSTALL) -D -m0755 $(SCRDIR)gensync $(DESTDIR)$(BINDIR)/gensync
|
$(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)pacman.8 $(DESTDIR)$(MANDIR)/man8/pacman.8
|
||||||
$(INSTALL) -D -m0644 $(MANSRC)makepkg.8 $(DESTDIR)$(MANDIR)/man8/makepkg.8
|
$(INSTALL) -D -m0644 $(MANSRC)makepkg.8 $(DESTDIR)$(MANDIR)/man8/makepkg.8
|
||||||
$(INSTALL) -D -m0644 etc/pacman.conf $(DESTDIR)/etc/pacman.conf
|
$(INSTALL) -D -m0644 etc/pacman.conf $(DESTDIR)/etc/pacman.conf
|
||||||
|
@ -115,7 +118,7 @@ clean:
|
||||||
(cd libftp; make clobber)
|
(cd libftp; make clobber)
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f pacman convertdb vercmp
|
rm -f pacman pacman.static convertdb vercmp
|
||||||
rm -f Makefile
|
rm -f Makefile
|
||||||
rm -f config.h config.status config.log
|
rm -f config.h config.status config.log
|
||||||
|
|
||||||
|
|
8
TODO
8
TODO
|
@ -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
|
|
|
@ -30,12 +30,15 @@ HoldPkg = pacman glibc
|
||||||
# REPOSITORIES
|
# REPOSITORIES
|
||||||
# - can be defined here or included from another file
|
# - can be defined here or included from another file
|
||||||
# - pacman will search repositories in the order defined here.
|
# - pacman will search repositories in the order defined here.
|
||||||
# - local/custom mirrors can be added here, above the respective Include
|
# - local/custom mirrors can be added here or in separate files
|
||||||
# for that repository
|
|
||||||
#
|
#
|
||||||
|
|
||||||
|
[current]
|
||||||
|
# Add your preferred servers here, they will be used first
|
||||||
Include = /etc/pacman.d/current
|
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/extra
|
||||||
|
|
||||||
#Include = /etc/pacman.d/unstable
|
#Include = /etc/pacman.d/unstable
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
# USA.
|
# USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
myver='2.8.3'
|
myver='2.8.4'
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "gensync $myver"
|
echo "gensync $myver"
|
||||||
|
@ -30,8 +30,8 @@ usage() {
|
||||||
echo "from <root>. gensync builds the database in a temporary directory"
|
echo "from <root>. gensync builds the database in a temporary directory"
|
||||||
echo "and then compresses it to <destfile>."
|
echo "and then compresses it to <destfile>."
|
||||||
echo
|
echo
|
||||||
echo "gensync will calculate md5sums of packages in <destdir>, unless an"
|
echo "gensync will calculate md5sums of packages in the same directory as"
|
||||||
echo "alternate [package_directory] is specified."
|
echo "<destfile>, unless an alternate [package_directory] is specified."
|
||||||
echo
|
echo
|
||||||
echo "note: The <destfile> name is important. It must be of the form"
|
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"
|
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
|
unset groups replaces provides depends conflicts
|
||||||
source $1 || return 1
|
source $1 || return 1
|
||||||
cd $gstmpdir
|
cd $gstmpdir
|
||||||
mkdir $pkgname-$pkgver-$pkgrel
|
mkdir $pkgname-$pkgver-$pkgrel || return 1
|
||||||
cd $pkgname-$pkgver-$pkgrel
|
cd $pkgname-$pkgver-$pkgrel
|
||||||
# desc
|
# desc
|
||||||
: >desc
|
: >desc
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
# USA.
|
# USA.
|
||||||
#
|
#
|
||||||
|
|
||||||
myver='2.8.3'
|
myver='2.8.4'
|
||||||
startdir=`pwd`
|
startdir=`pwd`
|
||||||
PKGDEST=$startdir
|
PKGDEST=$startdir
|
||||||
USE_COLOR="n"
|
USE_COLOR="n"
|
||||||
|
@ -611,7 +611,7 @@ if [ "$PACKAGER" != "" ]; then
|
||||||
else
|
else
|
||||||
packager="Arch Linux (http://www.archlinux.org)"
|
packager="Arch Linux (http://www.archlinux.org)"
|
||||||
fi
|
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
|
# write the .PKGINFO file
|
||||||
msg "Generating .PKGINFO file..."
|
msg "Generating .PKGINFO file..."
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
toplevel=`pwd`
|
toplevel=`pwd`
|
||||||
version="2.8.3"
|
version="2.8.4"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "makeworld version $version"
|
echo "makeworld version $version"
|
||||||
|
|
221
scripts/updatesync
Executable file
221
scripts/updatesync
Executable 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
|
29
src/db.c
29
src/db.c
|
@ -61,44 +61,21 @@ void db_close(pacdb_t* db)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* frees pkgcache if necessary and returns a new package
|
/* frees pkgcache if necessary and returns a new package
|
||||||
* cache from db
|
* cache from db
|
||||||
*/
|
*/
|
||||||
PMList* db_loadpkgs(pacdb_t *db)
|
PMList* db_loadpkgs(pacdb_t *db)
|
||||||
{
|
{
|
||||||
pkginfo_t *info;
|
pkginfo_t *info;
|
||||||
pkginfo_t **arr = NULL;
|
|
||||||
unsigned int arrct = 0;
|
|
||||||
int i;
|
|
||||||
PMList *cache = NULL;
|
PMList *cache = NULL;
|
||||||
|
|
||||||
rewinddir(db->dir);
|
rewinddir(db->dir);
|
||||||
while((info = db_scan(db, NULL, INFRQ_DESC | INFRQ_DEPENDS)) != NULL) {
|
while((info = db_scan(db, NULL, INFRQ_DESC | INFRQ_DEPENDS)) != NULL) {
|
||||||
/* add to the collective */
|
/* add to the collective */
|
||||||
/* we load all package names into a linear array first, so qsort can handle it */
|
cache = list_add_sorted(cache, info, pkgcmp);
|
||||||
if(arr == NULL) {
|
|
||||||
arr = (pkginfo_t**)malloc(sizeof(pkginfo_t*));
|
|
||||||
arrct++;
|
|
||||||
} else {
|
|
||||||
arr = (pkginfo_t**)realloc(arr, (++arrct)*sizeof(pkginfo_t*));
|
|
||||||
}
|
|
||||||
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);
|
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)) {
|
if(dbpkg2 && !is_in(filestr, p1->files) && is_in(filestr, dbpkg2->files)) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
FREE(dbpkg2);
|
FREEPKG(dbpkg2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
33
src/list.c
33
src/list.c
|
@ -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: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
|
|
@ -30,6 +30,11 @@ typedef struct __pmlist_t {
|
||||||
struct __pmlist_t* next;
|
struct __pmlist_t* next;
|
||||||
} PMList;
|
} PMList;
|
||||||
|
|
||||||
|
|
||||||
|
/* Sort comparison callback function declaration. */
|
||||||
|
typedef int (*cmp_fn) (const void *, const void *);
|
||||||
|
|
||||||
|
|
||||||
PMList* list_new();
|
PMList* list_new();
|
||||||
void list_free(PMList* list);
|
void list_free(PMList* list);
|
||||||
PMList* list_add(PMList* list, void* data);
|
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);
|
PMList *list_sort(PMList *list);
|
||||||
void list_display(const char *title, PMList *list);
|
void list_display(const char *title, PMList *list);
|
||||||
|
|
||||||
|
PMList* list_add_sorted(PMList *list, void *data, cmp_fn sortfunc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
|
|
@ -284,10 +284,10 @@ void freepkg(pkginfo_t *pkg)
|
||||||
*/
|
*/
|
||||||
int pkgcmp(const void *p1, const void *p2)
|
int pkgcmp(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
pkginfo_t **pkg1 = (pkginfo_t**)p1;
|
pkginfo_t *pkg1 = (pkginfo_t*)p1;
|
||||||
pkginfo_t **pkg2 = (pkginfo_t**)p2;
|
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*
|
/* Test for existence of a package in a PMList*
|
||||||
|
|
17
src/pacman.c
17
src/pacman.c
|
@ -115,6 +115,7 @@ int main(int argc, char *argv[])
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
pacdb_t *db_local = NULL;
|
pacdb_t *db_local = NULL;
|
||||||
char *cenv = NULL;
|
char *cenv = NULL;
|
||||||
|
uid_t myuid;
|
||||||
|
|
||||||
cenv = getenv("COLUMNS");
|
cenv = getenv("COLUMNS");
|
||||||
if(cenv) {
|
if(cenv) {
|
||||||
|
@ -144,6 +145,13 @@ int main(int argc, char *argv[])
|
||||||
return(ret);
|
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 */
|
/* check for permission */
|
||||||
pm_access = READ_ONLY;
|
pm_access = READ_ONLY;
|
||||||
if(pmo_op != PM_MAIN && pmo_op != PM_QUERY && pmo_op != PM_DEPTEST) {
|
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)) {
|
(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 */
|
/* special case: PM_SYNC can be used w/ pmo_s_search by any user */
|
||||||
} else {
|
} else {
|
||||||
if(geteuid() != 0) {
|
if(myuid) {
|
||||||
fprintf(stderr, "error: you cannot perform this operation unless you are root.\n");
|
fprintf(stderr, "error: you cannot perform this operation unless you are root.\n");
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +186,7 @@ int main(int argc, char *argv[])
|
||||||
if(pmo_usesyslog) {
|
if(pmo_usesyslog) {
|
||||||
openlog("pacman", 0, LOG_USER);
|
openlog("pacman", 0, LOG_USER);
|
||||||
}
|
}
|
||||||
if(pmo_logfile && geteuid() == 0) {
|
if(pmo_logfile && myuid == 0) {
|
||||||
/* open the log file */
|
/* open the log file */
|
||||||
logfd = fopen(pmo_logfile, "a");
|
logfd = fopen(pmo_logfile, "a");
|
||||||
if(logfd == NULL) {
|
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 */
|
/* see if this is an upgrade. if so, remove the old package first */
|
||||||
if(pmo_upgrade) {
|
if(pmo_upgrade) {
|
||||||
if(is_pkgin(info, pm_packages)) {
|
if(is_pkgin(info, pm_packages)) {
|
||||||
PMList* tmp = list_new();
|
|
||||||
int retcode;
|
int retcode;
|
||||||
|
|
||||||
printf("upgrading %s... ", info->name);
|
printf("upgrading %s... ", info->name);
|
||||||
|
@ -1701,10 +1708,10 @@ int pacman_add(pacdb_t *db, PMList *targets)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(oldpkg) {
|
if(oldpkg) {
|
||||||
list_add(tmp, strdup(info->name));
|
PMList* tmp = list_add(NULL, strdup(info->name));
|
||||||
vprint("removing old package first...\n");
|
vprint("removing old package first...\n");
|
||||||
retcode = pacman_remove(db, tmp);
|
retcode = pacman_remove(db, tmp);
|
||||||
list_free(tmp);
|
FREELIST(tmp);
|
||||||
if(retcode == 1) {
|
if(retcode == 1) {
|
||||||
fprintf(stderr, "\nupgrade aborted.\n");
|
fprintf(stderr, "\nupgrade aborted.\n");
|
||||||
return(1);
|
return(1);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define _PAC_PACMAN_H
|
#define _PAC_PACMAN_H
|
||||||
|
|
||||||
#ifndef PACVER
|
#ifndef PACVER
|
||||||
#define PACVER "2.8.3"
|
#define PACVER "2.8.4"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PKGDIR
|
#ifndef PKGDIR
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
/* borrowed and modified from Per Liden's pkgutils (http://crux.nu) */
|
/* 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;
|
char* gzoflags;
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -63,7 +63,7 @@ int gzopen_frontend(char *pathname, int oflags, int mode)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int)gzf;
|
return (long)gzf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unpack(char *archive, const char *prefix, const char *fn)
|
int unpack(char *archive, const char *prefix, const char *fn)
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#define FREE(p) { if (p) { free(p); (p)= NULL; }}
|
#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 unpack(char *archive, const char *prefix, const char *fn);
|
||||||
int copyfile(char *src, char *dest);
|
int copyfile(char *src, char *dest);
|
||||||
int makepath(char *path);
|
int makepath(char *path);
|
||||||
|
|
Loading…
Add table
Reference in a new issue