[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Dependencies [was Re: bugs, bugs, bugs!]



Hi Bill,

> There are oodles of tools to solve this problem (redhat-config-packages,
> up2date, yum, ....) Adding extraneous dependencies isn't a solution.

 This sounds a bit like putting the cart before the horse. A large part of the
problems that people are having with dependencies would be solved if they
were able to query the package without requiring an rpmdb or another tool
and still get a list of packages to install instead of a list of cryptic library
names. (I am not arguing the file dependencies should be dropped.)

 The overhead of adding the names of required packages to a package are
minimal. It is not very difficult to generate the requirements from the
existing requirements. The script below gives an indication of how this
could be solved. Or it just adds to the oodles ;).

 Anyway, I don't see why we shouldn't use the possibility to specify both
files and package names if this makes life easier. Currently the mix of
file/library and package name dependencies is a mess anyway.

Bye,
Leonard.

$ cat dependencies
#!/bin/sh

# dependencies

# This script assembles requirement information for a package
# It assumes all dependencies for queried packages are satisfied
# This could/should be changed to use an rpmdb instead
#
# Leonard den Ottolander <leonardjo hetnet nl>, 2003-07-30

# TODO Add package file handling
# TODO Add rpmlib version handling

# ${PACK}_requires              plain requirements (rpm -qR output)
# ${PACK}_requires_sorted       sorted requirements (versioning removed)
# ${PACK}_requires_libs         required library files (.so)
# ${PACK}_requires_libstemp     temporary list of library packages
# ${PACK}_requires_libpacks     sorted list of library packages
# ${PACK}_requires_execs        executables in requirements (contain /)
# ${PACK}_requires_execstemp    temporary list of executable packages
# ${PACK}_requires_execpacks    sorted list of executable packages
# ${PACK}_requires_rest         files other than library and execs
# ${PACK}_requires_restlibs     specific for rpmlib (why isn't librpm used as a req?)
# ${PACK}_requires_restpacks
# ${PACK}_requires_packs        package names in the original requirements

if [ "$1" == "" ]; then
#  echo "Usage: $0 <package | package file>"
  echo "Usage: $0 <package>"
  exit
fi

PACK=$1

#rpm -qf "Package: %{NAME}-%{VERSION}-%{RELEASE}\n" -qR ${PACK} > ${PACK}_requires
rpm -qR ${PACK} > ${PACK}_requires
cat  ${PACK}_requires | cut -f 1 -d \  | cut -f 1 -d \( | sort -u > ${PACK}_requires_sort

# .so is library (also catches absolute library paths)
# library search path: (absolute path) /lib /usr/lib . /etc/ld.so.conf
grep \.so ${PACK}_requires_sort > ${PACK}_requires_libs
echo -n '' > ${PACK}_requires_libstemp

for lib in $(cat ${PACK}_requires_libs); do
  found=0
  for path in /lib /usr/lib /usr/local/lib $(cat /etc/ld.so.conf) ; do
  # maybe library files with explicit paths need special handling
  #  if so, just moving the procedure for files before this should suffice
  if [ -e $path/$lib ]; then
    if [ -f $path/$lib ]; then
      found=1 # or inc and check if > 1 occurence
      pack=$(rpm -q --whatprovides $path/$lib)
      retval=$?
      if [ $retval -eq 0 ]; then
        echo $pack >> ${PACK}_requires_libstemp
      else
        if [ "$pack" == "$(echo $pack | grep not\ owned\ by\ any\ package)" ]; then
#         echo PACKAGE NOT OWNED
          # package not owned, follow symlink
#         ls -l $path/$lib | cut -f 2 -d \> | cut -b 2-
          tlib=$(ls -l $path/$lib | cut -f 2 -d \> | cut -b 2-)
          pack=$(rpm -q --whatprovides $path/$tlib)
          echo $pack >> ${PACK}_requires_libstemp
        else
          # don't know what to do
          echo "error: $pack"
        fi
      fi
    fi
  fi
  done
  if [ $found -eq 0 ]; then
    echo "$path/$lib: file not found"
  fi
done

sort -u ${PACK}_requires_libstemp > ${PACK}_requires_libpacks

# executables contain /
# / should be first char, or are relative paths allowed?
grep / ${PACK}_requires_sort > ${PACK}_requires_execs
echo -n '' > ${PACK}_requires_execstemp
for file in $(cat ${PACK}_requires_execs) ; do
  rpm -q --whatprovides $file >> ${PACK}_requires_execstemp
done
sort -u ${PACK}_requires_execstemp > ${PACK}_requires_execpacks

# no / or . is path nor file thus package name
grep -v / ${PACK}_requires_sort | grep -v "\." > ${PACK}_requires_rest

# specifically rpmlib (why is this used anyway?)
grep lib ${PACK}_requires_rest > ${PACK}_requires_restlibs
# how to handle rpmlib further?

# anything else is a package name
grep -v lib ${PACK}_requires_rest > ${PACK}_requires_packs

# Sort all requires
cat ${PACK}_requires_execpacks > ${PACK}_requires_alltemp
cat ${PACK}_requires_libpacks >> ${PACK}_requires_alltemp
sort -u ${PACK}_requires_alltemp > ${PACK}_requires_alltemp1

# Produce some output
rpm --queryformat "Package %{NAME}-%{VERSION}-%{RELEASE} Requires the following packages:\n" -q ${PACK}
#rpm -q ${PACK}
cat ${PACK}_requires_alltemp1 | rev | cut -f 2- -d \- | sed  's/-/ => /' | rev
echo
cat ${PACK}_requires_packs

--
How clean is a war when you shoot around nukelar waste?
Stop the use of depleted uranium ammo!
End all weapons of mass destruction.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]