Better detection of package version
[maemo-efl] / trunk / scripts / gen-deb-src.sh
index 70870f5..9cc771f 100755 (executable)
@@ -1,24 +1,50 @@
 #!/bin/bash
 
-E_BASE_REPO="http://svn.enlightenment.org/svn/e/trunk"
-E_PYTHON_REPO="$E_BASE_REPO/BINDINGS/python"
-E_SVN_REV="40978"
+E_BASE_REPO="http://svn.enlightenment.org/svn/e"
+E_TRUNK_REPO="$E_BASE_REPO/trunk"
+E_PYTHON_SUFIX="BINDINGS/python"
+E_PYTHON_REPO="$E_TRUNK_REPO/$E_PYTHON_SUFIX"
+E_PROTO_REPO="$E_TRUNK_REPO/PROTO"
+
+[ -z $OUTPUT_FILE ] && OUTPUT_FILE="/dev/null"
+[ -z $E_SVN_REV ] && E_SVN_REV="50928"
 
 TMP_DIR="maemo-efl-deb-src-$E_SVN_REV"
 VERSIONS_DIR="$TMP_DIR/versions"
 
-ALL_MODULES="eina eet evas ecore embryo edje epsilon etk e_dbus efl-core python-evas python-ecore python-edje python-epsilon python-etk python-e_dbus python-efl_utils python-efl-core"
+# C Modules
+ALL_MODULES=("eina"
+             "eet"
+             "evas"
+             "ecore"
+             "embryo"
+             "edje"
+             "e_dbus"
+             "emotion"
+             "epdf"
+             "ethumb"
+             "libeweather"
+             "elementary"
+             "efl-core")
+
+# Python Bindings
+ALL_MODULES+=("python-evas"
+              "python-ecore"
+              "python-edje"
+              "python-e_dbus"
+              "python-ethumb"
+              "python-efl_utils"
+              "python-elementary"
+              "python-efl-core")
 
 MAEMO_REV="maemo1"
 MAEMO_REPO="extras-devel"
 
-MAEMO_EFL_BASE_REPO="https://garage.maemo.org/svn/maemo-efl/trunk/"
-
-exit_error(){
+function exit_error(){
     echo " ERROR" && exit 1
 }
 
-init(){
+function init(){
     if [ -d $TMP_DIR ]; then
                echo -n "Cleaning up ..."
                rm -rf $TMP_DIR || exit_error
@@ -30,22 +56,38 @@ init(){
     echo " OK"
 }
 
-checkout_repositories(){
+function checkout_repositories(){
     echo "Checking out repositories ..."
-    for module in $ALL_MODULES;do
+    for module in ${ALL_MODULES[@]};do
         echo -n "      $module"
 
-               REPO=$E_BASE_REPO
+        case $module in
+            elementary)
+                REPO="$E_TRUNK_REPO/TMP/st"
+                ;;
+            epdf|libeweather)
+                REPO="$E_PROTO_REPO"
+                ;;
+            *efl-core)
+                cp -r $module $TMP_DIR >> $OUTPUT_FILE 2>&1 && echo " ... OK" || exit_error
+                continue
+                ;;
+            python-*)
+                REPO="$E_PYTHON_REPO"
+                ;;
+            *)
+                REPO=$E_TRUNK_REPO
+                ;;
+        esac
+
                REV="-r$E_SVN_REV "
-               echo -n $module | grep python > /dev/null 2>&1 && REPO=$E_PYTHON_REPO
-               echo -n $module | grep efl-core > /dev/null 2>&1 && cp -r $module $TMP_DIR && echo " ... OK" && continue
 
         echo -n " ."
-        svn co $REV $REPO/$module $TMP_DIR/$module > /dev/null 2>&1 || exit_error
+        svn co $REV $REPO/$module $TMP_DIR/$module >> $OUTPUT_FILE 2>&1 || exit_error
         echo -n "."
         rm -rf $TMP_DIR/$module/debian
         echo -n "."
-        cp -r $module/debian $TMP_DIR/$module/debian > /dev/null 2>&1 || exit_error
+        cp -r $module/debian $TMP_DIR/$module/debian >> $OUTPUT_FILE 2>&1 || exit_error
         echo " OK"
     done
 
@@ -55,24 +97,53 @@ checkout_repositories(){
     echo " OK"
 }
 
-update_changelogs(){
+function c_module_version() {
+    local mod=$1
+
+    [ -z $mod ] && exit_error
+
+    VERSION=`grep AC_INIT $TMP_DIR/$mod/configure.ac | cut -d[ -f3 | cut -d] -f1 || exit_error`
+    if [ $VERSION = "v_ver" ]; then
+        MAJOR=`grep v_maj $TMP_DIR/$mod/configure.ac | xargs | cut -d[ -f3 | cut -d] -f1 || exit_error`
+        MINOR=`grep v_min $TMP_DIR/$mod/configure.ac | xargs | cut -d[ -f3 | cut -d] -f1 || exit_error`
+        MICRO=`grep v_mic $TMP_DIR/$mod/configure.ac | xargs | cut -d[ -f3 | cut -d] -f1 || exit_error`
+        if [ -z $MAJOR ] || [ -z $MINOR ] || [ -z $MICRO ]; then
+            exit_error
+        fi
+
+        VERSION=$MAJOR.$MINOR.$MICRO
+    fi
+}
+
+function update_changelogs(){
        echo "Updating changelogs ..."
-    for module in $ALL_MODULES;do
-        echo -n "      $module "
+    for module in ${ALL_MODULES[@]};do
+        echo -n "      $module ."
+
+        case $module in
+            *efl-core)
+                c_module_version "evas"
+                ;;
+            python-*)
+                VERSION=`grep version $TMP_DIR/$module/setup.py | cut -d\' -f2 || exit_error`
+                ;;
+            *)
+                c_module_version "$module"
+                ;;
+        esac
 
-        echo -n $module | grep -v python | grep -v efl-core > /dev/null 2>&1 && VERSION=`grep AC_INIT $TMP_DIR/$module/configure.ac | cut -d[ -f3 | cut -d] -f1 || exit_error`
-        echo -n "."
-        echo -n $module | grep python | grep -v efl-core > /dev/null 2>&1 && VERSION=`grep version $TMP_DIR/$module/setup.py | cut -d\' -f2 || exit_error`
         echo -n "."
-        echo -n $module | grep efl-core > /dev/null 2>&1 && VERSION=`grep AC_INIT $TMP_DIR/evas/configure.ac | cut -d[ -f3 | cut -d] -f1 || exit_error`
+        if [ -z $VERSION ] || [ $VERSION = "v_ver" ]; then
+            exit_error
+        fi
 
         echo -n "."
-        dch --force-distribution -b -c $TMP_DIR/$module/debian/changelog -v $VERSION+svn$E_SVN_REV-$MAEMO_REV -D $MAEMO_REPO "SVN snapshot release $E_SVN_REV" > /dev/null 2>&1 || exit_error
+        dch --force-distribution -b -c $TMP_DIR/$module/debian/changelog -v $VERSION.$E_SVN_REV-$MAEMO_REV -D $MAEMO_REPO "SVN snapshot release $E_SVN_REV" >> $OUTPUT_FILE 2>&1 || exit_error
         echo " `head -n1 $TMP_DIR/$module/debian/changelog`"
     done
 }
 
-gen_versions(){
+function gen_versions(){
     if [ ! -d $VERSIONS_DIR ]; then
         echo -n "Creating versions dir $VERSIONS_DIR ..."
         mkdir -p $VERSIONS_DIR || exit_error
@@ -80,7 +151,7 @@ gen_versions(){
     fi
 
     echo "Generating version files ..."
-    for module in $ALL_MODULES;do
+    for module in ${ALL_MODULES[@]};do
         VERSION=`dpkg-parsechangelog -l$TMP_DIR/$module/debian/changelog | grep Version: | cut -d" " -f2 || exit_error`
         echo " $module ... $VERSION"
         echo "$VERSION" > $VERSIONS_DIR/"$module"_version
@@ -89,7 +160,7 @@ gen_versions(){
 
 gen_control(){
     echo "Generating control files ..."
-    for module in $ALL_MODULES; do
+    for module in ${ALL_MODULES[@]}; do
         echo -n "      $module ..."
         if [ -e $TMP_DIR/$module/debian/control.in ]; then
             TO_REPLACE=`grep -o -E '@([A-Z]|[0-9])+((-|_)*([A-Z]|[0-9]))*_VERSION@' $TMP_DIR/$module/debian/control.in | cut -d @ -f 2 | sort -u`
@@ -115,13 +186,13 @@ gen_control(){
 
 gen_src_packages(){
     echo "Generating source packages ..."
-    for module in $ALL_MODULES; do
+    for module in ${ALL_MODULES[@]}; do
         echo -n "      $module ."
         cd $TMP_DIR/$module || exit_error
         echo -n "."
-        dpkg-buildpackage -rfakeroot -us -uc -D -sa -S -I.git -I.gitignore -I.svn -I.svnignore -ICVS -I.cvsignore > /dev/null 2>&1|| exit_error
+        dpkg-buildpackage -rfakeroot -us -uc -sa -d -S -I.git -I.gitignore -I.svn -I.svnignore -ICVS -I.cvsignore >> $OUTPUT_FILE 2>&1|| exit_error
         echo -n "."
-        cd - > /dev/null 2>&1 || exit_error
+        cd - >> $OUTPUT_FILE 2>&1 || exit_error
         echo " OK"
     done
 }