let ipkg fail when a package file to be installed is not found
[openwrt.git] / openwrt / package / base-files / default / usr / lib / parse-config.awk
1 {
2         line=$0
3         gsub(/^[ \t]*/, "")
4         gsub(/[ \t]*$/, "")
5 }
6
7 $1 == "@define" {
8         v[$2] = $3
9 }
10
11 $1 == "@ifdef" {
12         if_open = 1
13         if (v[$2] != "") noprint = 0
14         else noprint = 1
15 }
16
17 $1 == "@ifndef" {
18         if_open = 1
19         if (v[$2] != "") noprint = 1
20         else noprint = 0
21 }
22
23 $1 == "@else" {
24         if (noprint == 1) noprint = 0
25         else noprint = 1
26 }
27
28 ($1 !~ /^@/) && (noprint != 1) {
29         n=split(line "@@", a, /@@/)
30         for (i=1; i<=n; i++) {
31                 if ((i % 2) == 1) printf a[i]
32                 else printf v[a[i]]
33         }
34         print ""
35 }
36
37 $1 == "@endif" {
38         if_open = 0
39         noprint = 0
40 }