source: internals/2011/cmce/trunk/uck/libraries/customization-profiles/localized_cd/customize @ 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: 5.4 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
21function failure()
22{
23        echo "$@"
24        exit 1
25}
26
27function prepare_install()
28{
29        #try 2 times to avoid slow proxies failures
30        apt-get update || apt-get update || failure "apt-get update failed, error=$?"
31}
32
33function install_packages()
34{
35        apt-get install --assume-yes --force-yes "$@" || failure "apt-get install $@ failed, error=$?"
36}
37
38function remove_packages()
39{
40        apt-get --purge remove --assume-yes --force-yes "$@" || failure "apt-get remove $@ failed, error=$?"
41}
42
43function run_console()
44{
45        echo "Starting console application..."
46       
47        CONSOLE_APP=`which konsole`
48        CONSOLE_APP_OPTIONS=(--caption "UCK customization console" -e /bin/bash)
49        if [ "$CONSOLE_APP" = "" ]; then
50                CONSOLE_APP=`which gnome-terminal`
51                CONSOLE_APP_OPTIONS=(-t "UCK customization console" -e /bin/bash)
52        fi
53        if [ "$CONSOLE_APP" = "" ]; then
54                CONSOLE_APP=`which xfce4-terminal`
55                CONSOLE_APP_OPTIONS=(-t "UCK customization console" -e /bin/bash)
56        fi
57        if [ "$CONSOLE_APP" = "" ]; then
58                CONSOLE_APP=`which xterm`
59                CONSOLE_APP_OPTIONS=(-title "UCK customization console" -e /bin/bash)
60        fi
61       
62        if [ "$CONSOLE_APP" = "" ]; then
63                dialog_msgbox "Failure" "Unable to find any console application"
64        else
65                eval `dbus-launch --sh-syntax --exit-with-session 2>/dev/null`
66                $CONSOLE_APP "${CONSOLE_APP_OPTIONS[@]}"
67                RESULT=$?
68       
69                if [ $RESULT -ne 0 ]; then
70                        echo "Running console application $CONSOLE_APP failed, trying the fallback xterm"
71                        xterm -title "UCK customization console" -e /bin/bash
72                        RESULT=$?
73                        if [ $RESULT -ne 0 ]; then
74                                dialog_msgbox "Failure" "Running console application $CONSOLE_APP failed, error=$RESULT"
75                        fi
76                fi
77        fi
78}
79
80
81# Inherit environment
82[ -f "$SCRIPT_DIR/environment" ] &&
83        . "$SCRIPT_DIR/environment"
84
85LIVECD_LANGS=`cat "$SCRIPT_DIR/language_packs"`
86RUN_MANUAL_CUSTOMIZATIONS=`cat "$SCRIPT_DIR/run_manual_customizations"`
87DESKTOP_TYPE=`cat "$SCRIPT_DIR/desktop_type"`
88
89DESKTOP_FLAVOURS=`cat "$SCRIPT_DIR/desktop_types"`
90
91# Print some information on the system being customized:
92rel="`lsb_release -is` `lsb_release -rs`"
93kernel=`ls /boot/config-* | sed 's/.*config-//'`
94arch=`if [ -d /lib64 ]; then echo x86_64; else echo i586; fi`
95echo ">> Customizing: $rel, $kernel $arch"
96
97prepare_install || failure "Preparing installation failed, error=$?"
98
99# List of packages to install to support the selected languages:
100PACKAGES_TO_INSTALL=""
101# Pattern to match all selected language packs:
102LANGPACKS_CONCATENATED=""
103# List of language related packages available in the repositories:
104REPO_LANGS=`apt-cache search "^language-" | sed 's/[    ].*//'`
105
106echo "Installing language packs ($LIVECD_LANGS)..."
107if [ -n "$LIVECD_LANGS" ]; then
108        for l in $LIVECD_LANGS; do
109                # Add language specific packages not releated to kde or gnome
110                add=`echo "$REPO_LANGS" | grep -- -"$l" | grep -Ev "kde|gnome"`
111                PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $add"
112       
113                # Add desktop specific language packages
114                if [ -n "$DESKTOP_FLAVOURS" ]; then
115                        for f in $DESKTOP_FLAVOURS; do
116                                add=`echo "$REPO_LANGS" | grep -- -$f-$l`
117                                PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $add"
118                        done
119                fi
120       
121                if [ -z "$LANGPACKS_CONCATENATED" ]; then
122                        LANGPACKS_CONCATENATED="$l"
123                else
124                        LANGPACKS_CONCATENATED="$LANGPACKS_CONCATENATED|$l"
125                fi
126        done
127       
128        install_packages $PACKAGES_TO_INSTALL ||
129                failure "Installing language packs failed, error=$?"
130       
131        # NOTE: we first install selected language packs, then remove others as
132        #       installing a language pack might pull in packages that were not
133        #       previously present
134        echo "Removing unnecessary language packages..."
135        REMOVED_PACKAGES=`dpkg-query --show | cut -f1 | grep -E '^(language-pack|language-support)' | grep -Ev "[-]($LANGPACKS_CONCATENATED)\>"`
136        remove_packages $REMOVED_PACKAGES ||
137                failure "Removing packages failed, error=$?"
138fi
139
140if [ "$RUN_MANUAL_CUSTOMIZATIONS" = "yes" ] ; then
141        eval `dbus-launch --sh-syntax --exit-with-session 2>/dev/null`
142        apt-get update || apt-get update
143        apt-get install xvfb x11vnc
144        export DISPLAY=:5
145        Xvfb :1 -screen 0 1024x768x16 &
146        x11vnc -display :1 -bg -nopw -listen localhost -xkb
147        gnome-session
148        apt-get purge xvfb x11vnc
149fi
150
151echo "Done"
Note: See TracBrowser for help on using the repository browser.