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

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

CMCE: added current version

  • 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`
71GFXBOOT_THEME_NAME="gfxboot-theme-caixamagica"
72if [ -d $REMASTER_HOME/$GFXBOOT_THEME_NAME ]
73then
74        cp -r $REMASTER_HOME/$GFXBOOT_THEME_NAME "$BUILD_DIR" ||
75                failure "Cannot copy $GFXBOOT_THEME_NAME to $BUILD_DIR"
76        pushd "$BUILD_DIR" >/dev/null ||
77                failure "Cannot change directory to $BUILD_DIR"
78else
79        pushd "$BUILD_DIR" >/dev/null ||
80                failure "Cannot change directory to $BUILD_DIR"
81        DISTRO_CODENAME=`cd "$ISO_REMASTER_DIR"/dists && find . -maxdepth 1 -type d | grep '/' | cut -d '/' -f2` ||
82                failure "Unable to identify Ubuntu distro codename"
83        GFXBOOT_THEME_SOURCE_PACKAGE=`wget -q -O - ftp://ftp.caixamagica.pt/caixamagica/pool/main/g/$GFXBOOT_THEME_NAME/ | grep ".tar.gz" | cut -d '"' -f2`
84        wget $GFXBOOT_THEME_SOURCE_PACKAGE ||
85                failure "Unable to download $GFXBOOT_THEME_NAME source package from $GFXBOOT_THEME_SOURCE_PACKAGE"
86        tar xfz *.tar.gz ||
87                failure "Unable to extract $GFXBOOT_THEME_NAME source package"
88fi
89
90# Build the gfx boot theme
91rm *.tar.gz
92cd *
93cd po
94ln -s pt.po pt_PT.po
95cd ..
96##if [ "$BOOT_LANG" = "pt_PT" ]; then
97##      make DEFAULT_LANG="pt" || failure "Failed to build gfxboot theme"
98##else
99        make DEFAULT_LANG="$BOOT_LANG" || failure "Failed to build gfxboot theme"
100##fi
101
102# Fix list of languages
103pushd boot >/dev/null
104
105# Create regexp that matches all language packs on CD
106langpack=""
107for langpack in `cat "$SCRIPT_DIR/language_packs"`; do
108        if [ -z "$LANGPACKS" ]; then
109                LANGPACKS="$langpack"
110        else
111                LANGPACKS="$LANGPACKS|$langpack"
112        fi
113done
114
115# Rewrite langlist
116cat "$SCRIPT_DIR/livecd_locales" >langlist
117popd >/dev/null
118
119# Copy to isolinux in image directory
120cp -af boot/* "$ISO_REMASTER_DIR/isolinux/" ||
121        failure "Error while copying boot files to $ISO_REMASTER_DIR/isolinux"
122
123popd >/dev/null
124
125# Cleanup
126[ "$BUILD_DIR" != "/" ] && rm -rf "$BUILD_DIR"
127
128# Copy kernel and initrd, in case it was changed during installation
129VMLINUZ=$(get_latest_kernel)
130if [ "$VMLINUZ" != "" ]
131then
132        INITRD="$REMASTER_DIR"/boot/initrd.img-$(echo `basename $VMLINUZ` | cut -d'-' -f 2-)
133        if [ -e "$VMLINUZ" -a -e "$INITRD" ]
134        then
135                echo "Updating kernel:"
136                echo "  kernel=$VMLINUZ"
137                echo "  initrd=$INITRD"
138                cp -f "$VMLINUZ" "$ISO_REMASTER_DIR/casper/vmlinuz"
139                cp -f "$INITRD" "$ISO_REMASTER_DIR/casper/initrd.gz"
140        else
141                echo "Not updating kernel as initrd not present"
142        fi
143fi
144
145# Misc fixup for Karmic
146pushd "$ISO_REMASTER_DIR"/isolinux >/dev/null
147
148# What used to be called "message" is now called "bootlogo"
149if [ -f isolinux.cfg -a -n "`grep "gfxboot bootlogo" isolinux.cfg 2>/dev/null`" ]
150then
151        if [ -f message ]
152        then
153                echo "Using bootlogo instead of message"
154                mv message bootlogo
155        fi
156fi
157
158# What used to be a gzipped initrd now is a lzma compressed initrd
159if [ -f text.cfg ] || [ -f txt.cfg ]
160then
161        # At least one of the .cfg file will be missing. Drop error message.
162        lzused=`grep initrd.lz text.cfg txt.cfg 2>/dev/null`
163        lzmacmd=`which lzma`
164        if [ -n "$lzused" ]
165        then
166                if [ -n "$lzmacmd" ]
167                then
168                        if [ -f ../casper/initrd.gz ]
169                        then
170                                pushd "$ISO_REMASTER_DIR"/casper >/dev/null
171                                echo "Recompressing initrd from gzip to lzma"
172                                rm -f initrd.lz
173                                gunzip <initrd.gz | $lzmacmd >initrd.lz
174                                rm -f initrd.gz
175                                popd >/dev/null
176                        fi
177                else
178                        if [ -f ../casper/initrd.gz ]
179                        then
180                                echo "lzma command not installed"
181                                echo "Switching permanently to gzipped initrd"
182                                sed -i -e 's/initrd\.lz/initrd.gz/g' text.cfg txt.cfg
183                                rm -f ../casper/initrd.lz
184                        else
185                                : do nothing - no initrd.gz
186                        fi
187                fi
188        else
189                : do nothing - initrd.lz not used
190        fi
191fi
Note: See TracBrowser for help on using the repository browser.