3 source "helper-functions.sh"
5 ###########################################################
7 ###########################################################
8 __this_script=`basename $0`
9 __this_script_dir=`dirname $0`
22 __git_clone="$__git clone -q"
23 __git_pull="$__git pull -q -n"
24 __git_clean="$__git clean -q -x -d"
25 __git_reset="$__git reset --hard HEAD"
26 __git_repo="git://staff.get-e.org/"
28 # e17 git repositories paths
30 __e17_proto="e17/proto"
31 __e17_python_efl="$__e17_proto/python-efl"
32 __e17_python_etk="users/cmarcelo"
35 #__lib_modules="edb eet evas ecore embryo edje efreet epeg epsilon emotion etk ewl e_dbus exml enhance"
36 __lib_modules="eet:evas:ecore:embryo:edje:epsilon:etk:e_dbus"
37 __python_modules="python-evas:python-ecore:python-edje:python-epsilon:python-e_dbus"
38 __python_etk_module="python-etk"
41 __common_build_pkg_options="-I.svn -I.git -I.gitignore -I.cvsignore -rfakeroot -us -uc -D -tc"
43 # Packages dirs and log file
44 __today=`$__date +%Y%m%d`
45 __base_pkg_dir="$__this_script_dir/packages_$__today"
46 __output_file="$PWD/$__base_pkg_dir/packages_$__today.log"
48 # Scratchbox definitions
49 __sbox_path="/scratchbox"
52 __update_repositories=1
54 ###########################################################
55 # Function definitions
56 ###########################################################
61 Usage: $__this_script [OPTIONS]
63 Build script for EFL debian packages for Maemo.
66 -c Don't update source repositories.
67 -h Show this usage guide.
68 -s PATH Specify alternate scratchbox path (default: $__sbox_path).
73 function create_log_file() {
74 if [ ! -r $__output_file ]; then
75 msg_begin "Creating log file"
79 msg "Using existing log file: $__output_file"
83 function log_to_file() {
88 if [ ! -r $__output_file ]; then
89 error "log_to_file(): Log file does not exist"
92 now=`$__date +%H:%M:%S`
93 echo "$now: $msg" >> $__output_file
96 function start_log() {
100 echo "" >> $__output_file
102 if [ $? != 0 ] ; then
103 error "start_log(): Could not create $__output_file file"
106 cat << EOF >> $__output_file
107 *********************************************************
108 * Started $__this_script: $now *
109 *********************************************************
114 function finish_log() {
118 if [ ! -r $__output_file ]; then
119 error "finish_log(): Log file does not exist"
122 cat << EOF >> $__output_file
124 * Finished $__this_script: $now
128 function clone_repository() {
131 `$__git_clone $repo.git >> $__output_file 2>&1 `
135 function update_repository() {
139 if [ ! -d $repo ]; then
140 error " Trying to update invalid repository"
144 `$__git_pull >> $__output_file 2>&1`
145 cd - > /dev/null 2>&1
150 function clean_repository() {
154 if [ ! -d $repo ]; then
155 error " Trying to clean invalid repository"
159 `$__git_reset >> $__output_file 2>&1`
160 `$__git_clean >> $__output_file 2>&1`
161 cd - > /dev/null 2>&1
166 function build_pkg() {
170 cat << EOF >> $dir/sbox_build_pkg
173 cd $dir/`basename $dir`
174 NOCONFIGURE=1 ./autogen.sh >> $dir/sbox_build_pkg.log 2>&1
175 $__sbox_dpkg_buildpackage $__build_pkg_options >> $dir/sbox_build_pkg.log 2>&1
179 `$__chmod 755 $dir/sbox_build_pkg`
180 `$__sbox $dir/sbox_build_pkg`
184 function install_pkg() {
189 function uninstall_pkg() {
194 function get_sources() {
197 modules=`echo $1|$__sed -e 's/:/ /g'`
200 for module in $modules; do
202 if [ ! -d $module ]; then
203 error "Directory $module does not exist."
208 if [ -d $module/.git ]; then
209 if [ ! $__update_repositories -eq 0 ]; then
210 log_to_file "Updating existing repository at $PWD/$module"
212 msg_begin " Updating $module repository"
213 update_repository $module
216 log_to_file "Skipping update of $module repository"
218 elif [ -d $module ]; then
219 log_to_file "Removing invalid repository at $PWD/$module"
223 if [ ! -d $module ]; then
224 msg_begin " Cloning $repo/$module.git"
225 clone_repository $repo/$module
233 function setup_distro() {
235 local sources_list_file
236 local target_conf_file
239 sources_list_file=$__sbox_path/users/$USER/targets/$target/etc/apt/sources.list
240 target_conf_file=$__sbox_path/users/$USER/targets/$target.config
243 log_to_file "setup_distro(): Target $target"
244 log_to_file "setup_distro(): sources.list file : $sources_list_file"
245 log_to_file "setup_distro(): config file: $target_conf_file"
247 if [ "x$target" != "x" ] && [ -r $sources_list_file ] && [ -r $target_conf_file ]; then
248 # XXX: FIXME Figure out a better way to get the distro string
249 __distro=`$__head -1 $sources_list_file|cut -d" " -f3`
250 __arch=`grep SBOX_CPU= $target_conf_file|cut -d= -f2`
251 __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
252 __build_pkg_options="$__common_build_pkg_options -sa"
253 if [ "x$__arch" = "xarm" ] ; then
254 __build_pkg_options="$__common_build_pkg_options -B"
259 if [ $ret -eq 0 ]; then
260 log_to_file "setup_distro(): Configuration:"
261 log_to_file "setup_distro(): distro...........: $__distro"
262 log_to_file "setup_distro(): arch.............: $__arch"
263 log_to_file "setup_distro(): build options....: $__build_pkg_options"
264 log_to_file "setup_distro(): pkg_dir..........: $__pkg_dir"
267 log_to_file "setup_distro(): Returning $ret"
272 function setup_sbox() {
273 if [ ! -d $__sbox_path ]; then
274 error "Invalid scratchbox path: $__sbox_path"
277 __sbox="$__sbox_path/login"
278 __sbox_tools_bin_path="$__sbox_path/tools/bin"
279 __sbox_sb_conf="$__sbox_tools_bin_path/sb-conf"
281 __sbox_maemo3_debian_bin_path="/scratchbox/devkits/maemo3-debian/bin"
282 __sbox_dpkg_buildpackage="$__sbox_maemo3_debian_bin_path/dpkg-buildpackage"
284 __sbox_debian_sarge_bin_path="/scratchbox/devkits/debian-sarge/bin"
285 __sbox_dch="$__sbox_debian_sarge_bin_path/dch"
288 function change_sbox_target() {
292 `$__sbox_sb_conf select $target`
296 ###########################################################
298 ###########################################################
300 # Parse comand line options
301 while getopts "chs:" opt ; do
304 __update_repositories=0
312 if [ "x$__sbox_path" = "x" ] || [ ! -d $__sbox_path ]; then
313 error "Invalid scratchbox path: $__sbox_path"
325 # Check if we're running inside scratchbox
326 if [ -r /targets/links/scratchbox.config ]; then
327 error "You should run this script ouside the scratchbox environment."
330 # Create base packages dir
331 if [ ! -d $__base_pkg_dir ]; then
332 msg_begin "Creating base packages dir $__base_pkg_dir"
333 $__mkdir -p $__base_pkg_dir
341 # Download modules under e17/libs
342 msg "Downloading e17 modules"
343 get_sources $__lib_modules $__git_repo$__e17_libs
345 # Download python modules under proto/python/efl
346 msg "Downloading python modules"
347 get_sources $__python_modules $__git_repo$__e17_python_efl
349 # Download python-etk module
350 get_sources $__python_etk_module $__git_repo$__e17_python_etk
352 # Setup scratchbox variables
355 # For each scratchbox target
356 for target in `$__sbox_sb_conf list --targets`; do
357 msg_begin "Checking distro and arch for target $target"
361 msg " Distribution..: $__distro"
362 msg " Architecture..: $__arch"
363 msg " Build Options.: $__build_pkg_options"
365 if [ ! -d $__pkg_dir ]; then
366 msg_begin "Creating dir for $__distro $__arch packages"
367 $__mkdir -p $__pkg_dir
372 for module in `echo $__lib_modules $__python_modules $__python_etk_module|$__sed -e 's/:/ /g'`; do
374 msg_begin "Changing current sbox target to $target"
375 change_sbox_target $target
378 msg " Building $module packages for $__distro $__arch"
380 if [ -d "./$module/$module/debian" ]; then
381 msg_begin " Removing existing debian directory"
382 rm -rf "./$module/$module/debian"
386 msg_begin " Copying specific debian directory"
387 if [ -d "./$module/debian_$__distro" ]; then
388 cp -r "./$module/debian_$__distro" "./$module/$module/debian"
389 elif [ -d "./$module/debian" ]; then
390 cp -r "./$module/debian" "./$module/$module/"
392 error " Missing debian directory for $module"
396 if [ -d "/tmp/$module" ]; then
397 msg_begin " Removing temporary $module"
398 rm -rf "/tmp/$module"
402 msg_begin " Copying $module dir to /tmp"
406 msg_begin " Cleaning $module repository"
407 clean_repository $module/$module
410 msg_begin " Building $module packages"
411 build_pkg /tmp/$module
414 msg_begin " Copying $module packages"
415 if [ "x$__arch" != "xarm" ]; then
416 mv /tmp/$module/*.dsc /tmp/$module/*.tar.gz $__pkg_dir
418 mv /tmp/$module/*.deb /tmp/$module/*.changes $__pkg_dir
421 msg_begin " Removing temporary $module"
428 clean_repository $module
431 # Uninstall all packages