anyway to rebuild /var/sadm/install/contents ?

anyway to rebuild /var/sadm/install/contents ?

Post by Vibhavasu Vuppa » Fri, 23 Jul 1993 01:06:08



Hi,

  Env : Solaris 2.2, 690MP

Is there anyway to rebuild /var/sadm/install/contents ?
It seems to have got corrupted.

Thanks in advance !

- vasu

 
 
 

anyway to rebuild /var/sadm/install/contents ?

Post by Casper H.S. D » Sat, 24 Jul 1993 23:40:26


vupp...@cuttlefish.msu.edu (Vibhavasu Vuppala) writes:
>Hi,
>  Env : Solaris 2.2, 690MP
>Is there anyway to rebuild /var/sadm/install/contents ?
>It seems to have got corrupted.
>Thanks in advance !

I've written a small program that will partially recover the contents
file from /var/sadm/pkg/*/pkg{map,info}

Casper

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#               "End of shell archive."
# Contents:  README Makefile main.c pkgdb.c pkgdb.h
# Wrapped by casper@mail on Fri Jul 23 16:37:10 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(441 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XThe pkgmake program will try to recreate most of /var/sadm/install/contents
Xfrom /var/sadm/pkg/*/{pkgmap,pkginfo}
X
XThis program will not:
X
X       - use the same sort order as the pkg programs,
X         running it through sort may/may not help.
X       - find the files installed with installf in the postinstall
X         script
X
XIf the contents file generated in this way doesn't work with the package
Xutilities, please let me know.
X
X
XCasper Dik (cas...@fwi.uva.nl)
END_OF_FILE
if test 441 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(209 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
XOBJS=main.o pkgdb.o
X.KEEP_STATE:
XCFLAGS=-O
XLDFLAGS=
X
Xpkgmake: $(OBJS)
X       $(LINK.c) -o $@ $(OBJS) $(LDLIBS)
X
XPACK=README Makefile $(OBJS:.o=.c)  pkgdb.h
Xshar :pkg.shar
X
Xpkg.shar: $(PACK)
X       shar $(PACK) > pkg.shar
END_OF_FILE
if test 209 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'main.c' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'main.c'\"
else
echo shar: Extracting \"'main.c'\" \(2406 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
X/*
X * /var/sadm/install/contents database regeneration tool
X *
X * Casper Dik, 1993.
X *
X * Usage: program [ /var/sadm/pkg [ pkg ] ]
X *
X * The default is adding packages in the order they were loaded
X * originally.
X *
X * Bugs: installf commands in postinstall scripts aren't executed.
X *      the output isn't totally sorted.
X */
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <dirent.h>
X#include <unistd.h>
X#include <stdlib.h>
X#include <malloc.h>
X#include "pkgdb.h"
X
Xchar defname[] = "/var/sadm/pkg";
X
Xtypedef struct entry {
X    char name[256];
X    struct stat info;
X} entry;
X
Xstatic int comp(const void *, const void *);
X
Xint
Xmain(int argc, char **argv)
X{
X    pkgdb_t db;
X    char *name;
X    int i = 0;
X    int cnt = 0;
X    struct entry *pkgs;
X    DIR *dir;
X    struct dirent *de;
X
X    if (argc == 1)
X       name = defname;
X    else
X       name = argv[1];
X    if (*name != '/') {
X       fprintf(stderr,"pkgdir must be an absolute pathname\n");
X       exit(1);
X    }
X    
X    if (chdir(name) == -1) {
X       perror(name);
X       exit(1);
X    }
X
X    db = newpkgdb(name);
X
X    if (db == 0) {
X       fprintf(stderr,"can't create database\n");
X       exit(1);
X    }
X    if (argc > 2) {
X       int off = 2;
X       cnt = argc - off;
X       pkgs = (struct entry *) malloc(sizeof(struct entry) * cnt);
X       for (i = 2; i < argc ; i++) {
X           strcpy(pkgs[i-off].name, argv[i]);
X           if (stat(argv[i],&pkgs[i-off].info) != 0)
X               off++;
X       }
X       cnt = argc - off;
X    } else {
X       dir = opendir(".");
X       for (;de = readdir(dir); ) {
X           i++;
X       }
X       rewinddir(dir);
X       cnt = i - 2;
X       i = 0;
X       pkgs = (struct entry *) malloc(sizeof(struct entry) * cnt);
X       for (;de = readdir(dir); ) {
X           if (i > cnt) {
X               fprintf(stderr,"Directory grows\n");
X               break;
X           }
X           if (de->d_name[0] == '.' && (de->d_name[1] == '\0' ||
X                   (de->d_name[1] == '.' && de->d_name[2] == '\0')))
X               continue;
X           if (stat(de->d_name,&pkgs[i].info) == 0 &&
X                   S_ISDIR(pkgs[i].info.st_mode)) {
X               strcpy(pkgs[i++].name,de->d_name);
X           }
X       }
X       closedir(dir);
X       cnt = i;
X    }
X    qsort(pkgs, (size_t) cnt, sizeof(struct entry), comp);
X    for (i = 0; i < cnt; i++) {
X       if (add_pkg(db, pkgs[i].name) == 0)
X           fprintf(stderr, "Added %s\n", pkgs[i].name);
X    }
X    print_db(stdout, db);
X    exit(0);
X}
X
Xstatic int comp(const void *p1, const void *p2)
X{
X    struct entry *pkg1 = (struct entry *)p1;
X    struct entry *pkg2 = (struct entry *)p2;
X
X    return difftime(pkg1->info.st_mtime, pkg2->info.st_mtime);
X}
END_OF_FILE
if test 2406 -ne `wc -c <'main.c'`; then
    echo shar: \"'main.c'\" unpacked with wrong size!
fi
# end of 'main.c'
fi
if test -f 'pkgdb.c' -a "${1}" != "-c" ; then
  echo shar: Will not clobber existing file \"'pkgdb.c'\"
else
echo shar: Extracting \"'pkgdb.c'\" \(12143 characters\)
sed "s/^X//" >'pkgdb.c' <<'END_OF_FILE'
X/*
X * Pkgdb recreation program.
X *
X * Casper Dik, 1993
X *
X * There doesn't seem te be a lot of comment in this file.
X *
X */
X
X#include <string.h>
X#include <unistd.h>
X#include <stdio.h>
X#include <fcntl.h>
X#include <ctype.h>
X#include <stdlib.h>
X#include <sys/types.h>
X#include <sys/mman.h>
X#include <sys/param.h>
X#include <sys/stat.h>
X
X#include "pkgdb.h"
X
Xtypedef struct package {
X    char *map, *name, *path, *lastvar, *basedir;
X    int size;
X} package;
X
Xtypedef struct stringlist {
X    struct stringlist *next;
X    char *name;
X} stringlist;
X
Xstatic stringlist *pkgclasses, *names, *pkgnames;
X
Xtypedef struct pkgmapline {
X    char ftype;
X    char *class, *path, *link, *mode, *major, *minor, *owner, *group,
X           *size, *cksum, *modtime;
X    char *pkgname;
X    struct pkgmapline *next;
X} pkgmapline;
X
Xtypedef struct fileinfo {
X    struct pkgmapline *first, *last;   /* add at the end */
X    struct fileinfo *next;             /* if a file, tail of file list */
X    struct fileinfo *files;            /* the files in this directory,
X                                          alfasort */
X    char *name;                                /* base name of current file */
X    int namelength;                    /* length of that name */
X} fileinfo;
X
Xstatic void del_pkg(package *pkg)
X{
X    if (pkg->map != 0 && pkg->map != (char*) -1)
X       munmap(pkg->map, pkg->size);
X
X    if (pkg->path)
X       free(pkg->path);
X    if (pkg->basedir)
X       free(pkg->basedir);
X    free(pkg);
X}
X
Xstatic char *find_string(stringlist *list, char *name) {
X    stringlist *c = pkgclasses, **d = &pkgclasses;
X
X    if (name == 0)
X       return 0;
X
X    while (c) {
X       if (strcmp(c->name, name) == 0)
X           return c->name;
X       d = &c->next;
X       c = c->next;
X    }
X    c = *d = (stringlist *) malloc(sizeof(stringlist));
X    if (*d == 0)
X       return name;
X    c->next = 0;
X    c->name = strdup(name);
X    return c->name;
X}
X
Xstatic char *getpkgvar(package *pkg, const char *variable)
X{
X    char *p = pkg->map;
X    int vlen = strlen(variable);
X
X    if (pkg->lastvar && strncmp(pkg->lastvar, variable, vlen) == 0)
X       return pkg->lastvar + vlen + 1;
X
X    while (p - pkg->map < pkg->size) {
X       while (isspace(*p))
X           p++;
X
X       if (strncmp(variable, p, vlen) == 0 && p[vlen] == '=') {
X           pkg->lastvar = p;
X           return p + vlen + 1;
X       }
X
X       while (*p++)
X           ;
X    }
X    return 0;
X}
X
Xstatic package *make_pkg(pkgdb_t db, char *name)
X{
X    char path[MAXPATHLEN];
X    struct stat buf;
X    int fd;
X    char *ptr;
X    package *pkg = (package*) malloc(sizeof(package));
X    char *classes;
X
X    if (pkg == 0)
X       return 0;
X
X    pkg->basedir = pkg->map = pkg->lastvar = 0;
X    pkg->name = name;
X
X    (void) strcpy(path,db->dir);
X    strcat(path, "/");
X    strcat(path, name);
X    strcat(path, "/");
X    pkg->path = strdup(path);
X    strcat(path,"pkginfo");
X
X    fd = open(path, O_RDONLY);
X    if (fd < 0) {
X       del_pkg(pkg);
X       return 0;
X    }
X
X    if (fstat(fd, &buf) < 0) {
X       close(fd);
X       return 0;
X    }
X
X    pkg->size = buf.st_size;
X    
X    pkg->map = mmap(0, pkg->size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
X    close(fd);
X
X    if (pkg->map == (caddr_t) -1) {
X       del_pkg(pkg);
X       return 0;
X    }
X
X    ptr = pkg->map;
X    while (ptr - pkg->map < pkg->size) {
X       ptr = strchr(ptr, '\n');
X       if (ptr == 0)
X           break;
X       *ptr = '\0';
X       ptr++;
X    }
X    classes = getpkgvar(pkg, "CLASSES");
X    pkg->basedir = getpkgvar(pkg, "BASEDIR");
X    if (pkg->basedir) {
X       strcpy(path, pkg->basedir);
X       if (path[strlen(path)-1] != '/')
X           strcat(path,"/");
X       pkg->basedir = strdup(path);
X    } else
X       pkg->basedir = strdup("/");
X    for (ptr = strtok(classes, "\t "); ptr ; ptr = strtok(0, "\t "))
X       (void) find_string(pkgclasses, ptr);
X
X    return pkg;
X}
X
Xstatic FILE *pkgmap_open(package *pkg)
X{
X    char path [MAXPATHLEN];
X
X    strcpy(path, pkg->name);
X    strcat(path, "/pkgmap");
X    return fopen(path, "r");
X}
X
Xstatic int
Xsplit_line(char *line, pkgmapline *split)
X{
X    char *ptr;
X
X    if ((ptr = strtok(line, " \n\t")) == 0) return -1;
X
X    if (isdigit(*ptr))
X       /* part #, ignore */
X       if ((ptr = strtok(0, " \n\t")) == 0) return 1;
X
X    /* not a valid ftype or ftype for installation use only (i)*/
X    if (strchr("fevdxlpcbs",*ptr) == 0)
X       return 1;
X
X    split->ftype = *ptr;
X
X    if ((ptr = strtok(0, " \n\t")) == 0) return -1;
X    split->class = ptr;
X    if ((ptr = strtok(0, " \n\t")) == 0) return -1;
X    split->path = ptr;
X
X    if (split->ftype == 'b' || split->ftype == 'c') {
X       /* get device */
X       if ((ptr = strtok(0, " \n\t")) == 0) return -1;
X       split->major = ptr;
X       if ((ptr = strtok(0, " \n\t")) == 0) return -1;
X       split->minor = ptr;
X    } else
X       split->major = split->minor = 0;
X
X    if (split->ftype != 'l' && split->ftype !=
...

read more »

 
 
 

anyway to rebuild /var/sadm/install/contents ?

Post by Ronald Hel » Tue, 27 Jul 1993 21:08:38


Hi,

First of all: I'm running Solaris 2.2 on all kind of SPARC's.

I've installed all the Answerbooks on a server. Now it looks like
the Answerbook Navigator is looking in /var/sadm for installed
answerbooks. So, on my clients the navigator finds nothing at all.
Is there anyway to do a 'fake install' to make the navigator find
the answerbook entries in /var/sadm without actually installing
them on every client? Or is there another solution for this problem?

Regards,

Ronald.

---

__

// Twente University
// Department of Computer Science
// The Netherlands

 
 
 

anyway to rebuild /var/sadm/install/contents ?

Post by Casper H.S. D » Tue, 27 Jul 1993 22:02:19



>Hi,
>First of all: I'm running Solaris 2.2 on all kind of SPARC's.
>I've installed all the Answerbooks on a server. Now it looks like
>the Answerbook Navigator is looking in /var/sadm for installed
>answerbooks. So, on my clients the navigator finds nothing at all.
>Is there anyway to do a 'fake install' to make the navigator find
>the answerbook entries in /var/sadm without actually installing
>them on every client? Or is there another solution for this problem?

This is probably a candidate for the Solaris FAQ.

From the manual page of answerbook(1) in Solaris 2.2 :

     Source answerbook_setup
          If there is an executable sh or ksh shell script called
          "answerbook_setup"  in  the  user's search path, source
          it.  Typically, this file would contain shell  commands
          that  enable  access to shared AnswerBooks available on
          the network.  See the "AnswerBook Administration" guide
          for  more  information on sharing AnswerBooks on a net-
          work.

and:

     AB_CARDCATALOG
          answerbook makes locally installed AnswerBooks accessi-
          ble  by  appending their card catalog file names to the
          this environment  variable,  which  navigator  uses  in
          assembling  its  list  of  available  AnswerBooks.  See
          ab_cardcatalog(4) for more information.

Sample answerbook_setup script:

# This script is sourced (. script) by the answerbook ksh script.
# This script must be executable, it must also be in your PATH
# Add more answerbooks as needed to this list
# The patnames mentioned here must be the exact names used during
# installation or things will go wrong.
for dir in \
        /opt/Solaris_2.2_AB \
        /opt/SUNWabe \
        /opt/SUNWspro \
        /opt/SUNWabhw
do
   catalog=$dir/ab_cardcatalog
   if [ -f $catalog ]
   then
        AB_CARDCATALOG=${AB_CARDCATALOG:+${AB_CARDCATALOG}:}$catalog
        export AB_CARDCATALOG
   fi
done

# Here we prevent the use of pkginfo on clients.
# alias SetUpLocalAnswerBooks=: makes sure no calls to pkginfo are made.
# Speeds things up on clients but can also be used on server when
# AB_CARDCATALOG is setup correctly above.

if [ ! -d /export/install_info ]
then
    alias SetUpLocalAnswerBooks=:
fi

 
 
 

1. frequency alphabet for files in /var/sadm/install/contents

not sure if anyone will have any use for this, but here goes.
(i got this as a side effect.)

i wanted to know what characters appeared in file names NORMALLY,
not everything that was possible.

nawk '{print $1}' /var/sadm/install/contents > scratch

take scratch, ignore / and newline, and count the characters.
ignore = since that serves to indicate links.  ignore # since
that occurs only as an artifact of the contents file.
remember that things like "usr" will get counted a lot.
here's what i got.  i did notice the tilde, which looks like a
packaging mistake.  i tracked it down:

/usr/share/lib/mailx/mailx.help
/usr/share/lib/mailx/mailx.help.~

SUNWcsu package.  but the two files are indeed quite
different, so i think it's not a mistake.

287074  s
224890  a
203628  e
190887  r
179342  o
179100  p
162660  i
155725  t
141892  n
140474  l
140236  .
131468  m
120406  c
81012   u
78606   S
74962   b
70963   d
66863   U
63377   W
59706   v
52406   g
50227   N
49836   h
49076   2
40985   f
39950   6
37067   3
31540   _
29449   k
26785   -
26317   1
23642   w
22806   x
22763   0
22096   C
15593   4
12734   j
12081   9
11736   T
11595   X
11346   7
10921   y
10081   E
10076   5
9697    8
8247    R
6931    D
6709    +
6621    V
5759    A
5395    I
5330    M
5150    F
5055    B
4412    P
3863    L
3134    O
2587    z
2575    %
2366    J
2295    G
1915    H
1598    q
1591    Z
1123    $
1108    K
673     ,
262     Y
220     Q
125     :

1       ~

all in /usr)
"," usually occurs in combination with "SUNW", in /usr/platform
and java primarily.

one frequency alphabet for ordinary english i found:

etoanrishcdlfmugypwbvkxjqz

though, of course, i don't have character counts.

j.
--

Head of Sun Support, Sr. Operating Systems Specialist
Applied Research Labs, Computer Science Div.                   S224
University of Texas at Austin

2. Changing Monitor Timings?!

3. Help - Corrupted /var/sadm/install/contents file

4. Modem configuration on solaris 2.3.

5. /var/sadm/install/contents

6. Can't setup XFree86 on Redhat-Display problem

7. Sol 2.5: Meaning of asterisks in /var/sadm/install/contents?

8. 2.5.65-mm4

9. /var/sadm/install/contents

10. pkg - recreated /var/sadm/install/contents

11. /var/sadm/install/contents format

12. how to rebuild /var/sadm/patch

13. copy /var/sadm vs. install patch