cvs commit: hints dependency.txt

timothy at linuxfromscratch.org timothy at linuxfromscratch.org
Sun Sep 29 08:04:21 PDT 2002


timothy     02/09/29 08:04:21

  Added:       .        dependency.txt
  Log:
  Initial commit.
  
  Revision  Changes    Path
  1.1                  hints/dependency.txt
  
  Index: dependency.txt
  ===================================================================
  TITLE:		Resolving Dependencies
  LFS VERSION:	BLFS Book 09/20/2002
  AUTHOR:		Joern Abatz <joern at abatz.de>
  
  SYNOPSIS:
  	This helps to install packages from the BLFS book in the right sequence.
  
  	This hint consists of:
  	- Additional packages to resolve open dependencies in the BLFS book
  	- Package list from the BLFS book (with additions and dependencies)
  	- Program to resolve dependencies before installing packages
  
  HINT:
  
  Dependency Hint 09/29/2002
  ==========================
  
  The LFS book can be worked through from top to bottom, but the BLFS book can
  not. If you go through it, you will get to a point (namely where all the X11
  software begins) where you get error messages because you have to install other
  packages first, some of which are located at a lower position in the book, some
  of the packages you would need, are not done yet, and some packages are not
  covered by the book at all yet.
  	
  I tried to bring the packages into the appropriate order by hand, but I found,
  that was a bit more work than I had thought. So I wrote a little program that
  does it for me.
  
  
  Overview:
  =========
  
  Part 1 is a list of additional packages and their download locations which are
  mentioned in the BLFS book, but are not covered yet. If you download all of the
  packages below, you should be able to resolve the open dependencies in your
  BLFS system. (WARNING: I did not yet install all those tarballs myself, so there
  might be some new problems.)
  
  Part 2 is a list of the packages with the additional packages from part 1,
  with dependencies. It can be re-sorted with the program in part 3, giving
  a list that can be installed top to bottom without dependency problems.
  
  Part 3 is a short program that takes 3 lists:
  - the dependency list from part 2
  - a "wishlist", i.e. packages you want to install (one word per line, no spaces)
  - a list of packages already installed (optional)
  
  The Program then produces a list of packages you need to install to fill the
  dependencies of the wishlist. The output list is named result.txt.
  
  
  Virtual packages and omitted dependencies:
  ==========================================
  
  There is one package name in the list in part 2, that does not exist: alsa.
  I put it in, because there are packages in the BLFS book, that depend on the
  package "alsa". Let's call alsa a "virtual package". It depends on 4 other
  packages: alsa-driver, alsa-lib, alsa-utils, alsa-tools, but it doesn't have
  it's own tarball. If you install those 4 packages, you have installed "alsa".
  
  The following dependencies from the BLFS book are not contained in this hint:
  - oss (because I prefer alsa, and oss was an optional dependency anyway)
  - medusa (because I did not find it, and it's also an optional dependency)
  
  
  How to work with the program:
  =============================
  
  1. First write a list with all the packages you already have, named "inst.txt".
  
  2. Then write a list of packages you want to install and save it as "wish.txt".
  
  If you want to install everything, say:
  
  cp deps.txt wish.txt
  > inst.txt
  
  3. Then call:
  
  ./depsort
  
  4. That produces an ordered list in a file named "result.txt", that you can
  use to install.
  
  
  To be done:
  ===========
  
  - Handle version information
  - Distinguish between "depends on" and "will utilize"
  - Create "deps.txt" automatically from the BLFS book (better: from the tarballs
    in a directory, or - ultimately - from all the tarballs available on the
    internet ;-)
  
  
  
  Part 1: Additional Packages and download locations:
  ===================================================
  
  zlib-1.1.4
  http://www.gzip.org/zlib/zlib-1.1.4.tar.gz
  
  expat-1.95.5
  expat-1.95.5.tar.gz
  http://sourceforge.net/projects/expat/
  
  readline-4.3
  ftp://ftp.cwru.edu/pub/bash/readline-4.3.tar.gz
  
  openldap-2.0.25
  ftp://ftp.nl.uu.net/pub/unix/db/openldap/openldap-stable/openldap-stable-20020618.tgz
  
  sane-1.0.8
  ftp://ftp.de.mostang.com/pub/sane/sane-1.0.8/sane-backends-1.0.8.tar.gz
  ftp://ftp.de.mostang.com/pub/sane/sane-1.0.8/sane-backends-1.0.8.lsm
  ftp://ftp.de.mostang.com/pub/sane/sane-1.0.8/sane-frontends-1.0.8.tar.gz
  ftp://ftp.de.mostang.com/pub/sane/sane-1.0.8/sane-frontends-1.0.8.lsm
  
  nas-1.5
  http://radscan.com/nas/nas-1.5.src.tar.gz
  
  nasm-0.98.35-1
  nasm-0.98.35.tar.bz2
  http://nasm.sourceforge.net/
  
  directfb-0.9.13
  http://www.directfb.org/download/DirectFB/DFB++-0.9.13.tar.gz
  http://www.directfb.org/download/DirectFB/DFBTutorials-0.5.0.tar.gz
  http://www.directfb.org/download/DirectFB/DirectFB-0.9.13.tar.gz
  http://www.directfb.org/download/DirectFB/DirectFB-examples-0.9.9.tar.gz
  http://www.directfb.org/download/DirectFB-extra/DirectFB-extra-0.9.13.tar.gz
  http://www.directfb.org/download/XDirectFB/XDirectFB-1.0-rc2.tar.gz
  
  x11-ssh-askpass-1.2.4.1
  http://www.ntrnet.net/~jmknoble/software/x11-ssh-askpass/x11-ssh-askpass-1.2.4.1.tar.gz
  http://www.ntrnet.net/~jmknoble/software/x11-ssh-askpass/README
  
  libghttp-1.0.9
  http://www.ibiblio.org/pub/Linux/X11/gnome/sources/libghttp/libghttp-1.0.9.tar.gz
  http://www.ibiblio.org/pub/Linux/X11/gnome/sources/libghttp/libghttp-1.0.9.tar.gz.md5
  
  openjade-1.3.1
  http://prdownloads.sourceforge.net/openjade/openjade-1.3.1.tar.gz
  
  guile-1.0.6
  ftp://ftp.gnu.org/pub/gnu/guile/guile-1.6.0.tar.gz
  ftp://ftp.gnu.org/pub/gnu/guile/md5sum
  
  xscreensaver-4.05
  http://www.jwz.org/xscreensaver/xscreensaver-4.05.tar.gz
  These commands were on the website:
  gzip -dc xscreensaver-4.05.tar.gz | tar -vxf -
  cd xscreensaver-4.05/
  ./configure
  make
  make install
  
  stlport-4.5.3
  http://www.stlport.org/archive/STLport-4.5.3.tar.gz
  
  libmikmod-3.1.10
  http://www.sourceforge.net
  depends on esound (optional) oss (optional)
  
  gtm-0.4.12
  http://prdownloads.sourceforge.net/gtm/gtm-0.4.12.tar.gz
  
  mozilla-1.2a
  http://ftp.mozilla.org/pub/mozilla/releases/mozilla1.2a/src/mozilla-source-1.2a.tar.bz2
  
  
  Part 2: List of Packages with dependencies:
  ===========================================
  
  The first word on each line is the package to be installed.
  The following words are the packages it depends on.
  The words must be separated by one space only.
  Leading or trailing whitespace is not allowed.
  
  ----- start of file deps.txt -----
  alsa alsa-driver alsa-lib alsa-utils alsa-tools
  alsa-driver
  alsa-lib
  alsa-tools alsa-lib
  alsa-utils alsa-lib
  apache
  arts qt
  atk glib2 gtk-doc
  audiofile
  bc
  bind
  bonobo-activation orbit2 gtk-doc
  bug-buddy libgnomeui
  cdparanoia-iii
  cdrdao pccts
  cdrtools
  control-center gnome-desktop xscreensaver gtk-doc
  cpio
  cups
  curl openssl openldap
  cvs
  daemontools daemontools-man
  daemontools-man
  db3
  db4
  dhcp
  dhcpcd
  directfb
  docbook
  eel libgnomeui
  emacs
  enlightenment xfree86 imlib fnlib freetype xfree86 gtk+1 esound libghttp
  eog libgnomeui libgnomeprint
  esound audiofile
  exim db4
  expat
  fcron sendmail
  fetchmail openssl procmail
  fluxbox xfree86
  fnlib imlib
  freetype
  freetype2
  gail gtk+2 libgnomecanvas
  galeon gnome-libs oaf gconf10 gnome-vfs1 libxml libglade2 gdk-pixbuf intltool mozilla gtm
  gcc
  gconf10 oaf db3 guile
  gconf12 orbit2 gtk-doc
  gdbm
  gdk-pixbuf glib1 gtk+1 libpng libjpeg libtiff gtk-doc gnome-libs
  gedit libgnomeui
  glib1
  glib2 pkgconfig gtk-doc
  gmp readline
  gnat tcsh
  gnome-applets gail gnome-panel
  gnome-common pkgconfig
  gnome-desktop libgnomeui
  gnome-games libgnomeui guile
  gnome-libs orbit gtk+1 imlib db4 audiofile esound gtk-doc
  gnome-media libgnomeui
  gnome-mime-data
  gnome-panel libgnomeui gtk-doc
  gnome-session libgnomeui
  gnome-system-monitor libgnomeui
  gnome-terminal libgnomeui
  gnome-utils libgnomeui
  gnome-vfs1 gconf10 gnome-libs openssl gtk-doc cdparanoia-iii
  gnome-vfs2 orbit2 gconf12 bonobo-activation gnome-mime-data libfam openssl cdparanoia-iii
  gnome2-user-docs scrollkeeper
  gpm
  gtk+1 glib1 libpng libtiff libjpeg
  gtk+2 glib2 pango atk libpng libtiff libjpeg gtk-doc
  gtk-doc openjade
  gtk-engines gtk+2
  gtm
  guile
  hdparm
  imlib xfree86 libjpeg libtiff libungif libpng glib1 gtk+1
  intltool
  iptables
  j2sdk xfree86 zip unzip cpio tcsh
  joe
  kdebase openssl lesstif cdparanoia-iii libvorbis shadow cups
  kdeaddons kdebase
  kdeadmin kdebase rpm shadow pam
  kdeartwork kdebase
  kdeedu kdebase
  kdegames kdebase
  kdegraphics kdebase which imlib sane
  kdelibs openssl alsa pcre libxml libxslt cups arts
  kdemultimedia kdebase
  kdenetwork kdebase
  kdepim kdebase pilot-link
  kdetoys kdebase
  kdeutils kdebase
  lame
  lcms
  leafnode pcre
  lesstif
  libao
  libart_lgpl
  libbonobo orbit2 bonobo-activation gtk-doc
  libbonoboui libgnome libbonobo libgnomecanvas
  libfam
  libghttp
  libglade2 libxml2 gtk+2 gnome-libs python expat
  libgnome esound audiofile orbit2 gconf12 bonobo-activation libxslt
  libgnomecanvas libglade2
  libgnomeprint libbonobo libart_lgpl gtk-doc
  libgnomeprintui libgnomeprint libgnomeui
  libgnomeui libgnome libgnomecanvas libbonoboui gtk-doc
  libgtkhtml gail gnome-vfs2
  libgtop glib2
  libidl glib2
  libjpeg
  libmikmod esound
  libmng zlib libjpeg lcms
  libogg
  libpng zlib
  librep gmp gdbm readline
  librsvg gtk+2 libxml libart_lgpl
  libtiff
  libungif
  libvorbis libogg
  libwnck gtk+2
  libxml zlib
  libxml2 zlib
  libxslt libxml2
  libzvt gtk+2 libart_lgpl
  linc glib2 gtk-doc openssl
  links openssl gpm
  lynx openssl zlib
  mozilla
  mpg123 alsa
  mutt
  mysql
  nano
  nas
  nasm
  nautilus libgnomeui
  ncftp
  nmap
  oaf orbit libxml gtk-doc
  openjade
  openldap
  openoffice freetype xfree86 j2sdk zip unzip tcsh db4 stlport
  openssh zlib openssl x11-ssh-askpass pam
  openssl
  orbit popt glib1
  orbit2 glib2 linc libidl popt
  pam
  pango glib2 freetype qt gtk-doc
  pccts
  pciutils
  pcre
  pilot-link
  pine
  pkgconfig
  popt
  portmap tcpwrappers
  postfix db4
  postgresql
  ppp
  procmail
  python expat
  qmail
  qpopper sendmail
  qt xfree86 libpng libmng libjpeg
  readline
  rep-gtk gtk+2 librep libglade2
  rpm
  ruby
  samba
  sane
  sawfish-gtk1 xfree86 imlib gdk-pixbuf librep gtk+1 rep-gtk audiofile esound libglade2
  sawfish-gtk2 xfree86 imlib librep rep-gtk gtk+2 audiofile libglade2 esound
  scrollkeeper libxml2 libxslt intltool docbook
  sdl alsa esound arts nas nasm xfree86 directfb
  sendmail db4 procmail
  shadow
  slang
  slrn slang sendmail
  stlport
  tcpwrappers
  tcsh
  telnet
  tex
  traceroute
  ucspi-tcp
  unzip
  vorbis-tools curl libao libogg libvorbis
  w3m
  wget openssl
  which
  whois
  wvdial wvstreams ppp
  wvstreams
  x11-ssh-askpass
  xfce xfree86 gtk+1 glib1 gdk-pixbuf imlib libpng libjpeg libungif
  xfree86
  xinetd
  xmms xfree86 gtk+1 glib1 esound gnome-libs gnome-applets libmikmod libogg libvorbis libxml
  xscreensaver
  yelp libgnomeui
  zip
  zlib
  ----- end of file deps.txt -----
  
  
  
  Part 3: C-Program to sort a Dependencies File (e.g. from Part 2):
  =================================================================
  
  Save it to depsort.c, then say:
  
  make depsort
  
  Run it with:
  
  ./depsort
  
  It needs the files deps.txt, inst.txt and wish.txt. It writes a file result.txt.
  
  
  ----- start of file depsort.c -----
  #include <stdlib.h>
  #include <stdio.h>
  #include <string.h>
  
  typedef struct { char *str; void* next; } REC;
  typedef struct { REC *first; int num; } LIST;
  
  int list_init(LIST *list)
  {
      list->first = NULL;
      list->num = 0;
      return 0;
  }
  
  int list_free(LIST *list)
  {
      int n = 0;
      REC *p, *q;
      
      p = q = list->first;
      while(p)
      {
  	free(p->str);
  	q = p->next;
  	free(p);
  	p = q;
  	n++;
      }
      list_init(list);
      
      return n;
  }
  
  REC *rec_get(LIST *list, int pos)
  {
      REC *p;
      int i;
      
      p = list->first;
      i = 0;
      for(i = 0; i < pos; i++)
  	p = p->next;
      return p;
  }
  
  int list_length(LIST *list)
  {
      int n = 0;
      REC *p;
      
      p = list->first;
      while(p)
      {
  	n++;
  	p = p->next;
      }
      list->num = n;    
      return n;
  }
  
  char *str_get(LIST *list, int pos)
  {
      return rec_get(list, pos)->str;
  }
  
  int str_pos(LIST *list, char *str)
  {
      int pos = 0;
      int found = -1;
      
      for(pos = 0; pos < list->num; pos++)
      {
  	if(strcmp(str_get(list, pos), str) == 0)
  	{
  	    found = pos;
  	    pos = list->num;
  	}
      }
      return found;
  }
  
  char *word_get(LIST *list, int strpos, int wordpos, char *word, int len)
  {
      char *str, *p;
      int i;
  
      p = str = str_get(list, strpos);
      for(i = 0; i < wordpos; i++)
      {
  	p = (char *)strchr(p, ' ');
  	if(p)
  	    p++;
      }
  
      if(p)
      {
  	strncpy(word, p, len);
  	word[len - 1] = '\0';
  	if(p = (char *)strchr(word, ' '))
  	    *p = '\0';
  	return word;
      }
  
      return NULL;
  }
  
  int word_pos(LIST *list, int strpos, char *word)
  {
      char *str, *off, *p;
      int i = 0;
      int found = -1;
  
      str = str_get(list, strpos);
      off = strstr(str, word);
      if(off)
      {
  	found = -2;
  	p = str;
  	while(p && found < 0)
  	{
  	    if(p == off)
  		found = i;
  	    p = strchr(p, ' ');
  	    if(p)
  		p++;
  	    i++;
  	}
      }
      return found;
  }
  
  int head_pos(LIST *list, char *word)
  {
      int i = 0;
      int pos;
      int found = -1;
      int nlist = list->num;
  
      while(i < nlist && found < 0)
      {
  	pos = word_pos(list, i, word);
  	if(pos == 0)
  	    found = i;
  	i++;
      }
  
      return found;
  }
  
  int str_put(LIST *list, char *str, int pos)
  {
      strcpy(rec_get(list, pos)->str, str);
      return pos;
  }
  
  int str_append(LIST *list, char *str)
  {
      REC *p, *q;
  
      p = q = list->first;
      while(p)
      {
  	q = p;
  	p = p->next;
      }
  
      if(q)
      {
  	q->next = (REC *)malloc(sizeof(REC));
  	((REC *)q->next)->str = (char *)malloc(strlen(str) + 1);
  	strcpy(((REC *)q->next)->str, str);
  	((REC *)q->next)->next = NULL;
  	list->num++;
      }
      else
      {
  	p = (REC *)malloc(sizeof(REC));
  	p->str = (char *)malloc(strlen(str) + 1);
  	strcpy(p->str, str);
  	p->next = NULL;
  	list->first = p;
  	list->num = 1;
      }
      return list_length(list);
  }
  
  int str_delete(LIST *list, int pos)
  {
      REC *p, *q;
      
      if(pos)
      {
  	p = rec_get(list, pos - 1);
  	q = rec_get(list, pos);
  	p->next = q->next;
  	free(q->str);
  	free(q);
  	list->num--;
      }
      else
      {
  	p = rec_get(list, 0);
  	list->first = p->next;
  	list->num--;
  	free(p->str);
  	free(p);
      }
      
      return list_length(list);
  }
  
  int list_read(LIST *list, char *file)
  {
      int n = 0;
      FILE *f;
      char line[1024];
      char *pstr;
  
      if(f = fopen(file, "r"))
      {
  	while(fgets(line, sizeof(line), f))
  	{
  	    if(pstr = (char*)strchr(line, '\n'))
  		*pstr = '\0';
  	    str_append(list, line);
  	    n++;
  	}
  	fclose(f);
      }
      return n;
  }
  
  int list_write(LIST *list, char *file)
  {
      int i;
      FILE *f;
      
      if(f = fopen(file, "w"))
      {
  	for(i = 0; i < list->num; i++)
  	    fprintf(f, "%s\n", str_get(list, i));
  	fclose(f);
      }
  
      return list->num;
  }
  
  
  int main(void)
  {
      /* input lists: */
      LIST deps; // all packages with dependencies
      LIST inst; // installed packages, with or without dependencies
      LIST wish; // packages to be checked, with or without dependencies
  
      /* output lists: */
      LIST done; // resolved wishlist, install the packages in that order
      LIST imp; // impossible to resolve, deps file has errors
      LIST rest; // still unresolved, should be empty after prog run
      LIST result;
  
      char pkg[1024]; // package name
      char tmp[1024];
      char *depword;
      int isdone;
      int isimp;
      int numrest;
      int irest, iwish, iinst, idone, ideps, depcol, iresult;
      int numdone;
      int i;
      int pos;
      
      list_init(&deps);
      list_init(&inst);
      list_init(&wish);
      list_init(&rest);
      list_init(&done);
      list_init(&imp);
      list_init(&result);
      
      /* read input files */
      list_read(&deps, "deps.txt");
      if(!deps.num)
  	printf("depsort needs file deps.txt (available packages with dependencies)\n");
      list_read(&inst, "inst.txt");
      list_read(&wish, "wish.txt");
      printf("lines read: deps=%d inst:=%d wish:=%d\n\n", deps.num, inst.num, wish.num);
  
      /* copy wish to rest */
      for(iwish = 0; iwish < wish.num; iwish++)
  	str_append(&rest, word_get(&wish, iwish, 0, tmp, sizeof(tmp)));
  
      /* go through rest: put package to done, to impossible, or leave there */
      /* we are finished when rest does not shrink any more */
      numrest = rest.num + 1; // just to make them unequal
      while(numrest > rest.num)
      {
  	numrest = rest.num;
  	irest = 0;
  	while(irest < rest.num)
  	{
  	    word_get(&rest, irest, 0, pkg, sizeof(pkg));
  	    isdone = 1;
  	    isimp = 0;
  	    ideps = head_pos(&deps, pkg);
  	    depcol = 1;
  	    while(depword = word_get(&deps, ideps, depcol, tmp, sizeof(tmp)))
  	    {
  		if(head_pos(&deps, depword) < 0)
  		{
  		    isimp = 1;
  		    isdone = 0;
  		    printf("unresolved: %s (misses %s)\n", pkg, depword);
  		}
  
  		if(!isimp)
  		{
  		    if(str_pos(&done, depword) < 0)
  		    {
  			isdone = 0;
  			if(str_pos(&imp, depword) < 0)
  			{
  			    pos = str_pos(&rest, depword);
  			    if(pos < 0)
  			    {
  				str_append(&rest, depword);
  				numrest = rest.num + 1;
  			    }
  			}
  		    }
  		}
  
  		depcol++;
  	    }
  	    
  	    if(isdone)
  	    {
  		str_append(&done, pkg);
  		str_delete(&rest, irest);
  		irest--;
  	    }
  	    
  	    if(isimp)
  	    {
  		str_append(&imp, pkg);
  		str_delete(&rest, irest);
  		irest--;
  	    }
  	    
  	    irest++;
  	}
      }
      printf("\n");
  
      /* write output files */
      
      for(idone = 0; idone < done.num; idone++)
      {
  	strcpy(pkg, str_get(&done, idone));
  	if(head_pos(&inst, pkg) < 0)
  	    str_append(&result, pkg);
      }
      list_write(&result, "result.txt");
  
      if(rest.num)
      {
  	printf("depending on unresolved packages:\n\n");
  	for(irest = 0; irest < rest.num; irest++)
  	    printf("%s\n", str_get(&rest, irest));
  	printf("\n");
      }
  
      printf("resolved packages:\n\n");
      for(iresult = 0; iresult < result.num; iresult++)
  	printf("%s\n", str_get(&result, iresult));
      printf("\n");
      printf("%d packages resolved\n", result.num);
  
      /* free the list */
      list_free(&deps);
      list_free(&inst);
      list_free(&wish);
      list_free(&rest);
      list_free(&done);
      list_free(&imp);
      list_free(&result);
          
      return 0;
  }
  ----- end of file depsort.c -----
  
  
  (end of hint)
  
  
  
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe hints' in the subject header of the message



More information about the hints mailing list