3 # splash_geninitramfs -- an utility to create initramfs images for use with fbsplash
5 # Copyright (C) 2004-2007, Michal Januszewski <spock@gentoo.org>
7 # This file is a part of the splashutils package.
9 # This file is subject to the terms and conditions of the GNU General Public
10 # License v2. See the file COPYING in the main directory of this archive for
22 splash_geninitramfs/splashutils-@PACKAGE_VERSION@
23 Usage: splash_geninitramfs [options] [--all|theme ...]
26 -g, --generate=IMG generate an initramfs image with all necessary files
27 -a, --append=IMG append a theme and helper files (if necessary)
29 -c, --copy=DIR copy all necessary files into the specified directory;
30 DIR should point to the root directory of an initramfs
31 -o, --overlay=DIR include the contents of DIR in the initramfs image
32 -h, --help show this help message
35 -r, --res=RES copy data for specific resolutions only; RES is a
36 comma-separated list of the resolutions for which the images
38 -v, --verbose verbose output
39 --no8bpp ignore 8bpp images (can save a lot of space)
42 # -d use dynamically linked splash helper
47 if [ $verbose -gt 0 ]; then
56 if [ "${item:0:1}" == "/" ]; then
57 cp -pRH --parents "${item}" "${imgdir}"
59 cp -pRH --parents "${themedir}/${theme}/${item}" "${imgdir}"
66 splash_hlp
="@sbindir@/fbcondecor_helper"
74 temp
=`getopt -l no8bpp,all,generate:,append:,copy:,overlay:,help,verbose,res: a:g:c:r:o:hv "$@"`
84 -a|
--append) mode
='a'; img
="$2"; shift; shift;;
85 -g|
--generate) mode
='g'; img
="$2"; shift; shift;;
86 -c|
--copy) mode
='c'; destdir
="$2"; shift; shift;;
87 -h|
--help) usage
; exit 2;;
88 -r|
--res) res
=${2/,/ }; shift; shift;;
89 -v|
--verbose) verbose
=$
(($verbose + 1)); shift;;
90 -o|
--overlay) overlay
="$2"; shift; shift;;
91 --no8bpp) no8bpp
=1; shift;;
95 for i
in ${themedir}/* ; do
96 if [ ! -d "$i" ] ; then
99 themes
[$index]="`basename "$i"`"
105 if [ "$mode" == "h" ]; then
109 if [ $index -eq 0 ]; then
116 if [ $index -eq 0 ]; then
117 echo "No themes specified." 1>&2 ; exit 5
120 if [ "$mode" == "c" ]; then
121 if [ ! -d $destdir ]; then
122 echo "Destination directory does not exist." 1>&2 ; exit 3
126 if [ "$mode" == "a" ] && [ ! -e $img ]; then
127 echo "Specified image file does not exist." 1>&2 ; exit 4
130 workdir
=${TMPDIR-/tmp}/splash.$$.
$RANDOM
132 if (umask 077 && mkdir
$workdir); then
135 echo "Could not create temporary directory! Exiting." 1>&2 ; exit 1
139 if [ "$mode" != "c" ]; then
140 imgdir
="${workdir}/img"
144 if [ "$mode" == "a" ]; then
145 printv
"o Unpacking $img.."
146 cp "$img" "${imgdir}"
147 (cd "${imgdir}"; (gunzip
-c "$(basename $img)" 2>/dev
/null ||
cat "$(basename $img)") |
cpio -idm --no-absolute-filenames --quiet -H newc
)
148 rm -f "${imgdir}/$(basename $img)"
151 printv
"o Creating directory structure.."
152 mkdir
-p ${imgdir}/{dev
,dev
/fb
,dev
/misc
,dev
/vc
,$themedir,@libdir@
/splash
/proc
,root
,sbin
,@libdir@
/splash
/sys
}
154 if [ $EUID == 0 ]; then
155 [[ ! -e "${imgdir}/dev/null" ]] && mknod
"${imgdir}/dev/null" c
1 3
156 [[ ! -e "${imgdir}/dev/console" ]] && mknod
"${imgdir}/dev/console" c
5 1
157 [[ ! -e "${imgdir}/dev/tty0" ]] && mknod
"${imgdir}/dev/tty0" c
4 0
159 echo "Since you are running this script as a non-root user, no device nodes" 1>&2
160 echo "will be created in the initramfs. Make sure your initramfs contains" 1>&2
161 echo "at least the following nodes: /dev/null, /dev/console, /dev/tty0." 1>&2
164 if [ ! -e ${splash_hlp} ]; then
165 echo "${splash_hlp} does not exist." 1>&2 ; exit 4
168 printv
"o Copying ${splash_hlp}.."
169 cp "${splash_hlp}" "${imgdir}@sbindir@"
170 ln -sf "${splash_hlp}" "${imgdir}@sbindir@/splash_helper"
174 printv
"o Copying themes.."
175 for (( i
=0 ; i
< index
; i
++ )) ; do
180 # check if the user specified which resolutions are accepted
182 if [ -z "$res" ]; then
183 res
=$
(cd ${themedir}/${theme} ; ls *cfg |
sed -e 's/.cfg//g')
187 if [ ! -e "${themedir}/${theme}/${j}.cfg" ]; then
188 echo "Warning: config file for theme '${theme}', resolution ${j} does not exist!" 1>&2
192 cp -pRH --parents "${themedir}/${theme}/${j}.cfg" "${imgdir}"
194 if [[ ${no8bpp} == 0 ]]; then
200 # config file parsing
201 pics
=`cat "${themedir}/${theme}/${j}.cfg" | \
202 sed -r -e "/(^(silent)?jpeg=)|(^(silent)?pic${t}*=)/! d" \
203 -e 's/[a-z0-9]+=(.*)/\1/'`
204 for pic
in $pics ; do
208 icons
=`cat "${themedir}/${theme}/${j}.cfg" | \
209 egrep -v '^#' | grep 'icon ' | awk '{print $2}'`
210 for icon
in ${icons} ; do
214 fonts
=`cat "${themedir}/${theme}/${j}.cfg" | \
215 egrep -v '^#' | grep 'text ' | grep -o '[^ ]\+\.ttf'`
216 for font
in ${fonts} ; do
220 font
=`cat "${themedir}/${theme}/${j}.cfg" | egrep -v '^#' | grep 'text_font='`
222 if [[ -n "${font}" ]]; then
225 put_item
"${themedir}/luxisri.ttf"
230 if [ -n "${overlay}" ]; then
231 printv
"o Adding files from overlay: $overlay"
232 cp -pRH ${overlay}/* "${imgdir}"
235 printv
"o Creating initramfs image.."
236 if [ "$mode" == "g" ] ||
[ "$mode" == "a" ]; then
237 (cd "${imgdir}" ; find . |
cpio --quiet -o -H newc |
gzip -9 >..
/img.
cpio.gz
)
238 mv "${workdir}/img.cpio.gz" "${img}"
243 # vim: set ts=4 sts=4 :