3 source "helper-functions.sh"
5 ###########################################################
7 ###########################################################
8 __this_script=`basename $0`
9 __this_script_dir=`dirname $0`
24 __git_clone="$__git clone -q"
25 __git_pull="$__git pull -q -n"
26 __git_clean="$__git clean -q -x -d"
27 __git_reset="$__git reset --hard HEAD"
28 __git_repo="git://staff.get-e.org/"
30 # e17 git repositories paths
32 __e17_proto="e17/proto"
33 __e17_python_efl="$__e17_proto/python-efl"
34 __e17_python_etk="users/cmarcelo"
37 #__lib_modules="edb eet evas ecore embryo edje efreet epeg epsilon emotion etk ewl e_dbus exml enhance"
38 __lib_modules="eet:evas:ecore:embryo:edje:epsilon:etk:e_dbus"
39 __python_modules="python-evas:python-ecore:python-edje:python-epsilon:python-e_dbus"
40 __python_etk_module="python-etk"
43 __common_build_pkg_options="-rfakeroot -us -uc -D"
45 # Packages dirs and log file
46 __today=`$__date +%Y%m%d`
47 __base_pkg_dir="$__this_script_dir/efl_packages_$__today"
48 __output_file="$PWD/$__base_pkg_dir/efl_packages_$__today.log"
50 # Scratchbox definitions
51 __sbox_path="/scratchbox"
54 __update_repositories=1
55 __installed_packages=""
57 ###########################################################
58 # Function definitions
59 ###########################################################
64 Usage: $__this_script [OPTIONS]
66 Build script for EFL debian packages for Maemo.
69 -c Don't update source repositories.
70 -h Show this usage guide.
71 -s PATH Specify alternate scratchbox path (default: $__sbox_path).
76 function create_log_file() {
77 if [ ! -r $__output_file ]; then
78 msg_begin "Creating log file"
82 msg "Using existing log file: $__output_file"
86 function log_to_file() {
91 if [ ! -r $__output_file ]; then
92 error "log_to_file(): Log file does not exist"
95 now=`$__date +%H:%M:%S`
96 echo "$now: $msg" >> $__output_file
99 function start_log() {
103 echo "" >> $__output_file
105 if [ $? != 0 ] ; then
106 error "start_log(): Could not create $__output_file file"
109 cat << EOF >> $__output_file
110 *********************************************************
111 * Started $__this_script: $now *
112 *********************************************************
117 function finish_log() {
121 if [ ! -r $__output_file ]; then
122 error "finish_log(): Log file does not exist"
125 cat << EOF >> $__output_file
127 * Finished $__this_script: $now
131 function clone_repository() {
134 `$__git_clone $repo.git >> $__output_file 2>&1 `
138 function update_repository() {
142 if [ ! -d $repo ]; then
143 error " Trying to update invalid repository"
147 `$__git_pull >> $__output_file 2>&1`
148 cd - > /dev/null 2>&1
153 function clean_repository() {
157 if [ ! -d $repo ]; then
158 error " Trying to clean invalid repository"
162 `$__git_reset >> $__output_file 2>&1`
163 `$__git_clean >> $__output_file 2>&1`
164 cd - > /dev/null 2>&1
169 function build_pkg() {
173 cat << EOF > $dir/sbox_build_pkgs
176 cd $dir/`basename $dir`
177 NOCONFIGURE=1 ./autogen.sh >> $dir/sbox_build_pkgs.log 2>&1 || exit 1
178 $__sbox_dpkg_buildpackage $__build_pkg_options >> $dir/sbox_build_pkgs.log 2>&1
182 `$__chmod 755 $dir/sbox_build_pkgs`
183 `$__sbox $dir/sbox_build_pkgs`
187 function install_pkgs() {
191 cat << EOF > $dir/sbox_install_pkgs
195 $__sbox_dpkg --install *.deb >> $dir/sbox_install_pkgs.log 2>&1
199 `$__chmod 755 $dir/sbox_install_pkgs`
200 `$__sbox $dir/sbox_install_pkgs` || return 1
202 for package in $dir/*.deb; do
203 pkg=`basename $package | cut -d_ -f1`
204 echo $__installed_packages | tr " " "\n" | sort -u | $__egrep "\^$pkg\$" > /dev/null 2>&1
206 if [ ! $? -eq 0 ]; then
207 __installed_packages="$__installed_packages $pkg"
214 function uninstall_pkgs() {
216 cat << EOF > /tmp/sbox_uninstall_pkgs
220 $__sbox_dpkg --purge $__installed_packages >> /tmp/sbox_uninstall_pkgs.log 2>&1
224 __installed_packages=""
225 `$__chmod 755 /tmp/sbox_uninstall_pkgs`
226 `$__sbox /tmp/sbox_uninstall_pkgs`
230 function get_sources() {
233 modules=`echo $1|$__sed -e 's/:/ /g'`
236 for module in $modules; do
238 if [ ! -d $module ]; then
239 error "Directory $module does not exist."
244 if [ -d $module/.git ]; then
245 if [ ! $__update_repositories -eq 0 ]; then
246 log_to_file "Updating existing repository at $PWD/$module"
248 msg_begin " Updating $module repository"
249 update_repository $module
252 log_to_file "Skipping update of $module repository"
254 elif [ -d $module ]; then
255 log_to_file "Removing invalid repository at $PWD/$module"
259 if [ ! -d $module ]; then
260 msg_begin " Cloning $repo/$module.git"
261 clone_repository $repo/$module
269 function setup_distro() {
271 local sources_list_file
272 local target_conf_file
275 sources_list_file=$__sbox_path/users/$USER/targets/$target/etc/apt/sources.list
276 target_conf_file=$__sbox_path/users/$USER/targets/$target.config
279 log_to_file "setup_distro(): Target $target"
280 log_to_file "setup_distro(): sources.list file : $sources_list_file"
281 log_to_file "setup_distro(): config file: $target_conf_file"
283 if [ "x$target" != "x" ] && [ -r $sources_list_file ] && [ -r $target_conf_file ]; then
284 # XXX: FIXME Figure out a better way to get the distro string
285 __distro=`$__head -1 $sources_list_file | cut -d" " -f3`
286 __arch=`$__grep SBOX_CPU= $target_conf_file | cut -d= -f2`
287 __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
288 if [ "x$__arch" = "xarm" ] ; then
289 __build_pkg_options="$__common_build_pkg_options -B"
291 __build_pkg_options="$__common_build_pkg_options -I.svn -I.git -I.gitignore -I.cvsignore -sa"
296 if [ $ret -eq 0 ]; then
297 log_to_file "setup_distro(): Configuration:"
298 log_to_file "setup_distro(): distro...........: $__distro"
299 log_to_file "setup_distro(): arch.............: $__arch"
300 log_to_file "setup_distro(): build options....: $__build_pkg_options"
301 log_to_file "setup_distro(): pkg_dir..........: $__pkg_dir"
304 log_to_file "setup_distro(): Returning $ret"
309 function setup_sbox() {
310 if [ ! -d $__sbox_path ]; then
311 error "Invalid scratchbox path: $__sbox_path"
314 __sbox="$__sbox_path/login"
315 __sbox_tools_bin_path="$__sbox_path/tools/bin"
316 __sbox_sb_conf="$__sbox_tools_bin_path/sb-conf"
318 __sbox_maemo3_debian_bin_path="/scratchbox/devkits/maemo3-debian/bin"
319 __sbox_dpkg="$__sbox_maemo3_debian_bin_path/dpkg"
320 __sbox_dpkg_buildpackage="$__sbox_dpkg-buildpackage"
322 __sbox_debian_sarge_bin_path="/scratchbox/devkits/debian-sarge/bin"
323 __sbox_dch="$__sbox_debian_sarge_bin_path/dch"
326 function change_sbox_target() {
330 `$__sbox_sb_conf select $target`
334 ###########################################################
336 ###########################################################
338 # Parse comand line options
339 while getopts "chs:" opt ; do
342 __update_repositories=0
350 if [ "x$__sbox_path" = "x" ] || [ ! -d $__sbox_path ]; then
351 error "Invalid scratchbox path: $__sbox_path"
363 # Check if we're running inside scratchbox
364 if [ -r /targets/links/scratchbox.config ]; then
365 error "You should run this script ouside the scratchbox environment."
368 # Create base packages dir
369 if [ ! -d $__base_pkg_dir ]; then
370 msg_begin "Creating base packages dir $__base_pkg_dir"
371 $__mkdir -p $__base_pkg_dir
379 # Download modules under e17/libs
380 msg "Downloading e17 modules"
381 get_sources $__lib_modules $__git_repo$__e17_libs
383 # Download python modules under proto/python/efl
384 msg "Downloading python modules"
385 get_sources $__python_modules $__git_repo$__e17_python_efl
387 # Download python-etk module
388 get_sources $__python_etk_module $__git_repo$__e17_python_etk
390 # Setup scratchbox variables
393 # For each scratchbox target
394 for target in `$__sbox_sb_conf list --targets`; do
395 msg_begin "Checking distro and arch for target $target"
399 msg " Distribution..: $__distro"
400 msg " Architecture..: $__arch"
401 msg " Build Options.: $__build_pkg_options"
403 if [ ! -d $__pkg_dir ]; then
404 msg_begin " Creating dir for $__distro $__arch packages"
405 $__mkdir -p $__pkg_dir
409 msg_begin " Changing current sbox target to $target"
410 change_sbox_target $target
414 for module in `echo $__lib_modules $__python_modules $__python_etk_module|$__sed -e 's/:/ /g'`; do
416 msg " Building $module packages for $__distro $__arch"
418 if [ -d "./$module/$module/debian" ]; then
419 msg_begin " Removing existing debian directory"
420 rm -rf "./$module/$module/debian"
424 msg_begin " Copying specific debian directory"
425 if [ -d "./$module/debian_$__distro" ]; then
426 cp -r "./$module/debian_$__distro" "./$module/$module/debian"
427 elif [ -d "./$module/debian" ]; then
428 cp -r "./$module/debian" "./$module/$module/"
430 error " Missing debian directory for $module"
434 if [ -d "/tmp/$module/$module" ]; then
435 msg_begin " Removing temporary $module"
436 rm -rf "/tmp/$module/$module"
440 msg_begin " Copying $module dir to /tmp"
441 cp -u -r $module /tmp
444 msg_begin " Cleaning $module repository"
445 clean_repository $module/$module
448 msg_begin " Building $module packages"
449 build_pkg /tmp/$module
452 msg_begin " Installing $module packages"
453 install_pkgs /tmp/$module
456 msg_begin " Copying $module packages"
457 if [ "x$__arch" != "xarm" ]; then
458 mv /tmp/$module/*.dsc /tmp/$module/*.tar.gz $__pkg_dir
460 mv /tmp/$module/*.deb /tmp/$module/*.changes $__pkg_dir
463 msg_begin " Removing temporary $module"
464 rm -rf "/tmp/$module/$module"
468 clean_repository $module
471 msg_begin " Uninstalling packages $__installed_packages"
474 # Uninstall all packages