source: internals/2011/cmce/trunk/uck/libraries/customization-profiles/localized_cd/customize @ 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.6 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_package_manager()
44{
45        echo "Starting package application..."
46       
47        PACKAGE_APP=`which adept`
48        PACKAGE_APP_OPTIONS=(--caption "UCK Package Manager")
49        if [ "$PACKAGE_APP" = "" ]; then
50                PACKAGE_APP=`which adept_manager`
51        fi
52        if [ "$PACKAGE_APP" = "" ]; then
53                PACKAGE_APP=`which kpackagekit`
54        fi
55        if [ "$PACKAGE_APP" = "" ]; then
56                PACKAGE_APP=`which synaptic`
57                PACKAGE_APP_OPTIONS=(-t "UCK Package manager")
58        fi
59       
60        if [ "$PACKAGE_APP" = "" ]; then
61                dialog_msgbox "Failure" "Unable to find any package manager application"
62        else
63                $PACKAGE_APP "${PACKAGE_APP_OPTIONS[@]}"
64                RESULT=$?
65       
66                if [ $RESULT -ne 0 ]; then
67                        dialog_msgbox "Failure" "Running package application $PACKAGE_APP failed, error=$RESULT"
68                fi
69        fi
70}
71
72function run_console()
73{
74        echo "Starting console application..."
75       
76        CONSOLE_APP=`which konsole`
77        CONSOLE_APP_OPTIONS=(--caption "UCK customization console" -e /bin/bash)
78        if [ "$CONSOLE_APP" = "" ]; then
79                CONSOLE_APP=`which gnome-terminal`
80                CONSOLE_APP_OPTIONS=(-t "UCK customization console" -e /bin/bash)
81        fi
82        if [ "$CONSOLE_APP" = "" ]; then
83                CONSOLE_APP=`which xfce4-terminal`
84                CONSOLE_APP_OPTIONS=(-t "UCK customization console" -e /bin/bash)
85        fi
86        if [ "$CONSOLE_APP" = "" ]; then
87                CONSOLE_APP=`which xterm`
88                CONSOLE_APP_OPTIONS=(-title "UCK customization console" -e /bin/bash)
89        fi
90       
91        if [ "$CONSOLE_APP" = "" ]; then
92                dialog_msgbox "Failure" "Unable to find any console application"
93        else
94                eval `dbus-launch --sh-syntax --exit-with-session 2>/dev/null`
95                $CONSOLE_APP "${CONSOLE_APP_OPTIONS[@]}"
96                RESULT=$?
97       
98                if [ $RESULT -ne 0 ]; then
99                        echo "Running console application $CONSOLE_APP failed, trying the fallback xterm"
100                        xterm -title "UCK customization console" -e /bin/bash
101                        RESULT=$?
102                        if [ $RESULT -ne 0 ]; then
103                                dialog_msgbox "Failure" "Running console application $CONSOLE_APP failed, error=$RESULT"
104                        fi
105                fi
106        fi
107}
108
109SCRIPT_DIR=`dirname "$0"`
110. "$SCRIPT_DIR/gui.sh"
111
112# Inherit environment
113[ -f "$SCRIPT_DIR/environment" ] &&
114        . "$SCRIPT_DIR/environment"
115
116LIVECD_LANGS=`cat "$SCRIPT_DIR/language_packs"`
117RUN_MANUAL_CUSTOMIZATIONS=`cat "$SCRIPT_DIR/run_manual_customizations"`
118DESKTOP_TYPE=`cat "$SCRIPT_DIR/desktop_type"`
119
120DESKTOP_FLAVOURS=`cat "$SCRIPT_DIR/desktop_types"`
121
122# Print some information on the system being customized:
123rel="`lsb_release -is` `lsb_release -rs`"
124kernel=`ls /boot/config-* | sed 's/.*config-//'`
125arch=`if [ -d /lib64 ]; then echo x86_64; else echo i586; fi`
126echo ">> Customizing: $rel, $kernel $arch"
127
128prepare_install || failure "Preparing installation failed, error=$?"
129
130# List of packages to install to support the selected languages:
131PACKAGES_TO_INSTALL=""
132# Pattern to match all selected language packs:
133LANGPACKS_CONCATENATED=""
134# List of language related packages available in the repositories:
135REPO_LANGS=`apt-cache search "^language-" | sed 's/[    ].*//'`
136
137echo "Installing language packs ($LIVECD_LANGS)..."
138if [ -n "$LIVECD_LANGS" ]; then
139        for l in $LIVECD_LANGS; do
140                # Add language specific packages not releated to kde or gnome
141                add=`echo "$REPO_LANGS" | grep -- -"$l" | grep -Ev "kde|gnome"`
142                PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $add"
143       
144                # Add desktop specific language packages
145                if [ -n "$DESKTOP_FLAVOURS" ]; then
146                        for f in $DESKTOP_FLAVOURS; do
147                                add=`echo "$REPO_LANGS" | grep -- -$f-$l`
148                                PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $add"
149                        done
150                fi
151       
152                if [ -z "$LANGPACKS_CONCATENATED" ]; then
153                        LANGPACKS_CONCATENATED="$l"
154                else
155                        LANGPACKS_CONCATENATED="$LANGPACKS_CONCATENATED|$l"
156                fi
157        done
158       
159        install_packages $PACKAGES_TO_INSTALL ||
160                failure "Installing language packs failed, error=$?"
161       
162        # NOTE: we first install selected language packs, then remove others as
163        #       installing a language pack might pull in packages that were not
164        #       previously present
165        echo "Removing unnecessary language packages..."
166        REMOVED_PACKAGES=`dpkg-query --show | cut -f1 | grep -E '^(language-pack|language-support)' | grep -Ev "[-]($LANGPACKS_CONCATENATED)\>"`
167        remove_packages $REMOVED_PACKAGES ||
168                failure "Removing packages failed, error=$?"
169fi
170
171if [ "$RUN_MANUAL_CUSTOMIZATIONS" = "yes" ] ; then
172        while true ; do
173                CHOICE_PACKAGE_MANAGER="Run package manager"
174                CHOICE_CONSOLE="Run console application"
175                CHOICE_EXIT="Continue building"
176                CHOICE=`dialog_menu "Please choose customization action" "$CHOICE_PACKAGE_MANAGER" "$CHOICE_CONSOLE" "$CHOICE_EXIT"`
177                RESULT=$?
178
179                if [ $RESULT -ne 0 ] ; then
180                        failure "Script cancelled by user"
181                fi
182                #workaround for KDE bug (https://bugs.kde.org/show_bug.cgi?id=139025)
183                CHOICE=`echo "$CHOICE" | grep -v -i kwrited | tail -n1`
184
185                echo "CHOICE='$CHOICE'"
186
187                if [ "$CHOICE" = "$CHOICE_EXIT" ] ; then
188                        break
189                elif [ "$CHOICE" = "$CHOICE_PACKAGE_MANAGER" ] ; then
190                        run_package_manager
191                elif [ "$CHOICE" = "$CHOICE_CONSOLE" ] ; then
192                        run_console
193                fi
194        done
195fi
196
197echo "Done"
Note: See TracBrowser for help on using the repository browser.