Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-01-24 08:51:50 +0000
committerAaron Griffin <aaron@archlinux.org>2007-01-24 08:51:50 +0000
commit170d63190a3cfb0c12ee9ddfe07b21f20825bd6f (patch)
treec1cad21e75daf695f61f83ca1072d0a52343a673
parent1b61cc8c69025ddd394401a506b21f16df5d4e6d (diff)
* 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
-rw-r--r--.cvsignore1
-rw-r--r--TODO.aaron3
-rwxr-xr-xconfig.rpath614
-rw-r--r--lib/libalpm/alpm_list.c55
-rw-r--r--lib/libalpm/alpm_list.h13
-rw-r--r--lib/libalpm/be_files.c23
-rw-r--r--lib/libalpm/cache.c9
-rw-r--r--lib/libalpm/package.c3
-rw-r--r--src/pacman/add.c2
-rw-r--r--src/pacman/deptest.c4
-rw-r--r--src/pacman/log.c6
-rw-r--r--src/pacman/query.c17
-rw-r--r--src/pacman/remove.c2
-rw-r--r--src/pacman/sync.c11
14 files changed, 710 insertions, 53 deletions
diff --git a/.cvsignore b/.cvsignore
index b2d0209a..76071c36 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -9,7 +9,6 @@ config.h.in
config.log
config.status
config.sub
-config.rpath
configure
depcomp
install-sh
diff --git a/TODO.aaron b/TODO.aaron
index 8fad56b8..508f0a5e 100644
--- a/TODO.aaron
+++ b/TODO.aaron
@@ -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.
diff --git a/config.rpath b/config.rpath
new file mode 100755
index 00000000..c492a93b
--- /dev/null
+++ b/config.rpath
@@ -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@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@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
diff --git a/lib/libalpm/alpm_list.c b/lib/libalpm/alpm_list.c
index 26fcb3dc..edb2e8e5 100644
--- a/lib/libalpm/alpm_list.c
+++ b/lib/libalpm/alpm_list.c
@@ -49,33 +49,37 @@ alpm_list_t *alpm_list_new()
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 @@ alpm_list_t *alpm_list_remove(alpm_list_t *haystack, void *needle, alpm_list_fn_
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
diff --git a/lib/libalpm/alpm_list.h b/lib/libalpm/alpm_list.h
index df19c9e9..5bad4dc2 100644
--- a/lib/libalpm/alpm_list.h
+++ b/lib/libalpm/alpm_list.h
@@ -30,18 +30,18 @@ struct __alpm_list_t {
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_add_sorted(alpm_list_t *list, void *data, alpm_list_fn_cm
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);
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 19e2bf1f..65a5fc71 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -217,9 +217,8 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
/* 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 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
/* 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 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
/* 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 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq)
_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 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq)
_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 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, unsigned int inforeq)
_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;
}
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index d03cf203..81737d3c 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -112,8 +112,13 @@ int _alpm_db_ensure_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
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) {
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index f35797be..beda20a4 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -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 @@ static int parse_descfile(char *descfile, pmpkg_t *info, int output)
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);
}
diff --git a/src/pacman/add.c b/src/pacman/add.c
index 1dedbafb..64e5264d 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -167,7 +167,7 @@ int pacman_add(alpm_list_t *targets)
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));
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index a46141db..e37f4791 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -130,7 +130,7 @@ int pacman_deptest(alpm_list_t *targets)
}
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 @@ int pacman_deptest(alpm_list_t *targets)
MSG(NL, _("conflict: %s"), alpm_dep_get_name(miss));
}
retval = 127;
- alpm_list_free(data, NULL);
+ alpm_list_free(data);
break;
default:
retval = 127;
diff --git a/src/pacman/log.c b/src/pacman/log.c
index 4685bd85..f139fb14 100644
--- a/src/pacman/log.c
+++ b/src/pacman/log.c
@@ -192,12 +192,14 @@ int yesno(char *fmt, ...)
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);
}
}
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 4124f400..62e7ef10 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -98,16 +98,23 @@ int pacman_query(alpm_list_t *targets)
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);
}
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index b8dd1544..94ee66a2 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -103,7 +103,7 @@ int pacman_remove(alpm_list_t *targets)
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;
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 6288ac50..6b1cb432 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -265,7 +265,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
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 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
if(db == NULL) {
ERR(NL, _("repository \"%s\" was not found.\n"),repo);
- FREELISTPTR(ls);
+ alpm_list_free(ls);
return(1);
}
@@ -395,7 +395,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
}
if(targets) {
- FREELISTPTR(ls);
+ alpm_list_free(ls);
}
return(0);
@@ -541,7 +541,7 @@ int pacman_sync(alpm_list_t *targets)
}
}
}
- FREELIST(pkgs);
+ alpm_list_free(pkgs);
}
}
if(!found) {
@@ -756,8 +756,7 @@ int pacman_sync(alpm_list_t *targets)
*/
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));