This is the old SliTaz forum - Please use the main forum.slitaz.org

tazpkg and package dependancies
  • jpegjpeg April 2010
    tazpkg doesn't do much for package dependancies, for example when you uninstall a package, you might be able to uninstall a few others as well. Wanting to explore this a bit I wrote a script. Unfortunately I don't know the markup for this site, and the indenting has gotten lost. Good luck & let me know what you think.

    #!/bin/sh
    # tazdeps
    # 0. read the receipts in the dir given on the cmdline
    # 1. for each pkg record the DEPENDS:
    # 2. for each pkg record the pkgs that depend on it
    # 3. for each pkg that none others require display those it alone
    # requires and which could thus be uninstalled if pkg was uninstalled
    # 4. for each pkg required by at least two pkgs, list which ones
    # 5. cleanup the tempfiles used

    # 0. Parse arguments and general preparation
    if [ "$1" = "" ]; then
    dirname="/var/lib/tazpkg/installed"
    else
    dirname=`echo $1 | sed 's!/$!!'`
    fi

    echo "Reading receipts from $dirname"

    depslist=`mktemp`
    tempdir=`mktemp -d`
    pkglist=`ls $dirname`
    manyreq="" # List of pkgs that many others require for step n°4
    unset IFS

    # 1. Read the receipts and record the depends in a tempfile
    DEPENDS=""
    for pkg in $pkglist; do
    . $dirname/$pkg/receipt
    echo "$pkg: " $DEPENDS >> $depslist
    # NB $DEPENDS is outside the quotes so that if it includes
    # newlines e.g. as for xorg, these get replaced by spaces.
    DEPENDS=""
    done

    # 2. For each pkg record the pkgs that require it
    IFS="
    "
    for entry in `cat $depslist`; do
    pkg=`echo $entry | cut -d":" -f1`
    deps=`echo $entry | cut -d":" -f2`
    unset IFS
    for dep in $deps; do
    echo $pkg >> $tempdir/$dep
    done
    done

    echo "===================================================================="
    echo " For each package that none others require, those it alone requires "
    echo "===================================================================="

    # 3. For each pkg that none others require display those it alone
    # requires.
    # Could be done recursively, e.g. python alone requires tk, but also
    # tcl is only required by python and tk. So if we uninstall python and
    # we don't care to keep tk, we could uninstall tcl as well.
    IFS="
    "
    for entry in `cat $depslist`; do
    pkg=`echo $entry | cut -d":" -f1`
    deps=`echo $entry | cut -d":" -f2`
    if [ ! -e $tempdir/$pkg ]; then
    echo -n "$pkg :"
    unset IFS
    for dep in $deps; do
    if [ -f $tempdir/$dep \
    -a `cat $tempdir/$dep | wc -l` -eq 1 ]; then
    echo -n " $dep"
    fi
    done
    echo
    elif [ `cat $tempdir/$pkg | wc -l` -gt 1 ]; then
    manyreq="$manyreq $pkg"
    fi
    done

    echo "=================================================="
    echo " Packages required by at least two other packages "
    echo "=================================================="

    # 4. for each pkg required by at least two pkgs, list which ones
    for pkg in $manyreq; do
    echo -n "$pkg : "
    cat $tempdir/$pkg | tr "\n" " "
    echo
    done

    # 5. Cleanups
    rm $depslist
    rm -rf $tempdir
  • RuppRupp April 2010
    Thanks what you posted shows real potential. I was about to post a script for automating converting and installing other binaries. I won't post it now because I don't want it to look like I was piggy backing your post.

    Thanks again


    Rupp
  • RuppRupp April 2010
    I tested it. Pretty sweet that it shows you what needs what. I wonder if you can purge deps that are no longer needed like you can in Archlinux?



    Rupp

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

SliTaz Social