X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=trunk%2Fbuild-all.sh;h=4e9130009061ebbdb256a77dcc3d2cf2aa73b4d7;hb=21dc73f67cf67dbf7a0e7762e52da1605e910036;hp=f62a7f9b73173a918050b0ee11d09c67b539bb4c;hpb=9ddf9bc3734f50c0d322b001c998a2b5796a5e00;p=maemo-efl diff --git a/trunk/build-all.sh b/trunk/build-all.sh index f62a7f9..4e91300 100755 --- a/trunk/build-all.sh +++ b/trunk/build-all.sh @@ -1,208 +1,427 @@ -#!/bin/bash - -source "helper-functions.sh" -__this_script=`basename $0` -__this_script_dir=`dirname $0` - -# git definitions -__git=`which git` -__git_clone="$__git clone" -__git_pull="$__git pull" -__git_clean="$__git clean" -__git_repo="git://staff.get-e.org/" - -# e17 repositories paths -__e17_libs="e17/libs" -__e17_proto="e17/proto" -__e17_python_efl="$__e17_proto/python-efl" -__e17_python_etk="users/cmarcelo" - -# modules -#__lib_modules="edb eet evas ecore embryo edje efreet epeg epsilon emotion etk ewl e_dbus exml enhance" -__lib_modules="eet:evas:ecore:embryo:edje:epsilon:etk:e_dbus" -__python_modules="python-evas:python-ecore:python-edje:python-epsilon:python-e_dbus" -__python_etk_module="python-etk" - -# dpkg definitions -__uname=`which uname` -__arch=`$__uname -m` -__common_build_pkg_options="-rfakeroot -us -uc -D -tc" -__build_pkg_options="$__common_build_pkg_options -sa" -if [ "x$__arch" = "xarm" ] ; then - __build_pkg_options="$__common_build_pkg_options -B" +#!/bin/sh + +########################################################### +# Maemo-efl building script +# Build script +########################################################### + +source "./scripts/message-functions.sh" +source "./scripts/var-definitions.sh" +source "./scripts/log-functions.sh" +source "./scripts/repository-functions.sh" +source "./scripts/package-functions.sh" +source "./scripts/setup-functions.sh" + +########################################################### +# Begin script +########################################################### + + +# Parse comand line options + +usage () { + cat << EOF +Usage: $__this_script [OPTIONS] +Build script for Maemo EFL debian packages. +Options: + -n Don't sign packages. + -c Don't update source repositories. + -h Show this usage guide. + -s PATH Specify alternate scratchbox path (default: $__sbox_path). + -r Remove module sub-directories (not the high level debian dir) + and then exit. + -t A:B:Z Specify scratchbox building targets + (default: all targets installed). + -u svn_rev Update the latest revision number to "svn_rev" and exit. This + only works on revision numbers that has the svn label on + the version part (e.g 0.9.9.043+svn32000-maemo1) Also, + this option will not create a new entry on the changelog + file, it will only change its first line. If you want to + update to the latest repository revision number, just use + HEAD as parameter. + -p P1:P2:PN Specify packges to build (default: build all packages available). + +EOF +} + +while getopts "anchre:s:t:u:p:" opt ; do + case "$opt" in + p) + __lib_modules_temp="" + __python_modules_temp="" + __python_efl_utils_module_temp="" + __python_dispatcher_module_temp="" + __virtual_packages_temp="" + __not_all_pkgs=1 + __parameters=`echo "$OPTARG" | $__sed -e 's/:/ /g'` + for i in $__parameters; do + for module in `echo "$__lib_modules"|$__sed -e 's/:/ /g'`; do + if [ x$module == x$i ]; then + __lib_modules_temp=$__lib_modules_temp:$i + continue + fi + done + + for module in `echo "$__python_modules"|$__sed -e 's/:/ /g'`; do + if [ x$module == x$i ]; then + __python_modules_temp=$__python_modules_temp:$i + fi + done + + for module in `echo "$__python_efl_utils_module"|$__sed -e 's/:/ /g'`; do + if [ x$module == x$i ]; then + __python_efl_utils_module_temp=$__python_efl_utils_module_temp:$i + continue + fi + done + + for module in `echo "$__python_dispatcher_module" |$__sed -e 's/:/ /g'`; do + if [ x$module == x$i ]; then + __python_dispatcher_module_temp=$__python_dispatcher_module_temp:$i + continue + fi + done + + for module in `echo "$__virtual_packages" |$__sed -e 's/:/ /g'`; do + if [ x$module == x$i ]; then + __virtual_packages_temp=$__virtual_packages_temp:$i + continue + fi + done + + done + __lib_modules_temp=`echo "$__lib_modules_temp" | tr "[:upper:]" "[:lower:]"` + __python_modules_temp=`echo "$__python_modules_temp" | tr "[:upper:]" "[:lower:]"` + __python_efl_utils_module_temp=`echo "$__python_efl_utils_module_temp" | tr "[:upper:]" "[:lower:]"` + __python_dispatcher_module_temp=`echo "$__python_dispatcher_module_temp" | tr "[:upper:]" "[:lower:]"` + __virtual_packages_temp=`echo "$__virtual_packages_temp" | tr "[:upper:]" "[:lower:]"` + ;; + c) + __update_repositories=0 + ;; + e) + __export_dir=$OPTARG + if [ "x$__sbox_path" = "x" ] || [ ! -d $__sbox_path ]; then + error "Invalid export path: $__export_dir" + exit 1 + fi + ;; + h) + usage + exit 0 + ;; + r) + __force_remove=1 + ;; + s) + __sbox_path=$OPTARG + if [ "x$__sbox_path" = "x" ] || [ ! -d $__sbox_path ]; then + error "Invalid scratchbox path: $__sbox_path" + exit 1 + fi + ;; + n) + __no_signing=1 + ;; + t) + __sbox_targets_temp=`echo $OPTARG | tr "[:lower:]" "[:upper:]"` + ;; + u) + __changelog_update=$OPTARG + ;; + ?) + usage + exit 1 + ;; + esac +done + +############################ +# Initial checks # +########################### + +update_all_modules +init_checks + +# Remove modules subdirectories and exit +if [ $__force_remove -eq 1 ]; then + clean_modules + exit 0 fi -# other definitions -__sed=`which sed` -__mkdir=`which mkdir` -__date=`which date` -__today=`$__date +%Y%m%d` +# Modify debian changelog +if [ -n "$__changelog_update" ]; then + update_changelog $__changelog_update + exit 0 +fi -__head=`which head` -__distro=`$__head -1 /etc/apt/sources.list|cut -d" " -f3` +setup_dirs +generate_versions -__base_pkg_dir="$__this_script_dir/packages_$__today" -__pkg_dir="$__base_pkg_dir/$__distro/$__arch" +if [ $__not_all_pkgs -eq 1 ]; then + __lib_modules=$__lib_modules_temp + __python_modules=$__python_modules_temp + __python_efl_utils_module=$__python_efl_utils_module_temp + __python_dispatcher_module=$__python_dispatcher_module_temp + __virtual_packages=$__virtual_packages_temp -__output_file="$PWD/$__base_pkg_dir/packages_$__today.log" + update_all_modules -# Function definitions -function log_to_file() { - local now - local msg - msg=$1 +fi - if [ ! -r $__output_file ]; then - error "log_to_file(): Log file does not exist" - fi +# Create log file +create_log_file +start_log - now=`$__date +%H:%M:%S` - echo "$now: $msg" >> $__output_file -} +# update modules +download_modules +# Setup scratchbox variables +setup_sbox -function start_log() { - local now - now=`$__date -R` +# Setup scratchbox targets if option -t was used +if [ ! -z $__sbox_targets_temp ]; then + __sbox_targets=`echo $__sbox_targets_temp|$__sed -e 's/:/ /g'` +fi - if [ ! -r $__output_file ]; then - msg_begin "Creating log file" - touch $__output_file +########################################################### +# ARCHITECTURE DEPENDENT MODULES +########################################################### +# For each scratchbox target +for target in $__sbox_targets; do + msg_begin "Checking distro and arch for target $target" + setup_distro $target + msg_end $? + + msg " Distribution..: $__distro" + msg " Architecture..: $__arch" + msg " Build Options.: $__build_pkg_options" + + if [ ! -d $__pkg_dir ]; then + msg_begin " Creating dir for $__distro $__arch packages" + $__mkdir -p $__pkg_dir msg_end $? - else - echo "" >> $__output_file fi - if [ $? != 0 ] ; then - error "start_log(): Could not create $__output_file file" - fi + msg_begin " Changing current sbox target to $target" + change_sbox_target $target + msg_end $? -cat << EOF >> $__output_file -********************************************************* -* Started $__this_script: $now * -********************************************************* + # For each module + for module in `echo $__lib_modules:$__python_modules|$__sed -e 's/:/ /g'`; do + msg " Building $module packages for $__distro $__arch" -Configuration: - Distro.: $__distro - Arch...: $__arch + update_debian_dir $module -EOF -} + if [ -d $__tmp_dir/$module/$module ]; then + msg_begin " Removing temporary $module" + rm -rf $__tmp_dir/$module/$module + msg_end $? + fi -function finish_log() { - local now - now=`$__date -R` + msg_begin " Copying $module dir to $__tmp_dir" + $__tar c --exclude=.svn --exclude=.git $module | $__tar x --directory $__tmp_dir + msg_end $? - if [ ! -r $__output_file ]; then - error "finish_log(): Log file does not exist" - fi +# msg_begin " Cleaning $module repository" +# git_clean_repository $module/$module +# msg_end $? -cat << EOF >> $__output_file + msg_begin " Building $module packages" + build_pkg $__tmp_dir/$module + msg_end $? -* Finished $__this_script: $now -EOF -} + if [ -z $__no_signing ]; then + msg_begin " Signing $module packages" + sign_pkgs $__tmp_dir/$module + msg_end $? + fi -function clone() { - local repo - repo=$1 - `$__git_clone $repo.git 2>&1>> $__output_file` - return $? -} + msg_begin " Installing $module packages" + install_pkgs $__tmp_dir/$module + msg_end $? -function pull() { - `$__git_pull 2>&1>> $__output_file` - return $? -} + msg_begin " Copying $module packages" + if [ "x$__arch" != "xarmel" ]; then + mv $__tmp_dir/$module/*.dsc $__tmp_dir/$module/*.tar.gz $__pkg_dir + fi + mv $__tmp_dir/$module/*.deb $__tmp_dir/$module/*.changes $__pkg_dir + msg_end $? -function clean() { - return $? -} + msg_begin " Removing temporary $module" + rm -rf $__tmp_dir/$module/$module + msg_end $? + done -function build_pkg() { - echo "build_pkg" - return $? -} + msg_begin " Uninstalling packages $__installed_packages" + uninstall_pkgs + msg_end $? +done + +########################################################### +# ARCHITECTURE INDEPENDENT MODULES +########################################################### +# For each scratchbox target +for target in $__sbox_targets; do + msg_begin "Checking distro and arch for target $target" + setup_distro $target + msg_end $? + + msg " Distribution..: $__distro" + msg " Architecture..: $__arch" + msg " Build Options.: $__build_pkg_options" + + if [ "x$__arch" = "xarmel" ]; then + warn "Skipping target $target for architecture independent packages" + continue + fi -function install_pkg() { - echo "install_pkg" - return $? -} + __arch="all" + __pkg_dir=`dirname $__pkg_dir`/$__arch -function uninstall_pkg() { - echo "uninstall_pkg" - return $? -} + if [ ! -d $__pkg_dir ]; then + msg_begin " Creating dir for $__distro $__arch packages" + $__mkdir -p $__pkg_dir + msg_end $? + fi -function get_sources() { - local modules - local repo - modules=`echo $1|$__sed -e 's/:/ /g'` - repo=$2 - - for module in $modules; do - if [ -d $module/$module/.git ]; then - log_to_file "Updating existing repository at $PWD/$module/$module" - cd $module/$module - msg_begin " Updating $module repository" - pull - msg_end $? - cd - 2>&1 >> /dev/null - elif [ -d $module/$module ]; then - log_to_file "Removing invalid repository at $PWD/$module/$module" - rm -rf $module/$module + msg_begin " Changing current sbox target to $target" + change_sbox_target $target + msg_end $? + + # For each module + for module in `echo $__python_efl_utils_module|$__sed -e 's/:/ /g'`; do + + msg " Building $module packages for $__distro $__arch" + update_debian_dir $module + + + if [ ! -d $__tmp_dir/$module ]; then + mkdir $__tmp_dir/$module fi - if [ ! -d $module/$module ]; then - cd $module - msg_begin " Cloning $repo/$module.git" - clone $repo/$module + if [ -d $__tmp_dir/$module/$module ]; then + msg_begin " Removing temporary $module" + rm -rf $__tmp_dir/$module/$module msg_end $? - cd - 2>&1 >> /dev/null - elif [ ! -d $module ]; then - error "Directory $module does not exist." fi + + + msg_begin " Copying $module dir to $__tmp_dir" + $__tar c --exclude=.svn --exclude=.git $module | $__tar x --directory $__tmp_dir + #cp -f -u -r $module $__tmp_dir + msg_end $? + +# msg_begin " Cleaning $module repository" +# git_clean_repository $module/$module +# msg_end $? + + msg_begin " Building $module packages" + build_pkg $__tmp_dir/$module + msg_end $? + + if [ -z $__no_signing ]; then + msg_begin " Signing $module packages" + sign_pkgs $__tmp_dir/$module + msg_end $? + fi + + msg_begin " Installing $module packages" + install_pkgs $__tmp_dir/$module + msg_end $? + + msg_begin " Copying $module packages" + mv $__tmp_dir/$module/*.dsc $__tmp_dir/$module/*.tar.gz $__tmp_dir/$module/*.deb $__tmp_dir/$module/*.changes $__pkg_dir + msg_end $? + + msg_begin " Removing temporary $module" + rm -rf $__tmp_dir/$module/$module + msg_end $? done -} -# Initial checks + msg_begin " Uninstalling packages $__installed_packages" + uninstall_pkgs + msg_end $? +done + +########################################################### +# VIRTUAL PACKAGES +########################################################### +# For each scratchbox target +for target in $__sbox_targets; do + msg_begin "Checking distro and arch for target $target" + setup_distro $target + msg_end $? + + msg " Distribution..: $__distro" + msg " Architecture..: $__arch" + msg " Build Options.: $__build_pkg_options" + + if [ "x$__arch" = "xarmel" ]; then + warn "Skipping target $target for architecture independent packages" + continue + fi -# Distro variable must not be empty -msg_begin "Checking maemo distro" -test "x$__distro" != "x" -msg_end $? + __arch="all" + __pkg_dir=`dirname $__pkg_dir`/$__arch -# Check if we're running inside scratchbox -msg_begin "Checking for scratchbox environment" -test -r /targets/links/scratchbox.config -msg_end $? + if [ ! -d $__pkg_dir ]; then + msg_begin " Creating dir for $__distro $__arch packages" + $__mkdir -p $__pkg_dir + msg_end $? + fi -# Begin -$__mkdir -p $__pkg_dir -start_log -log_to_file "Created $__pkg_dir" + msg_begin " Changing current sbox target to $target" + change_sbox_target $target + msg_end $? -# Download modules under e17/libs -msg "Downloading e17 modules" -get_sources $__lib_modules $__git_repo$__e17_libs + # For each module + for module in `echo $__virtual_packages|$__sed -e 's/:/ /g'`; do + msg " Building $module packages for $__distro $__arch" -# Download python modules under proto/python/efl -msg "Downloading python modules" -get_sources $__python_modules $__git_repo$__e17_python_efl + update_debian_dir $module + + if [ ! -d $__tmp_dir/$module ]; then + mkdir $__tmp_dir/$module + fi + + if [ -d $__tmp_dir/$module/$module ]; then + msg_begin " Removing temporary $module" + rm -rf $__tmp_dir/$module/$module + msg_end $? + fi -# Download python-etk module -get_sources $__python_etk_module $__git_repo$__e17_python_etk + msg_begin " Copying $module dir to $__tmp_dir" + $__tar c --exclude=.svn --exclude=.git $module | $__tar x --directory $__tmp_dir + #cp -f -u -r $module $__tmp_dir/$module + msg_end $? -# Build package + msg_begin " Building $module packages" + build_pkg $__tmp_dir/$module + msg_end $? -# Install package + if [ -z $__no_signing ]; then + msg_begin " Signing $module packages" + sign_pkgs $__tmp_dir/$module + msg_end $? + fi -# Download user modules (python-etk) + msg_begin " Installing $module packages" + install_pkgs $__tmp_dir/$module + msg_end $? -# Build package + msg_begin " Copying $module packages" + mv $__tmp_dir/$module/*.dsc $__tmp_dir/$module/*.tar.gz $__tmp_dir/$module/*.deb $__tmp_dir/$module/*.changes $__pkg_dir + msg_end $? -# Install package + msg_begin " Removing temporary $module" + rm -rf $__tmp_dir/$module/$module + msg_end $? + done -# Uninstall all packages + msg_begin " Uninstalling packages $__installed_packages" + uninstall_pkgs + msg_end $? +done # END finish_log