/[gentoo-src]/rc-scripts/src/awk/cachedepends.awk
Gentoo

Diff of /rc-scripts/src/awk/cachedepends.awk

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.9 Revision 1.10
1# Copyright 1999-2003 Gentoo Technologies, Inc. 1# Copyright 1999-2003 Gentoo Technologies, Inc.
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# Author: Martin Schlemmer <azarah@gentoo.org> 3# Author: Martin Schlemmer <azarah@gentoo.org>
4# $Header: /var/cvsroot/gentoo-src/rc-scripts/src/awk/cachedepends.awk,v 1.9 2003/02/06 02:08:05 azarah Exp $ 4# $Header: /var/cvsroot/gentoo-src/rc-scripts/src/awk/cachedepends.awk,v 1.10 2003/05/11 23:32:47 azarah Exp $
5 5
6function print_start() { 6function print_start() {
7 print "source /sbin/functions.sh" >> (DEPCACHE) 7 print "source /sbin/functions.sh"
8 print "" >> (DEPCACHE) 8 print ""
9 print "need() {" >> (DEPCACHE) 9 print "need() {"
10 print " echo \"NEED $*\"; return 0" >> (DEPCACHE) 10 print " echo \"NEED $*\"; return 0"
11 print "}" >> (DEPCACHE) 11 print "}"
12 print "" >> (DEPCACHE) 12 print ""
13 print "use() {" >> (DEPCACHE) 13 print "use() {"
14 print " echo \"USE $*\"; return 0" >> (DEPCACHE) 14 print " echo \"USE $*\"; return 0"
15 print "}" >> (DEPCACHE) 15 print "}"
16 print "" >> (DEPCACHE) 16 print ""
17 print "before() {" >> (DEPCACHE) 17 print "before() {"
18 print " echo \"BEFORE $*\"; return 0" >> (DEPCACHE) 18 print " echo \"BEFORE $*\"; return 0"
19 print "}" >> (DEPCACHE) 19 print "}"
20 print "" >> (DEPCACHE) 20 print ""
21 print "after() {" >> (DEPCACHE) 21 print "after() {"
22 print " echo \"AFTER $*\"; return 0" >> (DEPCACHE) 22 print " echo \"AFTER $*\"; return 0"
23 print "}" >> (DEPCACHE) 23 print "}"
24 print "" >> (DEPCACHE) 24 print ""
25 print "provide() {" >> (DEPCACHE) 25 print "provide() {"
26 print " echo \"PROVIDE $*\"; return 0" >> (DEPCACHE) 26 print " echo \"PROVIDE $*\"; return 0"
27 print "}" >> (DEPCACHE) 27 print "}"
28 print "" >> (DEPCACHE) 28 print ""
29 print "parallel() {"
30 print " echo \"PARALLEL $*\"; return 0"
31 print "}"
32 print ""
29} 33}
30 34
31function print_header1() { 35function print_header1() {
32 print "#*** " MYFILENAME " ***" >> (DEPCACHE) 36 print "#*** " MYFILENAME " ***"
33 print "" >> (DEPCACHE) 37 print ""
34 print "myservice=\"" MYFILENAME "\"" >> (DEPCACHE) 38 print "myservice=\"" MYFILENAME "\""
35 print "myservice=\"${myservice##*/}\"" >> (DEPCACHE) 39 print "myservice=\"${myservice##*/}\""
36 print "echo \"RCSCRIPT ${myservice}\"" >> (DEPCACHE) 40 print "echo \"RCSCRIPT ${myservice}\""
37 print "" >> (DEPCACHE) 41 print ""
38} 42}
39 43
40function print_header2() { 44function print_header2() {
41 print "(" >> (DEPCACHE) 45 print "("
42 print " # Get settings for rc-script ..." >> (DEPCACHE) 46 print " # Get settings for rc-script ..."
43 print " [ -e /etc/conf.d/basic ] && source /etc/conf.d/basic" >> (DEPCACHE) 47 print " [ -e /etc/conf.d/basic ] && source /etc/conf.d/basic"
44 print "" >> (DEPCACHE) 48 print ""
45 print " [ -e \"/etc/conf.d/${myservice}\" ] && source \"/etc/conf.d/${myservice}\"" >> (DEPCACHE) 49 print " [ -e \"/etc/conf.d/${myservice}\" ] && source \"/etc/conf.d/${myservice}\""
46 print "" >> (DEPCACHE) 50 print ""
47 print " [ -e /etc/conf.d/net ] && \\" >> (DEPCACHE) 51 print " [ -e /etc/conf.d/net ] && \\"
48 print " [ \"${myservice%%.*}\" = \"net\" ] && \\" >> (DEPCACHE) 52 print " [ \"${myservice%%.*}\" = \"net\" ] && \\"
49 print " [ \"${myservice##*.}\" != \"${myservice}\" ] && source /etc/conf.d/net" >> (DEPCACHE) 53 print " [ \"${myservice##*.}\" != \"${myservice}\" ] && source /etc/conf.d/net"
50 print "" >> (DEPCACHE) 54 print ""
51 print " [ -e /etc/rc.conf ] && source /etc/rc.conf" >> (DEPCACHE) 55 print " [ -e /etc/rc.conf ] && source /etc/rc.conf"
52 print "" >> (DEPCACHE) 56 print ""
53 print " depend() {" >> (DEPCACHE) 57 print " depend() {"
54 print " return 0" >> (DEPCACHE) 58 print " return 0"
55 print " }" >> (DEPCACHE) 59 print " }"
56 print "" >> (DEPCACHE) 60 print ""
57} 61}
58 62
59function print_end() { 63function print_end() {
60 print "" >> (DEPCACHE) 64 print ""
61 print " depend" >> (DEPCACHE) 65 print " depend"
62 print ")" >> (DEPCACHE) 66 print ")"
63 print "" >> (DEPCACHE) 67 print ""
64} 68}
65 69
66BEGIN { 70BEGIN {
67 71
68 extension("/lib/rcscripts/filefuncs.so", "dlload") 72 extension("/lib/rcscripts/filefuncs.so", "dlload")
87 91
88 if (RCCOUNT == 0) { 92 if (RCCOUNT == 0) {
89 eerror("No scripts to process!") 93 eerror("No scripts to process!")
90 exit 1 94 exit 1
91 } 95 }
92
93 DEPCACHE=SVCDIR "/depcache"
94
95 unlink(DEPCACHE)
96 96
97 print_start() 97 print_start()
98 98
99 for (count = 1;count <= RCCOUNT;count++) { 99 for (count = 1;count <= RCCOUNT;count++) {
100 100
127 if ($0 ~ /depend[[:space:]]*\(\)/) { 127 if ($0 ~ /depend[[:space:]]*\(\)/) {
128 128
129 GOTDEPEND = 1 129 GOTDEPEND = 1
130 130
131 print_header2() 131 print_header2()
132 print " # Actual depend() function ..." >> (DEPCACHE) 132 print " # Actual depend() function ..."
133 } 133 }
134 134
135 # We have the depend function... 135 # We have the depend function...
136 if (GOTDEPEND) { 136 if (GOTDEPEND) {
137 137
143 # This is just to verify that we have started with 143 # This is just to verify that we have started with
144 # the body of depend() 144 # the body of depend()
145 SBCOUNT += gsub(/{/, "{") 145 SBCOUNT += gsub(/{/, "{")
146 146
147 # Print the depend() function 147 # Print the depend() function
148 print " " $0 >> (DEPCACHE) 148 print " " $0
149 149
150 # If COUNT=0, and SBCOUNT>0, it means we have read 150 # If COUNT=0, and SBCOUNT>0, it means we have read
151 # all matching '{' and '}' for depend(), so stop. 151 # all matching '{' and '}' for depend(), so stop.
152 if ((SBCOUNT > 0) && (COUNT == 0)) { 152 if ((SBCOUNT > 0) && (COUNT == 0)) {
153 153
170 close(RCSCRIPTS[count]) 170 close(RCSCRIPTS[count])
171 171
172 NEXTFILE = 0 172 NEXTFILE = 0
173 173
174 } 174 }
175
176 close (DEPCACHE)
177} 175}
178 176
179 177
180# vim:ts=4 178# vim:ts=4

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.20