lfs-uefi: fix efivar-37 FTBFS
[linux_from_scratch_hints.git] / pio-files / pod
blobe617019443860c4e2f4603b0aa3429b1f6fc4a64
1 #!/bin/bash
2 #PGR facit
3 parms=1 # How many parameters must it have?
4 usage="Usage: pod COMMAND [PARM]
5 Action: pod is a collection of quick and dirty little scripts that aid
6 pod development.
8 mkdist: PARM = destination_directory
10 Make tarballs of the system's build scripts, installed files, patches,
11 uninstall scripts, tarballs, and cloning execs, i.e. what we need to
12 write a release candidate CD/DVD.
13 ---
14 rename: PARM = pkg-now pkg-new
16 Renames a pod package in build scripts, pio uninstall and backup files,
17 then fixes-up dependencies.
18 ---
19 fixtimes: PARM =
21 Fixes timestamps on pio's uninstall scripts to match the time its
22 header says it was run.
23 ---
24 listpod: PARM =
26 List the POD built packages, i.e. omit the LFS packages.
27 ---
28 listlfs: PARM =
30 List the LFS built packages, i.e. omit the POD packages.
31 ---
32 collect: PARM = package_name
34 Collect a package's uninstall script, installed files, build script, and
35 source tarball into one tarball useful for updates
36 ---
37 chkup: PARM = collection1 [collection2 ... collectionN]
39 Go through a collected update looking for the updated files.
40 ---
41 xdeps: PARM =
43 Cross reference dependencies on stdout.
44 pkg1 requires pkg2: pkg1 ==> pkg2
45 pkg2 <== pkg1
46 pkg1 uses pkg2: pkg1 --> pkg2
47 pkg2 <-- pkg1
50 function doit () {
51 # get to it
52 command=$1
53 shift
54 case $command in
55 mkdist)
56 if [ $1 = "" ]; then
57 echo "No destination given"
58 else
59 here=`pwd`
60 mkdir -p $1
61 cd /usr/local
62 echo "Compressing pio scripts"
63 tar -czpf $1/pio.tgz pio/*-* --exclude=kernel\*
64 cd pio
65 echo "Tarballing asbuilt binaries"
66 tar -cpf $1/backups.tar backups/ --exclude=kernel\*
67 cd /usr/local/src/
68 echo "Compressing patches"
69 tar -czpf $1/patches.tgz patches/
70 echo "Compressing build scripts"
71 tar -czpf $1/scripts.tgz scripts/
72 echo "Tarballing source tarballs"
73 tar -cpf $1/tarballs.tar tarballs/
74 # Sometimes this may have been moved around
75 ex=`find / -xdev -type d -name execs`
76 if [ $ex ]; then
77 cd $ex
78 cd ..
79 echo "Compressing execs at " $ex
80 tar -czpf $1/execs.tgz execs
81 else
82 echo "execs directory not found"
84 cd $here
87 rename)
88 if [ $# -eq 2 ]; then
89 # rename script
90 mv /usr/local/src/scripts/$1 \
91 /usr/local/src/scripts/$2
92 # rename as-installed backup
93 mv /usr/local/pio/backups/$1.tgz \
94 /usr/local/pio/backups/$2.tgz
95 # rename the removal script
96 mv /usr/local/pio/$1 \
97 /usr/local/pio/$2
98 # change references in pio scripts
99 # (catch self-reference, and dependencies in others)
100 for fn in `ls /usr/local/pio/*-*` # avoid backups/
102 grep -q $1 $fn # sets return code 0 when found
103 if [ $? -eq 0 ]; then
104 mtime=mktemp
105 touch -r $fn $mtime
106 sed -i 's/'$1'/'$2'/' $fn # $1 & $2 are exposed for substitution
107 touch -mr $mtime $fn
108 rm -f $mtime
110 done
111 else
112 echo "Now and new names not given"
115 fixtimes)
116 for i in `ls /usr/local/pio/*-*`
118 echo $i
119 touch -t `gawk '/# created by/{
120 month["Jan"]=1
121 month["Feb"]=2
122 month["Mar"]=3
123 month["Apr"]=4
124 month["May"]=5
125 month["Jun"]=6
126 month["Jul"]=7
127 month["Aug"]=8
128 month["Sep"]=9
129 month["Oct"]=10
130 month["Nov"]=11
131 month["Dec"]=12
132 split($12,time,":")
133 printf("%4d%02d%02d%02d%02d.%02d",$14,month[$10],$11,time[1],time[2],time[3]) }' $i` $i
134 done
136 listpod)
137 ls /usr/local/pio/ |\
138 grep -v ch[4-8] |\
139 awk -F- '{OFS="-";print $3, $4, $5, $6, $7}' |\
140 sed -e 's/---$//' -e 's/--$//' -e 's/-$//' |\
141 grep "-" |\
142 sort
144 listlfs)
145 ls /usr/local/pio/ |\
146 grep ch[4-8] |\
147 awk -F- '{OFS="-";print $3, $4, $5, $6, $7}' |\
148 sed -e 's/---$//' -e 's/--$//' -e 's/-$//' |\
149 grep "-" |\
150 sort
152 collect)
153 if [ $1 = "" ]; then
154 echo "No package name given"
155 else
156 # pull apart argument
157 wg=${1#*-} # without group
158 ws=${wg#*-} # without group & sequence number
159 wv=${ws%-*} # without version
160 vn=${ws##*-} # version number
161 src=`find /usr/local/src/tarballs -iname "${ws}*" -print`
162 # if it's null, i.e. not found, try with "_" replaced by "-"
163 # duplicates ARE possible, quote it
164 if [ ! "$src" ]; then
165 tr=${ws//_/-}
166 src=`find /usr/local/src/tarballs -iname "${tr}*" -print`
168 # list of patches in the build script
169 patches=`grep "../patches" /usr/local/src/scripts/$1 | \
170 sed 's/&&//' | \
171 sed 's:patch -Np1 -i ..:/usr/local/src:'`
172 tar cvpPf $1.tar \
173 /usr/local/pio/$1 \
174 /usr/local/pio/backups/${1}.t* \
175 /usr/local/src/scripts/$1 \
176 $src \
177 $patches
180 chkup)
181 tempfile=`mktemp -p /var/run` # in a tempfs
182 while [ $1 ]
184 tar tvPf $1 >$tempfile
185 while read tarred_file
187 tarred_data=`echo $tarred_file|cut -d " " -f 3-6`
188 fn=${tarred_data##*" "}
189 current_data=`ls -l --time-style=long-iso $fn|cut -d " " -f 5-8`
190 if [ "$tarred_data" = "$current_data" ]; then
191 echo "OK: " $fn
192 else
193 echo "Fix: "$fn
194 echo "Update:"$tarred_data # It's hard for me to suggest what
195 echo "Active:"$current_data # the fix would be, easy for you.
197 done < $tempfile
198 shift
199 done
200 rm -f $tempfile
202 xdeps)
203 i=`mktemp`
204 o=`mktemp`
205 pio --deps > $i
206 awk '/requires/ {print $1,"==>",$3,"\n" $3,"<==", $1}' <$i >$o
207 awk '/uses/ {print $1,"-->",$3,"\n" $3,"<--",$1}' <$i >>$o
208 sort <$o|column -c 3 -t
209 rm -f $i $o
212 echo "unknown command:" $command
214 esac
217 case $* in
218 -[?h]) echo "$usage"
220 --help) echo "$usage"
223 if [ $# -ge $parms ]; then
224 doit "$@"
225 else
226 echo "$usage"
229 esac