update to use efl svn
[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 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 | cut -d"/" -f1`
28         __arch=`$__grep SBOX_CPU= $target_conf_file | cut -d= -f2`
29         if [ "x$__arch" == "xi686" ]; then
30             __arch="i386"
31         elif [ "x$__arch" == "xarm" ]; then
32             __arch="armel"
33         fi
34         __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
35         if [ "x$__arch" = "xarmel" ] ; then
36             __build_pkg_options="$__common_build_pkg_options -B"
37         else
38             __build_pkg_options="$__common_build_pkg_options -I.svn -I.git -I.gitignore -I.cvsignore -sa"
39         fi
40         ret=0
41     fi
42
43     if [ $ret -eq 0 ]; then
44         log_to_file "setup_distro(): Configuration:"
45         log_to_file "setup_distro(): distro...........: $__distro"
46         log_to_file "setup_distro(): arch.............: $__arch"
47         log_to_file "setup_distro(): build options....: $__build_pkg_options"
48         log_to_file "setup_distro(): pkg_dir..........: $__pkg_dir"
49     fi
50
51     return $ret
52 }
53
54 setup_sbox() {
55     if [ ! -d $__sbox_path ]; then
56         error "Invalid scratchbox path: $__sbox_path"
57     fi
58
59     __sbox="$__sbox_path/login"
60     __sbox_tools_bin_path="$__sbox_path/tools/bin"
61     __sbox_sb_conf="$__sbox_tools_bin_path/sb-conf"
62
63     __sbox_maemo3_debian_bin_path="/scratchbox/devkits/maemo3-debian/bin"
64     __sbox_dpkg="$__sbox_maemo3_debian_bin_path/dpkg"
65     __sbox_dpkg_buildpackage="$__sbox_dpkg-buildpackage"
66     __sbox_dpkg_parsechangelog="$__sbox_dpkg-parsechangelog"
67     __sbox_dpkg_checkbuilddeps="$__sbox_dpkg-checkbuilddeps"
68
69     __sbox_debian_sarge_bin_path="/scratchbox/devkits/debian-sarge/bin"
70     __sbox_dch="$__sbox_debian_sarge_bin_path/dch"
71
72     __sbox_targets=`$__sbox_sb_conf list --targets`
73 }
74
75 change_sbox_target () {
76     local target
77     target=$1
78
79     $__sbox_sb_conf select $target >> $__output_file 2>&1
80     return $?
81 }
82
83 init_checks () {
84
85     if [ x$USER == xroot ]; then
86         error "You should not run this script as root"
87     fi
88
89     if [ -r /targets/links/scratchbox.config ]; then
90         error "You should run this script outside the scratchbox environment."$
91     fi
92 }
93
94 setup_dirs () {
95     if [ ! -d $__base_pkg_dir ]; then
96         msg_begin "Creating base packages dir $__base_pkg_dir"
97         $__mkdir -p $__base_pkg_dir
98         msg_end $?
99     fi
100
101     # Create tmp dir
102     if [ ! -d $__tmp_dir ]; then
103         msg_begin "Creating tmp dir $__tmp_dir"
104         $__mkdir -p $__tmp_dir
105         msg_end $?
106     fi
107
108 }