coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch: add basic package management for 'install'


From: Pádraig Brady
Subject: Re: Patch: add basic package management for 'install'
Date: Fri, 29 Jul 2016 11:31:06 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 29/07/16 01:34, address@hidden wrote:
> 
> Hello,
> 
> Attached is a patch that extends the functionality of Coreutils  
> install creating a basic package management capability. If it is to be  
> considered useful or viable, I would like very much to receive  
> reveiews, suggestions for improvements or bug reports. My purpose is  
> to get the code integrated to Coreutils 'install'.
> 
> Thank you,
> Joao Luis.
> 
> ** RATIONALE **
> 
> When installing programs from upstream source code, 'install' is the  
> traditional way makefiles install files to /usr/local or other  
> locations. After that, it is difficult to get a full listing of what  
> was installed where, and usually one must keep the source code so it  
> is possible to 'make uninstall' in the future, in case the makefile  
> provides this possibility.
> 
> This patch allows 'install' to make a list of all installed files and  
> created directories, making it easy to track all files and uninstall  
> the "package".
> 
> ** USAGE **
> 
> With this patch, when 'install' is executed with the command line options
> 
> -l FILE
> 
> or
> 
> --list=FILE
> 
> it will append to FILE the canonicalized name of the installed file or  
> directory.
> 
> For example
> 
> install -l file_list -D my_file /usr/local/my_dir/my_file
> 
> or
> 
> install --list=file_list -D my_file /usr/local/my_dir/my_file
> 
> or
> 
> export INSTALL_LIST=file_list
> install -D my_file /usr/local/my_dir/my_file
> 
> will append to file_list (or create it if it doesn't exist) containing
> 
> /usr/local/my_dir
> /usr/local/my_dir/my_file
> 
> After that, files and directories may be easily uninstalled with
> 
> tac file_list | while read f; do test -d "$f" && \rmdir "$f" || \rm  
> "$f"; done; \rm file_list
> 
> ** USE CASES **
> 
> Install may be called in new makefiles with the option -l to generate  
> a list of installed files and direcory. For legacy makefiles, one can  
> execute
> 
> INSTALL_LIST=somefile make install
> 
> or
> 
> export INSTALL_LIST=somefile
> make install
> 
> or the like.
> 
> ** DETAILS **
> 
> A global variable
> 
> static FILE *install_list = NULL;
> 
> was created to hold the stream for the file list. This stream is  
> fopen()ed for append in main() and closed by the atexit() handler  
> close_install_list().
> 
> A function
> 
> static void install_list_append (const char *fname)
> 
> was created to write to the file list. This function is called by:
> 
> make_ancestor(), to record all the created parent directories (case of  
> option -D)
> 
> process_dir(), to record a created dir (case of option -d)
> 
> install_file_in_file(), to record installed files.

Interesting. Thanks for the careful proposal.

My first though was that since install(1) needs to be given
a list of files or directories to create and doesn't recurse into
source directories, that all info required to uninstall is available
and therefore `make uninstall` is the correct way to do it
(which may also do other things than just remove(2)).

I also thought that one could leverage --verbose to get
the same functionality, though that is awkward and
one would have to deal with quoting etc.

wrt quoting you've have to be careful with '\n' in filenames
(maybe from a malicious `make install`) that could induce
an unintended unlink() in a subsequent processing of the list file.
You'd probably still quote in that case.

Also I don't like the list file management within install(1).
If we were to do this I'd just output the list of created files/dirs.
Perhaps with an interface like:
  install --verbose=manifest > install.list

With the above caveats I'm 50:50 on supporting this
due to lack of generality.

Have you considered managing the installed list in a more
abstract way, like with `checkinstall` to auto create packages,
or using GNU stow to manage the list with symlinks.

thanks,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]