|
@@ -3,18 +3,6 @@
|
3
|
3
|
. "$MKIT_DIR/include/ini.sh" || die "cannot import ini.sh"
|
4
|
4
|
|
5
|
5
|
|
6
|
|
-build() {
|
7
|
|
- #
|
8
|
|
- # Add meat to all skeletons
|
9
|
|
- #
|
10
|
|
- local srcpath
|
11
|
|
- find src -type f -name '*.skel' \
|
12
|
|
- | while read srcpath;
|
13
|
|
- do
|
14
|
|
- _build1 "$srcpath"
|
15
|
|
- done
|
16
|
|
-}
|
17
|
|
-
|
18
|
6
|
_build1() {
|
19
|
7
|
#
|
20
|
8
|
# Process one skeleton
|
|
@@ -30,6 +18,73 @@ _build1() {
|
30
|
18
|
echo "$dstpath" >> "$MKIT_LOCAL/built.lst"
|
31
|
19
|
}
|
32
|
20
|
|
|
21
|
+_build1_ftype() {
|
|
22
|
+ #
|
|
23
|
+ # Build a file of type $1
|
|
24
|
+ #
|
|
25
|
+ local ftype="$1"
|
|
26
|
+ case $ftype in
|
|
27
|
+ MKIT_COMMON) _expand_variables "vars" ;;
|
|
28
|
+ markdown) _expand_includes | _expand_variables "vars" ;;
|
|
29
|
+ rpmstuff) _expand_variables "vars" "rpmstuff:vars" ;;
|
|
30
|
+ *) die "unknown file type: $ftype" ;;
|
|
31
|
+ esac
|
|
32
|
+}
|
|
33
|
+
|
|
34
|
+_expand_includes() {
|
|
35
|
+ #
|
|
36
|
+ # Expand include directives
|
|
37
|
+ #
|
|
38
|
+ # Expand e.g. `<!-- include4: foo.sh -->` to include code of foo.sh
|
|
39
|
+ #
|
|
40
|
+ perl -we '
|
|
41
|
+ use strict;
|
|
42
|
+ my $text;
|
|
43
|
+ while (<>) {
|
|
44
|
+ chomp;
|
|
45
|
+ if (m/<!-- include4: (\S+) -->/) {
|
|
46
|
+ open my $fh, $1 or warn "cannot find: $1";
|
|
47
|
+ my $text = do { local($/); <$fh> };
|
|
48
|
+ close $fh;
|
|
49
|
+ $text =~ s/^(.)/ $1/gm;
|
|
50
|
+ chomp $text;
|
|
51
|
+ print "$text\n";
|
|
52
|
+ } else {
|
|
53
|
+ print "$_\n";
|
|
54
|
+ }
|
|
55
|
+ }
|
|
56
|
+ '
|
|
57
|
+}
|
|
58
|
+
|
|
59
|
+_expand_variables() {
|
|
60
|
+ #
|
|
61
|
+ # Expand variables from sections $@
|
|
62
|
+ #
|
|
63
|
+ local script=$(mktemp --tmpdir mkit-tmp.XXXXXXXXXX)
|
|
64
|
+ local section varname varvalue
|
|
65
|
+ {
|
|
66
|
+ for section in "$@";
|
|
67
|
+ do
|
|
68
|
+ debug_var section
|
|
69
|
+ ini lskeys "$section" \
|
|
70
|
+ | while read varname;
|
|
71
|
+ do
|
|
72
|
+ varvalue="$(ini 1value "$section:$varname" | sed -e 's/\$/\\$/' )"
|
|
73
|
+ echo "s|$varname|$varvalue|g;"
|
|
74
|
+ debug_var varname varvalue
|
|
75
|
+ done
|
|
76
|
+ done
|
|
77
|
+ echo "s|__MKIT_PROJ_NAME__|$(ini 1value project:name)|g;"
|
|
78
|
+ echo "s|__MKIT_PROJ_CODENAME__|$(ini 1value project:codename)|g;"
|
|
79
|
+ echo "s|__MKIT_PROJ_PKGNAME__|$(ini 1value project:pkgname)|g;"
|
|
80
|
+ echo "s|__MKIT_PROJ_TAGLINE__|$(ini 1value project:tagline)|g;"
|
|
81
|
+ echo "s|__MKIT_PROJ_VERSION__|$(get_version)|g;"
|
|
82
|
+ echo "s|__MKIT_SELF_VERSION__|$MKIT_VERSION|g;"
|
|
83
|
+ } >> "$script"
|
|
84
|
+ perl -wp "$script" || die "_expand_variables failed"
|
|
85
|
+ rm "$script"
|
|
86
|
+}
|
|
87
|
+
|
33
|
88
|
_guess_ftype() {
|
34
|
89
|
#
|
35
|
90
|
# Guess file type from destination path $1
|
|
@@ -41,17 +96,17 @@ _guess_ftype() {
|
41
|
96
|
esac
|
42
|
97
|
}
|
43
|
98
|
|
44
|
|
-_build1_ftype() {
|
|
99
|
+
|
|
100
|
+build() {
|
45
|
101
|
#
|
46
|
|
- # Build a file of type $1
|
|
102
|
+ # Add meat to all skeletons
|
47
|
103
|
#
|
48
|
|
- local ftype="$1"
|
49
|
|
- case $ftype in
|
50
|
|
- MKIT_COMMON) _expand_variables "vars" ;;
|
51
|
|
- markdown) _expand_includes | _expand_variables "vars" ;;
|
52
|
|
- rpmstuff) _expand_variables "vars" "rpmstuff:vars" ;;
|
53
|
|
- *) die "unknown file type: $ftype" ;;
|
54
|
|
- esac
|
|
104
|
+ local srcpath
|
|
105
|
+ find src -type f -name '*.skel' \
|
|
106
|
+ | while read srcpath;
|
|
107
|
+ do
|
|
108
|
+ _build1 "$srcpath"
|
|
109
|
+ done
|
55
|
110
|
}
|
56
|
111
|
|
57
|
112
|
build_manpages() {
|
|
@@ -85,25 +140,6 @@ clean() {
|
85
|
140
|
true
|
86
|
141
|
}
|
87
|
142
|
|
88
|
|
-dist() {
|
89
|
|
- #
|
90
|
|
- # Create distributable tarball
|
91
|
|
- #
|
92
|
|
- #FIXME: lacking Makefile skills, we do this step twice fot
|
93
|
|
- # rpmstuff, hence -f hack for gzip
|
94
|
|
- #
|
95
|
|
- local version=$(get_version)
|
96
|
|
- local dirname=$MKIT_PROJ_PKGNAME-$version
|
97
|
|
- mkdir -p "$dirname"
|
98
|
|
- ini values "lists:dist" | xargs -I DIST_ITEM cp -R DIST_ITEM "$dirname"
|
99
|
|
- update_version "$version" "$dirname/mkit.ini"
|
100
|
|
- tar -cf "$dirname.tar" "$dirname"
|
101
|
|
- gzip -f "$dirname.tar" # see above FIXME
|
102
|
|
- mkdir -p "$MKIT_LOCAL"
|
103
|
|
- echo "$dirname.tar.gz" >> "$MKIT_LOCAL/built.lst"
|
104
|
|
- rm -rf "$dirname"
|
105
|
|
-}
|
106
|
|
-
|
107
|
143
|
debstuff() {
|
108
|
144
|
#
|
109
|
145
|
# Build Debian stuff (eamed tarball, debian dir)
|
|
@@ -134,69 +170,23 @@ debstuff() {
|
134
|
170
|
echo debian >> "$MKIT_LOCAL/built.lst"
|
135
|
171
|
}
|
136
|
172
|
|
137
|
|
-rpmstuff() {
|
138
|
|
- #
|
139
|
|
- # Build specfile
|
140
|
|
- #
|
141
|
|
- local specname="$MKIT_PROJ_PKGNAME.spec"
|
142
|
|
- local specsrc="$(ini 1value "rpmstuff:spec_skel")"
|
143
|
|
- test -n "$specsrc" || die "rpmstuff:spec_skel not specified"
|
144
|
|
- test -f "$specsrc" || die "specfile template not found: $specsrc"
|
145
|
|
- _build1 "$specsrc" "$specname"
|
146
|
|
-}
|
147
|
|
-
|
148
|
|
-_expand_includes() {
|
149
|
|
- #
|
150
|
|
- # Expand include directives
|
151
|
|
- #
|
152
|
|
- # Expand e.g. `<!-- include4: foo.sh -->` to include code of foo.sh
|
|
173
|
+dist() {
|
153
|
174
|
#
|
154
|
|
- perl -we '
|
155
|
|
- use strict;
|
156
|
|
- my $text;
|
157
|
|
- while (<>) {
|
158
|
|
- chomp;
|
159
|
|
- if (m/<!-- include4: (\S+) -->/) {
|
160
|
|
- open my $fh, $1 or warn "cannot find: $1";
|
161
|
|
- my $text = do { local($/); <$fh> };
|
162
|
|
- close $fh;
|
163
|
|
- $text =~ s/^(.)/ $1/gm;
|
164
|
|
- chomp $text;
|
165
|
|
- print "$text\n";
|
166
|
|
- } else {
|
167
|
|
- print "$_\n";
|
168
|
|
- }
|
169
|
|
- }
|
170
|
|
- '
|
171
|
|
-}
|
172
|
|
-
|
173
|
|
-_expand_variables() {
|
|
175
|
+ # Create distributable tarball
|
174
|
176
|
#
|
175
|
|
- # Expand variables from sections $@
|
|
177
|
+ #FIXME: lacking Makefile skills, we do this step twice fot
|
|
178
|
+ # rpmstuff, hence -f hack for gzip
|
176
|
179
|
#
|
177
|
|
- local script=$(mktemp --tmpdir mkit-tmp.XXXXXXXXXX)
|
178
|
|
- local section varname varvalue
|
179
|
|
- {
|
180
|
|
- for section in "$@";
|
181
|
|
- do
|
182
|
|
- debug_var section
|
183
|
|
- ini lskeys "$section" \
|
184
|
|
- | while read varname;
|
185
|
|
- do
|
186
|
|
- varvalue="$(ini 1value "$section:$varname" | sed -e 's/\$/\\$/' )"
|
187
|
|
- echo "s|$varname|$varvalue|g;"
|
188
|
|
- debug_var varname varvalue
|
189
|
|
- done
|
190
|
|
- done
|
191
|
|
- echo "s|__MKIT_PROJ_NAME__|$(ini 1value project:name)|g;"
|
192
|
|
- echo "s|__MKIT_PROJ_CODENAME__|$(ini 1value project:codename)|g;"
|
193
|
|
- echo "s|__MKIT_PROJ_PKGNAME__|$(ini 1value project:pkgname)|g;"
|
194
|
|
- echo "s|__MKIT_PROJ_TAGLINE__|$(ini 1value project:tagline)|g;"
|
195
|
|
- echo "s|__MKIT_PROJ_VERSION__|$(get_version)|g;"
|
196
|
|
- echo "s|__MKIT_SELF_VERSION__|$MKIT_VERSION|g;"
|
197
|
|
- } >> "$script"
|
198
|
|
- perl -wp "$script" || die "_expand_variables failed"
|
199
|
|
- rm "$script"
|
|
180
|
+ local version=$(get_version)
|
|
181
|
+ local dirname=$MKIT_PROJ_PKGNAME-$version
|
|
182
|
+ mkdir -p "$dirname"
|
|
183
|
+ ini values "lists:dist" | xargs -I DIST_ITEM cp -R DIST_ITEM "$dirname"
|
|
184
|
+ update_version "$version" "$dirname/mkit.ini"
|
|
185
|
+ tar -cf "$dirname.tar" "$dirname"
|
|
186
|
+ gzip -f "$dirname.tar" # see above FIXME
|
|
187
|
+ mkdir -p "$MKIT_LOCAL"
|
|
188
|
+ echo "$dirname.tar.gz" >> "$MKIT_LOCAL/built.lst"
|
|
189
|
+ rm -rf "$dirname"
|
200
|
190
|
}
|
201
|
191
|
|
202
|
192
|
get_version() {
|
|
@@ -280,3 +270,14 @@ get_version() {
|
280
|
270
|
fi
|
281
|
271
|
echo "$version"
|
282
|
272
|
}
|
|
273
|
+
|
|
274
|
+rpmstuff() {
|
|
275
|
+ #
|
|
276
|
+ # Build specfile
|
|
277
|
+ #
|
|
278
|
+ local specname="$MKIT_PROJ_PKGNAME.spec"
|
|
279
|
+ local specsrc="$(ini 1value "rpmstuff:spec_skel")"
|
|
280
|
+ test -n "$specsrc" || die "rpmstuff:spec_skel not specified"
|
|
281
|
+ test -f "$specsrc" || die "specfile template not found: $specsrc"
|
|
282
|
+ _build1 "$specsrc" "$specname"
|
|
283
|
+}
|