-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuck-remaster
More file actions
232 lines (190 loc) · 6.16 KB
/
uck-remaster
File metadata and controls
232 lines (190 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#!/bin/bash
###################################################################################
# UCK - Ubuntu Customization Kit #
# Copyright (C) 2006-2010 UCK Team #
# #
# UCK is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# UCK is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with UCK. If not, see <http://www.gnu.org/licenses/>. #
###################################################################################
##################
# some functions #
##################
function usage()
{
echo "Usage: $0 [-m] iso-file.iso [customization-scripts-dir] [remaster-home]"
}
function check_exit_code()
{
RESULT=$?
if [ "$RESULT" -ne 0 ]; then
if [ x"$use_mount" = x-m ]; then
$SCRIPTS_DIR/uck-remaster-umount "$REMASTER_HOME"
fi
exit "$RESULT"
fi
}
function check_if_user_is_root()
{
if [ `id -un` != "root" ]; then
echo "You need root privileges"
exit 2
fi
}
#########################
# input parameter check #
#########################
use_mount=
if [ x"$1" = x-m ]; then
use_mount=-m; shift
fi
ISO_IMAGE="$1"
CUSTOMIZE_DIR="$2"
REMASTER_HOME=${3:-~/tmp}
if [ -z "$ISO_IMAGE" ]; then
usage
exit 1
fi
COPY_CUSTOMIZE_DIR="yes"
if [ -z "$CUSTOMIZE_DIR" -o -d "$REMASTER_HOME/customization-scripts" ]; then
COPY_CUSTOMIZE_DIR="no"
CUSTOMIZE_DIR="$REMASTER_HOME/customization-scripts"
fi
########
# main #
########
check_if_user_is_root
if [ -e libraries/remaster-live-cd.sh ]; then
SCRIPTS_DIR=`dirname "$0"`
VERSION=`cat VERSION`
else
SCRIPTS_DIR=/usr/bin
VERSION=`cat /usr/lib/uck/VERSION`
fi
# Some information of the hosting system
rel="`lsb_release -is` `lsb_release -rs`"
kernel=`uname -rm`
echo ">> Ubuntu Customization Kit $VERSION on $rel, $kernel"
echo "Starting CD remastering on " `date`
echo "Customization dir=$CUSTOMIZE_DIR"
CUSTOMIZE_ROOTFS="no"
CUSTOMIZE_INITRD="no"
CUSTOMIZE_ISO="no"
REMOVE_WIN32_FILES="no"
CLEAN_DESKTOP_MANIFEST="no"
HYBRID="no"
if [ "$COPY_CUSTOMIZE_DIR" = "yes" ] && [ -e "$REMASTER_HOME/customization-scripts" ]; then
echo "\"customization-scripts\" directory already exists inside $REMASTER_HOME, remove it and run uck-remaster again"
exit 2
fi
if [ -e "$CUSTOMIZE_DIR/remove_win32_files" ]; then
REMOVE_WIN32_FILES=`cat "$CUSTOMIZE_DIR/remove_win32_files"`
fi
if [ -e "$CUSTOMIZE_DIR/customize" ]; then
CUSTOMIZE_ROOTFS="yes"
fi
if [ -e "$CUSTOMIZE_DIR/customize_initrd" ]; then
CUSTOMIZE_INITRD="yes"
fi
if [ -e "$CUSTOMIZE_DIR/customize_iso" ]; then
CUSTOMIZE_ISO="yes"
fi
if [ -e "$CUSTOMIZE_DIR/clean_desktop_manifest" ]; then
CLEAN_DESKTOP_MANIFEST="yes"
fi
if [ -e "$CUSTOMIZE_DIR/hybrid" ]; then
HYBRID="yes"
fi
$SCRIPTS_DIR/uck-remaster-clean "$REMASTER_HOME"
check_exit_code
#############
# unpacking #
#############
if [ "$CUSTOMIZE_ISO" = "yes" ] ; then
$SCRIPTS_DIR/uck-remaster-unpack-iso $use_mount "$ISO_IMAGE" "$REMASTER_HOME"
check_exit_code
fi
if [ "$CUSTOMIZE_ISO" = "yes" ] && [ "$CUSTOMIZE_ROOTFS" = "yes" ] ; then
$SCRIPTS_DIR/uck-remaster-unpack-rootfs $use_mount "$REMASTER_HOME"
check_exit_code
fi
###############
# customizing #
###############
if [ "$REMOVE_WIN32_FILES" = "yes" ]; then
"$SCRIPTS_DIR/uck-remaster-remove-win32-files" "$REMASTER_HOME"
check_exit_code
fi
if [ "$CUSTOMIZE_ISO" = "yes" ] && [ "$CUSTOMIZE_ROOTFS" = "yes" ]; then
if [ "$COPY_CUSTOMIZE_DIR" = "yes" ]; then
cp -a "$CUSTOMIZE_DIR" "$REMASTER_HOME/customization-scripts"
check_exit_code
fi
$SCRIPTS_DIR/uck-remaster-chroot-rootfs "$REMASTER_HOME" "/tmp/customization-scripts/customize"
check_exit_code
fi
if [ "$CUSTOMIZE_ISO" = "yes" ] ; then
echo "Running ISO customization script $CUSTOMIZE_DIR/customize_iso..."
"$CUSTOMIZE_DIR/customize_iso" "$REMASTER_HOME"
check_exit_code
echo "ISO customization script finished"
fi
if [ "$MANUAL_CUSTOMIZATION_PAUSE" = "yes" ] ; then
echo "Pausing for manual customization, press Enter when finished..."
read DUMMY
fi
if [ "$CUSTOMIZE_INITRD" = "yes" ] ; then
$SCRIPTS_DIR/uck-remaster-unpack-initrd "$REMASTER_HOME"
check_exit_code
fi
if [ "$CUSTOMIZE_INITRD" = "yes" ]; then
echo "Running initrd customization script $CUSTOMIZE_DIR/customize_initrd..."
"$CUSTOMIZE_DIR/customize_initrd" "$REMASTER_HOME"
check_exit_code
echo "Initrd customization script finished"
fi
###########
# packing #
###########
if [ "$CUSTOMIZE_INITRD" = "yes" ] ; then
$SCRIPTS_DIR/uck-remaster-pack-initrd "$REMASTER_HOME"
check_exit_code
fi
if [ "$CUSTOMIZE_ROOTFS" = "yes" ] ; then
if [ "$CLEAN_DESKTOP_MANIFEST" = "yes" ]; then
$SCRIPTS_DIR/uck-remaster-pack-rootfs -c "$REMASTER_HOME"
else
$SCRIPTS_DIR/uck-remaster-pack-rootfs "$REMASTER_HOME"
fi
check_exit_code
fi
if [ "$HYBRID" = "yes" ] ; then
HYBRID="-h"
else
HYBRID=""
fi
$SCRIPTS_DIR/uck-remaster-pack-iso "livecd.iso" "$REMASTER_HOME" $HYBRID
check_exit_code
#############
# finishing #
#############
if [ "$COPY_CUSTOMIZE_DIR" = "yes" ]; then
# since we copied the customization-scripts dir from outside
# can can safely remove it to leave the REMASTER_HOME as it was
# at the beginning of the process
rm -rf "$REMASTER_HOME/customization-scripts"
check_exit_code
fi
$SCRIPTS_DIR/uck-remaster-clean "$REMASTER_HOME"
check_exit_code
echo "Generation completed SUCCESSFULLY, find your ISO in $REMASTER_HOME/remaster-new-files"
exit 0