3 source "helper-functions.sh"
5 ###########################################################
7 ###########################################################
8 __this_script=`basename $0`
9 __this_script_dir=`dirname $0`
21 __git_clone="$__git clone -q"
22 __git_pull="$__git pull -q -n"
23 __git_clean="$__git clean -q -x -d"
24 __git_reset="$__git reset --hard HEAD"
25 __git_repo="git://staff.get-e.org/"
27 # e17 git repositories paths
29 __e17_proto="e17/proto"
30 __e17_python_efl="$__e17_proto/python-efl"
31 __e17_python_etk="users/cmarcelo"
34 #__lib_modules="edb eet evas ecore embryo edje efreet epeg epsilon emotion etk ewl e_dbus exml enhance"
35 __lib_modules="eet:evas:ecore:embryo:edje:epsilon:etk:e_dbus"
36 __python_modules="python-evas:python-ecore:python-edje:python-epsilon:python-e_dbus"
37 __python_etk_module="python-etk"
40 __common_build_pkg_options="-I.svn -I.git -I.gitignore -I.cvsignore -rfakeroot -us -uc -D -tc"
42 # Packages dirs and log file
43 __today=`$__date +%Y%m%d`
44 __base_pkg_dir="$__this_script_dir/packages_$__today"
45 __output_file="$PWD/$__base_pkg_dir/packages_$__today.log"
47 # Scratchbox definitions
48 __sbox_path="/scratchbox"
51 __update_repositories=1
53 ###########################################################
54 # Function definitions
55 ###########################################################
60 Usage: $__this_script [OPTIONS]
62 Build script for EFL debian packages for Maemo.
65 -c Don't update source repositories.
66 -h Show this usage guide.
67 -s PATH Specify alternate scratchbox path (default: $__sbox_path).
72 function create_log_file() {
73 if [ ! -r $__output_file ]; then
74 msg_begin "Creating log file"
78 msg "Using existing log file: $__output_file"
82 function log_to_file() {
87 if [ ! -r $__output_file ]; then
88 error "log_to_file(): Log file does not exist"
91 now=`$__date +%H:%M:%S`
92 echo "$now: $msg" >> $__output_file
95 function start_log() {
99 echo "" >> $__output_file
101 if [ $? != 0 ] ; then
102 error "start_log(): Could not create $__output_file file"
105 cat << EOF >> $__output_file
106 *********************************************************
107 * Started $__this_script: $now *
108 *********************************************************
113 function finish_log() {
117 if [ ! -r $__output_file ]; then
118 error "finish_log(): Log file does not exist"
121 cat << EOF >> $__output_file
123 * Finished $__this_script: $now
130 `$__git_clone $repo.git >> $__output_file 2>&1 `
135 `$__git_pull >> $__output_file 2>&1`
140 `$__git_reset >> $__output_file 2>&1`
141 `$__git_clean >> $__output_file 2>&1`
145 function build_pkg() {
150 function install_pkg() {
155 function uninstall_pkg() {
160 function get_sources() {
163 modules=`echo $1|$__sed -e 's/:/ /g'`
166 for module in $modules; do
167 if [ -d $module/$module/.git ]; then
168 if [ ! $__update_repositories -eq 0 ]; then
169 log_to_file "Updating existing repository at $PWD/$module/$module"
171 msg_begin " Updating $module repository"
174 cd - > /dev/null 2>&1
176 log_to_file "Skipping update of $module repository"
178 elif [ -d $module/$module ]; then
179 log_to_file "Removing invalid repository at $PWD/$module/$module"
180 rm -rf $module/$module
183 if [ ! -d $module/$module ]; then
185 msg_begin " Cloning $repo/$module.git"
188 cd - > /dev/null 2>&1
189 elif [ ! -d $module ]; then
190 error "Directory $module does not exist."
195 function setup_distro() {
197 local sources_list_file
198 local target_conf_file
201 sources_list_file=$__sbox_path/users/$USER/targets/$target/etc/apt/sources.list
202 target_conf_file=$__sbox_path/users/$USER/targets/$target.config
205 log_to_file "setup_distro(): Target $target"
206 log_to_file "setup_distro(): sources.list file : $sources_list_file"
207 log_to_file "setup_distro(): config file: $target_conf_file"
209 if [ "x$target" != "x" ] && [ -r $sources_list_file ] && [ -r $target_conf_file ]; then
210 # XXX: FIXME Figure out a better way to get the distro string
211 __distro=`$__head -1 $sources_list_file|cut -d" " -f3`
212 __arch=`grep SBOX_CPU= $target_conf_file|cut -d= -f2`
213 __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
214 __build_pkg_options="$__common_build_pkg_options -sa"
215 if [ "x$__arch" = "xarm" ] ; then
216 __build_pkg_options="$__common_build_pkg_options -B"
221 if [ $ret -eq 0 ]; then
222 log_to_file "setup_distro(): Configuration:"
223 log_to_file "setup_distro(): distro...........: $__distro"
224 log_to_file "setup_distro(): arch.............: $__arch"
225 log_to_file "setup_distro(): build options....: $__build_pkg_options"
226 log_to_file "setup_distro(): pkg_dir..........: $__pkg_dir"
229 log_to_file "setup_distro(): Returning $ret"
234 function setup_sbox() {
235 if [ ! -d $__sbox_path ]; then
236 error "Invalid scratchbox path: $__sbox_path"
239 __sbox="$__sbox_path/login"
240 __sbox_sb_conf="$__sbox /scratchbox/tools/bin/sb-conf"
242 __sbox_maemo3_debian_bin_path="/scratchbox/devkits/maemo3-debian/bin"
243 __sbox_dpkg_buildpackage="$__sbox $__sbox_maemo3_debian_bin_path/dpkg-buildpackage"
245 __sbox_debian_sarge_bin_path="/scratchbox/devkits/debian-sarge/bin"
246 __sbox_dch="$__sbox $__sbox_debian_sarge_bin_path/dch"
248 PATH="$__orig_path:$__sbox_maemo3_debian_bin_path:$__sbox_debian_sarge_bin_path"
251 ###########################################################
253 ###########################################################
255 # Parse comand line options
256 while getopts "chs:" opt ; do
259 __update_repositories=0
267 if [ "x$__sbox_path" = "x" ] || [ ! -d $__sbox_path ]; then
268 error "Invalid scratchbox path: $__sbox_path"
280 # Check if we're running inside scratchbox
281 if [ -r /targets/links/scratchbox.config ]; then
282 error "You should run this script ouside the scratchbox environment."
285 # Create base packages dir
286 if [ ! -d $__base_pkg_dir ]; then
287 msg_begin "Creating base packages dir $__base_pkg_dir"
288 $__mkdir -p $__base_pkg_dir
296 # Download modules under e17/libs
297 msg "Downloading e17 modules"
298 get_sources $__lib_modules $__git_repo$__e17_libs
300 # Download python modules under proto/python/efl
301 msg "Downloading python modules"
302 get_sources $__python_modules $__git_repo$__e17_python_efl
304 # Download python-etk module
305 get_sources $__python_etk_module $__git_repo$__e17_python_etk
307 # Setup scratchbox variables
310 # For each scratchbox target
311 for target in `$__sbox_sb_conf list --targets`; do
312 msg_begin "Checking distro and arch for target $target"
316 msg " Distribution..: $__distro"
317 msg " Architecture..: $__arch"
318 msg " Build Options.: $__build_pkg_options"
320 if [ ! -d $__pkg_dir ]; then
321 msg_begin "Creating dir for $__distro $__arch packages"
322 $__mkdir -p $__pkg_dir
327 for module in `echo $__lib_modules $__python_modules $__python_etk_module|$__sed -e 's/:/ /g'`; do
328 msg " Building $module packages for $__distro $__arch"
331 if [ -d ./debian ]; then
332 msg_begin " Removing existing debian directory"
340 `$__sbox_dpkg_buildpackage $__build_pkg_options >> $__output_file 2>&1`
347 cd - > /dev/null 2>&1
351 # Uninstall all packages