New version of build scripts
[maemo-efl] / trunk / scripts / setup-functions.sh
1 #!/bin/sh
2
3 ###########################################################
4 # Maemo-efl building script
5 # Enviroment setup functions definitions
6 #
7 # Note: var-definitions.sh, log-functions.sh
8 #       and helper-functions.sh needed.
9 ###########################################################
10
11 function setup_distro() {
12     local target
13     local sources_list_file
14     local target_conf_file
15     local ret
16     target=$1
17     sources_list_file=$__sbox_path/users/$USER/targets/$target/etc/apt/sources.list
18     target_conf_file=$__sbox_path/users/$USER/targets/$target.config
19     ret=1
20
21     log_to_file "setup_distro(): Target $target"
22     log_to_file "setup_distro(): sources.list file : $sources_list_file"
23     log_to_file "setup_distro(): config file: $target_conf_file"
24
25     if [ "x$target" != "x" ] && [ -r $sources_list_file ] && [ -r $target_conf_file ]; then
26         # XXX: FIXME Figure out a better way to get the distro string
27         __distro=`$__head -1 $sources_list_file | cut -d" " -f3`
28         __arch=`$__grep SBOX_CPU= $target_conf_file | cut -d= -f2`
29         __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
30         if [ "x$__arch" = "xarm" ] ; then
31             __build_pkg_options="$__common_build_pkg_options -B"
32         else
33             __build_pkg_options="$__common_build_pkg_options -I.svn -I.git -I.gitignore -I.cvsignore -sa"
34         fi
35         ret=0
36     fi
37
38     if [ $ret -eq 0 ]; then
39         log_to_file "setup_distro(): Configuration:"
40         log_to_file "setup_distro(): distro...........: $__distro"
41         log_to_file "setup_distro(): arch.............: $__arch"
42         log_to_file "setup_distro(): build options....: $__build_pkg_options"
43         log_to_file "setup_distro(): pkg_dir..........: $__pkg_dir"
44     fi
45
46     return $ret
47 }
48
49 function setup_sbox() {
50     if [ ! -d $__sbox_path ]; then
51         error "Invalid scratchbox path: $__sbox_path"
52     fi
53
54     __sbox="$__sbox_path/login"
55     __sbox_tools_bin_path="$__sbox_path/tools/bin"
56     __sbox_sb_conf="$__sbox_tools_bin_path/sb-conf"
57
58     __sbox_maemo3_debian_bin_path="/scratchbox/devkits/maemo3-debian/bin"
59     __sbox_dpkg="$__sbox_maemo3_debian_bin_path/dpkg"
60     __sbox_dpkg_buildpackage="$__sbox_dpkg-buildpackage"
61     __sbox_dpkg_parsechangelog="$__sbox_dpkg-parsechangelog"
62     __sbox_dpkg_checkbuilddeps="$__sbox_dpkg-checkbuilddeps"
63
64     __sbox_debian_sarge_bin_path="/scratchbox/devkits/debian-sarge/bin"
65     __sbox_dch="$__sbox_debian_sarge_bin_path/dch"
66
67     __sbox_targets=`$__sbox_sb_conf list --targets`
68 }
69
70 function change_sbox_target() {
71     local target
72     target=$1
73
74     $__sbox_sb_conf select $target >> $__output_file 2>&1
75     return $?
76 }
77