[pacman-dev] CVS update of pacman-lib (14 files)
Aaron Griffin
aaron at archlinux.org
Wed Jan 24 03:51:51 EST 2007
Date: Wednesday, January 24, 2007 @ 03:51:51
Author: aaron
Path: /home/cvs-pacman/pacman-lib
Added: config.rpath (1.1)
Modified: .cvsignore (1.2 -> 1.3) TODO.aaron (1.9 -> 1.10)
lib/libalpm/alpm_list.c (1.3 -> 1.4)
lib/libalpm/alpm_list.h (1.1 -> 1.2)
lib/libalpm/be_files.c (1.21 -> 1.22)
lib/libalpm/cache.c (1.26 -> 1.27)
lib/libalpm/package.c (1.50 -> 1.51)
src/pacman/add.c (1.24 -> 1.25) src/pacman/deptest.c (1.11 -> 1.12)
src/pacman/log.c (1.23 -> 1.24) src/pacman/query.c (1.18 -> 1.19)
src/pacman/remove.c (1.24 -> 1.25) src/pacman/sync.c (1.98 -> 1.99)
* Shuffled some of the alpm_list free funtions - still not perfect, but better
* Added alpm_list_remove_node for single list node removal
* Proper error checking/output for failed db_read/db_write (missing files)
* Invalid packages (missing files) are now removed from the package cache
* -Qs and -Ss output now look the same
* config.rpath causes errors on one machine I had, so I added it to CVS
* Fixed a "clobbered memory" issue when installing groups - only the outer list
should be free'd, not the contained data
-------------------------+
.cvsignore | 1
TODO.aaron | 3
config.rpath | 614 ++++++++++++++++++++++++++++++++++++++++++++++
lib/libalpm/alpm_list.c | 55 +++-
lib/libalpm/alpm_list.h | 13
lib/libalpm/be_files.c | 23 -
lib/libalpm/cache.c | 9
lib/libalpm/package.c | 3
src/pacman/add.c | 2
src/pacman/deptest.c | 4
src/pacman/log.c | 6
src/pacman/query.c | 17 -
src/pacman/remove.c | 2
src/pacman/sync.c | 11
14 files changed, 710 insertions(+), 53 deletions(-)
Index: pacman-lib/.cvsignore
diff -u pacman-lib/.cvsignore:1.2 pacman-lib/.cvsignore:1.3
--- pacman-lib/.cvsignore:1.2 Tue Jan 16 22:40:08 2007
+++ pacman-lib/.cvsignore Wed Jan 24 03:51:50 2007
@@ -9,7 +9,6 @@
config.log
config.status
config.sub
-config.rpath
configure
depcomp
install-sh
Index: pacman-lib/TODO.aaron
diff -u pacman-lib/TODO.aaron:1.9 pacman-lib/TODO.aaron:1.10
--- pacman-lib/TODO.aaron:1.9 Fri Jan 19 12:42:58 2007
+++ pacman-lib/TODO.aaron Wed Jan 24 03:51:50 2007
@@ -22,6 +22,9 @@
- maybe it's my fault, but I see little difference between PM_LOG_FLOW1,
PM_LOG_FLOW2, and PM_LOG_DEBUG. We might want to just do away with flow1
and flow2 and use debug across the board.
+ - clear up list allocation/deallocation - some lists need to be free'd, some
+ do not and there is no clear indication WHEN this should happen.
+ - remove DB entries (directories) on a read error?
* pacman: A LOT of functions are way too long. There should be an upper limit of
100-200 lines. _alpm_add_commit is around 600 lines, and is far too complex.
Index: pacman-lib/config.rpath
diff -u /dev/null pacman-lib/config.rpath:1.1
--- /dev/null Wed Jan 24 03:51:51 2007
+++ pacman-lib/config.rpath Wed Jan 24 03:51:50 2007
@@ -0,0 +1,614 @@
+#! /bin/sh
+# Output a system dependent set of variables, describing how to set the
+# run time search path of shared libraries in an executable.
+#
+# Copyright 1996-2006 Free Software Foundation, Inc.
+# Taken from GNU libtool, 2001
+# Originally by Gordon Matzigkeit <gord at gnu.ai.mit.edu>, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# The first argument passed to this file is the canonical host specification,
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
+# should be set by the caller.
+#
+# The set of defined variables is at the end of this script.
+
+# Known limitations:
+# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
+# than 256 bytes, otherwise the compiler driver will dump core. The only
+# known workaround is to choose shorter directory names for the build
+# directory and/or the installation directory.
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+shrext=.so
+
+host="$1"
+host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+# Code taken from libtool.m4's _LT_CC_BASENAME.
+
+for cc_temp in $CC""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
+
+# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
+
+wl=
+if test "$GCC" = yes; then
+ wl='-Wl,'
+else
+ case "$host_os" in
+ aix*)
+ wl='-Wl,'
+ ;;
+ darwin*)
+ case $cc_basename in
+ xlc*)
+ wl='-Wl,'
+ ;;
+ esac
+ ;;
+ mingw* | pw32* | os2*)
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ wl='-Wl,'
+ ;;
+ irix5* | irix6* | nonstopux*)
+ wl='-Wl,'
+ ;;
+ newsos6)
+ ;;
+ linux*)
+ case $cc_basename in
+ icc* | ecc*)
+ wl='-Wl,'
+ ;;
+ pgcc | pgf77 | pgf90)
+ wl='-Wl,'
+ ;;
+ ccc*)
+ wl='-Wl,'
+ ;;
+ como)
+ wl='-lopt='
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ wl='-Wl,'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ osf3* | osf4* | osf5*)
+ wl='-Wl,'
+ ;;
+ sco3.2v5*)
+ ;;
+ solaris*)
+ wl='-Wl,'
+ ;;
+ sunos4*)
+ wl='-Qoption ld '
+ ;;
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ wl='-Wl,'
+ ;;
+ sysv4*MP*)
+ ;;
+ unicos*)
+ wl='-Wl,'
+ ;;
+ uts4*)
+ ;;
+ esac
+fi
+
+# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
+
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+
+case "$host_os" in
+ cygwin* | mingw* | pw32*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ # Unlike libtool, we use -rpath here, not --rpath, since the documented
+ # option of GNU ld is called -rpath, not --rpath.
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ case "$host_os" in
+ aix3* | aix4* | aix5*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs=no
+ fi
+ ;;
+ amigaos*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ # Samuel A. Falvo II <kc5tja at dolphin.openprojects.net> reports
+ # that the semantics of dynamic libraries on AmigaOS, at least up
+ # to version 4, is to share data among multiple programs linked
+ # with the same dynamic library. Since this doesn't match the
+ # behavior of shared libraries on other platforms, we cannot use
+ # them.
+ ld_shlibs=no
+ ;;
+ beos*)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ cygwin* | mingw* | pw32*)
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ interix3*)
+ hardcode_direct=no
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ linux*)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ netbsd*)
+ ;;
+ solaris*)
+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+ ld_shlibs=no
+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs=no
+ ;;
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ ;;
+ sunos4*)
+ hardcode_direct=yes
+ ;;
+ *)
+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+ :
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ if test "$ld_shlibs" = no; then
+ hardcode_libdir_flag_spec=
+ fi
+else
+ case "$host_os" in
+ aix3*)
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$GCC" = yes; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+ aix4* | aix5*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ else
+ aix_use_runtimelinking=no
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+ fi
+ hardcode_direct=yes
+ hardcode_libdir_separator=':'
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" && \
+ strings "$collect2name" | grep resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ hardcode_direct=yes
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ hardcode_minus_L=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ fi
+ ;;
+ esac
+ fi
+ # Begin _LT_AC_SYS_LIBPATH_AIX.
+ echo 'int main () { return 0; }' > conftest.c
+ ${CC} ${LDFLAGS} conftest.c -o conftest
+ aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+ if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
+}'`
+ fi
+ if test -z "$aix_libpath"; then
+ aix_libpath="/usr/lib:/lib"
+ fi
+ rm -f conftest.c conftest
+ # End _LT_AC_SYS_LIBPATH_AIX.
+ if test "$aix_use_runtimelinking" = yes; then
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+ else
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ fi
+ fi
+ ;;
+ amigaos*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ # see comment about different semantics on the GNU ld section
+ ld_shlibs=no
+ ;;
+ bsdi[45]*)
+ ;;
+ cygwin* | mingw* | pw32*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec=' '
+ libext=lib
+ ;;
+ darwin* | rhapsody*)
+ hardcode_direct=no
+ if test "$GCC" = yes ; then
+ :
+ else
+ case $cc_basename in
+ xlc*)
+ ;;
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+ fi
+ ;;
+ dgux*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ ;;
+ freebsd1*)
+ ld_shlibs=no
+ ;;
+ freebsd2.2*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ ;;
+ freebsd2*)
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ ;;
+ freebsd* | kfreebsd*-gnu | dragonfly*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ ;;
+ hpux9*)
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ hpux10*)
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ fi
+ ;;
+ hpux11*)
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct=no
+ ;;
+ *)
+ hardcode_direct=yes
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+ irix5* | irix6* | nonstopux*)
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ netbsd*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ ;;
+ newsos6)
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ openbsd*)
+ hardcode_direct=yes
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ else
+ case "$host_os" in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ ;;
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ osf3*)
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+ osf4* | osf5*)
+ if test "$GCC" = yes; then
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ else
+ # Both cc and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec='-rpath $libdir'
+ fi
+ hardcode_libdir_separator=:
+ ;;
+ solaris*)
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ sunos4*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ ;;
+ sysv4)
+ case $host_vendor in
+ sni)
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ hardcode_direct=no
+ ;;
+ motorola)
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ ;;
+ sysv4.3*)
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ ld_shlibs=yes
+ fi
+ ;;
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7*)
+ ;;
+ sysv5* | sco3.2v5* | sco5v6*)
+ hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+ hardcode_libdir_separator=':'
+ ;;
+ uts4*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ ;;
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+fi
+
+# Check dynamic linker characteristics
+# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
+libname_spec='lib$name'
+case "$host_os" in
+ aix3*)
+ ;;
+ aix4* | aix5*)
+ ;;
+ amigaos*)
+ ;;
+ beos*)
+ ;;
+ bsdi[45]*)
+ ;;
+ cygwin* | mingw* | pw32*)
+ shrext=.dll
+ ;;
+ darwin* | rhapsody*)
+ shrext=.dylib
+ ;;
+ dgux*)
+ ;;
+ freebsd1*)
+ ;;
+ kfreebsd*-gnu)
+ ;;
+ freebsd* | dragonfly*)
+ ;;
+ gnu*)
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $host_cpu in
+ ia64*)
+ shrext=.so
+ ;;
+ hppa*64*)
+ shrext=.sl
+ ;;
+ *)
+ shrext=.sl
+ ;;
+ esac
+ ;;
+ interix3*)
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case "$host_os" in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
+ *) libsuff= shlibsuff= ;;
+ esac
+ ;;
+ esac
+ ;;
+ linux*oldld* | linux*aout* | linux*coff*)
+ ;;
+ linux*)
+ ;;
+ knetbsd*-gnu)
+ ;;
+ netbsd*)
+ ;;
+ newsos6)
+ ;;
+ nto-qnx*)
+ ;;
+ openbsd*)
+ ;;
+ os2*)
+ libname_spec='$name'
+ shrext=.dll
+ ;;
+ osf3* | osf4* | osf5*)
+ ;;
+ solaris*)
+ ;;
+ sunos4*)
+ ;;
+ sysv4 | sysv4.3*)
+ ;;
+ sysv4*MP*)
+ ;;
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ ;;
+ uts4*)
+ ;;
+esac
+
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
+shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
+escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+
+LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
+
+# How to pass a linker flag through the compiler.
+wl="$escaped_wl"
+
+# Static library suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally "so").
+shlibext="$shlibext"
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator="$hardcode_libdir_separator"
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct="$hardcode_direct"
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L="$hardcode_minus_L"
+
+EOF
Index: pacman-lib/lib/libalpm/alpm_list.c
diff -u pacman-lib/lib/libalpm/alpm_list.c:1.3 pacman-lib/lib/libalpm/alpm_list.c:1.4
--- pacman-lib/lib/libalpm/alpm_list.c:1.3 Mon Jan 22 20:34:58 2007
+++ pacman-lib/lib/libalpm/alpm_list.c Wed Jan 24 03:51:51 2007
@@ -49,33 +49,37 @@
return(list);
}
-/** Free a list structure and possibly the internal data as well
+/** Free a list, but not the contained data
* @param list the list to free
- * @param fn a free function for the internal data, or NULL for none
*/
-void alpm_list_free(alpm_list_t *list, alpm_list_fn_free fn)
+void alpm_list_free(alpm_list_t *list)
{
alpm_list_t *it = list;
while(it) {
- alpm_list_t *ptr = it->next;
- if(fn && it->data) {
- fn(it->data);
- }
- FREE(it);
- it = ptr;
+ alpm_list_t *tmp = it->next;
+ free(it);
+ it = tmp;
}
}
-/** Free the outer list, but not the contained data
- * A minor simplification of alpm_list_free
+/** Free the internal data of a list structure
* @param list the list to free
+ * @param fn a free function for the internal data
*/
-void alpm_list_free_outer(alpm_list_t *list)
+void alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn)
{
- alpm_list_free(list, NULL);
+ alpm_list_t *it = list;
+
+ while(it) {
+ if(fn && it->data) {
+ fn(it->data);
+ }
+ it = it->next;
+ }
}
+
/* Mutators */
/** Add a new item to the list
@@ -271,6 +275,31 @@
return(haystack);
}
+/** Remove the passed in node from the list that it is a part of
+ * @note this DOES NOT free the node
+ * @param node the list node we're removing
+ * @return the node which took the place of this one
+ */
+alpm_list_t *alpm_list_remove_node(alpm_list_t *node)
+{
+ if(!node) return(NULL);
+
+ alpm_list_t *ret = NULL;
+
+ if(node->prev) {
+ node->prev->next = node->next;
+ ret = node->prev;
+ node->prev = NULL;
+ }
+ if(node->next) {
+ node->next->prev = node->prev;
+ ret = node->next;
+ node->next = NULL;
+ }
+
+ return(ret);
+}
+
/** Create a new list without any duplicates
* @note DOES NOT copy data members
* @param list the list to copy
Index: pacman-lib/lib/libalpm/alpm_list.h
diff -u pacman-lib/lib/libalpm/alpm_list.h:1.1 pacman-lib/lib/libalpm/alpm_list.h:1.2
--- pacman-lib/lib/libalpm/alpm_list.h:1.1 Fri Jan 19 04:28:44 2007
+++ pacman-lib/lib/libalpm/alpm_list.h Wed Jan 24 03:51:51 2007
@@ -30,18 +30,18 @@
struct __alpm_list_t *next;
};
-/* TODO we should do away with these... they're messy */
-#define _FREELIST(p, f) do { if(p) { alpm_list_free(p, f); p = NULL; } } while(0)
-#define FREELIST(p) _FREELIST(p, free)
-#define FREELISTPTR(p) _FREELIST(p, NULL)
+/* TODO we should do away with these... they're messy*/
+#define _FREELIST(p, f) do { alpm_list_free_inner(p, f); alpm_list_free(p); p = NULL; } while(0)
+#define FREELIST(p) _FREELIST(p, free)
+#define FREELISTPTR(p) do { alpm_list_free(p); p = NULL; } while(0)
typedef void (*alpm_list_fn_free)(void *); /* item deallocation callback */
typedef int (*alpm_list_fn_cmp)(const void *, const void *); /* item comparison callback */
/* allocation */
alpm_list_t *alpm_list_new(void);
-void alpm_list_free(alpm_list_t *list, alpm_list_fn_free fn);
-void alpm_list_free_outer(alpm_list_t *list);
+void alpm_list_free(alpm_list_t *list);
+void alpm_list_free_inner(alpm_list_t *list, alpm_list_fn_free fn);
/* item mutators */
alpm_list_t *alpm_list_add(alpm_list_t *list, void *data);
@@ -49,6 +49,7 @@
alpm_list_t* alpm_list_mmerge(alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn);
alpm_list_t* alpm_list_msort(alpm_list_t *list, int n, alpm_list_fn_cmp fn);
alpm_list_t *alpm_list_remove(alpm_list_t *haystack, void *needle, alpm_list_fn_cmp fn, void **data);
+alpm_list_t *alpm_list_remove_node(alpm_list_t *node);
alpm_list_t *alpm_list_remove_dupes(alpm_list_t *list);
alpm_list_t *alpm_list_strdup(alpm_list_t *list);
alpm_list_t *alpm_list_reverse(alpm_list_t *list);
Index: pacman-lib/lib/libalpm/be_files.c
diff -u pacman-lib/lib/libalpm/be_files.c:1.21 pacman-lib/lib/libalpm/be_files.c:1.22
--- pacman-lib/lib/libalpm/be_files.c:1.21 Tue Jan 23 22:02:54 2007
+++ pacman-lib/lib/libalpm/be_files.c Wed Jan 24 03:51:51 2007
@@ -217,9 +217,8 @@
/* DESC */
if(inforeq & INFRQ_DESC) {
snprintf(path, PATH_MAX, "%s/%s-%s/desc", db->path, info->name, info->version);
- fp = fopen(path, "r");
- if(fp == NULL) {
- _alpm_log(PM_LOG_DEBUG, "%s (%s)", path, strerror(errno));
+ if((fp = fopen(path, "r")) == NULL) {
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), path, strerror(errno));
goto error;
}
while(!feof(fp)) {
@@ -362,9 +361,8 @@
/* FILES */
if(inforeq & INFRQ_FILES) {
snprintf(path, PATH_MAX, "%s/%s-%s/files", db->path, info->name, info->version);
- fp = fopen(path, "r");
- if(fp == NULL) {
- _alpm_log(PM_LOG_WARNING, "%s (%s)", path, strerror(errno));
+ if((fp = fopen(path, "r")) == NULL) {
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), path, strerror(errno));
goto error;
}
while(fgets(line, 256, fp)) {
@@ -386,9 +384,8 @@
/* DEPENDS */
if(inforeq & INFRQ_DEPENDS) {
snprintf(path, PATH_MAX, "%s/%s-%s/depends", db->path, info->name, info->version);
- fp = fopen(path, "r");
- if(fp == NULL) {
- _alpm_log(PM_LOG_WARNING, "%s (%s)", path, strerror(errno));
+ if((fp = fopen(path, "r")) == NULL) {
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), path, strerror(errno));
goto error;
}
while(!feof(fp)) {
@@ -474,8 +471,8 @@
_alpm_log(PM_LOG_DEBUG, _("writing %s-%s DESC information back to db"), info->name, info->version);
snprintf(path, PATH_MAX, "%s/%s-%s/desc", db->path, info->name, info->version);
if((fp = fopen(path, "w")) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("db_write: could not open file %s/desc"), db->treename);
- retval = 1;
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), path, strerror(errno));
+ retval = -1;
goto cleanup;
}
fprintf(fp, "%%NAME%%\n%s\n\n"
@@ -560,7 +557,7 @@
_alpm_log(PM_LOG_DEBUG, _("writing %s-%s FILES information back to db"), info->name, info->version);
snprintf(path, PATH_MAX, "%s/%s-%s/files", db->path, info->name, info->version);
if((fp = fopen(path, "w")) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("db_write: could not open file %s/files"), db->treename);
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), path, strerror(errno));
retval = -1;
goto cleanup;
}
@@ -587,7 +584,7 @@
_alpm_log(PM_LOG_DEBUG, _("writing %s-%s DEPENDS information back to db"), info->name, info->version);
snprintf(path, PATH_MAX, "%s/%s-%s/depends", db->path, info->name, info->version);
if((fp = fopen(path, "w")) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("db_write: could not open file %s/depends"), db->treename);
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), path, strerror(errno));
retval = -1;
goto cleanup;
}
Index: pacman-lib/lib/libalpm/cache.c
diff -u pacman-lib/lib/libalpm/cache.c:1.26 pacman-lib/lib/libalpm/cache.c:1.27
--- pacman-lib/lib/libalpm/cache.c:1.26 Tue Jan 23 22:02:54 2007
+++ pacman-lib/lib/libalpm/cache.c Wed Jan 24 03:51:51 2007
@@ -112,8 +112,13 @@
for(p = db->pkgcache; p; p = p->next) {
pmpkg_t *pkg = (pmpkg_t *)p->data;
if(infolevel != INFRQ_NONE && !(pkg->infolevel & infolevel)) {
- _alpm_db_read(db, infolevel, pkg);
- reloaded = 1;
+ if(_alpm_db_read(db, infolevel, pkg) == -1) {
+ _alpm_log(PM_LOG_ERROR, _("failed to read package '%s-%s', removing from package cache"),
+ pkg->name, pkg->version);
+ p = alpm_list_remove_node(p);
+ } else {
+ reloaded = 1;
+ }
}
}
if(reloaded) {
Index: pacman-lib/lib/libalpm/package.c
diff -u pacman-lib/lib/libalpm/package.c:1.50 pacman-lib/lib/libalpm/package.c:1.51
--- pacman-lib/lib/libalpm/package.c:1.50 Tue Jan 23 22:02:54 2007
+++ pacman-lib/lib/libalpm/package.c Wed Jan 24 03:51:51 2007
@@ -29,6 +29,7 @@
#include <string.h>
#include <libintl.h>
#include <locale.h>
+#include <errno.h>
/* pacman */
#include "log.h"
#include "util.h"
@@ -136,7 +137,7 @@
int linenum = 0;
if((fp = fopen(descfile, "r")) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not open file %s"), descfile);
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), descfile, strerror(errno));
return(-1);
}
Index: pacman-lib/src/pacman/add.c
diff -u pacman-lib/src/pacman/add.c:1.24 pacman-lib/src/pacman/add.c:1.25
--- pacman-lib/src/pacman/add.c:1.24 Tue Jan 23 22:02:55 2007
+++ pacman-lib/src/pacman/add.c Wed Jan 24 03:51:51 2007
@@ -167,7 +167,7 @@
cleanup:
if(data) {
- alpm_list_free(data, NULL);
+ alpm_list_free(data);
}
if(alpm_trans_release() == -1) {
ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno));
Index: pacman-lib/src/pacman/deptest.c
diff -u pacman-lib/src/pacman/deptest.c:1.11 pacman-lib/src/pacman/deptest.c:1.12
--- pacman-lib/src/pacman/deptest.c:1.11 Tue Jan 23 22:02:55 2007
+++ pacman-lib/src/pacman/deptest.c Wed Jan 24 03:51:51 2007
@@ -130,7 +130,7 @@
}
synctargs = alpm_list_add(synctargs, strdup(alpm_dep_get_name(miss)));
}
- alpm_list_free(data, NULL);
+ alpm_list_free(data);
break;
case PM_ERR_CONFLICTING_DEPS:
/* we can't auto-resolve conflicts */
@@ -139,7 +139,7 @@
MSG(NL, _("conflict: %s"), alpm_dep_get_name(miss));
}
retval = 127;
- alpm_list_free(data, NULL);
+ alpm_list_free(data);
break;
default:
retval = 127;
Index: pacman-lib/src/pacman/log.c
diff -u pacman-lib/src/pacman/log.c:1.23 pacman-lib/src/pacman/log.c:1.24
--- pacman-lib/src/pacman/log.c:1.23 Fri Jan 19 04:28:46 2007
+++ pacman-lib/src/pacman/log.c Wed Jan 24 03:51:51 2007
@@ -192,12 +192,14 @@
pch--;
}
*++pch = 0;
- strtrim(response);
+ if(strlen(response) != 0) {
+ strtrim(response);
+ }
/* User hits 'enter', forcing a newline here */
neednl = 0;
- if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES")) || !strlen(response)) {
+ if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES")) || strlen(response) == 0) {
return(1);
}
}
Index: pacman-lib/src/pacman/query.c
diff -u pacman-lib/src/pacman/query.c:1.18 pacman-lib/src/pacman/query.c:1.19
--- pacman-lib/src/pacman/query.c:1.18 Fri Jan 19 04:28:46 2007
+++ pacman-lib/src/pacman/query.c Wed Jan 24 03:51:51 2007
@@ -98,16 +98,23 @@
return(1);
}
for(i = ret; i; i = alpm_list_next(i)) {
+ char *group = NULL;
+ alpm_list_t *grp;
pmpkg_t *pkg = alpm_list_getdata(i);
- printf("local/%s/%s %s\n ",
- (char *)alpm_list_getdata(alpm_pkg_get_groups(pkg)),
- alpm_pkg_get_name(pkg),
- alpm_pkg_get_version(pkg));
+ printf("local/%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+
+ if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
+ group = alpm_list_getdata(grp);
+ printf(" (%s)\n ", (char *)alpm_list_getdata(grp));
+ } else {
+ printf("\n ");
+ }
+
indentprint(alpm_pkg_get_desc(pkg), 4);
printf("\n");
}
- alpm_list_free_outer(ret);
+ alpm_list_free(ret);
return(0);
}
Index: pacman-lib/src/pacman/remove.c
diff -u pacman-lib/src/pacman/remove.c:1.24 pacman-lib/src/pacman/remove.c:1.25
--- pacman-lib/src/pacman/remove.c:1.24 Fri Jan 19 04:28:46 2007
+++ pacman-lib/src/pacman/remove.c Wed Jan 24 03:51:51 2007
@@ -103,7 +103,7 @@
MSG(NL, _(":: %s is required by %s\n"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
}
- alpm_list_free(data, NULL);
+ alpm_list_free(data);
break;
default:
break;
Index: pacman-lib/src/pacman/sync.c
diff -u pacman-lib/src/pacman/sync.c:1.98 pacman-lib/src/pacman/sync.c:1.99
--- pacman-lib/src/pacman/sync.c:1.98 Tue Jan 23 22:02:55 2007
+++ pacman-lib/src/pacman/sync.c Wed Jan 24 03:51:51 2007
@@ -265,7 +265,7 @@
indentprint(alpm_pkg_get_desc(pkg), 4);
printf("\n\n");
}
- alpm_list_free_outer(ret);
+ alpm_list_free(ret);
} else {
for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
pmpkg_t *pkg = alpm_list_getdata(j);
@@ -375,7 +375,7 @@
if(db == NULL) {
ERR(NL, _("repository \"%s\" was not found.\n"),repo);
- FREELISTPTR(ls);
+ alpm_list_free(ls);
return(1);
}
@@ -395,7 +395,7 @@
}
if(targets) {
- FREELISTPTR(ls);
+ alpm_list_free(ls);
}
return(0);
@@ -541,7 +541,7 @@
}
}
}
- FREELIST(pkgs);
+ alpm_list_free(pkgs);
}
}
if(!found) {
@@ -756,8 +756,7 @@
*/
cleanup:
if(data) {
- alpm_list_free(data, NULL);
- data = NULL;
+ alpm_list_free(data);
}
if(alpm_trans_release() == -1) {
ERR(NL, _("failed to release transaction (%s)\n"), alpm_strerror(pm_errno));
More information about the pacman-dev
mailing list