updated on Thu Jan 19 00:16:31 UTC 2012
[aur-mirror.git] / fbsplash / fbsplash.initcpio_install
blob841405baafca6346c09dd9784af49b8a18dcbb1b
2 build() {
3         # Add config file, splash-functions and the helper
4         add_file   /etc/conf.d/splash
5         add_file   /sbin/splash-functions.sh
6         add_binary /sbin/fbcondecor_helper
8         # Get in configuration, parameters and functions
9         . /etc/conf.d/splash
10         . /sbin/splash-functions.sh
12         # Unmount any stale cache tmpfs
13         splash_cache_cleanup
15         SPLASH_PROFILE=off
17         if [[ $SPLASH_DAEMON = early ]]; then
18                 # Add stuff needed to run splash_start function (except optional evdev module)
19                 add_dir    $spl_tmpdir
20                 add_binary $spl_daemon
21                 if [[ -e /etc/rc.d/functions.d/fbsplash-extras.sh ]]; then
22                         . /etc/rc.d/functions.d/fbsplash-extras.sh
23                         # Add files from a prepared cache (faking sysinit)
24                         splash_cache_prep_initcpio && add_full_dir $spl_cachedir
25                 fi
26         fi
28         # List file paths contained in given Fbsplash theme cfg files
29         # (Only file paths containing at least one slash will be found by this.)
30         fbsplash_list_paths() {
31                 (( $# )) || return 0
32                 /bin/sed -re '
33                         # convert all whitespace into single blanks
34                         s,[[:space:]]+, ,g ; t L1
35                         :L1
36                         # drop comments, grouping directives and blank lines
37                         /^ *([#<]|$)/ d
38                         # get a filepath or drop
39                         s,.*[ =]([^ ]*/[^ ]+).*,\1, ; t ; d
40                 ' "$@" | /usr/bin/sort -u
41         }
43         # Check if arg is a theme cfg file path
44         fbsplash_is_cfg() {
45                 [[ $1 =~ ^/etc/splash/[^/]+/[0-9]+x[0-9]+\.cfg$ ]]
46         }
48         # Add all files referenced by path in given theme cfg files
49         # args: <theme-root-dir> <cfg-file>...
50         fbsplash_add_files_from_cfgs() {
51                 local file theme_dir=$1; shift
52                 while read file; do
53                         if [[ $file == /* ]]; then
54                                 add_file $file
55                         else # Path may be relative to /etc/splash or theme-dir
56                                 local found=0
57                                 for file in /etc/splash/$file "$theme_dir"/$file; do
58                                         [[ -f $file ]] && { add_file $file; found=1; }
59                                 done
60                                 (( found )) || error "Theme '${theme_dir##*/}': File not found: '$file'"
61                         fi
62                 done < <( fbsplash_list_paths "$@" )
63         }
65         # Add common files (may be referenced in cfg by plain file name)
66         local file
67         for file in /etc/splash/*; do
68                 [[ -f $file ]] && add_file "$file"
69         done
71         # Add themes
72         local file theme
73         for theme in $SPLASH_THEMES; do
74                 if [[ -d /etc/splash/$theme && $theme != */* ]]; then
75                         add_full_dir /etc/splash/$theme
76                         local files=()
77                         for file in /etc/splash/$theme/*.cfg; do
78                                 [[ -f $file ]] && fbsplash_is_cfg "$file" && files+=( $file )
79                         done
80                         fbsplash_add_files_from_cfgs /etc/splash/$theme "${files[@]}"
81                 elif [[ -f /etc/splash/$theme ]] && fbsplash_is_cfg /etc/splash/$theme; then
82                         file=/etc/splash/$theme; theme=${theme%/*}
83                         add_file $file
84                         fbsplash_add_files_from_cfgs /etc/splash/$theme $file
85                         # Add all non-cfg files from theme dir (may be referenced by plain file name)
86                         for file in /etc/splash/$theme/*; do
87                                 [[ -f $file ]] && ! fbsplash_is_cfg "$file" && add_file "$file"
88                         done
89                 else
90                         error "Theme invalid or not found: '$theme'"
91                 fi
92         done
94         SCRIPT="fbsplash"
97 help() {
98 cat<<HELPEOF
99   This hook adds the FBconDecor helper and Fbsplash themes and maybe the
100   Fbsplash daemon as specified in /etc/conf.d/splash.
101 HELPEOF
104 #EOF