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 -n"
27 __git_clean="$__git clean -q -x -d"
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"
38 #__lib_modules="edb eet evas ecore embryo edje efreet epeg epsilon emotion etk ewl e_dbus exml enhance"
39 __lib_modules="eet:evas:ecore:embryo:edje:imlib2:epeg:epsilon:etk:e_dbus"
40 __python_modules="python-evas:python-ecore:python-edje:python-epsilon:python-e_dbus"
41 __python_etk_module="python-etk"
44 __common_build_pkg_options="-rfakeroot -us -uc -D"
46 # Packages dirs and log file
47 __today=`$__date +%Y%m%d`
48 __base_pkg_dir="$__this_script_dir/efl_packages_$__today"
49 __output_file="$PWD/$__base_pkg_dir/efl_packages_$__today.log"
51 # Scratchbox definitions
52 __sbox_path="/scratchbox"
55 __update_repositories=1
56 __installed_packages=""
58 ###########################################################
59 # Function definitions
60 ###########################################################
65 Usage: $__this_script [OPTIONS]
67 Build script for EFL debian packages for Maemo.
70 -c Don't update source repositories.
71 -h Show this usage guide.
72 -s PATH Specify alternate scratchbox path (default: $__sbox_path).
77 function create_log_file() {
78 if [ ! -r $__output_file ]; then
79 msg_begin "Creating log file"
83 msg "Using existing log file: $__output_file"
87 function log_to_file() {
92 if [ ! -r $__output_file ]; then
93 error "log_to_file(): Log file does not exist"
96 now=`$__date +%H:%M:%S`
97 echo "$now: $msg" >> $__output_file
100 function start_log() {
104 echo "" >> $__output_file
106 if [ $? != 0 ] ; then
107 error "start_log(): Could not create $__output_file file"
110 cat << EOF >> $__output_file
111 *********************************************************
112 * Started $__this_script: $now *
113 *********************************************************
118 function finish_log() {
122 if [ ! -r $__output_file ]; then
123 error "finish_log(): Log file does not exist"
126 cat << EOF >> $__output_file
128 * Finished $__this_script: $now
132 function clone_repository() {
135 $__git_clone $repo.git >> $__output_file 2>&1
139 function update_repository() {
143 if [ ! -d $repo ]; then
144 error " Trying to update invalid repository"
148 $__git_pull >> $__output_file 2>&1 || return 1
149 cd - > /dev/null 2>&1
154 function clean_repository() {
158 if [ ! -d $repo ]; then
159 error " Trying to clean invalid repository"
163 $__git_reset >> $__output_file 2>&1 || return 1
164 $__git_clean >> $__output_file 2>&1 || return 1
165 cd - > /dev/null 2>&1
170 function build_pkg() {
174 cat << EOF > $dir/sbox_build_pkgs
177 export DEBFULLNAME="$DEBFULLNAME"
178 export DEBEMAIL="$DEBEMAIL"
180 cd $dir/`basename $dir`
182 if [ -x ./autogen.sh ]; then
183 NOCONFIGURE=1 ./autogen.sh >> $dir/sbox_build_pkgs.log 2>&1 || exit 1
186 VERSION=\`$__sbox_dpkg_parsechangelog | grep Version: | cut -d" " -f2 | cut -d- -f1\`
187 REVISION=\`$__sbox_dpkg_parsechangelog | grep Version: | cut -d- -f2\`
189 $__sbox_dch -v \$VERSION+cvs$__today-\$REVISION -D $__distro "Snapshot CVS release of $__today" >> $dir/sbox_build_pkgs.log 2>&1 || exit 1
190 $__sbox_dpkg_buildpackage $__build_pkg_options >> $dir/sbox_build_pkgs.log 2>&1
194 $__chmod 755 $dir/sbox_build_pkgs
195 $__sbox $dir/sbox_build_pkgs
199 function install_pkgs() {
203 cat << EOF > $dir/sbox_install_pkgs
207 $__sbox_dpkg --install *.deb >> $dir/sbox_install_pkgs.log 2>&1
211 $__chmod 755 $dir/sbox_install_pkgs
212 $__sbox $dir/sbox_install_pkgs || return 1
214 for package in $dir/*.deb; do
215 pkg=`basename $package | cut -d_ -f1`
216 echo $__installed_packages | tr " " "\n" | sort -u | $__egrep "\^$pkg\$" > /dev/null 2>&1
218 if [ ! $? -eq 0 ]; then
219 __installed_packages="$__installed_packages $pkg"
226 function uninstall_pkgs() {
228 cat << EOF > /tmp/sbox_uninstall_pkgs
232 $__sbox_dpkg --purge $__installed_packages >> /tmp/sbox_uninstall_pkgs.log 2>&1
236 __installed_packages=""
237 $__chmod 755 /tmp/sbox_uninstall_pkgs
238 $__sbox /tmp/sbox_uninstall_pkgs
242 function sign_pkgs() {
247 $__debsign *.changes >> $dir/sign_pkgs.log 2>&1 || return 1
249 cd - > /dev/null 2>&1
254 function get_sources() {
257 modules=`echo $1|$__sed -e 's/:/ /g'`
260 for module in $modules; do
262 if [ ! -d $module ]; then
263 error "Directory $module does not exist."
268 if [ -d $module/.git ]; then
269 if [ ! $__update_repositories -eq 0 ]; then
270 log_to_file "Updating existing repository at $PWD/$module"
272 msg_begin " Updating $module repository"
273 update_repository $module
276 log_to_file "Skipping update of $module repository"
278 elif [ -d $module ]; then
279 log_to_file "Removing invalid repository at $PWD/$module"
283 if [ ! -d $module ]; then
284 msg_begin " Cloning $repo/$module.git"
285 clone_repository $repo/$module
293 function setup_distro() {
295 local sources_list_file
296 local target_conf_file
299 sources_list_file=$__sbox_path/users/$USER/targets/$target/etc/apt/sources.list
300 target_conf_file=$__sbox_path/users/$USER/targets/$target.config
303 log_to_file "setup_distro(): Target $target"
304 log_to_file "setup_distro(): sources.list file : $sources_list_file"
305 log_to_file "setup_distro(): config file: $target_conf_file"
307 if [ "x$target" != "x" ] && [ -r $sources_list_file ] && [ -r $target_conf_file ]; then
308 # XXX: FIXME Figure out a better way to get the distro string
309 __distro=`$__head -1 $sources_list_file | cut -d" " -f3`
310 __arch=`$__grep SBOX_CPU= $target_conf_file | cut -d= -f2`
311 __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
312 if [ "x$__arch" = "xarm" ] ; then
313 __build_pkg_options="$__common_build_pkg_options -B"
315 __build_pkg_options="$__common_build_pkg_options -I.svn -I.git -I.gitignore -I.cvsignore -sa"
320 if [ $ret -eq 0 ]; then
321 log_to_file "setup_distro(): Configuration:"
322 log_to_file "setup_distro(): distro...........: $__distro"
323 log_to_file "setup_distro(): arch.............: $__arch"
324 log_to_file "setup_distro(): build options....: $__build_pkg_options"
325 log_to_file "setup_distro(): pkg_dir..........: $__pkg_dir"
331 function setup_sbox() {
332 if [ ! -d $__sbox_path ]; then
333 error "Invalid scratchbox path: $__sbox_path"
336 __sbox="$__sbox_path/login"
337 __sbox_tools_bin_path="$__sbox_path/tools/bin"
338 __sbox_sb_conf="$__sbox_tools_bin_path/sb-conf"
340 __sbox_maemo3_debian_bin_path="/scratchbox/devkits/maemo3-debian/bin"
341 __sbox_dpkg="$__sbox_maemo3_debian_bin_path/dpkg"
342 __sbox_dpkg_buildpackage="$__sbox_dpkg-buildpackage"
343 __sbox_dpkg_parsechangelog="$__sbox_dpkg-parsechangelog"
345 __sbox_debian_sarge_bin_path="/scratchbox/devkits/debian-sarge/bin"
346 __sbox_dch="$__sbox_debian_sarge_bin_path/dch"
349 function change_sbox_target() {
353 $__sbox_sb_conf select $target >> $__output_file 2>&1
357 ###########################################################
359 ###########################################################
361 # Parse comand line options
362 while getopts "chs:" opt ; do
365 __update_repositories=0
373 if [ "x$__sbox_path" = "x" ] || [ ! -d $__sbox_path ]; then
374 error "Invalid scratchbox path: $__sbox_path"
386 # Check if we're running inside scratchbox
387 if [ -r /targets/links/scratchbox.config ]; then
388 error "You should run this script ouside the scratchbox environment."
391 # Create base packages dir
392 if [ ! -d $__base_pkg_dir ]; then
393 msg_begin "Creating base packages dir $__base_pkg_dir"
394 $__mkdir -p $__base_pkg_dir
402 # Download modules under e17/libs
403 msg "Downloading e17 modules"
404 get_sources $__lib_modules $__git_repo$__e17_libs
406 # Download python modules under proto/python/efl
407 msg "Downloading python modules"
408 get_sources $__python_modules $__git_repo$__e17_python_efl
410 # Download python-etk module
411 get_sources $__python_etk_module $__git_repo$__e17_python_etk
413 # Setup scratchbox variables
416 # For each scratchbox target
417 for target in `$__sbox_sb_conf list --targets`; do
418 msg_begin "Checking distro and arch for target $target"
422 msg " Distribution..: $__distro"
423 msg " Architecture..: $__arch"
424 msg " Build Options.: $__build_pkg_options"
426 if [ ! -d $__pkg_dir ]; then
427 msg_begin " Creating dir for $__distro $__arch packages"
428 $__mkdir -p $__pkg_dir
432 msg_begin " Changing current sbox target to $target"
433 change_sbox_target $target
437 for module in `echo $__lib_modules $__python_modules $__python_etk_module|$__sed -e 's/:/ /g'`; do
439 msg " Building $module packages for $__distro $__arch"
441 if [ -d ./$module/$module/debian ]; then
442 msg_begin " Removing existing debian directory"
443 rm -rf ./$module/$module/debian
447 msg_begin " Copying specific debian directory"
448 if [ -d ./$module/debian_$__distro ]; then
449 cp -r ./$module/debian_$__distro ./$module/$module/debian
450 elif [ -d ./$module/debian ]; then
451 cp -r ./$module/debian ./$module/$module/
453 error " Missing debian directory for $module"
457 if [ -d /tmp/$module/$module ]; then
458 msg_begin " Removing temporary $module"
459 rm -rf /tmp/$module/$module
463 msg_begin " Copying $module dir to /tmp"
464 cp -u -r $module /tmp
467 msg_begin " Cleaning $module repository"
468 clean_repository $module/$module
471 msg_begin " Building $module packages"
472 build_pkg /tmp/$module
475 msg_begin " Signing $module packages"
476 sign_pkgs /tmp/$module
479 msg_begin " Installing $module packages"
480 install_pkgs /tmp/$module
483 msg_begin " Copying $module packages"
484 if [ "x$__arch" != "xarm" ]; then
485 mv /tmp/$module/*.dsc /tmp/$module/*.tar.gz $__pkg_dir
487 mv /tmp/$module/*.deb /tmp/$module/*.changes $__pkg_dir
490 msg_begin " Removing temporary $module"
491 rm -rf /tmp/$module/$module
495 msg_begin " Uninstalling packages $__installed_packages"