This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A list of installed packages (no dependencies) -- this may help


> Is there in Cygwin a command to recover a list of installed packages chosen by
> the user without the dependencies?
>
> For example, the archlinux package manager with
>
> pacman -Qqe > pkglist

> can save the list of package chosen by the user only and this is useful in case
> one wants/needs to reinstall all the packages.

Hi Angelo,

I replied to your entry in an earlier attempt, but my reply got stuck in the machinery
at sourceware.org (my message had a shell script and a .bat file attached).

Below (I hope) you will find a script, that may be of help to you ...

It computes the "top vertices" of the forest (i.e. the dependency graph), i.e. the pkgs
that no other pkg depends on (within the context of a specific installation of Cygwin).

In my case, it reduced a list of 161 pkgs to one of only (about) 15 pkgs.

(using a .bat file - quiet-install.bat - which I will attempt to include as well, I
 installed Cygwin afresh and verified the result)

Of course your situation may be different from mine ... then somebody else may find good
use of the script.

Henri

top-sters-sh:

#!/bin/bash

# compute the top vertices of the forest (the dependency graph), i.e. the packages that no other package depends on.

case $(uname -s) in
*WOW64)
setup_ini='/drv/e/_cygwin_repository/http%3a%2f%2fftp.snt.utwente.nl%2fpub%2fsoftware%2fcygwin%2f/x86/setup.ini' ;;
*)     
setup_ini='/drv/e/_cygwin64_repository/http%3a%2f%2fftp.snt.utwente.nl%2fpub%2fsoftware%2fcygwin%2f/x86_64/setup.ini'
;;
esac

( awk '
NR == 1 { next }
        {
          if ($1 ~ /-debuginfo/) next # skip -debuginfo packages
          printf "%s\n", $1
        }' /etc/setup/installed.db
# each 'requires: line' WILL be preceeded by a corresponding '@ <package>' line
awk '
/^@ /   { left = $2; next }
/^requires: / \
        {
          if (left ~ /-debuginfo$/) next # skip the -debuginfo pkgs (irrelevant pkgs for regular users)
          printf "%s", left
          for (i = 2; i <= NF; ++i) {
            if ($i ~ /-debuginfo$/) continue # skip any -debuginfo pkg (never reached)
            printf " %s", $i

          }
          printf "\n"
        } ' $setup_ini ) | sort | \
awk '
# pkg1 <==== must be printed (even in case the following line is missing)
# pkg1 pkg2 ...
BEGIN   { pkg = "" }
NF == 1 {
          if (pkg != "") { # pkg wo dependencies
            printf "%s\n", pkg
          }
          pkg = $1
          next
        }
NF > 1  {
          if (pkg == "") next
          if ($1 == pkg) {
            printf "%s\n", $0
          } else { # pkg wo dependencies
            printf "%s\n", pkg
          }
          pkg = ""
        } ' | \
awk '
# pkg1 [ pkg2 ... ]
        {
          for (j = 1; j <= NF; j++) {
            # keep count of number of pkgs that depend on a pkg (for each pkg)
            if ($j in ary) {
              ary[$j]++
            } else {
              ary[$j] = 0
            }
          }
        }
END     {
          for (elm in ary) {
           if (ary[elm] == 0) {
            printf "%s\n", elm
           }
          }
        } ' | sort # sort, as arrays are indexed by string values in awk

exit # <==== !!!!!

# each 'requires: line' WILL be preceeded by a corresponding '@ <package>' line
awk '
/^@ /   { left = $2; next }
/^requires: / \
        {
          if (left ~ /-debuginfo$/) next # skip the -debuginfo pkgs (irrelevant pkgs for regular users)
          if ($0 ~ /-debuginfo/) { # test: none of the regular packages should depend on a -debuginfo pkg
            printf "%s %s\n", left, $0
          }
        } ' $setup_ini

#=====

quiet-install.bat:

@echo off

e:/_cygwin64_repository/setup-x86_64 -q -L -n -N -d -M -A -a x86_64 -R e:/Cygwin64 -l e:/_cygwin64_repository -P ^
base-files,^
<pkg>,^
...
<last-pkg>

::=====


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]