coreutils
[Top][All Lists]
Advanced

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

Patch: add basic package management for 'install'


From: assirati
Subject: Patch: add basic package management for 'install'
Date: Thu, 28 Jul 2016 21:34:42 -0300
User-agent: Internet Messaging Program (IMP) H5 (6.2.1)


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.


Attachment: install-list.diff
Description: Text Data


reply via email to

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