[pacman-dev] [PATCH] Show 'Required By' in -Si output

Allan McRae allan at archlinux.org
Wed Oct 7 23:40:05 EDT 2009


Dan McGee wrote:
> On Wed, Oct 7, 2009 at 10:14 PM, Allan McRae <allan at archlinux.org> wrote:
>   
>> Dan McGee wrote:
>>     
>>> Just as we do in -Qi, we can compute required by information for sync
>>> database packages. The behavior seems sane; for a given package, the -Si
>>> required by will show all packages in *any* sync database that require it.
>>>
>>> Implements FS#16244.
>>>
>>> Signed-off-by: Dan McGee <dan at archlinux.org>
>>> ---
>>>  lib/libalpm/package.c |   46
>>> ++++++++++++++++++++++++++++++++++++----------
>>>  src/pacman/package.c  |   13 ++++---------
>>>  2 files changed, 40 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
>>> index de17166..b0b6480 100644
>>> --- a/lib/libalpm/package.c
>>> +++ b/lib/libalpm/package.c
>>> @@ -556,6 +556,21 @@ unsigned short SYMEXPORT
>>> alpm_pkg_has_scriptlet(pmpkg_t *pkg)
>>>        return pkg->scriptlet;
>>>  }
>>>  +static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t
>>> **reqs)
>>> +{
>>> +       const alpm_list_t *i;
>>> +       for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
>>> +               if(!i->data) {
>>> +                       continue;
>>> +               }
>>> +               pmpkg_t *cachepkg = i->data;
>>> +               if(_alpm_dep_edge(cachepkg, pkg)) {
>>> +                       const char *cachepkgname =
>>> alpm_pkg_get_name(cachepkg);
>>> +                       *reqs = alpm_list_add(*reqs,
>>> strdup(cachepkgname));
>>> +               }
>>> +       }
>>> +}
>>> +
>>>  /**
>>>  * @brief Compute the packages requiring a given package.
>>>  * @param pkg a package
>>> @@ -565,18 +580,29 @@ alpm_list_t SYMEXPORT
>>> *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
>>>  {
>>>        const alpm_list_t *i;
>>>        alpm_list_t *reqs = NULL;
>>> +       pmdb_t *db;
>>>  -       pmdb_t *localdb = alpm_option_get_localdb();
>>> -       for(i = _alpm_db_get_pkgcache(localdb); i; i = i->next) {
>>> -               if(!i->data) {
>>> -                       continue;
>>> -               }
>>> -               pmpkg_t *cachepkg = i->data;
>>> -               if(_alpm_dep_edge(cachepkg, pkg)) {
>>> -                       const char *cachepkgname =
>>> alpm_pkg_get_name(cachepkg);
>>> -                       reqs = alpm_list_add(reqs, strdup(cachepkgname));
>>> +       if(pkg->origin == PKG_FROM_FILE) {
>>> +               /* The sane option; search locally for things that require
>>> this. */
>>> +               db = alpm_option_get_localdb();
>>> +               fprintf(stderr, "db name: %s\n", db->treename);
>>> +               find_requiredby(pkg, db, &reqs);
>>> +       } else {
>>> +               /* We have a DB package. if it is a local package, then we
>>> should
>>> +                * only search the local DB; else search all known sync
>>> databases. */
>>> +               db = pkg->origin_data.db;
>>> +               if(db->is_local) {
>>> +                       fprintf(stderr, "db name: %s\n", db->treename);
>>> +                       find_requiredby(pkg, db, &reqs);
>>> +               } else {
>>> +                       for(i = handle->dbs_sync; i; i = i->next) {
>>> +                               db = i->data;
>>> +                               fprintf(stderr, "db name: %s\n",
>>> db->treename);
>>> +                               find_requiredby(pkg, db, &reqs);
>>> +                       }
>>>                }
>>>        }
>>> +
>>>        return(reqs);
>>>  }
>>>  diff --git a/src/pacman/package.c b/src/pacman/package.c
>>> index 3b14516..e7e2552 100644
>>> --- a/src/pacman/package.c
>>> +++ b/src/pacman/package.c
>>> @@ -83,10 +83,8 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
>>>                depstrings = alpm_list_add(depstrings,
>>> alpm_dep_compute_string(dep));
>>>        }
>>>  -       if(level>0) {
>>> -               /* compute this here so we don't get a pause in the middle
>>> of output */
>>> -               requiredby = alpm_pkg_compute_requiredby(pkg);
>>> -       }
>>> +       /* compute this here so we don't get a pause in the middle of
>>> output */
>>> +       requiredby = alpm_pkg_compute_requiredby(pkg);
>>>          /* actual output */
>>>        string_display(_("Name           :"), alpm_pkg_get_name(pkg));
>>> @@ -97,11 +95,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
>>>        list_display(_("Provides       :"), alpm_pkg_get_provides(pkg));
>>>        list_display(_("Depends On     :"), depstrings);
>>>        list_display_linebreak(_("Optional Deps  :"),
>>> alpm_pkg_get_optdepends(pkg));
>>> -       /* Only applicable if installed */
>>> -       if(level > 0) {
>>> -               list_display(_("Required By    :"), requiredby);
>>> -               FREELIST(requiredby);
>>> -       }
>>> +       list_display(_("Required By    :"), requiredby);
>>>        list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
>>>        list_display(_("Replaces       :"), alpm_pkg_get_replaces(pkg));
>>>        if(level < 0) {
>>> @@ -142,6 +136,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
>>>        printf("\n");
>>>          FREELIST(depstrings);
>>> +       FREELIST(requiredby);
>>>  }
>>>   /* Display the content of a sync package
>>>
>>>       
>> Looking at this, I can not see a way of turning it off.  I might be missing
>> something....
>>
>>     
>>> cd /var/abs
>>> grep -R "depends" {core,extra}/* | grep glibc | wc -l
>>>       
>> 365
>>     
>>> grep -R "depends" {core,extra}/* | grep perl | wc -l
>>>       
>> 237
>>
>> How many lines of output will that result in?
>>     
>
> Obviously glibc is the exception and not the rule, but yeah it is
> pretty big. I'm not saying this is the final patch; putting this in
> -Sii isn't a bad option (there is no such thing as -Sii right now
> however). That is why I submit here first. :)

I always like thinking about the worst case scenario.  And I was being 
ever so slightly facetious...    :P

> Required By    : archboot  aufs2-util  dhcpcd  erlang  fakeroot  gzip
>                  iptables  librpcsecgss  mlocate  nfs-utils  perl  popt
>                  wpa_actiond  attr  b43-fwcutter  bash  bin86  binutils  bison
>                  bridge-utils  bzip2  coreutils  cpio  cracklib  dcron
>                  device-mapper  dhcpcd  diffutils  ed  eventlog  expat
>                  fakeroot  file  findutils  flex  gawk  gcc-libs  gdbm
>                  gen-init-cpio  grep  gzip  hdparm  ifenslave  initscripts
>                  iptables  iputils  kbd  libcap  libevent  libgpg-error  libnl
>                  libpcap  librpcsecgss  libtirpc  linux-atm  lzo2  m4  mailx
>                  make  mdadm  mlocate  module-init-tools  nano  ncurses
>                  ndiswrapper-utils  net-tools  nfs-utils  nfsidmap  pam  patch
>                  pciutils  pcmciautils  perl  pkgconfig  popt  ppp  pptpclient
>                  procinfo  psmisc  readline  rpcbind  run-parts  sdparm  sudo
>                  sysfsutils  sysvinit  tar  tcp_wrappers  udev  usbutils  wget
>                  which  wireless_tools  wlan-ng26-utils  zlib  a52dec  aalib
>                  acct  acpi  acpid  alsa-lib  alsa-oss  anthy  antiword
>                  archboot  arj  audiofile  aufs2-util  babl  barcode  beep
>                  bftpd  biogrep  biopython  bladeenc  c-ares  cabextract
>                  capi4hylafax  capi4k-utils  catdoc  ccache  cd-discid  cdargs
>                  cdparanoia  chmlib  compface  cpudyn  ctags  dbh  dcfldd  di
>                  diffstat  dmapi  dmidecode  dnsmasq  docker  dosfstools
>                  dvdrtools  eject  enscript  erlang  ethtool  faac  faad2
>                  fbset  fetchmail  fftw  fftw2  figlet  flac  flite  fping
>                  fribidi  ftjam  fuse  glib  gnu-netcat  gnuchess  gnugo  gocr
>                  gpart  gsl  hddtemp  hdup  help2man  hexedit  hping  hspell
>                  httptunnel  i8kutils  icmake  id3v2  imake  indent
>                  isapnptools  jhead  joe  latex2rtf  lcab  lensfun  libao
>                  libart-lgpl  libburn  libcdaudio  libcddb  libchewing
>                  libdaemon  libdatrie  libdrm  libdvbpsi  libdvdcss
>                  libdvdread  libelf  libexif  libffi  libfs  libhangul
>                  libical  libice  libidn  libixp  libjpeg  libksba  liblo
>                  liblqr  libmad  libmcrypt  libmikmod  libmowgli  libmpcdec
>                  libmpdclient  libmpeg2  libmspack  libmusepack  libmythes
>                  libnet  libnova  libogg  liboil  libpciaccess  libproxy
>                  libraw1394  libsigsegv  libstroke  libtasn1  libusb1  libv4l
>                  libvisual  libx86  libxau  libxdmcp  libxmi  libytnef
>                  link-grammar  linux_logo  lpsolve  lsof  ltrace  lxsplit  lzo
>                  m17n-db  mcpp  mhash  mp3wrap  mpck  mpg123  mt-st  mtx
>                  muparser  nasm  ne  netkit-bsd-finger  netselect  nspr
>                  nss-mdns  ntfs-3g  ntfsprogs  openal  openjpeg  openslp
>                  pdksh  perl-term-readkey  pixman  pm-utils  potrace  procmail
>                  proftpd  psutils  pth  pwgen  pyogg  qstat  razor  rcs
>                  recode  rpmunpack  rssh  sbcl  sdl  setserial  sg3_utils
>                  silc-toolkit  slang  snarf  squashfs-tools  srm  strace
>                  streamripper  sysklogd  syslinux  tcl  tidyhtml  time  tpb
>                  tree  tsocks  unarj  unison  v86d  valgrind  vconfig  vsftpd
>                  watchdog  wavpack  wipe  wmii  xf86-input-aiptek
>                  xf86-input-calcomp  xf86-input-citron  xf86-input-digitaledge
>                  xf86-input-dmc  xf86-input-dynapro  xf86-input-elo2300
>                  xf86-input-elographics  xf86-input-evdev  xf86-input-fpit
>                  xf86-input-hyperpen  xf86-input-jamstudio
>                  xf86-input-joystick  xf86-input-keyboard  xf86-input-magellan
>                  xf86-input-magictouch  xf86-input-microtouch
>                  xf86-input-mouse  xf86-input-mutouch  xf86-input-palmax
>                  xf86-input-penmount  xf86-input-spaceorb  xf86-input-summa
>                  xf86-input-tek4957  xf86-input-ur98  xf86-input-vmmouse
>                  xf86-input-void  xf86-video-apm  xf86-video-ark
>                  xf86-video-chips  xf86-video-cirrus  xf86-video-dummy
>                  xf86-video-fbdev  xf86-video-glint  xf86-video-i128
>                  xf86-video-i740  xf86-video-mach64  xf86-video-mga
>                  xf86-video-neomagic  xf86-video-nv  xf86-video-r128
>                  xf86-video-radeonhd  xf86-video-rendition  xf86-video-s3
>                  xf86-video-s3virge  xf86-video-savage
>                  xf86-video-siliconmotion  xf86-video-sis  xf86-video-sisusb
>                  xf86-video-tdfx  xf86-video-trident  xf86-video-tseng
>                  xf86-video-v4l  xf86-video-vesa  xf86-video-vga
>                  xf86-video-vmware  xf86-video-voodoo  xsnow  xtermcontrol
>                  xvidcore  yasm  yp-tools  zip  nvidia-cg-toolkit  adns
>                  anacron  apg  arpack  aumix-gtk  axel  bbpager  bchunk
>                  bin2iso  binutils-avr  calc  ccd2iso  ccrypt  chrootuid
>                  chrpath  cksfv  confuse  cross-arm-elf-binutils
>                  cross-arm-wince-cegcc-cegccdll
>                  cross-arm-wince-cegcc-cegccdll-dummy
>                  cross-arm-wince-cegcc-cegccthrddll
>                  cross-arm-wince-cegcc-docs  cross-arm-wince-cegcc-gcc-base
>                  cross-arm-wince-cegcc-importlibs
>                  cross-arm-wince-cegcc-libstdcppdll
>                  cross-arm-wince-cegcc-newlib  cross-arm-wince-cegcc-profile
>                  cross-arm-wince-cegcc-w32api  cutter  cvs-feature  darkhttpd
>                  datemath  dgpsip  docbook2x  duff  dumb  eina-svn  embryo-svn
>                  esekeyd  fcrackzip  floyd  freedroid  gavl  gnustep-make
>                  hashcash  iasl  iniparser  inputattach  ircservices  jbigkit
>                  jdk  jre  libasyncns  libcgi  libdlna  libev  libmemcached
>                  libnfnetlink  libnsbmp  libnsgif  libparserutils  librcd
>                  libtextcat  libtlen  libtrash  libupnp  libvc  libxdg-basedir
>                  linuxtv-dvb-apps  mdf2iso  mingw32-binutils  moreutils
>                  mp3gain  mxml  nemesis  nrg2iso  oidentd  optipng  pdnsd
>                  pptpd  pv  pyid3lib  recoverdm  sarg  scponly
>                  selinux-coreutils  selinux-flex  selinux-pam
>                  selinux-sysvinit  ser2net  shapelib  shfs-utils  simh  splint
>                  sshguard  stegdetect  swarp  synce-libsynce  synce-rra
>                  sysstat  t1utils  tclgeomap  tinycdb  toolame  tre
>                  ultimate-ircd  unrtf  uptimed  ustr  visitors  xmms-volnorm
>                  xvkbd

Should these be sorted?  They are currently sorted within each repo so 
it will be quite a simple operation.

Allan




More information about the pacman-dev mailing list