Преглед изворни кода

Move caching and build-recording code into private part of build.sh

Alois Mahdal пре 6 година
родитељ
комит
a8266e3479
2 измењених фајлова са 41 додато и 41 уклоњено
  1. 41
    7
      src/include/build.sh
  2. 0
    34
      src/include/mkit.sh

+ 41
- 7
src/include/build.sh Прегледај датотеку

@@ -17,7 +17,7 @@ __build1() {
17 17
     test -n "$ftype"    || ftype=$(__guess_ftype "$dstpath")
18 18
     debug_var srcpath dstpath ftype
19 19
     <"$srcpath" __build1_ftype "$ftype" >"$dstpath"
20
-    rec_built "$dstpath"
20
+    __rec_built "$dstpath"
21 21
 }
22 22
 
23 23
 __build1_ftype() {
@@ -100,9 +100,43 @@ __cached() {
100 100
     # arguments).
101 101
     #
102 102
     local name=$1
103
-    local_get "$name" && return 0
104
-    "$name" | local_putb "$name"
105
-    local_get "$name"
103
+    __local_get "$name" && return 0
104
+    "$name" | __local_putb "$name"
105
+    __local_get "$name"
106
+}
107
+
108
+__local_putb() {
109
+    #
110
+    # Make file $1 in $MKIT_LOCAL from stdin and mark as built
111
+    #
112
+    local fpath=$1
113
+    __local_put "$fpath" && __rec_built "$MKIT_LOCAL/$fpath"
114
+}
115
+
116
+__local_put() {
117
+    #
118
+    # Make file $1 in $MKIT_LOCAL from stdin
119
+    #
120
+    local fpath="$MKIT_LOCAL/$1"
121
+    { mkdir -p "${fpath%/*}" && cat >"$fpath"; } \
122
+     || die "cannot write to local cache: $fpath"
123
+}
124
+
125
+__local_get() {
126
+    #
127
+    # Read file $1 in $MKIT_LOCAL
128
+    #
129
+    local fpath="$MKIT_LOCAL/$1"
130
+    cat "$fpath" 2>/dev/null
131
+}
132
+
133
+__rec_built() {
134
+    #
135
+    # Record file $1 for deletion on `clean`
136
+    #
137
+    local file=$1
138
+    mkdir -p "$MKIT_LOCAL"
139
+    echo "$file" >> "$MKIT_LOCAL/built.lst"
106 140
 }
107 141
 
108 142
 _mkit_data() {
@@ -177,7 +211,7 @@ debstuff() {
177 211
     mv "${MKIT_PROJ_PKGNAME}-$version.tar.gz" \
178 212
        "${MKIT_PROJ_PKGNAME}_$version.orig.tar.gz" \
179 213
      || die "could not rename tarball"
180
-    rec_built "${MKIT_PROJ_PKGNAME}_$version.orig.tar.gz"
214
+    __rec_built "${MKIT_PROJ_PKGNAME}_$version.orig.tar.gz"
181 215
 
182 216
     # read content of each mandatory file from debian_skel
183 217
     #
@@ -191,7 +225,7 @@ debstuff() {
191 225
             mkdir -p "$(dirname "$dftgt")"
192 226
             __build1 "$dfsrc" "$dftgt" debstuff
193 227
         done
194
-    rec_built debian
228
+    __rec_built debian
195 229
 }
196 230
 
197 231
 dist() {
@@ -214,7 +248,7 @@ dist() {
214 248
     echo -n "$git_lasthash" > "$dirname/.mkit/git_lasthash"
215 249
     tar -cf "$dirname.tar" "$dirname"
216 250
     gzip -f "$dirname.tar"      # see above FIXME
217
-    rec_built "$dirname.tar.gz"
251
+    __rec_built "$dirname.tar.gz"
218 252
     rm -rf "$dirname"
219 253
 }
220 254
 

+ 0
- 34
src/include/mkit.sh Прегледај датотеку

@@ -125,31 +125,6 @@ __chkiniversion() {
125 125
      || die "bad mkit.ini version: $their_ver does not match $MKIT_VERSION"
126 126
 }
127 127
 
128
-local_putb() {
129
-    #
130
-    # Make file $1 in $MKIT_LOCAL from stdin and mark as built
131
-    #
132
-    local fpath=$1
133
-    local_put "$fpath" && rec_built "$MKIT_LOCAL/$fpath"
134
-}
135
-
136
-local_put() {
137
-    #
138
-    # Make file $1 in $MKIT_LOCAL from stdin
139
-    #
140
-    local fpath="$MKIT_LOCAL/$1"
141
-    { mkdir -p "${fpath%/*}" && cat >"$fpath"; } \
142
-     || die "cannot write to local cache: $fpath"
143
-}
144
-
145
-local_get() {
146
-    #
147
-    # Read file $1 in $MKIT_LOCAL
148
-    #
149
-    local fpath="$MKIT_LOCAL/$1"
150
-    cat "$fpath" 2>/dev/null
151
-}
152
-
153 128
 mkit_init() {
154 129
     #
155 130
     # Do basic initialization
@@ -163,15 +138,6 @@ mkit_init() {
163 138
     __chkiniversion
164 139
 }
165 140
 
166
-rec_built() {
167
-    #
168
-    # Record file $1 for deletion on `clean`
169
-    #
170
-    local file=$1
171
-    mkdir -p "$MKIT_LOCAL"
172
-    echo "$file" >> "$MKIT_LOCAL/built.lst"
173
-}
174
-
175 141
 route() {
176 142
     #
177 143
     # Call correct function based on $1