summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/fbsplash/fbsplash.initcpio_install
blob: 4485f914788ea36755937003432c658c9044c055 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

install() {
	(
		. /etc/conf.d/splash

		if /bin/mountpoint -q /lib/splash/cache; then
			/bin/umount /lib/splash/cache
		fi

		# Add the helper
		add_binary /sbin/fbcondecor_helper

		# Add the daemon for early start
		if [[ $SPLASH_DAEMON = early ]]; then
			add_binary /sbin/fbsplashd.static
		fi

		# Add a clean config file avoiding errors when running the hook
		file=$( /usr/bin/mktemp )
		for var in SPLASH_INIT_MESSAGE SPLASH_MODE_REQ SPLASH_THEME SPLASH_TTY \
		           SPLASH_AUTOVERBOSE SPLASH_EFFECTS SPLASH_TEXTBOX
		do
			eval value=\"\$$var\"
			[ -n "$value" ] && echo $var="'$value'"
		done >|$file
		add_file $file /etc/conf.d/splash

		# List file paths contained in given Fbsplash theme cfg file
		_get_cfg_files() {
			< "$1" /bin/sed -re '
				# convert all whitespace into single blanks
				s,[[:space:]]+, ,g ; t L1
				:L1
				# drop comments, grouping directives and blank lines
				/^ *([#<]|$)/ d
				# get a filepath or drop
				s,.*[ =]([^ ]*/[^ ]+).*,\1, ; t ; d
			' | /usr/bin/sort -u
		}

		# Check if cfg file name or path
		_match_cfg() {
			[[ "$1" =~ (^|/)[0-9]+x[0-9]+\.cfg$ ]]
		}

		# Add non-cfg files in given dir
		_add_non_cfg_files() {
			local file dir="$1"
			for file in $( /bin/ls "$dir" ); do
				if [ -f "$dir/$file" ]; then
					_match_cfg "$file" || add_file "$dir/$file"
				fi
			done
		}

		# Add global non-cfg files
		_add_non_cfg_files /etc/splash

		# Add themes
		dirs=""
		for theme in ${SPLASH_THEMES[*]}; do # string list and array allowed
			[ ${theme:0:1} = / ] || theme=/etc/splash/$theme
			if [ -f $theme ]; then
				if ! _match_cfg $theme; then
					err "Not a valid theme cfg file name: $theme"
					continue
				fi
				add_file $theme || continue
				dir=$( dirname $theme )
				# Add non-cfg files in theme dir
				_add_non_cfg_files $dir
				# Add files refered in cfg file by paths
				for file in $( _get_cfg_files $theme ); do
					if [ ${file:0:1} = / ]; then
						add_file $file
						continue
					fi
					# Path may be relative to theme-dir or to /etc/splash
					[ -e $dir/$file -o ! -f /etc/splash/$file ] && add_file $dir/$file
					[ -e /etc/splash/$file -o ! -f $dir/$file ] && add_file /etc/splash/$file
				done
			elif [ -d $theme ]; then
				dir=$theme
				add_full_dir $dir
			else
				err "Theme not found: $theme"
				continue
			fi
			if [[ " "$dirs" " != *" "$dir" "* ]]; then
				dirs+=" "$dir
			fi
		done
		for dir in $dirs; do
			# Add the rc_init-pre script if we have one
			# Currently this just prevents early daemon start for the theme
			if [[ $SPLASH_DAEMON = early && -x $dir/scripts/rc_init-pre ]]; then
				add_file $dir/scripts/rc_init-pre || continue
				echo "WARNING: rc_init-pre script found - no early daemon with '${dir##*/}'!" >&2
			fi
		done
	)

	SCRIPT="fbsplash"
}

help() {
cat<<HELPEOF
  This hook adds the FBconDecor helper and Fbsplash themes and maybe the
  Fbsplash daemon as specified in /etc/conf.d/splash. Put it after udev
  for early daemon start or when using a FBconDecor kernel.
HELPEOF
}

#EOF