3 source "helper-functions.sh"
5 ###########################################################
7 ###########################################################
8 __this_script=`basename $0`
9 __this_script_dir=`dirname $0`
22 __debsign=`which debsign`
25 __git_clone="$__git clone -q"
26 __git_pull="$__git pull -q"
27 __git_clean="$__git clean -q -x -d -f"
28 __git_reset="$__git reset --hard HEAD"
29 __git_repo="git://staff.get-e.org/"
31 # e17 git repositories paths
33 __e17_proto="e17/proto"
34 __e17_python_efl="$__e17_proto/python-efl"
35 __e17_python_etk="users/cmarcelo"
36 __e17_python_efl_utils="users/barbieri"
37 #__e17_python_dispatcher="users/ulisses"
40 #__lib_modules="edb eet evas ecore embryo edje efreet epeg epsilon emotion etk ewl e_dbus exml enhance"
41 __lib_modules="eet:evas:ecore:embryo:edje:imlib2:epeg:epsilon:etk:e_dbus"
42 __other_modules="himf-ecore:himf-ecore-chinook:lightmediascanner:python-lightmediascanner"
43 __python_modules="python-evas:python-ecore:python-edje:python-epsilon:python-e_dbus"
44 __python_etk_module="python-etk"
45 __python_efl_utils_module="python-efl_utils"
46 #__python_dispatcher_module="python-dispatcher"
47 __virtual_packages="efl-core python-efl-core"
50 __common_build_pkg_options="-rfakeroot -us -uc -D"
52 # Packages dirs and log file
53 __today=`$__date +%Y%m%d`
54 __base_pkg_dir="$__this_script_dir/packages_$__today"
55 __output_file="$PWD/$__base_pkg_dir/packages_$__today.log"
57 # Scratchbox definitions
58 __sbox_path="/scratchbox"
61 __update_repositories=1
62 __installed_packages=""
64 ###########################################################
65 # Function definitions
66 ###########################################################
71 Usage: $__this_script [OPTIONS]
73 Build script for EFL debian packages for Maemo.
76 -c Don't update source repositories.
77 -h Show this usage guide.
78 -s PATH Specify alternate scratchbox path (default: $__sbox_path).
83 function create_log_file() {
84 if [ ! -r $__output_file ]; then
85 msg_begin "Creating log file"
89 msg "Using existing log file: $__output_file"
93 function log_to_file() {
98 if [ ! -r $__output_file ]; then
99 error "log_to_file(): Log file does not exist"
102 now=`$__date +%H:%M:%S`
103 echo "$now: $msg" >> $__output_file
106 function start_log() {
110 echo "" >> $__output_file
112 if [ $? != 0 ] ; then
113 error "start_log(): Could not create $__output_file file"
116 cat << EOF >> $__output_file
117 *********************************************************
118 * Started $__this_script: $now *
119 *********************************************************
124 function finish_log() {
128 if [ ! -r $__output_file ]; then
129 error "finish_log(): Log file does not exist"
132 cat << EOF >> $__output_file
134 * Finished $__this_script: $now
138 function clone_repository() {
141 $__git_clone $repo.git >> $__output_file 2>&1
145 function update_repository() {
149 if [ ! -d $repo ]; then
150 error " Trying to update invalid repository"
154 $__git_pull >> $__output_file 2>&1 || return 1
155 cd - > /dev/null 2>&1
160 function clean_repository() {
164 if [ ! -d $repo ]; then
165 error " Trying to clean invalid repository"
169 $__git_reset >> $__output_file 2>&1 || return 1
170 $__git_clean >> $__output_file 2>&1 || return 1
171 cd - > /dev/null 2>&1
176 function configure_pkg() {
180 cd $dir/`basename $dir`
182 if [ -x ./autogen.sh ]; then
183 NOCONFIGURE=1 ./autogen.sh >> $dir/sbox_build_pkgs.log 2>&1 || return 1
186 cd - > /dev/null 2>&1
191 function build_pkg() {
195 configure_pkg $dir || return 1
197 local DEB_BUILD_OPTIONS=n8x0
198 if [ "x$__distro" = "xgregale" ]; then
199 DEB_BUILD_OPTIONS=n770
202 cat << EOF > $dir/sbox_build_pkgs
205 export DEBFULLNAME="$DEBFULLNAME"
206 export DEBEMAIL="$DEBEMAIL"
207 export DEB_BUILD_OPTIONS="$DEB_BUILD_OPTIONS"
209 cd $dir/`basename $dir`
211 VERSION=\`$__sbox_dpkg_parsechangelog | grep Version: | cut -d" " -f2 | cut -d- -f1 >> $dir/sbox_build_pkgs.log 2>&1 || exit 1\`
212 REVISION=\`$__sbox_dpkg_parsechangelog | grep Version: | cut -d- -f2 >> $dir/sbox_build_pkgs.log 2>&1 || exit 1\`
214 # $__sbox_dch -v \$VERSION+cvs$__today-\$REVISION -D $__distro "Snapshot CVS release of $__today" >> $dir/sbox_build_pkgs.log 2>&1 || exit 1
215 $__sbox_dpkg_buildpackage $__build_pkg_options >> $dir/sbox_build_pkgs.log 2>&1
219 $__chmod 755 $dir/sbox_build_pkgs
220 $__sbox $dir/sbox_build_pkgs
224 function install_pkgs() {
228 cat << EOF > $dir/sbox_install_pkgs
232 $__sbox_dpkg --install *.deb >> $dir/sbox_install_pkgs.log 2>&1
236 $__chmod 755 $dir/sbox_install_pkgs
237 $__sbox $dir/sbox_install_pkgs || return 1
239 for package in $dir/*.deb; do
240 pkg=`basename $package | cut -d_ -f1`
241 echo $__installed_packages | tr " " "\n" | sort -u | $__egrep "\^$pkg\$" > /dev/null 2>&1
243 if [ ! $? -eq 0 ]; then
244 __installed_packages="$__installed_packages $pkg"
251 function uninstall_pkgs() {
253 cat << EOF > /tmp/sbox_uninstall_pkgs
257 $__sbox_dpkg --purge $__installed_packages >> /tmp/sbox_uninstall_pkgs.log 2>&1
261 __installed_packages=""
262 $__chmod 755 /tmp/sbox_uninstall_pkgs
263 #$__sbox /tmp/sbox_uninstall_pkgs
267 function sign_pkgs() {
272 $__debsign *.changes >> $dir/sign_pkgs.log 2>&1 || return 1
274 cd - > /dev/null 2>&1
279 function get_sources() {
282 modules=`echo $1|$__sed -e 's/:/ /g'`
285 for module in $modules; do
287 if [ ! -d $module ]; then
288 error "Directory $module does not exist."
293 if [ -d $module/.git ]; then
294 if [ ! $__update_repositories -eq 0 ]; then
295 log_to_file "Updating existing repository at $PWD/$module"
297 msg_begin " Updating $module repository"
298 update_repository $module
301 log_to_file "Skipping update of $module repository"
303 elif [ -d $module ]; then
304 log_to_file "Removing invalid repository at $PWD/$module"
308 if [ ! -d $module ]; then
309 msg_begin " Cloning $repo/$module.git"
310 clone_repository $repo/$module
318 function setup_distro() {
320 local sources_list_file
321 local target_conf_file
324 sources_list_file=$__sbox_path/users/$USER/targets/$target/etc/apt/sources.list
325 target_conf_file=$__sbox_path/users/$USER/targets/$target.config
328 log_to_file "setup_distro(): Target $target"
329 log_to_file "setup_distro(): sources.list file : $sources_list_file"
330 log_to_file "setup_distro(): config file: $target_conf_file"
332 if [ "x$target" != "x" ] && [ -r $sources_list_file ] && [ -r $target_conf_file ]; then
333 # XXX: FIXME Figure out a better way to get the distro string
334 __distro=`$__head -1 $sources_list_file | cut -d" " -f3`
335 __arch=`$__grep SBOX_CPU= $target_conf_file | cut -d= -f2`
336 __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
337 if [ "x$__arch" = "xarm" ] ; then
338 __build_pkg_options="$__common_build_pkg_options -B"
340 __build_pkg_options="$__common_build_pkg_options -I.svn -I.git -I.gitignore -I.cvsignore -sa"
345 if [ $ret -eq 0 ]; then
346 log_to_file "setup_distro(): Configuration:"
347 log_to_file "setup_distro(): distro...........: $__distro"
348 log_to_file "setup_distro(): arch.............: $__arch"
349 log_to_file "setup_distro(): build options....: $__build_pkg_options"
350 log_to_file "setup_distro(): pkg_dir..........: $__pkg_dir"
356 function setup_sbox() {
357 if [ ! -d $__sbox_path ]; then
358 error "Invalid scratchbox path: $__sbox_path"
361 __sbox="$__sbox_path/login"
362 __sbox_tools_bin_path="$__sbox_path/tools/bin"
363 __sbox_sb_conf="$__sbox_tools_bin_path/sb-conf"
365 __sbox_maemo3_debian_bin_path="/scratchbox/devkits/maemo3-debian/bin"
366 __sbox_dpkg="$__sbox_maemo3_debian_bin_path/dpkg"
367 __sbox_dpkg_buildpackage="$__sbox_dpkg-buildpackage"
368 __sbox_dpkg_parsechangelog="$__sbox_dpkg-parsechangelog"
370 __sbox_debian_sarge_bin_path="/scratchbox/devkits/debian-sarge/bin"
371 __sbox_dch="$__sbox_debian_sarge_bin_path/dch"
374 function change_sbox_target() {
378 $__sbox_sb_conf select $target >> $__output_file 2>&1
382 ###########################################################
384 ###########################################################
386 # Parse comand line options
387 while getopts "chs:" opt ; do
390 __update_repositories=0
398 if [ "x$__sbox_path" = "x" ] || [ ! -d $__sbox_path ]; then
399 error "Invalid scratchbox path: $__sbox_path"
411 # Check if we're running inside scratchbox
412 if [ -r /targets/links/scratchbox.config ]; then
413 error "You should run this script ouside the scratchbox environment."
416 # Create base packages dir
417 if [ ! -d $__base_pkg_dir ]; then
418 msg_begin "Creating base packages dir $__base_pkg_dir"
419 $__mkdir -p $__base_pkg_dir
427 # Download modules under e17/libs
428 msg "Downloading e17 modules"
429 get_sources $__lib_modules $__git_repo$__e17_libs
431 # Download python modules under proto/python/efl
432 msg "Downloading python modules"
433 get_sources $__python_modules $__git_repo$__e17_python_efl
435 # Download python-etk module
436 get_sources $__python_etk_module $__git_repo$__e17_python_etk
438 # Download python-efl-utils module
439 get_sources $__python_efl_utils_module $__git_repo$__e17_python_efl_utils
441 # Download python-dispatcher module
442 #get_sources $__python_dispatcher_module $__git_repo$__e17_python_dispatcher
444 # Setup scratchbox variables
447 ###########################################################
448 # ARCHITECTURE DEPENDENT MODULES
449 ###########################################################
450 # For each scratchbox target
451 for target in `$__sbox_sb_conf list --targets`; do
452 msg_begin "Checking distro and arch for target $target"
456 msg " Distribution..: $__distro"
457 msg " Architecture..: $__arch"
458 msg " Build Options.: $__build_pkg_options"
460 if [ ! -d $__pkg_dir ]; then
461 msg_begin " Creating dir for $__distro $__arch packages"
462 $__mkdir -p $__pkg_dir
466 msg_begin " Changing current sbox target to $target"
467 change_sbox_target $target
471 for module in `echo $__lib_modules:$__python_modules:$__python_etk_module|$__sed -e 's/:/ /g'`; do
472 msg " Building $module packages for $__distro $__arch"
474 if [ -d ./$module/$module/debian ]; then
475 msg_begin " Removing existing debian directory"
476 rm -rf ./$module/$module/debian
480 msg_begin " Copying specific debian directory"
481 if [ -d ./$module/debian ]; then
482 cp -r ./$module/debian ./$module/$module/
484 if [ -d ./$module/debian_$__distro ]; then
485 cp -r ./$module/debian_$__distro/* ./$module/$module/debian/
488 if [ -d ./$module/debian_$__distro ]; then
489 cp -r ./$module/debian_$__distro ./$module/$module/debian
492 warn "Missing debian directory for $module. Ignoring"
498 if [ -d /tmp/$module/$module ]; then
499 msg_begin " Removing temporary $module"
500 rm -rf /tmp/$module/$module
504 msg_begin " Copying $module dir to /tmp"
505 cp -u -r $module /tmp
508 msg_begin " Cleaning $module repository"
509 clean_repository $module/$module
512 msg_begin " Building $module packages"
513 build_pkg /tmp/$module
516 msg_begin " Signing $module packages"
517 sign_pkgs /tmp/$module
520 msg_begin " Installing $module packages"
521 install_pkgs /tmp/$module
524 msg_begin " Copying $module packages"
525 if [ "x$__arch" != "xarm" ]; then
526 mv /tmp/$module/*.dsc /tmp/$module/*.tar.gz $__pkg_dir
528 mv /tmp/$module/*.deb /tmp/$module/*.changes $__pkg_dir
531 msg_begin " Removing temporary $module"
532 rm -rf /tmp/$module/$module
536 msg_begin " Uninstalling packages $__installed_packages"
542 ###########################################################
543 # ARCHITECTURE INDEPENDENT MODULES
544 ###########################################################
545 # For each scratchbox target
546 for target in `$__sbox_sb_conf list --targets`; do
547 msg_begin "Checking distro and arch for target $target"
551 msg " Distribution..: $__distro"
552 msg " Architecture..: $__arch"
553 msg " Build Options.: $__build_pkg_options"
555 if [ "x$__arch" = "xarm" ]; then
556 warn "Skipping target $target for architecture independent packages"
561 __pkg_dir=`dirname $__pkg_dir`/$__arch
563 if [ ! -d $__pkg_dir ]; then
564 msg_begin " Creating dir for $__distro $__arch packages"
565 $__mkdir -p $__pkg_dir
569 msg_begin " Changing current sbox target to $target"
570 change_sbox_target $target
574 for module in $__python_efl_utils_module; do
575 msg " Building $module packages for $__distro $__arch"
577 if [ ! -d /tmp/$module ]; then
581 if [ -d /tmp/$module/$module ]; then
582 msg_begin " Removing temporary $module"
583 rm -rf /tmp/$module/$module
587 msg_begin " Copying specific debian directory"
588 if [ -d ./$module/debian ]; then
589 cp -r ./$module/debian ./$module/$module/
591 if [ -d ./$module/debian_$__distro ]; then
592 cp -r ./$module/debian_$__distro/* ./$module/$module/debian/
596 warn " Missing debian directory for $module. Ignoring"
601 msg_begin " Copying $module dir to /tmp"
602 cp -u -r $module /tmp
605 msg_begin " Cleaning $module repository"
606 clean_repository $module/$module
609 msg_begin " Building $module packages"
610 build_pkg /tmp/$module
613 msg_begin " Signing $module packages"
614 sign_pkgs /tmp/$module
617 msg_begin " Installing $module packages"
618 install_pkgs /tmp/$module
621 msg_begin " Copying $module packages"
622 mv /tmp/$module/*.dsc /tmp/$module/*.tar.gz /tmp/$module/*.deb /tmp/$module/*.changes $__pkg_dir
625 msg_begin " Removing temporary $module"
626 rm -rf /tmp/$module/$module
630 msg_begin " Uninstalling packages $__installed_packages"
635 ###########################################################
637 ###########################################################
638 # For each scratchbox target
639 for target in `$__sbox_sb_conf list --targets`; do
640 msg_begin "Checking distro and arch for target $target"
644 msg " Distribution..: $__distro"
645 msg " Architecture..: $__arch"
646 msg " Build Options.: $__build_pkg_options"
648 if [ "x$__arch" = "xarm" ]; then
649 warn "Skipping target $target for architecture independent packages"
654 __pkg_dir=`dirname $__pkg_dir`/$__arch
656 if [ ! -d $__pkg_dir ]; then
657 msg_begin " Creating dir for $__distro $__arch packages"
658 $__mkdir -p $__pkg_dir
662 msg_begin " Changing current sbox target to $target"
663 change_sbox_target $target
667 for module in $__virtual_packages; do
668 msg " Building $module packages for $__distro $__arch"
670 if [ ! -d /tmp/$module ]; then
674 if [ -d /tmp/$module/$module ]; then
675 msg_begin " Removing temporary $module"
676 rm -rf /tmp/$module/$module
680 msg_begin " Copying $module dir to /tmp"
681 cp -u -r $module /tmp/$module
684 msg_begin " Building $module packages"
685 build_pkg /tmp/$module
688 msg_begin " Signing $module packages"
689 sign_pkgs /tmp/$module
692 msg_begin " Installing $module packages"
693 install_pkgs /tmp/$module
696 msg_begin " Copying $module packages"
697 mv /tmp/$module/*.dsc /tmp/$module/*.tar.gz /tmp/$module/*.deb /tmp/$module/*.changes $__pkg_dir
700 msg_begin " Removing temporary $module"
701 rm -rf /tmp/$module/$module
705 msg_begin " Uninstalling packages $__installed_packages"