source: common/libs/func_compare.sh@ bea551c

trunk
Last change on this file since bea551c was 06b7314, checked in by Pierre Labastie <pierre.labastie@…>, 16 months ago

Allow two names for scriptlet containing "userdel"

It used to be named "revised_chroot", it is now named "cleanup"
Allow both names by testing whether revised something is present.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1#----------------------------------#
2wrt_compare_targets() { #
3#----------------------------------#
4
5 for ((N=1; N <= ITERATIONS ; N++)) ; do # Double parentheses,
6 # and "ITERATIONS" with no "$".
7 ITERATION=iteration-$N
8 if [ "$N" != "1" ] ; then
9 wrt_system_build "$1" "$N" "$PREV_IT"
10 fi
11 # add needed Makefile target
12 this_script=$ITERATION
13 CHROOT_wrt_target "$ITERATION" "$PREV"
14 wrt_compare_work "$ITERATION" "$PREV_IT"
15 wrt_logs "$N"
16 wrt_touch
17 PREV_IT=$ITERATION
18 PREV=$ITERATION
19 done
20 # We need to prevent "userdel" in all iterations but the last
21 # We need to access the scriptlets in "dir"
22 local dir
23 printf -v dir chapter%02d "$1"
24
25 REVISED=cleanup
26 if ls $dir/*revised* 2>/dev/null; then REVISED=revised; fi
27 sed -i '/userdel/d' $dir/*$REVISED*
28 for (( N = 2; N < ITERATIONS; N++ )); do
29 sed -i '/userdel/d' $dir-build_$N/*$REVISED*
30 done
31
32}
33
34#----------------------------------#
35wrt_system_build() { #
36#----------------------------------#
37 local CHAP=$1
38 local RUN=$2
39 local PREV_IT=$3
40
41 chapter_targets $CHAP $RUN
42
43 CHROOT_TGT="$CHROOT_TGT $PREV_IT $system_build"
44
45 if [[ "$RUN" = "$ITERATIONS" ]] ; then
46 CHROOT_TGT="$CHROOT_TGT iteration-$RUN"
47 fi
48}
49
50#----------------------------------#
51wrt_compare_work() { #
52#----------------------------------#
53 local ITERATION=$1
54 local PREV_IT=$2
55 local PRUNEPATH="/dev /home /${SCRIPT_ROOT} /lost+found /media /mnt /opt /proc \
56/sources /root /run /srv /sys /tmp /tools /usr/local /usr/src /var"
57
58 local ROOT_DIR=/
59 local DEST_TOPDIR=/${SCRIPT_ROOT}
60 local ICALOGDIR=/${SCRIPT_ROOT}/logs/ICA
61
62 if [[ "$RUN_ICA" = "y" ]] ; then
63 local DEST_ICA=$DEST_TOPDIR/ICA && \
64 # the PRUNEPATH additional setting is to avoid .pyc files to show up in diff
65(
66 cat << EOF
67 @PRUNEPATH="$PRUNEPATH \$\$(find /usr/lib -name __pycache__)"; \\
68 extras/do_copy_files "\$\$PRUNEPATH" $ROOT_DIR $DEST_ICA/$ITERATION >>logs/\$@ 2>&1 && \\
69 extras/do_ica_prep $DEST_ICA/$ITERATION >>logs/\$@ 2>&1
70EOF
71) >> $MKFILE.tmp
72 if [[ "$ITERATION" != "iteration-1" ]] ; then
73 wrt_do_ica_work "$PREV_IT" "$ITERATION" "$DEST_ICA"
74 fi
75 fi
76}
77
78#----------------------------------#
79wrt_do_ica_work() { #
80#----------------------------------#
81 echo -e "\t@extras/do_ica_work $1 $2 $ICALOGDIR $3 >>logs/\$@ 2>&1" >> $MKFILE.tmp
82}
83
84#----------------------------------#
85wrt_logs() { #
86#----------------------------------#
87 local build=build_$1
88 local file
89
90(
91 cat << EOF
92 @cd logs && \\
93 mkdir $build && \\
94 mv -f `echo ${system_build} | sed 's/ /* /g'`* $build && \\
95 if [ ! $build = build_1 ] ; then \\
96 cd $build && \\
97 for file in \`ls .\` ; do \\
98 mv -f \$\$file \`echo \$\$file | sed -e 's,-$build,,'\` ; \\
99 done ; \\
100 fi
101 @cd /\$(SCRIPT_ROOT)
102 @if [ -d test-logs ] ; then \\
103 cd test-logs && \\
104 mkdir $build && \\
105 mv -f `echo ${system_build} | sed 's/ /* /g'`* $build && \\
106 if [ ! $build = build_1 ] ; then \\
107 cd $build && \\
108 for file in \`ls .\` ; do \\
109 mv -f \$\$file \`echo \$\$file | sed -e 's,-$build,,'\` ; \\
110 done ; \\
111 fi ; \\
112 cd /\$(SCRIPT_ROOT) ; \\
113 fi ;
114EOF
115) >> $MKFILE.tmp
116}
Note: See TracBrowser for help on using the repository browser.