Hi!

In 1997 I mailed you a patch to the install program in fileutils 3.16
to make it log installations to a file.  It has proven very useful to
me (I don't use any kind of package management tool for my
"do-it-yourself" GNU/Linux installation that has lived since 1994.)

You never answered me.  Now I've made the same improvement to
fileutils 4.1.  You probably still wish I didn't exist, but I mail you
the patch anyway.  I just made it, no testing at all.

Here's part of the description I mailed you five years ago.  It still
applies:

  I was missing a logging feature of the install program, so I
  modified the source to include simple logging.  If you think a
  logging install program may be useful, feel free to check this patch
  and do whatever you want with it (including throwing it away, of
  course). I hope the logging feature will simplify the task of moving
  and removing program packages, and also to copy an installed package
  from one computer to another.

  The version in the included patch, will log to the file given by the
  environment variable INSTALL_LOG_FILE.  This way, logging may be
  done even if no logging is specified in Makefiles using the install
  program.  Lines written to the log file may be tagged with an
  identifier, taken from the environment variable INSTALL_LOG_ID.  One
  would typically set this environment variable to the name of the
  package of which one intends to do a "make install", to easily spot
  the files installed from this package.

  The patch should be performed on the fileutils-4.1 distribution:

        cd /directory/of/fileutils-4.1
        patch -p1 < the-file-containing-this-patch

  The following files are affected:

        src/install.c
        man/install.1
        doc/install.texi
        doc/install.info

  [...] Please tell me what you do with this patch!  And while I have
  your attention, I would like to thank you for all the work and
  effort you have put into the GNU project.  I run GNU/Linux at home,
  so I rely heavily on your great work.  Thanks!

Since then, I've been running GNU/Linux both at home and at work.


Sverre.

-- 
[EMAIL PROTECTED]                        Play my free Nerd Quiz at
http://shh.thathost.com/                http://nerdquiz.thathost.com/
diff -r fileutils-4.1/doc/fileutils.info fileutils-4.1-shh/doc/fileutils.info
2107a2108,2147
>    By setting the environment variable `INSTALL_LOG_FILE' to the name
> of a file, `install' will log changes by appending lines to the end of
> the given file. An identifier for the installation process may be given
> in the environment variable `INSTALL_LOG_ID'. This identifier is
> usefull if you want to separate files that come from different source
> packages.
> 
>    Lines in the log file contains the following fields, separated by a
> single space character:
> 
> `date'
>      The date of the installation, in ISO date format.
> 
> `time'
>      The time of the installation, in local time.
> 
> `ID'
>      Identifier as given by the `INSTALL_LOG_ID' environment variable.
>      Defaults to "no-id" if the environment variable is unset. Note
>      that any occurences of space characters in the ID is replaced by
>      an underscore character. This simplifies automatic extraction of
>      fields from the log file.
> 
> `mode'
>      The octal file permission mode of the file.
> 
> `owner'
>      The owner of the installed file.
> 
> `group'
>      The group of the file.
> 
> `directory'
>      Indicates whether the file name refers to a directory or not. A 1
>      in this field means the file is a directory. A 0 indicates a
>      regular file.
> 
> `name'
>      The directory and name of the installed file.
> 
4125,4143c4165,4183
< Node: mv invocation78410
< Node: rm invocation81682
< Node: shred invocation83756
< Node: Special file types90267
< Node: ln invocation91551
< Node: mkdir invocation95807
< Node: mkfifo invocation97295
< Node: mknod invocation98191
< Node: rmdir invocation99675
< Node: Changing file attributes100827
< Node: chown invocation101637
< Node: chgrp invocation105665
< Node: chmod invocation107590
< Node: touch invocation109185
< Node: Disk usage112196
< Node: df invocation112809
< Node: du invocation117911
< Node: sync invocation121424
< Node: Index122244
---
> Node: mv invocation79671
> Node: rm invocation82943
> Node: shred invocation85017
> Node: Special file types91528
> Node: ln invocation92812
> Node: mkdir invocation97068
> Node: mkfifo invocation98556
> Node: mknod invocation99452
> Node: rmdir invocation100936
> Node: Changing file attributes102088
> Node: chown invocation102898
> Node: chgrp invocation106926
> Node: chmod invocation108851
> Node: touch invocation110446
> Node: Disk usage113457
> Node: df invocation114070
> Node: du invocation119172
> Node: sync invocation122685
> Node: Index123505
diff -r fileutils-4.1/doc/fileutils.texi fileutils-4.1-shh/doc/fileutils.texi
1797a1798,1803
> By setting the environment variable @code{INSTALL_LOG_FILE} to the
> name of a file, @code{install} will log changes by appending lines to
> the end of the given file. An identifier for the installation process
> may be given in the environment variable @code{INSTALL_LOG_ID}. This
> identifier is usefull if you want to separate files that come from
> different source packages.
1798a1805,1841
> Lines in the log file contains the following fields, separated by
> a single space character:
> 
> @table @samp
> 
> @item date
> The date of the installation, in ISO date format.
> 
> @item time
> The time of the installation, in local time.
> 
> @item ID
> Identifier as given by the @code{INSTALL_LOG_ID} environment
> variable. Defaults to "no-id" if the environment variable is
> unset. Note that any occurences of space characters in the ID is
> replaced by an underscore character. This simplifies automatic
> extraction of fields from the log file.
> 
> @item mode
> The octal file permission mode of the file.
> 
> @item owner
> The owner of the installed file.
> 
> @item group
> The group of the file.
> 
> @item directory
> Indicates whether the file name refers to a directory or not. A 1 in
> this field means the file is a directory. A 0 indicates a regular
> file.
> 
> @item name
> The directory and name of the installed file.
> 
> @end table
>  
diff -r fileutils-4.1/doc/stamp-vti fileutils-4.1-shh/doc/stamp-vti
1,2c1,2
< @set UPDATED 23 April 2001
< @set UPDATED-MONTH April 2001
---
> @set UPDATED 2 February 2002
> @set UPDATED-MONTH February 2002
diff -r fileutils-4.1/doc/version.texi fileutils-4.1-shh/doc/version.texi
1,2c1,2
< @set UPDATED 23 April 2001
< @set UPDATED-MONTH April 2001
---
> @set UPDATED 2 February 2002
> @set UPDATED-MONTH February 2002
diff -r fileutils-4.1/man/ginstall.1 fileutils-4.1-shh/man/ginstall.1
2c2
< .TH INSTALL "1" "April 2001" "install (fileutils) 4.1" FSF
---
> .TH INSTALL "1" "February 2002" "install (fileutils) 4.1" FSF
78a79,119
> .SH LOGGING
> By setting the environment variable INSTALL_LOG_FILE to the name of a
> file,
> .B install
> will log changes by appending lines to the end of the given file. An
> identifier for the installation process may be given in the
> environment variable INSTALL_LOG_ID. This identifier is usefull if you
> want to separate files that come from different source packages.
> .PP
> Lines in the log file contains the following fields, separated by
> a single space character:
> .TP
> .I date
> The date of the installation, in ISO date format.
> .TP
> .I time
> The time of the installation, in local time.
> .TP
> .I ID
> Identifier as given by the INSTALL_LOG_ID environment
> variable. Defaults to "no-id" if the environment variable is
> unset. Note that any occurences of space characters in the ID is
> replaced by an underscore character. This simplifies automatic
> extraction of fields from the log file.
> .TP
> .I mode
> The octal file permission mode of the file.
> .TP
> .I owner
> The owner of the installed file.
> .TP
> .I group
> The group of the file.
> .TP
> .I directory
> Indicates whether the file name refers to a directory or not. A 1 in
> this field means the file is a directory. A 0 indicates a regular
> file.
> .TP
> .I name
> The directory and name of the installed file.
diff -r fileutils-4.1/src/install.c fileutils-4.1-shh/src/install.c
29a30
> #include <time.h>
89a91,94
> /* SHH: logging */
> static void log_install PARAMS ((const char *to, int mode,
>                                  uid_t uid, gid_t gid,
>                                  int is_dir));
126a132,141
> /* SHH: If non-NULL, the name of the file to which logging should be
>  * written. */
> static char *log_file;
> 
> /* SHH: The current identification to include in loglines. No SPC allowed. */
> static char *log_id;
> 
> /* SHH: Perform logging to a file? */
> static int log_enabled = 0;
> 
193a209,210
>   /* SHH: logging */
>   char *log;
213a231,243
>   /* SHH: log stuff */
>   log = getenv ("INSTALL_LOG_FILE");
>   if (log) {
>     log_file = log;
>     log_enabled = 1;
>   }
>   log = getenv ("INSTALL_LOG_ID");
>   if (log) {
>     /* make a copy, since this one may be changed later. */
>     log_id = xmalloc (strlen (log) + 1);
>     strcpy (log_id, log);
>   }
> 
275a306,317
>   /* SHH: Remove any spaces from the log_id to simplify interpretation
>    * of the log file. */
>   if (log_id) {
>     char *s = log_id;
> 
>     while (*s) {
>       if (*s == ' ')
>       *s = '_';
>       ++s;
>     }
>   }
> 
310c352,354
<         errors |=
---
>           int result;
> 
>         result =
312a357,360
>           /* SHH: log it */
>           if (result == 0)
>             log_install(file[i], mode, owner_id, group_id, 1);
>         errors |= result;
351a400,457
> /* SHH: Write logging information to a log file, if specified on the
>    command line or in environment variables. */
> 
> static void
> log_install (const char *to, int mode,
>            uid_t uid, gid_t gid,
>            int is_dir)
> {
>   static FILE   *f;  /* Log file. Closed on program termination. */
>   time_t        t;
>   struct tm     *tm;
>   struct passwd *pw;
>   char          pws[20], *pwp;
>   struct group  *gr;
>   char          grs[20], *grp;
> 
>   if (!log_enabled)
>     return;
> 
>   if (!f && (f = fopen (log_file, "a")) == NULL) {
>     error (0, errno, "%s", log_file);
>     log_enabled = 0;
>     return;
>   }
> 
>   time (&t);
>   tm = localtime (&t);
> printf("uid is %u\n", (unsigned) uid);
>   /* Attempt mapping the user id to something more human. */
>   if (uid == (uid_t) -1)
>     uid = geteuid();
>   if ((pw = getpwuid (uid)) == NULL) {
>     sprintf (pws, "%u", (unsigned) uid);
>     pwp = pws;
>   } else
>     pwp = pw->pw_name;
> 
>   /* Ditto for the group id. */
>   if (gid == (uid_t) -1)
>     gid = getegid();
>   if ((gr = getgrgid (gid)) == NULL) {
>     sprintf (grs, "%u", (unsigned) gid);
>     grp = grs;
>   } else
>     grp = gr->gr_name;
> 
>   if (fprintf (f,
>              "%04d-%02d-%02d %02d:%02d:%02d %s %o %s %s %d %s\n",
>              tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
>              tm->tm_hour, tm->tm_min, tm->tm_sec,
>              log_id ? log_id : "no-id",
>              mode, pwp, grp,
>              is_dir, to) < 0) {
>     error (0, errno, "%s", log_file);
>     log_enabled = 0;
>   }
> }
> 
394a501
>   log_install(to, mode, owner_id, group_id, 0);

Reply via email to