|
@@ -19,17 +19,41 @@ build1() {
|
19
|
19
|
#
|
20
|
20
|
# Process one skeleton
|
21
|
21
|
#
|
22
|
|
- local srcpath dstpath
|
23
|
|
- srcpath=$1
|
24
|
|
- dstpath=${srcpath%.skel}
|
25
|
|
- case $dstpath in
|
26
|
|
- *.md) <"$srcpath" expand_includes | expand_variables >"$dstpath" ;;
|
27
|
|
- *) <"$srcpath" expand_variables >"$dstpath" ;;
|
28
|
|
- esac
|
|
22
|
+ local srcpath="$1"
|
|
23
|
+ local dstpath="$2"
|
|
24
|
+ local ftype="$3"
|
|
25
|
+ test -n "$dstpath" || dstpath=${srcpath%.skel}
|
|
26
|
+ test -n "$ftype" || ftype=$(guess_ftype "$dstpath")
|
|
27
|
+ debug_var srcpath dstpath ftype
|
|
28
|
+ <"$srcpath" build1_ftype "$ftype" >"$dstpath"
|
29
|
29
|
mkdir -p "$MKIT_LOCAL"
|
30
|
30
|
echo "$dstpath" >> "$MKIT_LOCAL/built.lst"
|
31
|
31
|
}
|
32
|
32
|
|
|
33
|
+guess_ftype() {
|
|
34
|
+ #
|
|
35
|
+ # Guess file type from destination path $1
|
|
36
|
+ #
|
|
37
|
+ local dstpath="$1"
|
|
38
|
+ case $dstpath in
|
|
39
|
+ *.md) echo markdown ;;
|
|
40
|
+ *) echo MKIT_COMMON ;;
|
|
41
|
+ esac
|
|
42
|
+}
|
|
43
|
+
|
|
44
|
+build1_ftype() {
|
|
45
|
+ #
|
|
46
|
+ # Build a file of type $1
|
|
47
|
+ #
|
|
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
|
|
55
|
+}
|
|
56
|
+
|
33
|
57
|
build_manpages() {
|
34
|
58
|
local manfile mdfile
|
35
|
59
|
if command -v ronn >/dev/null;
|
|
@@ -64,16 +88,32 @@ dist() {
|
64
|
88
|
#
|
65
|
89
|
# Create distributable tarball
|
66
|
90
|
#
|
|
91
|
+ #FIXME: lacking Makefile skills, we do this step twice fot
|
|
92
|
+ # rpmstuff, hence -f hack for gzip
|
|
93
|
+ #
|
67
|
94
|
local version=$(get_version)
|
68
|
95
|
local dirname=$MKIT_PKGNAME-$version
|
69
|
96
|
mkdir -p "$dirname"
|
70
|
97
|
ini values "lists:dist" | xargs -I DIST_ITEM cp -R DIST_ITEM "$dirname"
|
71
|
98
|
sed -i -e "s/^VERSION = .*/VERSION = $version/" "$dirname/config.mk"
|
72
|
99
|
tar -cf "$dirname.tar" "$dirname"
|
73
|
|
- gzip "$dirname.tar"
|
|
100
|
+ gzip -f "$dirname.tar" # see above FIXME
|
|
101
|
+ mkdir -p "$MKIT_LOCAL"
|
|
102
|
+ echo "$dirname.tar.gz" >> "$MKIT_LOCAL/built.lst"
|
74
|
103
|
rm -rf "$dirname"
|
75
|
104
|
}
|
76
|
105
|
|
|
106
|
+rpmstuff() {
|
|
107
|
+ #
|
|
108
|
+ # Build specfile
|
|
109
|
+ #
|
|
110
|
+ local specname="$(ini 1value ENV:PKGNAME).spec"
|
|
111
|
+ local specsrc="$(ini 1value "rpmstuff:spec_skel")"
|
|
112
|
+ test -n "$specsrc" || die "rpmstuff:spec_skel not specified"
|
|
113
|
+ test -f "$specsrc" || die "specfile template not found: $specsrc"
|
|
114
|
+ build1 "$specsrc" "$specname"
|
|
115
|
+}
|
|
116
|
+
|
77
|
117
|
expand_includes() {
|
78
|
118
|
#
|
79
|
119
|
# Expand include directives
|
|
@@ -101,19 +141,24 @@ expand_includes() {
|
101
|
141
|
|
102
|
142
|
expand_variables() {
|
103
|
143
|
#
|
104
|
|
- # Expand variable values
|
|
144
|
+ # Expand variables from sections $@
|
105
|
145
|
#
|
106
|
146
|
local script=$(mktemp --tmpdir mkit-tmp.XXXXXXXXXX)
|
107
|
|
- local varname varvalue
|
108
|
|
- ini lskeys "vars" \
|
109
|
|
- | while read varname;
|
110
|
|
- do
|
111
|
|
- varvalue="$(ini 1value "vars:$varname" | sed -e 's/\$/\\$/' )"
|
112
|
|
- echo "s|$varname|$varvalue|;" >> "$script"
|
113
|
|
- done
|
|
147
|
+ local section varname varvalue
|
|
148
|
+ for section in "$@";
|
|
149
|
+ do
|
|
150
|
+ debug_var section
|
|
151
|
+ ini lskeys "$section" \
|
|
152
|
+ | while read varname;
|
|
153
|
+ do
|
|
154
|
+ varvalue="$(ini 1value "$section:$varname" | sed -e 's/\$/\\$/' )"
|
|
155
|
+ echo "s|$varname|$varvalue|;" >> "$script"
|
|
156
|
+ debug_var varname varvalue
|
|
157
|
+ done
|
|
158
|
+ done
|
114
|
159
|
echo "s|__CODENAME__|$CODENAME|;" >> "$script"
|
115
|
160
|
echo "s|__VERSION__|$(get_version)|;" >> "$script"
|
116
|
|
- perl -wp "$script"
|
|
161
|
+ perl -wp "$script" || die "expand_variables failed"
|
117
|
162
|
rm "$script"
|
118
|
163
|
}
|
119
|
164
|
|