-#!/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"
-__users="users"
-
-# modules
-__lib_modules="edb eet evas ecore embryo edje efreet epeg epsilon emotion etk ewl e_dbus exml enhance"
-__python_modules="python-evas python-ecore python-edje python-epsilon python-e_dbus"
-__user_modules="python-etk"
-
-# dpkg definitions
-__uname=`which uname`
-__arch=`$__uname -m`
-__common_build_pkg_options="-rfakeroot -us -uc -D"
-__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
-__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="$__base_pkg_dir/packages_$__today.log"
+ update_all_modules
+fi
-function clone() {
- local repo
- repo=$1
- `$__git_clone $repo 2>&1 >> $__output_file`
- return $?
-}
+# Create log file
+create_log_file
+start_log
-function pull() {
- `$__git_pull 2>&1 >> $__output_file`
- return $?
-}
+# update modules
+download_modules
+# Setup scratchbox variables
+setup_sbox
-function clean() {
- echo "clean"
- return $?
-}
-
-function build_pkg() {
- echo "build_pkg"
- return $?
-}
+# 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
-function install_pkg() {
- echo "install_pkg"
- return $?
-}
+###########################################################
+# 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 $?
+ fi
-function uninstall_pkg() {
- echo "uninstall_pkg"
- return $?
-}
+ msg_begin " Changing current sbox target to $target"
+ change_sbox_target $target
+ msg_end $?
+
+ # For each module
+ for module in `echo $__lib_modules:$__python_modules|$__sed -e 's/:/ /g'`; do
+ msg " Building $module packages for $__distro $__arch"
+
+ update_debian_dir $module
+
+ 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
+ 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"
+ 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 $?
+
+ 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
+
+###########################################################
+# 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 log_to_file() {
- local now
- local msg
- msg=$1
+ __arch="all"
+ __pkg_dir=`dirname $__pkg_dir`/$__arch
- if [ ! -r $__output_file ]; then
- error "Log file $__output_file does not exist"
+ if [ ! -d $__pkg_dir ]; then
+ msg_begin " Creating dir for $__distro $__arch packages"
+ $__mkdir -p $__pkg_dir
+ msg_end $?
fi
- now=`$__date +%H:%M:%S`
- echo "$now: $msg" >> $__output_file
-}
+ msg_begin " Changing current sbox target to $target"
+ change_sbox_target $target
+ msg_end $?
-function start_log() {
- local now
- now=`$__date -R`
+ # For each module
+ for module in `echo $__python_efl_utils_module|$__sed -e 's/:/ /g'`; do
- if [ ! -r $__output_file ]; then
- touch $__output_file
- fi
+ 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
+ msg_end $?
+
+# msg_begin " Cleaning $module repository"
+# git_clean_repository $module/$module
+# msg_end $?
- if [ $? != 0 ] ; then
- error "Could not create log file $__output_file"
+ 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
- echo "*********************************************************" >> $__output_file
- echo "* Started $__this_script: $now *" >> $__output_file
- echo "*********************************************************" >> $__output_file
- echo "" >> $__output_file
- echo "Configuration:" >> $__output_file
- echo " Distro.: $__distro" >> $__output_file
- echo " Arch...: $__arch" >> $__output_file
- echo "" >> $__output_file
-}
+ 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 $__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 finish_log() {
- local now
- now=`$__date -R`
+ __arch="all"
+ __pkg_dir=`dirname $__pkg_dir`/$__arch
- if [ ! -r $__output_file ]; then
- error "Log file $__output_file does not exist"
+ if [ ! -d $__pkg_dir ]; then
+ msg_begin " Creating dir for $__distro $__arch packages"
+ $__mkdir -p $__pkg_dir
+ msg_end $?
fi
- echo "" >> $__output_file
- echo "* Finished $__this_script: $now" >> $__output_file
- echo "" >> $__output_file
-}
+ msg_begin " Changing current sbox target to $target"
+ change_sbox_target $target
+ msg_end $?
-# Initial checks
-# Check if we're running inside scratchbox
-msg_begin "Checking for scratchbox environment"
-test -r /targets/links/scratchbox.config
-msg_end $?
+ # For each module
+ for module in `echo $__virtual_packages|$__sed -e 's/:/ /g'`; do
+ msg " Building $module packages for $__distro $__arch"
-# Begin
-mkdir -p $__pkg_dir
-start_log
-log_to_file "Created $__pkg_dir"
+ update_debian_dir $module
+
+ if [ ! -d $__tmp_dir/$module ]; then
+ mkdir $__tmp_dir/$module
+ fi
-# Check for fakeroot
+ if [ -d $__tmp_dir/$module/$module ]; then
+ msg_begin " Removing temporary $module"
+ rm -rf $__tmp_dir/$module/$module
+ msg_end $?
+ fi
-# Download official modules
+ 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