WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Script using installwatch to create file list and package.  (Read 5414 times)

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Script using installwatch to create file list and package.
« on: March 27, 2011, 04:02:33 PM »
This script uses installwatch to create packages in the case where DESTDIR or similar is not available.  Simply invoke the script followed by 'make install"

/tmp/installscript make install


And it will do it's thing.  The file is commented with what can be changed and what does what.

Requires tar.tcz and checkinstall-tc.tcz

Code: [Select]
#!/bin/sh
# Installwatch parsing routines taken from Lunar Linux and Checkinstall to
# create file lists and/or packages from 'make install'.

. /etc/init.d/tc-functions

if [ ! -f /usr/local/tce.installed/tar ]; then
echo "${RED}You need to install tar.tcz.  Exiting..${NORMAL}"
exit 1
fi

if [ ! -f /usr/local/tce.installed/checkinstall-tc ]; then
echo "${RED}You need to install checkinstall-tc.tcz.  Exiting..${NORMAL}"
exit 1
fi


######## SET THESE VARIABLES IF DESIRED.

WORKPATH=/tmp  # a directory will be created in this path using the $PWD where the script
       # was run, and will be where the files and package will reside.  It is
       # named using the $PWD to seperate the results of different package builds.

INSTALLWATCHLOGPATH=/tmp     # Location of installwatch files, not important per se.

PACKAGE=YES  ## YES creates a tarball of the package in $WORKPATH, leave blank to not.

COMMAND="${*##${0}}" # Uses the command invoked after this script, can hardcode to 'make install' if desired.

BASEDIR="$WORKPATH"/`basename "$PWD"`  # The actual directory where the results will reside.
       # Adjust WORKPATH for the desired location.

########

[ -d "$INSTALLWATCHLOGPATH" ] || mkdir "$INSTALLWATCHLOGPATH"


[ -d "$BASEDIR" ] || mkdir -p "$BASEDIR"

> "$INSTALLWATCHLOGPATH"/logfile

installwatch -r "$INSTALLWATCHLOGPATH" ${COMMAND}

cd "$BASEDIR"

EXCLUDE="(^/dev|^/tmp|^$BASEDIR|^/mnt|^/home|^/proc|^/sys)"

parse_file() {
cat "$INSTALLWATCHLOGPATH"/logfile | egrep -v '^[-0-9][0-9]*[[:space:]]*(unlink|access|rename)' | cut -f 3 | egrep -v "$EXCLUDE" | grep "^/"
cat "$INSTALLWATCHLOGPATH"/logfile | cut -f 4 | egrep -v "$EXCLUDE" | grep "^/"
}

existing(){
while read FILE ; do
if [ -e "$FILE" ] ; then
echo "$FILE"
fi
done
}

parse_file | sort | uniq | existing > filelist


sed -i 's:^/::g' filelist

PKGNAME=`basename "$PWD"`

if [ "$PACKAGE" == "YES" ]; then
sed -i 's:^/::g' filelist
cd /
echo "${YELLOW}Tarring files to ${GREEN}"$BASEDIR"/package-"$PKGNAME".tar.gz${NORMAL}"
tar --no-recursion -T "$BASEDIR"/filelist -cpzf "$BASEDIR"/package-"$PKGNAME".tar.gz
fi

# Unpack package if desired to directory with the command:
# tar xvf package-(name).tar.gz -C /desired/directory



« Last Edit: March 27, 2011, 08:06:04 PM by Jason W »

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: Script using installwatch to create file list and package.
« Reply #1 on: March 28, 2011, 06:19:59 AM »
even so I can't make it work

Code: [Select]
tc@box:/tmp/inst$ bash ./installscript mkdir /tmp/provax
Tarring files to /tmp/inst/package-inst.tar.gz
tc@box:/tmp/inst$
tc@box:/tmp/inst$ ls -l
total 8
-rw-r--r--    1 tc       staff            0 Mar 28 12:16 filelist
-rwxr-xr-x    1 tc       staff         2240 Mar 28 11:37 installscript
-rw-r--r--    1 tc       staff           45 Mar 28 12:16 package-inst.tar.gz
tc@box:/tmp/inst$ cat filelist
tc@box:/tmp/inst$

I hope that someone else try it to determine if it's only my problem or generalized problem
« Last Edit: March 28, 2011, 06:23:01 AM by vinnie »

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Script using installwatch to create file list and package.
« Reply #2 on: March 28, 2011, 08:31:56 AM »
It's tuned to ignore entries in /tmp, /dev, etc where you normally don't want to install files.

Adjust the EXCLUDE variable if needed.

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: Script using installwatch to create file list and package.
« Reply #3 on: March 28, 2011, 10:24:21 AM »
Ok, Work!

Code: [Select]
tc@box:/tmp/inst$  bash ./installscript mkdir /home/provax
mkdir: can't create directory '/home/provax': Permission denied
Tarring files to /tmp/inst/package-inst.tar.gz
tc@box:/tmp/inst$ ls -l
total 8
-rw-r--r--    1 tc       staff            0 Mar 28 15:55 filelist
-rwxr-xr-x    1 tc       staff         2240 Mar 28 11:37 installscript
-rw-r--r--    1 tc       staff           45 Mar 28 15:55 package-inst.tar.gz
tc@box:/tmp/inst$ cat filelist
tc@box:/tmp/inst$
tc@box:/tmp/inst$ sudo bash ./installscript mkdir /usr/provax
Tarring files to /tmp/inst/package-inst.tar.gz
tc@box:/tmp/inst$ ls -l
total 12
-rw-r--r--    1 root     root            11 Mar 28 15:56 filelist
-rwxr-xr-x    1 tc       staff         2240 Mar 28 11:37 installscript
-rw-r--r--    1 root     root           110 Mar 28 15:56 package-inst.tar.gz
tc@box:/tmp/inst$ cat filelist
usr/provax
tc@box:/tmp/inst$

Also installwatch if i using /usr but its output is completely different from your showed me in other topic:

my output
Code: [Select]
tc@box:/usr$ sudo bash installwatch mkdir -p dir/{1,2,3,4,5,7,8,9}

INFO : Using a default root directory : /tmp/tmp.zaXH03

tc@box:/usr$ sudo cat /tmp/tmp.zaXH03/logfile
0       mkdir   /tmp/dir        #success
0       mkdir   /tmp/dir/{1,2,3,4,5,7,8,9}      #success

your
Code: [Select]
0 mkdir /home/tc/dir #success
0 mkdir /home/tc/dir/1 #success
-1 mkdir /home/tc/dir #File exists
0 mkdir /home/tc/dir/2 #success
-1 mkdir /home/tc/dir #File exists
0 mkdir /home/tc/dir/3 #success
-1 mkdir /home/tc/dir #File exists
0 mkdir /home/tc/dir/4 #success
-1 mkdir /home/tc/dir #File exists
0 mkdir /home/tc/dir/5 #success
-1 mkdir /home/tc/dir #File exists
0 mkdir /home/tc/dir/7 #success
-1 mkdir /home/tc/dir #File exists
0 mkdir /home/tc/dir/8 #success
-1 mkdir /home/tc/dir #File exists
0 mkdir /home/tc/dir/9 #success

and in fact changing your script and commenting EXCLUDE line what happens in the home is not monitored.
seems seriously that we have two different installwatch (but this is impossible!)
I probably will have to renounce, i will use find & diff.

I want to thank you anyway  ;)
« Last Edit: March 28, 2011, 10:30:46 AM by vinnie »

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Script using installwatch to create file list and package.
« Reply #4 on: March 28, 2011, 07:02:36 PM »
If you set EXCLUDE to an empty value rather than comment it, it monitors what happes in home, I just tried it.   So it should work in that case.

Code: [Select]
tc@box:~$ /mnt/hda2/installscript mkdir -p /home/tc/files
Tarring files to /tmp/tc/package-tc.tar.gz
tc@box:~$ cat /tmp/tc/filelist
home
home/tc
home/tc/files
tc@box:~$

Offline vinnie

  • Hero Member
  • *****
  • Posts: 1187
  • HandMace informatic works
Re: Script using installwatch to create file list and package.
« Reply #5 on: March 29, 2011, 05:23:04 AM »
I did not know whether to lift the quotation marks and then I did both tests
Code: [Select]
...
EXCLUDE=""
...

Code: [Select]
tc@box:~/inst$ bash ./installscript mkdir ~/prova
Tarring files to /tmp/inst/package-inst.tar.gz
tc@box:~/inst$
tc@box:~/inst$ ls -l /tmp/inst/
total 4
-rw-r--r--    1 tc       staff            0 Mar 29 11:10 filelist
-rw-r--r--    1 tc       staff           45 Mar 29 11:10 package-inst.tar.gz
tc@box:~/inst$
tc@box:~/inst$ cat /tmp/inst/filelist
tc@box:~/inst$


Code: [Select]
...
EXCLUDE=
...

Code: [Select]
tc@box:~/inst$ rm -rf /tmp/inst/
tc@box:~/inst$
tc@box:~/inst$ bash ./installscript mkdir ~/prova2
Tarring files to /tmp/inst/package-inst.tar.gz
tc@box:~/inst$
tc@box:~/inst$ ls -l /tmp/inst/
total 4
-rw-r--r--    1 tc       staff            0 Mar 29 11:15 filelist
-rw-r--r--    1 tc       staff           45 Mar 29 11:15 package-inst.tar.gz
tc@box:~/inst$
tc@box:~/inst$ cat /tmp/inst/filelist
tc@box:~/inst$


There really is something strange