-#!/bin/bash
-
-source "helper-functions.sh"
+#!/bin/sh
###########################################################
-# Variable definitions
+# Maemo-efl building script
+# Build script
###########################################################
-__this_script=`basename $0`
-__this_script_dir=`dirname $0`
-
-# Binaries
-__date=`which date`
-__git=`which git`
-__head=`which head`
-__mkdir=`which mkdir`
-__sed=`which sed`
-__uname=`which uname`
-
-# git definitions
-__git_clone="$__git clone -q"
-__git_pull="$__git pull -q -n"
-__git_clean="$__git clean -q -x -d"
-
-__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
-__common_build_pkg_options="-rfakeroot -us -uc -D -tc"
-
-# Packages dirs and log file
-__today=`$__date +%Y%m%d`
-__base_pkg_dir="$__this_script_dir/packages_$__today"
-__output_file="$PWD/$__base_pkg_dir/packages_$__today.log"
-
-# Scratchbox definitions
-__scratchbox=/scratchbox
-
-# Other
-__update_repositories=1
+
+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"
###########################################################
-# Function definitions
+# Begin script
###########################################################
-function usage() {
- cat << EOF
-
-Usage: $__this_script [OPTIONS]
-Build script for EFL debian packages for Maemo.
+# Parse comand line options
+usage () {
+ cat << EOF
+Usage: $__this_script [OPTIONS]
+Build script for Maemo EFL debian packages.
Options:
- -c Don't update source repositories.
- -h Show this usage guide.
- -s PATH Specify alternate scratchbox path (default: $__scratchbox).
+ -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
}
-function create_log_file() {
- if [ ! -r $__output_file ]; then
- msg_begin "Creating log file"
- touch $__output_file
- msg_end $?
- else
- msg "Using existing log file: $__output_file"
- fi
-}
+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
-function log_to_file() {
- local now
- local msg
- msg=$1
+############################
+# Initial checks #
+###########################
- if [ ! -r $__output_file ]; then
- error "log_to_file(): Log file does not exist"
- fi
+update_all_modules
+init_checks
- now=`$__date +%H:%M:%S`
- echo "$now: $msg" >> $__output_file
-}
+# Remove modules subdirectories and exit
+if [ $__force_remove -eq 1 ]; then
+ clean_modules
+ exit 0
+fi
-function start_log() {
- local now
- now=`$__date -R`
+# Modify debian changelog
+if [ -n "$__changelog_update" ]; then
+ update_changelog $__changelog_update
+ exit 0
+fi
- echo "" >> $__output_file
+setup_dirs
+generate_versions
- if [ $? != 0 ] ; then
- error "start_log(): Could not create $__output_file file"
- fi
+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
- cat << EOF >> $__output_file
-*********************************************************
-* Started $__this_script: $now *
-*********************************************************
+ update_all_modules
-Configuration:
- Distro.: $__distro
- Arch...: $__arch
+fi
-EOF
-}
+# Create log file
+create_log_file
+start_log
-function finish_log() {
- local now
- now=`$__date -R`
+# update modules
+download_modules
+# Setup scratchbox variables
+setup_sbox
- if [ ! -r $__output_file ]; then
- error "finish_log(): Log file does not exist"
- fi
+# 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
+
+###########################################################
+# 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 $?
- cat << EOF >> $__output_file
+ msg " Distribution..: $__distro"
+ msg " Architecture..: $__arch"
+ msg " Build Options.: $__build_pkg_options"
-* Finished $__this_script: $now
-EOF
-}
+ if [ ! -d $__pkg_dir ]; then
+ msg_begin " Creating dir for $__distro $__arch packages"
+ $__mkdir -p $__pkg_dir
+ msg_end $?
+ fi
-function clone() {
- local repo
- repo=$1
- `$__git_clone $repo.git 2>&1 >> $__output_file`
- return $?
-}
+ msg_begin " Changing current sbox target to $target"
+ change_sbox_target $target
+ msg_end $?
-function pull() {
- `$__git_pull 2>&1 >> $__output_file`
- return $?
-}
+ # For each module
+ for module in `echo $__lib_modules:$__python_modules|$__sed -e 's/:/ /g'`; do
+ msg " Building $module packages for $__distro $__arch"
-function clean() {
- `$__git_clean 2>&1>> $__output_file`
- return $?
-}
+ update_debian_dir $module
-function build_pkg() {
- echo "build_pkg"
- return $?
-}
+ if [ -d $__tmp_dir/$module/$module ]; then
+ msg_begin " Removing temporary $module"
+ rm -rf $__tmp_dir/$module/$module
+ msg_end $?
+ fi
-function install_pkg() {
- echo "install_pkg"
- return $?
-}
+ msg_begin " Copying $module dir to $__tmp_dir"
+ $__tar c --exclude=.svn --exclude=.git $module | $__tar x --directory $__tmp_dir
+ msg_end $?
-function uninstall_pkg() {
- echo "uninstall_pkg"
- return $?
-}
+# msg_begin " Cleaning $module repository"
+# git_clean_repository $module/$module
+# msg_end $?
-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
- if [ ! $__update_repositories -eq 0 ]; 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
- else
- log_to_file "Skipping update of $module repository"
- fi
- elif [ -d $module/$module ]; then
- log_to_file "Removing invalid repository at $PWD/$module/$module"
- rm -rf $module/$module
- fi
+ msg_begin " Building $module packages"
+ build_pkg $__tmp_dir/$module
+ msg_end $?
- if [ ! -d $module/$module ]; then
- cd $module
- msg_begin " Cloning $repo/$module.git"
- clone $repo/$module
+ if [ -z $__no_signing ]; then
+ msg_begin " Signing $module packages"
+ sign_pkgs $__tmp_dir/$module
msg_end $?
- cd - 2>&1 >> /dev/null
- elif [ ! -d $module ]; then
- error "Directory $module does not exist."
fi
- done
-}
-# XXX: FIXME Figure out a better way to get the distro string
-function check_distro() {
- local target
- local sources_list_file
- local target_conf_file
- local ret
- target=$1
- sources_list_file=$__scratchbox/users/$USER/targets/$target/etc/apt/sources.list
- target_conf_file=$__scratchbox/users/$USER/targets/$target.config
- ret=1
-
- log_to_file "check_distro(): Target $target"
- log_to_file "check_distro(): sources.list file : $sources_list_file"
- log_to_file "check_distro(): config file: $target_conf_file"
-
- if [ "x$target" != "x" ] && [ -r $sources_list_file ] && [ -r $target_conf_file ]; then
- __distro=`$__head -1 $sources_list_file|cut -d" " -f3`
- __arch=`grep SBOX_CPU= $target_conf_file|cut -d= -f2`
- __pkg_dir="$__base_pkg_dir/$__distro/$__arch"
- __build_pkg_options="$__common_build_pkg_options -sa"
- if [ "x$__arch" = "xarm" ] ; then
- __build_pkg_options="$__common_build_pkg_options -B"
- fi
- ret=0
- fi
+ msg_begin " Installing $module packages"
+ install_pkgs $__tmp_dir/$module
+ msg_end $?
- if [ $ret -eq 0 ]; then
- log_to_file "check_distro(): Configuration:"
- log_to_file "check_distro(): distro...........: $__distro"
- log_to_file "check_distro(): arch.............: $__arch"
- log_to_file "check_distro(): build options....: $__build_pkg_options"
- log_to_file "check_distro(): pkg_dir..........: $__pkg_dir"
- fi
+ 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 $?
- log_to_file "check_distro(): Returning $ret"
+ msg_begin " Removing temporary $module"
+ rm -rf $__tmp_dir/$module/$module
+ msg_end $?
+ done
- return $ret
-}
+ msg_begin " Uninstalling packages $__installed_packages"
+ uninstall_pkgs
+ msg_end $?
+done
###########################################################
-# Begin script
+# 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 $?
-# Parse comand line options
-while getopts "chs" opt ; do
- case "$opt" in
- c)
- __update_repositories=0
- ;;
- h)
- usage
- exit 0
- ;;
- s)
- __scratchbox=$OPTARG
- ;;
- [?])
- usage
- exit 1
- ;;
- esac
-done
+ msg " Distribution..: $__distro"
+ msg " Architecture..: $__arch"
+ msg " Build Options.: $__build_pkg_options"
-# Initial checks
+ if [ "x$__arch" = "xarmel" ]; then
+ warn "Skipping target $target for architecture independent packages"
+ continue
+ fi
-# Check if we're running inside scratchbox
-if [ -r /targets/links/scratchbox.config ]; then
- error "You should run this script ouside the scratchbox environment."
-fi
+ __arch="all"
+ __pkg_dir=`dirname $__pkg_dir`/$__arch
-# Create base packages dir
-if [ ! -d $__base_pkg_dir ]; then
- msg_begin "Creating base packages dir $__base_pkg_dir"
- $__mkdir -p $__base_pkg_dir
+ if [ ! -d $__pkg_dir ]; then
+ msg_begin " Creating dir for $__distro $__arch packages"
+ $__mkdir -p $__pkg_dir
+ msg_end $?
+ fi
+
+ msg_begin " Changing current sbox target to $target"
+ change_sbox_target $target
msg_end $?
-fi
-# Create log file
-create_log_file
+ # For each module
+ for module in `echo $__python_efl_utils_module|$__sed -e 's/:/ /g'`; do
-# Download modules under e17/libs
-msg "Downloading e17 modules"
-get_sources $__lib_modules $__git_repo$__e17_libs
+ msg " Building $module packages for $__distro $__arch"
+ update_debian_dir $module
-# Download python modules under proto/python/efl
-msg "Downloading python modules"
-get_sources $__python_modules $__git_repo$__e17_python_efl
-# Download python-etk module
-get_sources $__python_etk_module $__git_repo$__e17_python_etk
+ 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
+
+
+ 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
+
+ msg_begin " Uninstalling packages $__installed_packages"
+ uninstall_pkgs
+ msg_end $?
+done
+
+###########################################################
+# VIRTUAL PACKAGES
+###########################################################
# For each scratchbox target
-for target in `$__scratchbox/tools/bin/sb-conf list --targets`; do
+for target in $__sbox_targets; do
msg_begin "Checking distro and arch for target $target"
- check_distro $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
+
+ __arch="all"
+ __pkg_dir=`dirname $__pkg_dir`/$__arch
+
if [ ! -d $__pkg_dir ]; then
- msg_begin "Creating dir for $__distro $__arch packages"
+ msg_begin " Creating dir for $__distro $__arch packages"
$__mkdir -p $__pkg_dir
msg_end $?
fi
- # Build package
- # Install packages
+ msg_begin " Changing current sbox target to $target"
+ change_sbox_target $target
+ msg_end $?
+
+ # For each module
+ for module in `echo $__virtual_packages|$__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 $__tmp_dir/$module/$module ]; then
+ msg_begin " Removing temporary $module"
+ rm -rf $__tmp_dir/$module/$module
+ msg_end $?
+ 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/$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 $?
- # Clean tree
+ 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
+
+ msg_begin " Uninstalling packages $__installed_packages"
+ uninstall_pkgs
+ msg_end $?
done
-# Uninstall all packages
# END
finish_log