* updated ktuberling (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / package / base / mkpkg / mkpkg.sh
blob31e1387f967448c3fa83b64bfd70e62653f84abd
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 #
5 # T2 SDE: package/.../mkpkg/mkpkg.sh
6 # Copyright (C) 2004 - 2006 The T2 SDE Project
7 # Copyright (C) 2003 - 2003 ROCK Linux Project
8 #
9 # More information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; version 2 of the License. A copy of the
14 # GNU General Public License can be found in the file COPYING.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 if [ "$#" -lt 2 -o -z "$1" -o -z "${1##-*}" ]; then
18 echo ""
19 echo "Usage: $0 <pkg-name> <install-command>"
20 echo ""
21 echo "E.g.:"
22 echo ""
23 echo " cd /usr/local/src/foobar-1.0"
24 echo " ./configure && make"
25 echo " mkpkg foobar make install"
26 echo ""
27 exit 1
30 pkg=$1; shift
31 slog=`mktemp` wlog=`mktemp` flog=`mktemp`
33 strace -o $slog -F -f -q -e open,creat,`
34 `mkdir,mknod,link,symlink,rename,utime,chdir,`
35 `execve,fork,vfork,_exit,exit_group -p $$ &
36 strace_pid=$!; sleep 1; cd $PWD
38 "$@"
40 sleep 1; kill -INT $strace_pid; sleep 1
41 /usr/lib/fl_stparse -w $wlog < $slog
42 touch /var/adm/flists/$pkg
44 /usr/lib/fl_wrparse -s -r / -p "$pkg" < $wlog
45 for x in flists packages dependencies descs cksums md5sums ; do
46 echo "$pkg: var/adm/$x/$pkg" ; done
47 } | cat /var/adm/flists/$pkg - |
48 egrep -v '^[^ ]+: (dev|proc|tmp)(/|$)' | sort -u > $flog
49 cat $flog > /var/adm/flists/$pkg
51 cd /
52 egrep -v "^$pkg: var/adm/" var/adm/flists/$pkg | cut -f2- -d' ' | \
53 xargs cksum > var/adm/cksums/$pkg
54 egrep -v "^$pkg: var/adm/" var/adm/flists/$pkg | cut -f2- -d' ' | \
55 xargs md5sum > var/adm/md5sums/$pkg
57 touch var/adm/{dependencies,descs}/$pkg
58 echo "Package Name and Version: $pkg 0000 mkpkg" > var/adm/packages/$pkg
60 echo "[ Created package $pkg with" $( wc -l < $flog ) "files. ]"
62 rm -f $wlog $slog $flog