Gentoo Archives: gnap-dev

From: Philipp Riegger <lists@××××××××××××.de>
To: gnap-dev@l.g.o
Subject: [gnap-dev] [PATCH 2/4] GNAP split
Date: Fri, 03 Aug 2007 13:37:08
Message-Id: 1186147976.10651.29.camel@b136a
In Reply to: [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 by Philipp Riegger
1 In this patch i put all the sunctions and global variables
2 (initialisation and read-only stuff) in gnap_shared.sh in tools. This
3 file is expected to be in GNAP_LIBDIR which defaults to /usr/lib/gnap. I
4 also initialised all variables... this is a little senseless since it
5 will be removed in one of the next patches, but i used it as a helper to
6 know which vars exist, what i have to take care of.
7
8 Philipp
9
10
11 diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
12 +cleanup/src/gnap_make gnap-2.0+cleanup+split/src/gnap_make
13 --- gnap-2.0+cleanup/src/gnap_make 2007-08-02 15:55:38.000000000 +0300
14 +++ gnap-2.0+cleanup+split/src/gnap_make 2007-08-02 15:54:29.000000000
15 +0300
16 @@ -1,78 +1,9 @@
17 #!/bin/bash
18 GNAPVERSION='2.0'
19
20 -GNAPNAME=$(basename "$0")
21 -echo "GNAP Core Building tool ${GNAPNAME} version ${GNAPVERSION}"
22 GNAPLIBDIR='/usr/lib/gnap'
23 -STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
24 -SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
25 -SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
26 -TEMPDIR=''
27 -
28 -G=$'\e[32;01m'
29 -B=$'\e[31;01m'
30 -N=$'\e[0m'
31 -W=$'\e[33;01m'
32 -K=$'\e[34;01m'
33 -C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
34 -E=$'\e['${C}'G'
35 -
36 -gwarn() {
37 - echo -e " ${W}*${N} ${*}"
38 -}
39 -
40 -ginfo() {
41 - echo -e " ${G}*${N} ${*}"
42 -}
43 -
44 -gmkdir() {
45 - mkdir -p "$1"
46 - gtest continued $? "Failed to create directory \"$1\"."
47 -}
48 -
49 -gconfirm() {
50 - if [[ "${FORCEYES}" -eq 1 ]]; then
51 - gwarn "${*} forced to yes"
52 - else
53 - read -ep " ${W}*${N} ${*} [N]: " answer
54 - if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
55 - if [[ -n "${TEMPDIR}" ]]; then
56 - cleanup
57 - fi
58 - echo Build aborted!
59 - exit 2
60 - fi
61 - fi
62 -}
63 -
64 -gbegin() {
65 - echo -ne " ${G}*${N} ${*}..."
66 -}
67 -
68 -gtest() {
69 - continued=0
70 - if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
71 - shift
72 - continued=1
73 - fi
74 - if [[ "$#" -eq 0 || "${1}" -eq 0 ]]; then
75 - if [[ "${continued}" -eq 0 ]]; then
76 - echo -e "${E} ${K}[ ${G}ok${K} ]${N}"
77 - fi
78 - else
79 - echo -e "${E} ${K}[ ${B}!!${K} ]${N}"
80 - if [[ "$#" -ge 2 ]]; then
81 - shift
82 - echo -en " ${B}*${N} ${*}"
83 - echo -e "${E} ${K}[ ${B}!!${K} ]${N}"
84 - fi
85 - if [[ -n "${TEMPDIR}" ]]; then
86 - cleanup
87 - fi
88 - echo "Build failed, try man ${GNAPNAME} for more help"
89 - exit 1
90 - fi
91 -}
92 +source ${GNAPLIBDIR}/gnap_shared.sh
93 +echo "GNAP Core Building tool ${GNAPNAME} version ${GNAPVERSION}"
94
95 usage() {
96 echo 'Options:'
97 @@ -89,18 +20,6 @@
98 echo "Please use man ${GNAPNAME} for more details."
99 }
100
101 -cleanup() {
102 - gbegin 'Cleaning temporary directories'
103 - if [[ -d "${TEMPDIR}" ]]; then
104 - DIRTOREMOVE="${TEMPDIR}"
105 - TEMPDIR=''
106 - rm -rf "${DIRTOREMOVE}"
107 - gtest $? "Failed to remove ${DIRTOREMOVE}"
108 - else
109 - gtest 0
110 - fi
111 -}
112 -
113 if [[ "$#" -eq 0 ]]; then
114 usage
115 exit 0
116 @@ -109,7 +28,7 @@
117 gbegin 'Checking parameters'
118
119 # Catalyst executable and config file
120 -CATALYST_BIN="/usr/bin/catayst"
121 +CATALYST_BIN="/usr/bin/catalyst"
122 CATALYST_CONF="/etc/catalyst/catalyst.conf"
123
124 # Read options
125 @@ -250,7 +169,7 @@
126 ginfo "${TARGETLIST}"
127
128 # Confirm tarball overwrite if TARBALL stage selected
129 -if [[ "${TARBALL}" -eq 1 -a -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]];
130 then
131 +if [[ "${TARBALL}" -eq 1 && -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]];
132 then
133 gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
134 fi
135
136 diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
137 +cleanup/tools/gnap_overlay gnap-2.0+cleanup+split/tools/gnap_overlay
138 --- gnap-2.0+cleanup/tools/gnap_overlay 2007-08-02 15:56:18.000000000
139 +0300
140 +++ gnap-2.0+cleanup+split/tools/gnap_overlay 2007-07-27
141 16:00:56.000000000 +0300
142 @@ -1,79 +1,11 @@
143 #!/bin/bash
144 VERSION='2.0'
145
146 -GNAPNAME=$(basename "$0")
147 -echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
148 GNAPLIBDIR='/usr/lib/gnap'
149 -GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
150 -GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
151 -TEMPDIR=''
152 -IMG_SIZE=15
153 -
154 -G=$'\e[32;01m'
155 -B=$'\e[31;01m'
156 -N=$'\e[0m'
157 -W=$'\e[33;01m'
158 -K=$'\e[34;01m'
159 -C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
160 -E=$'\e['${C}'G'
161 -
162 -gwarn() {
163 - echo -e " ${W}*${N} ${*}"
164 -}
165 -
166 -ginfo() {
167 - echo -e " ${G}*${N} ${*}"
168 -}
169 -
170 -gmkdir() {
171 - mkdir -p "$1"
172 - gtest continued $? "Failed to create directory \"$1\"."
173 -}
174 -
175 -gconfirm() {
176 - if [[ "${FORCEYES}" -eq 1 ]]; then
177 - gwarn "${*} forced to yes"
178 - else
179 - read -ep " ${W}*${N} ${*} [N]: " answer
180 - if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
181 - if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
182 - cleanup
183 - fi
184 - echo 'Overlay aborted!'
185 - exit 2
186 - fi
187 - fi
188 -}
189 -
190 -gbegin() {
191 - echo -ne " ${G}*${N} ${*}..."
192 -}
193 -
194 -gtest() {
195 - continued=0
196 - if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
197 - shift
198 - continued=1
199 - fi
200 +source ${GNAPLIBDIR}/gnap_shared.sh
201 +echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
202
203 - if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
204 - if [[ "${continued}" -eq 0 ]]; then
205 - echo -e "${E} ${K}[ ${G}ok${K} ]${N}"
206 - fi
207 - else
208 - echo -e "${E} ${K}[ ${B}!!${K} ]${N}"
209 - if [[ "$#" -ge 2 ]]; then
210 - shift
211 - echo -en " ${B}*${N} ${*}"
212 - echo -e "${E} ${K}[ ${B}!!${K} ]${N}"
213 - fi
214 - if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
215 - cleanup
216 - fi
217 - echo "Overlay failed, try ${GNAPNAME} -h for more help"
218 - exit 1
219 - fi
220 -}
221 +IMG_SIZE=15
222
223 usage() {
224 echo
225 @@ -107,23 +39,6 @@
226 echo "Please use man ${GNAPNAME} for more details."
227 }
228
229 -cleanup() {
230 - if [[ -n "${LOOP}" ]]; then
231 - gbegin 'Unmounting loop filesystem'
232 - umount "${LOOP}" && losetup -d "${LOOP}"
233 - gtest $? "Failed to unmount ${LOOP}"
234 - fi
235 - gbegin 'Cleaning temporary directories'
236 - if [[ -d "${TEMPDIR}" ]]; then
237 - DIRTOREMOVE="${TEMPDIR}"
238 - TEMPDIR=''
239 - rm -rf "${DIRTOREMOVE}"
240 - gtest $? "Failed to remove ${DIRTOREMOVE}"
241 - else
242 - gtest 0
243 - fi
244 -}
245 -
246 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
247 usage
248 exit 0
249 @@ -226,7 +141,7 @@
250
251 if [[ -n "${BAUDRATE}" ]]; then
252 gbegin 'Adding baudrate for serial console'
253 - gmkdir "${TEMPOVERDIR}/etc/gnap"
254 + gmkdir -p "${TEMPOVERDIR}/etc/gnap"
255 echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
256 gtest $? 'Failed to create /etc/gnap/baudrate'
257 fi
258 diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
259 +cleanup/tools/gnap_remaster gnap-2.0+cleanup+split/tools/gnap_remaster
260 --- gnap-2.0+cleanup/tools/gnap_remaster 2007-08-02 15:56:39.000000000
261 +0300
262 +++ gnap-2.0+cleanup+split/tools/gnap_remaster 2007-07-27
263 16:10:54.000000000 +0300
264 @@ -1,76 +1,11 @@
265 #!/bin/bash
266 VERSION='2.0'
267
268 -GNAPNAME=$(basename "$0")
269 -echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
270 GNAPLIBDIR='/usr/lib/gnap'
271 -GNAPEXTDIR="${GNAPLIBDIR}/extensions"
272 -TEMPDIR=''
273 -GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
274 -GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
275 -OUTPUT='mygnap-core.tar'
276 -
277 -G=$'\e[32;01m'
278 -B=$'\e[31;01m'
279 -N=$'\e[0m'
280 -W=$'\e[33;01m'
281 -K=$'\e[34;01m'
282 -C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
283 -E=$'\e['${C}'G'
284 -
285 -gwarn() {
286 - echo -e " ${W}*${N} ${*}"
287 -}
288 -
289 -gmkdir() {
290 - mkdir -p "$1"
291 - gtest continued $? "Failed to create directory \"$1\"."
292 -}
293 -
294 -gconfirm() {
295 - if [[ "${FORCEYES}" -eq 1 ]]; then
296 - gwarn "${*} forced to yes"
297 - else
298 - read -ep " ${W}*${N} ${*} [N]: " answer
299 - if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
300 - if [[ -n "${TEMPDIR}" ]]; then
301 - cleanup
302 - fi
303 - echo 'Remaster aborted!'
304 - exit 2
305 - fi
306 - fi
307 -}
308 -
309 -gbegin() {
310 - echo -ne " ${G}*${N} ${*}..."
311 -}
312 +source ${GNAPLIBDIR}/gnap_shared.sh
313 +echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
314
315 -gtest() {
316 - continued=0
317 - if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
318 - shift
319 - continued=1
320 - fi
321 -
322 - if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
323 - if [[ "${continued}" -eq 0 ]]; then
324 - echo -e "${E} ${K}[ ${G}ok${K} ]${N}"
325 - fi
326 - else
327 - echo -e "${E} ${K}[ ${B}!!${K} ]${N}"
328 - if [[ "$#" -ge 2 ]]; then
329 - shift
330 - echo -en " ${B}*${N} ${*}"
331 - echo -e "${E} ${K}[ ${B}!!${K} ]${N}"
332 - fi
333 - if [[ -n "${TEMPDIR}" ]]; then
334 - cleanup
335 - fi
336 - echo "Remaster failed, try ${GNAPNAME} -h for more help"
337 - exit 1
338 - fi
339 -}
340 +OUTPUT='mygnap-core.tar'
341
342 usage() {
343 echo
344 @@ -90,18 +25,6 @@
345 echo "Please use man ${GNAPNAME} for more details."
346 }
347
348 -cleanup() {
349 - gbegin 'Cleaning temporary directories'
350 - if [[ -d "${TEMPDIR}" ]]; then
351 - DIRTOREMOVE="${TEMPDIR}"
352 - TEMPDIR=''
353 - rm -rf "${DIRTOREMOVE}"
354 - gtest $? "Failed to remove ${DIRTOREMOVE}"
355 - else
356 - gtest 0
357 - fi
358 -}
359 -
360 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
361 usage
362 exit 0
363 diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
364 +cleanup/tools/gnap_shared.sh gnap-2.0+cleanup
365 +split/tools/gnap_shared.sh
366 --- gnap-2.0+cleanup/tools/gnap_shared.sh 2007-08-03 16:28:37.000000000
367 +0300
368 +++ gnap-2.0+cleanup+split/tools/gnap_shared.sh 2007-08-02
369 15:54:46.000000000 +0300
370 @@ -0,0 +1,102 @@
371 +GNAPNAME=$(basename "$0")
372 +
373 +case ${GNAPNAME} in
374 + gnap_make ) GNAP_PRODUCT="Build";;
375 + gnap_overlay ) GNAP_PRODUCT="Overlay";;
376 + gnap_remaster ) GNAP_PRODUCT="Remaster";;
377 + * ) GNAP_PRODUCT="Something";;
378 +esac
379 +STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
380 +SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
381 +SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
382 +GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
383 +GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
384 +GNAPEXTDIR="${GNAPLIBDIR}/extensions"
385 +GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
386 +
387 +TEMPDIR=''
388 +LOOP=''
389 +FORCEYES=0
390 +
391 +G=$'\e[32;01m'
392 +B=$'\e[31;01m'
393 +N=$'\e[0m'
394 +W=$'\e[33;01m'
395 +K=$'\e[34;01m'
396 +C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
397 +E=$'\e['${C}'G'
398 +
399 +gwarn() {
400 + echo -e " ${W}*${N} ${*}"
401 +}
402 +
403 +ginfo() {
404 + echo -e " ${G}*${N} ${*}"
405 +}
406 +
407 +gmkdir() {
408 + mkdir -p "$1"
409 + gtest continued $? "Failed to create \"$1\"."
410 +}
411 +
412 +gconfirm() {
413 + if [[ "${FORCEYES}" -eq 1 ]]; then
414 + gwarn "${*} forced to yes"
415 + else
416 + read -ep " ${W}*${N} ${*} [N]: " answer
417 + if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
418 + if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
419 + cleanup
420 + fi
421 + echo '${GNAP_PRODUCT} aborted!'
422 + exit 2
423 + fi
424 + fi
425 +}
426 +
427 +gbegin() {
428 + echo -ne " ${G}*${N} ${*}..."
429 +}
430 +
431 +gtest() {
432 + continued=0
433 + if [[ "${#}" -gt 0 && "${1}" == 'continued' ]]; then
434 + shift
435 + continued=1
436 + fi
437 +
438 + if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
439 + if [[ "${continued}" -eq 0 ]]; then
440 + echo -e "${E} ${K}[ ${G}ok${K} ]${N}"
441 + fi
442 + else
443 + echo -e "${E} ${K}[ ${B}!!${K} ]${N}"
444 + if [[ "${#}" -ge 2 ]]; then
445 + shift
446 + echo -en " ${B}*${N} ${*}"
447 + echo -e "${E} ${K}[ ${B}!!${K} ]${N}"
448 + fi
449 + if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
450 + cleanup
451 + fi
452 + echo " ${GNAP_PRODUCT} failed, try ${GNAPNAME} -h for more help"
453 + exit 1
454 + fi
455 +}
456 +
457 +cleanup() {
458 + if [[ -n "${LOOP}" ]]; then
459 + gbegin 'Unmounting loop filesystem'
460 + umount "${LOOP}" && losetup -d "${LOOP}"
461 + gtest $? "Failed to unmount ${LOOP}"
462 + fi
463 + gbegin 'Cleaning temporary directories'
464 + if [[ -d "${TEMPDIR}" ]]; then
465 + DIRTOREMOVE="${TEMPDIR}"
466 + TEMPDIR=''
467 + rm -rf "${DIRTOREMOVE}"
468 + gtest $? "Failed to remove ${DIRTOREMOVE}"
469 + else
470 + gtest 0
471 + fi
472 +}
473
474 --
475 gnap-dev@g.o mailing list