source: internals/2011/cmce/trunk/uck/libraries/customization-profiles/localized_cd/customize_iso @ 4876

Last change on this file since 4876 was 4876, checked in by goncalo.pinheira, 9 years ago

added UCK source to trunk - revision 425 of https://uck.svn.sourceforge.net/svnroot/uck/trunk/uck

  • Property svn:executable set to *
File size: 6.5 KB
Line 
1#!/bin/bash
2
3###################################################################################
4# UCK - Ubuntu Customization Kit                                                  #
5# Copyright (C) 2006-2010 UCK Team                                                #
6#                                                                                 #
7# UCK is free software: you can redistribute it and/or modify                     #
8# it under the terms of the GNU General Public License as published by            #
9# the Free Software Foundation, either version 3 of the License, or               #
10# (at your option) any later version.                                             #
11#                                                                                 #
12# UCK is distributed in the hope that it will be useful,                          #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of                  #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                   #
15# GNU General Public License for more details.                                    #
16#                                                                                 #
17# You should have received a copy of the GNU General Public License               #
18# along with UCK.  If not, see <http://www.gnu.org/licenses/>.                    #
19###################################################################################
20
21# NAME:
22#    customize_iso -- customize iso image outside of root FS
23#
24# SYNOPSIS:
25#    customize_iso [remaster_home] [customization_scripts_dir]
26#
27# DESCRIPTION:
28#    This procedure performs additional customization that needs to
29#    happen outside of the image of the root file system:
30#        - Configuration of the boot environment
31#            - isolinux configuration
32#            - gfxboot configuration (language/keyboard support!)
33#            - propagation of a new kernel/initrd
34#            - Simple bootmanager (directory "install" in image)
35#        - Configuration of additional resources outside the root FS
36#            - Add-Ons (like sample document/music/video files)
37#            - More Add-Ons (like OSS for Win / Mac)
38#
39# NOTES:
40#    Execution of the procedure may require Internet access to download
41#    the source of the latest version gfxboot-theme-ubuntu.
42#
43#    If a local copy of gfxboot-theme-ubuntu is available in the remaster
44#    home, it will be used instead of a (possibly updated) download.
45
46SCRIPT_DIR=`dirname "$0"`
47REMASTER_HOME=${1:-~/tmp}
48SCRIPT_DIR=${2-$REMASTER_HOME/customization-scripts}
49ISO_REMASTER_DIR="$REMASTER_HOME/remaster-iso"
50REMASTER_DIR="$REMASTER_HOME/remaster-root"
51BOOT_LANG=`cat "$SCRIPT_DIR/livecd_locale"`
52
53function failure()
54{
55        echo "$@"
56        exit 1
57}
58
59function get_latest_kernel()
60{
61        set -- $(ls "$REMASTER_DIR"/boot/vmlinuz* 2>/dev/null |
62                sed -e "s@$REMASTER_DIR/boot/@@" |
63                tr --  '-.' '\t' |
64                sort --key=2 --key=3 --key=4  --key=5 --numeric-sort |
65                tail -n1 )
66        [ "$1" = "vmlinuz" ] && echo "$REMASTER_DIR/boot/$1-$2.$3.$4-$5-$6"
67}
68
69# Create a temporary directory to assemble the gfxboot stuff in
70BUILD_DIR=`mktemp -d`
71if [ -d $REMASTER_HOME/gfxboot-theme-ubuntu ]
72then
73        cp -r $REMASTER_HOME/gfxboot-theme-ubuntu "$BUILD_DIR" ||
74                failure "Cannot copy gfxboot-theme-ubuntu to $BUILD_DIR"
75        pushd "$BUILD_DIR" >/dev/null ||
76                failure "Cannot change directory to $BUILD_DIR"
77else
78        pushd "$BUILD_DIR" >/dev/null ||
79                failure "Cannot change directory to $BUILD_DIR"
80        DISTRO_CODENAME=`cd "$ISO_REMASTER_DIR"/dists && find . -maxdepth 1 -type d | grep '/' | cut -d '/' -f2` ||
81                failure "Unable to identify Ubuntu distro codename"
82        GFXBOOT_THEME_UBUNTU_SOURCE_PACKAGE=`wget -q -O - http://packages.ubuntu.com/$DISTRO_CODENAME/gfxboot-theme-ubuntu | grep ".tar.gz" | cut -d '"' -f2`
83        wget $GFXBOOT_THEME_UBUNTU_SOURCE_PACKAGE ||
84                failure "Unable to download gfxboot-theme-ubuntu source package from $GFXBOOT_THEME_UBUNTU_SOURCE_PACKAGE"
85        tar xfz *.tar.gz ||
86                failure "Unable to extract gfxboot-theme-ubuntu source package"
87fi
88
89# Build the gfx boot theme
90cd gfxboot-theme-ubuntu
91cd po
92ln -s pt.po pt_PT.po
93cd ..
94##if [ "$BOOT_LANG" = "pt_PT" ]; then
95##      make DEFAULT_LANG="pt" || failure "Failed to build gfxboot theme"
96##else
97        make DEFAULT_LANG="$BOOT_LANG" || failure "Failed to build gfxboot theme"
98##fi
99
100# Fix list of languages
101pushd boot >/dev/null
102
103# Create regexp that matches all language packs on CD
104langpack=""
105for langpack in `cat "$SCRIPT_DIR/language_packs"`; do
106        if [ -z "$LANGPACKS" ]; then
107                LANGPACKS="$langpack"
108        else
109                LANGPACKS="$LANGPACKS|$langpack"
110        fi
111done
112
113# Rewrite langlist
114cat "$SCRIPT_DIR/livecd_locales" >langlist
115popd >/dev/null
116
117# Copy to isolinux in image directory
118cp -af boot/* "$ISO_REMASTER_DIR/isolinux/" ||
119        failure "Error while copying boot files to $ISO_REMASTER_DIR/isolinux"
120
121popd >/dev/null
122
123# Cleanup
124[ "$BUILD_DIR" != "/" ] && rm -rf "$BUILD_DIR"
125
126# Copy kernel and initrd, in case it was changed during installation
127VMLINUZ=$(get_latest_kernel)
128if [ "$VMLINUZ" != "" ]
129then
130        INITRD="$REMASTER_DIR"/boot/initrd.img-$(echo `basename $VMLINUZ` | cut -d'-' -f 2-)
131        if [ -e "$VMLINUZ" -a -e "$INITRD" ]
132        then
133                echo "Updating kernel:"
134                echo "  kernel=$VMLINUZ"
135                echo "  initrd=$INITRD"
136                cp -f "$VMLINUZ" "$ISO_REMASTER_DIR/casper/vmlinuz"
137                cp -f "$INITRD" "$ISO_REMASTER_DIR/casper/initrd.gz"
138        else
139                echo "Not updating kernel as initrd not present"
140        fi
141fi
142
143# Misc fixup for Karmic
144pushd "$ISO_REMASTER_DIR"/isolinux >/dev/null
145
146# What used to be called "message" is now called "bootlogo"
147if [ -f isolinux.cfg -a -n "`grep "gfxboot bootlogo" isolinux.cfg 2>/dev/null`" ]
148then
149        if [ -f message ]
150        then
151                echo "Using bootlogo instead of message"
152                mv message bootlogo
153        fi
154fi
155
156# What used to be a gzipped initrd now is a lzma compressed initrd
157if [ -f text.cfg ] || [ -f txt.cfg ]
158then
159        # At least one of the .cfg file will be missing. Drop error message.
160        lzused=`grep initrd.lz text.cfg txt.cfg 2>/dev/null`
161        lzmacmd=`which lzma`
162        if [ -n "$lzused" ]
163        then
164                if [ -n "$lzmacmd" ]
165                then
166                        if [ -f ../casper/initrd.gz ]
167                        then
168                                pushd "$ISO_REMASTER_DIR"/casper >/dev/null
169                                echo "Recompressing initrd from gzip to lzma"
170                                rm -f initrd.lz
171                                gunzip <initrd.gz | $lzmacmd >initrd.lz
172                                rm -f initrd.gz
173                                popd >/dev/null
174                        fi
175                else
176                        if [ -f ../casper/initrd.gz ]
177                        then
178                                echo "lzma command not installed"
179                                echo "Switching permanently to gzipped initrd"
180                                sed -i -e 's/initrd\.lz/initrd.gz/g' text.cfg txt.cfg
181                                rm -f ../casper/initrd.lz
182                        else
183                                : do nothing - no initrd.gz
184                        fi
185                fi
186        else
187                : do nothing - initrd.lz not used
188        fi
189fi
Note: See TracBrowser for help on using the repository browser.