Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 70009 | Differences between
and this patch

Collapse All | Expand All

(-)/sbin/depscan.sh.orig (-52 / +75 lines)
Lines 5-76 Link Here
5
5
6
source /etc/init.d/functions.sh
6
source /etc/init.d/functions.sh
7
7
8
if [ ! -d "${svcdir}" ]
8
force=1
9
then
9
write=1
10
	if ! mkdir -p -m 0755 "${svcdir}" 2>/dev/null
10
11
for arg in "$@"; do
12
	if [[ ${arg} == "-u" ]]
13
	then
14
		force=0
15
	elif [[ ${arg} == "--write=no" ]]
11
	then
16
	then
12
		eerror " Could not create needed directory '${svcdir}'!"
17
		write=0
13
	fi
18
	fi
14
fi
19
done	
20
21
22
if [[ ${write} -eq 1 ]] 
23
then
15
24
16
for x in softscripts snapshot options started
25
	if [ ! -d "${svcdir}" ]
17
do
18
	if [ ! -d "${svcdir}/${x}" ]
19
	then
26
	then
20
		if ! mkdir -p -m 0755 "${svcdir}/${x}" 2>/dev/null
27
		if ! mkdir -p -m 0755 "${svcdir}" 2>/dev/null
21
		then
28
		then
22
			eerror " Could not create needed directory '${svcdir}/${x}'!"
29
			eerror " Could not create needed directory '${svcdir}'!"
23
		fi
30
		fi
24
	fi
31
	fi
25
done
32
	
26
33
	for x in softscripts snapshot options started
27
# Only update if files have actually changed
28
update=1
29
if [ "$1" == "-u" ]
30
then
31
	update=0
32
	for config in /etc/conf.d /etc/init.d /etc/rc.conf
33
	do
34
	do
34
		if [ "${config}" -nt "${svcdir}/depcache" ]
35
		if [ ! -d "${svcdir}/${x}" ]
35
		then
36
		then
36
			update=1
37
			if ! mkdir -p -m 0755 "${svcdir}/${x}" 2>/dev/null
37
			break
38
			then
39
				eerror " Could not create needed directory '${svcdir}/${x}'!"
40
			fi
38
		fi
41
		fi
39
	done
42
	done
40
	shift
41
fi
43
fi
42
[ ${update} -eq 0 ] && exit 0
43
44
ebegin "Caching service dependencies"
45
46
# Clean out the non volitile directories ...
47
rm -rf "${svcdir}"/dep{cache,tree} "${svcdir}"/{broken,snapshot}/*
48
44
49
retval=0
50
SVCDIR="${svcdir}"
51
DEPTYPES="${deptypes}"
52
ORDTYPES="${ordtypes}"
53
45
54
export SVCDIR DEPTYPES ORDTYPES
46
# Only update if files have actually changed
55
47
is_older_than "${svcdir}"/deptree /etc/conf.d /etc/init.d /etc/rc.conf && force=1
56
cd /etc/init.d
57
58
/bin/gawk \
59
	-f /lib/rcscripts/awk/functions.awk \
60
	-f /lib/rcscripts/awk/cachedepends.awk || \
61
	retval=1
62
63
bash "${svcdir}/depcache" | \
64
/bin/gawk \
65
	-f /lib/rcscripts/awk/functions.awk \
66
	-f /lib/rcscripts/awk/gendepends.awk || \
67
	retval=1
68
69
touch -m "${svcdir}"/dep{cache,tree}
70
71
eend ${retval} "Failed to cache service dependencies"
72
48
73
exit ${retval}
49
if [[ ${force} -eq 0 ]]
50
then
51
	# -u has been passed
52
	# and "${svcdir}"/deptree is up to date
53
	source "${svcdir}"/deptree
54
else
55
	
56
	ebegin "Caching service dependencies"
57
	
58
	if [[ ${write} -eq 1 ]] 
59
	then
60
		# Clean out the non volitile directories ...
61
		rm -rf "${svcdir}"/dep{cache,tree} "${svcdir}"/{broken,snapshot}/*
62
	fi
63
		
64
	retval=0
74
65
66
	DEPTREE="$(
75
67
76
# vim:ts=4
68
		SVCDIR="${svcdir}"
69
		DEPTYPES="${deptypes}"
70
		ORDTYPES="${ordtypes}"
71
		
72
		export SVCDIR DEPTYPES ORDTYPES
73
74
		set -o pipefail
75
		cd /etc/init.d
76
		/bin/gawk \
77
			-f /lib/rcscripts/awk/functions.awk \
78
			-f /lib/rcscripts/awk/cachedepends.awk | \
79
		bash | \
80
		/bin/gawk \
81
			-f /lib/rcscripts/awk/functions.awk \
82
			-f /lib/rcscripts/awk/gendepends.awk 
83
	)"
84
	
85
	retval=$?
86
	
87
	if [[ ${write} -eq 1 ]]
88
	then
89
		echo "${DEPTREE}" > "${svcdir}"/deptree
90
		touch -m "${svcdir}"/deptree
91
	fi
92
	
93
	eval "${DEPTREE}"
94
	eend ${retval} "Failed to cache service dependencies"
95
	
96
	# this is in a subshell just in case we were sourced
97
	# yet we do return ${retval}
98
	( exit ${retval} )
99
fi
(-)/lib/rcscripts/awk/cachedepends.awk.orig (-73 / +56 lines)
Lines 3-91 Link Here
3
# $Header: /var/cvsroot/gentoo-src/rc-scripts/src/awk/cachedepends.awk,v 1.19 2004/11/15 16:23:41 vapier Exp $
3
# $Header: /var/cvsroot/gentoo-src/rc-scripts/src/awk/cachedepends.awk,v 1.19 2004/11/15 16:23:41 vapier Exp $
4
4
5
function print_start() {
5
function print_start() {
6
	print "source /sbin/functions.sh" >> TMPCACHE
6
	print "source /sbin/functions.sh" 
7
	print "" >> TMPCACHE
7
	print "" 
8
	print "need() {" >> TMPCACHE
8
	print "need() {" 
9
	print "	echo \"NEED $*\"; return 0" >> TMPCACHE
9
	print "	echo \"NEED $*\"; return 0" 
10
	print "}" >> TMPCACHE
10
	print "}" 
11
	print "" >> TMPCACHE
11
	print "" 
12
	print "use() {" >> TMPCACHE
12
	print "use() {" 
13
	print "	echo \"USE $*\"; return 0" >> TMPCACHE
13
	print "	echo \"USE $*\"; return 0" 
14
	print "}" >> TMPCACHE
14
	print "}" 
15
	print "" >> TMPCACHE
15
	print "" 
16
	print "before() {" >> TMPCACHE
16
	print "before() {" 
17
	print "	echo \"BEFORE $*\"; return 0" >> TMPCACHE
17
	print "	echo \"BEFORE $*\"; return 0" 
18
	print "}" >> TMPCACHE
18
	print "}" 
19
	print "" >> TMPCACHE
19
	print "" 
20
	print "after() {" >> TMPCACHE
20
	print "after() {" 
21
	print "	echo \"AFTER $*\"; return 0" >> TMPCACHE
21
	print "	echo \"AFTER $*\"; return 0" 
22
	print "}" >> TMPCACHE
22
	print "}" 
23
	print "" >> TMPCACHE
23
	print "" 
24
	print "provide() {" >> TMPCACHE
24
	print "provide() {" 
25
	print "	echo \"PROVIDE $*\"; return 0" >> TMPCACHE
25
	print "	echo \"PROVIDE $*\"; return 0" 
26
	print "}" >> TMPCACHE
26
	print "}" 
27
	print "" >> TMPCACHE
27
	print "" 
28
	print "parallel() {" >> TMPCACHE
28
	print "parallel() {" 
29
	print "	echo \"PARALLEL $*\"; return 0" >> TMPCACHE
29
	print "	echo \"PARALLEL $*\"; return 0" 
30
	print "}" >> TMPCACHE
30
	print "}" 
31
	print "" >> TMPCACHE
31
	print "" 
32
}
32
}
33
33
34
function print_header1(mtime) {
34
function print_header1(mtime) {
35
	print "#*** " MYFILENAME " ***" >> TMPCACHE
35
	print "#*** " MYFILENAME " ***" 
36
	print "" >> TMPCACHE
36
	print "" 
37
	print "myservice=\"" MYFILENAME "\"" >> TMPCACHE
37
	print "myservice=\"" MYFILENAME "\"" 
38
	print "myservice=\"${myservice##*/}\"" >> TMPCACHE
38
	print "myservice=\"${myservice##*/}\"" 
39
	print "echo \"RCSCRIPT ${myservice}\"" >> TMPCACHE
39
	print "echo \"RCSCRIPT ${myservice}\"" 
40
	print "" >> TMPCACHE
40
	print "" 
41
	print "echo \"MTIME " mtime "\"" >> TMPCACHE
41
	print "echo \"MTIME " mtime "\"" 
42
	print "" >> TMPCACHE
42
	print "" 
43
}
43
}
44
44
45
function print_header2(mtime) {
45
function print_header2(mtime) {
46
	print "(" >> TMPCACHE
46
	print "(" 
47
	print "  # Get settings for rc-script ..." >> TMPCACHE
47
	print "  # Get settings for rc-script ..." 
48
	print "" >> TMPCACHE
48
	print "" 
49
	print "  [ -e \"/etc/conf.d/${myservice}\" ]        && source \"/etc/conf.d/${myservice}\"" >> TMPCACHE
49
	print "  [ -e \"/etc/conf.d/${myservice}\" ]        && source \"/etc/conf.d/${myservice}\"" 
50
	print "" >> TMPCACHE
50
	print "" 
51
	print "  [ -e /etc/conf.d/net ]                   && \\" >> TMPCACHE
51
	print "  [ -e /etc/conf.d/net ]                   && \\" 
52
	print "  [ \"${myservice%%.*}\" = \"net\" ]           && \\" >> TMPCACHE
52
	print "  [ \"${myservice%%.*}\" = \"net\" ]           && \\" 
53
	print "  [ \"${myservice##*.}\" != \"${myservice}\" ] && source /etc/conf.d/net" >> TMPCACHE
53
	print "  [ \"${myservice##*.}\" != \"${myservice}\" ] && source /etc/conf.d/net" 
54
	print "" >> TMPCACHE
54
	print "" 
55
	print "  [ -e /etc/rc.conf ]                      && source /etc/rc.conf" >> TMPCACHE
55
	print "  [ -e /etc/rc.conf ]                      && source /etc/rc.conf" 
56
	print "" >> TMPCACHE
56
	print "" 
57
	print "  depend() {" >> TMPCACHE
57
	print "  depend() {" 
58
	print "    return 0" >> TMPCACHE
58
	print "    return 0" 
59
	print "  }" >> TMPCACHE
59
	print "  }" 
60
	print "" >> TMPCACHE
60
	print "" 
61
}
61
}
62
62
63
function print_end() {
63
function print_end() {
64
	print "" >> TMPCACHE
64
	print "" 
65
	print "  depend" >> TMPCACHE
65
	print "  depend" 
66
	print ")" >> TMPCACHE
66
	print ")" 
67
	print "" >> TMPCACHE
67
	print "" 
68
}
68
}
69
69
70
BEGIN {
70
BEGIN {
71
71
72
	extension("/lib/rcscripts/filefuncs.so", "dlload")
72
	extension("/lib/rcscripts/filefuncs.so", "dlload")
73
73
74
	# Get our environment variables
75
	SVCDIR = ENVIRON["SVCDIR"]
76
	if (SVCDIR == "") {
77
		eerror("Could not get SVCDIR!")
78
		exit 1
79
	}
80
81
	# Since this could be called more than once simultaneously, use a
82
	# temporary cache and rename when finished.  See bug 47111
83
	("/bin/mktemp "SVCDIR"/depcache.XXXXXXX") | getline TMPCACHE
84
	if (TMPCACHE == "") {
85
		eerror("Failed to create temporary cache!")
86
		exit 1
87
	}
88
89
	pipe = "ls /etc/init.d/*"
74
	pipe = "ls /etc/init.d/*"
90
	while ((pipe | getline tmpstring) > 0)
75
	while ((pipe | getline tmpstring) > 0)
91
		scripts = scripts " " tmpstring
76
		scripts = scripts " " tmpstring
Lines 106-112 Link Here
106
91
107
	if (RCCOUNT == 0) {
92
	if (RCCOUNT == 0) {
108
		eerror("No scripts to process!")
93
		eerror("No scripts to process!")
109
		system("rm -f "TMPCACHE)
110
		exit 1
94
		exit 1
111
	}
95
	}
112
96
Lines 156-162 Link Here
156
					GOTDEPEND = 1
140
					GOTDEPEND = 1
157
141
158
					print_header2()
142
					print_header2()
159
					print "  # Actual depend() function ..." >> TMPCACHE
143
					print "  # Actual depend() function ..." 
160
				}
144
				}
161
	
145
	
162
				# We have the depend function...
146
				# We have the depend function...
Lines 174-183 Link Here
174
					# Make sure depend() contain something, else bash
158
					# Make sure depend() contain something, else bash
175
					# errors out (empty function).
159
					# errors out (empty function).
176
					if ((SBCOUNT > 0) && (COUNT == 0))
160
					if ((SBCOUNT > 0) && (COUNT == 0))
177
						print "  \treturn 0" >> TMPCACHE
161
						print "  \treturn 0" 
178
		
162
		
179
					# Print the depend() function
163
					# Print the depend() function
180
					print "  " $0 >> TMPCACHE
164
					print "  " $0 
181
		
165
		
182
					# If COUNT=0, and SBCOUNT>0, it means we have read
166
					# If COUNT=0, and SBCOUNT>0, it means we have read
183
					# all matching '{' and '}' for depend(), so stop.
167
					# all matching '{' and '}' for depend(), so stop.
Lines 205-211 Link Here
205
189
206
	}
190
	}
207
191
208
	system("mv "TMPCACHE" "SVCDIR"/depcache")
209
}
192
}
210
193
211
194
(-)/lib/rcscripts/awk/functions.awk.orig (-3 / +3 lines)
Lines 4-20 Link Here
4
4
5
function einfo(string)
5
function einfo(string)
6
{
6
{
7
	printf(" %s %s%s", "\033[32;01m*\033[0m", string, "\n")
7
	printf(" %s %s%s", "\033[32;01m*\033[0m", string, "\n") > "/dev/stderr"
8
}
8
}
9
9
10
function ewarn(string)
10
function ewarn(string)
11
{
11
{
12
	printf(" %s %s%s" , "\033[33;01m*\033[0m", string, "\n")
12
	printf(" %s %s%s" , "\033[33;01m*\033[0m", string, "\n") > "/dev/stderr"
13
}
13
}
14
14
15
function eerror(string)
15
function eerror(string)
16
{
16
{
17
	printf(" %s %s%s" , "\033[31;01m*\033[0m", string, "\n")
17
	printf(" %s %s%s" , "\033[31;01m*\033[0m", string, "\n") > "/dev/stderr"
18
}
18
}
19
19
20
function isfile(pathname,   x, ret, data)
20
function isfile(pathname,   x, ret, data)
(-)/lib/rcscripts/awk/gendepends.awk.orig (-27 / +15 lines)
Lines 324-343 Link Here
324
	TYPE_NAMES[PARALLEL] = "parallel"
324
	TYPE_NAMES[PARALLEL] = "parallel"
325
	TYPE_NAMES[MTIME] = "mtime"
325
	TYPE_NAMES[MTIME] = "mtime"
326
326
327
	# Get our environment variables
328
	SVCDIR = ENVIRON["SVCDIR"]
329
	if (SVCDIR == "") {
330
		eerror("Could not get SVCDIR!")
331
		exit 1
332
	}
333
334
	# There we do not really use yet
327
	# There we do not really use yet
335
	DEPTYPES = ENVIRON["DEPTYPES"]
328
	DEPTYPES = ENVIRON["DEPTYPES"]
336
	ORDTYPES = ENVIRON["ORDTYPES"]
329
	ORDTYPES = ENVIRON["ORDTYPES"]
337
338
	CACHEDTREE = SVCDIR "/deptree"
339
340
	assert(dosystem("rm -f " CACHEDTREE ), "system(rm -f " CACHEDTREE ")")
341
}
330
}
342
331
343
{
332
{
Lines 437-449 Link Here
437
	}
426
	}
438
427
439
	for (x = TYPES_MIN; x <= TYPES_MAX; x++)
428
	for (x = TYPES_MIN; x <= TYPES_MAX; x++)
440
		print "rc_type_" TYPE_NAMES[x] "=" x >> (CACHEDTREE)
429
		print "rc_type_" TYPE_NAMES[x] "=" x 
441
	print "rc_index_scale=" (TYPES_MAX + 1) >> (CACHEDTREE)
430
	print "rc_index_scale=" (TYPES_MAX + 1) 
442
	print "" >> (CACHEDTREE)
431
	print "" 
443
	print "declare -a RC_DEPEND_TREE" >> (CACHEDTREE)
432
	print "declare -a RC_DEPEND_TREE" 
444
	print "" >> (CACHEDTREE)
433
	print "" 
445
	print "RC_DEPEND_TREE[0]=" RC_NUMBER >> (CACHEDTREE)
434
	print "RC_DEPEND_TREE[0]=" RC_NUMBER 
446
	print "" >> (CACHEDTREE)
435
	print "" 
447
436
448
	# Generate the resolved CACHEDTREE
437
	# Generate the resolved CACHEDTREE
449
	#
438
	#
Lines 453-459 Link Here
453
	#
442
	#
454
	for (x = 1;x <= RC_NUMBER;x++) {
443
	for (x = 1;x <= RC_NUMBER;x++) {
455
444
456
		print "RC_DEPEND_TREE[" (x * (TYPES_MAX + 1)) "]=\"" DEPTREE[x,NAME] "\"" >> (CACHEDTREE)
445
		print "RC_DEPEND_TREE[" (x * (TYPES_MAX + 1)) "]=\"" DEPTREE[x,NAME] "\"" 
457
446
458
		for (y = TYPES_MIN; y <= TYPES_MAX; y++) {
447
		for (y = TYPES_MIN; y <= TYPES_MAX; y++) {
459
448
Lines 468-491 Link Here
468
				for (i = 2;i <= count;i++)
457
				for (i = 2;i <= count;i++)
469
					tmpstr = tmpstr " " tmparray2[i]
458
					tmpstr = tmpstr " " tmparray2[i]
470
				
459
				
471
				print tmpname "=\"" tmpstr "\"" >> (CACHEDTREE)
460
				print tmpname "=\"" tmpstr "\"" 
472
			} else
461
			} else
473
				print tmpname "=" >> (CACHEDTREE)
462
				print tmpname "=" 
474
		}
463
		}
475
464
476
		print "" >> (CACHEDTREE)
465
		print "" 
477
	}
466
	}
478
467
479
	# Do not export these, as we want them local
468
	# Do not export these, as we want them local
480
	print "RC_GOT_DEPTREE_INFO=\"yes\"" >> (CACHEDTREE)
469
	print "RC_GOT_DEPTREE_INFO=\"yes\"" 
481
	print "" >> (CACHEDTREE)
470
	print "" 
482
471
483
	if (check_provide("logger"))
472
	if (check_provide("logger"))
484
		print "LOGGER_SERVICE=\"" get_provide("logger") "\"" >> (CACHEDTREE)
473
		print "LOGGER_SERVICE=\"" get_provide("logger") "\"" 
485
	else
474
	else
486
		print "LOGGER_SERVICE=" >> (CACHEDTREE)
475
		print "LOGGER_SERVICE=" 
487
		
476
		
488
	close(CACHEDTREE)
489
}
477
}
490
478
491
479

Return to bug 70009