Fetching source files from staff.get-e.org git repository
[maemo-efl] / trunk / build-all.sh
1 #!/bin/bash
2
3 source "helper-functions.sh"
4 __this_script=`basename $0`
5 __this_script_dir=`dirname $0`
6
7 # git definitions
8 __git=`which git`
9 __git_clone="$__git clone"
10 __git_pull="$__git pull"
11 __git_clean="$__git clean"
12 __git_repo="git://staff.get-e.org/"
13
14 # e17 repositories paths
15 __e17_libs="e17/libs"
16 __e17_proto="e17/proto"
17 __e17_python_efl="$__e17_proto/python-efl"
18 __e17_python_etk="users/cmarcelo"
19
20 # modules
21 #__lib_modules="edb eet evas ecore embryo edje efreet epeg epsilon emotion etk ewl e_dbus exml enhance"
22 __lib_modules="eet:evas:ecore:embryo:edje:epsilon:etk:e_dbus"
23 __python_modules="python-evas:python-ecore:python-edje:python-epsilon:python-e_dbus"
24 __python_etk_module="python-etk"
25
26 # dpkg definitions
27 __uname=`which uname`
28 __arch=`$__uname -m`
29 __common_build_pkg_options="-rfakeroot -us -uc -D -tc"
30 __build_pkg_options="$__common_build_pkg_options -sa"
31 if [ "x$__arch" = "xarm" ] ; then
32     __build_pkg_options="$__common_build_pkg_options -B"
33 fi
34
35 # other definitions
36 __sed=`which sed`
37 __mkdir=`which mkdir`
38 __date=`which date`
39 __today=`$__date +%Y%m%d`
40
41 __head=`which head`
42 __distro=`$__head -1 /etc/apt/sources.list|cut -d" " -f3`
43
44 __base_pkg_dir="$__this_script_dir/packages_$__today"
45 __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
46
47 __output_file="$PWD/$__base_pkg_dir/packages_$__today.log"
48
49 # Function definitions
50 function log_to_file() {
51     local now
52     local msg
53     msg=$1
54
55     if [ ! -r $__output_file ]; then
56         error "log_to_file(): Log file does not exist"
57     fi
58
59     now=`$__date +%H:%M:%S`
60     echo "$now: $msg" >> $__output_file
61 }
62
63 function start_log() {
64     local now
65     now=`$__date -R`
66
67     if [ ! -r $__output_file ]; then
68         msg_begin "Creating log file"
69         touch $__output_file
70         msg_end $?
71     else
72         echo "" >> $__output_file
73     fi
74
75     if [ $? != 0 ] ; then
76         error "start_log(): Could not create $__output_file file"
77     fi
78
79 cat << EOF >> $__output_file
80 *********************************************************
81 * Started $__this_script: $now *
82 *********************************************************
83
84 Configuration:
85    Distro.: $__distro
86    Arch...: $__arch
87
88 EOF
89 }
90
91 function finish_log() {
92     local now
93     now=`$__date -R`
94
95     if [ ! -r $__output_file ]; then
96         error "finish_log(): Log file does not exist"
97     fi
98
99 cat << EOF >> $__output_file
100
101 * Finished $__this_script: $now
102 EOF
103 }
104
105 function clone() {
106     local repo
107     repo=$1
108     `$__git_clone $repo.git 2>&1>> $__output_file`
109     return $?
110 }
111
112 function pull() {
113     `$__git_pull 2>&1>> $__output_file`
114     return $?
115 }
116
117 function clean() {
118     return $?
119 }
120
121 function build_pkg() {
122     echo "build_pkg"
123     return $?
124 }
125
126 function install_pkg() {
127     echo "install_pkg"
128     return $?
129 }
130
131 function uninstall_pkg() {
132     echo "uninstall_pkg"
133     return $?
134 }
135
136 function get_sources() {
137     local modules
138     local repo
139     modules=`echo $1|$__sed -e 's/:/ /g'`
140     repo=$2
141
142     for module in $modules; do
143         if [ -d $module/$module/.git ]; then
144             log_to_file "Updating existing repository at $PWD/$module/$module"
145             cd $module/$module
146             msg_begin "  Updating $module repository"
147             pull
148             msg_end $?
149             cd - 2>&1 >> /dev/null
150         elif [ -d $module/$module ]; then
151             log_to_file "Removing invalid repository at $PWD/$module/$module"
152             rm -rf $module/$module
153         fi
154
155         if [ ! -d $module/$module ]; then
156             cd $module
157             msg_begin "  Cloning $repo/$module.git"
158             clone $repo/$module
159             msg_end $?
160             cd - 2>&1 >> /dev/null
161         elif [ ! -d $module ]; then
162             error "Directory $module does not exist."
163         fi
164     done
165 }
166
167 # Initial checks
168
169 # Distro variable must not be empty
170 msg_begin "Checking maemo distro"
171 test "x$__distro" != "x"
172 msg_end $?
173
174 # Check if we're running inside scratchbox
175 msg_begin "Checking for scratchbox environment"
176 test -r /targets/links/scratchbox.config
177 msg_end $?
178
179 # Begin
180 $__mkdir -p $__pkg_dir
181 start_log
182 log_to_file "Created $__pkg_dir"
183
184 # Download modules under e17/libs
185 msg "Downloading e17 modules"
186 get_sources $__lib_modules $__git_repo$__e17_libs
187
188 # Download python modules under proto/python/efl
189 msg "Downloading python modules"
190 get_sources $__python_modules $__git_repo$__e17_python_efl
191
192 # Download python-etk module
193 get_sources $__python_etk_module $__git_repo$__e17_python_etk
194
195 # Build package
196
197 # Install package
198
199 # Download user modules (python-etk)
200
201 # Build package
202
203 # Install package
204
205 # Uninstall all packages
206
207 # END
208 finish_log