Show
Ignore:
Timestamp:
09/15/06 18:45:08 (2 years ago)
Author:
piotras
Message:

Updated to build debian packages from unpacked upstream tarballs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/makedebs

    r7488 r10083  
    22# 
    33# Make Debian packages for Midgard  
    4 # Copyright (C) 2004 Piotr Pokora <piotr.pokora@infoglob.pl> 
     4# Copyright (C) 2006 Piotr Pokora <piotrek.pokora@gmail.com> 
     5#  
     6# This script is not intented to build cvs , testing or any other  
     7# similiar packages. It should be used only for already generated 
     8# debian files. 
    59 
    6 set -x 
     10#set -x 
    711 
    8 WTD=$1 
     12if [ $# -eq 0 ]; then 
     13        echo  
     14        echo "Usage: makedebs [directory with ungzipped tarballs] [debs directory]" 
     15        echo 
     16        exit 
     17fi 
    918 
    10 if [ "$WTD" == "release" ]; then 
     19if [ ! -x "/usr/bin/dpkg-buildpackage" ];then 
     20        echo 
     21        echo "Please install dpkg-dev before making packages" 
     22        echo 
     23fi 
    1124 
    12 RDIR=$2 
    13 cd $RDIR 
     25ALLINONE=$1 
     26DEBS_DIR=$2 
     27 
     28if [ ! -d $ALLINONE ]; then 
     29        exit 
     30fi 
     31 
     32cd $ALLINONE 
     33 
    1434DPKGS="midgard-core midgard-apache1 midgard-apache2 midgard-php4 midgard-data" 
    1535 
     36 
     37#TODO , get debian files automagiacally when we move them out from upstream files 
    1638for DEBS in $DPKGS; do 
    17   cd ${DEBS}* 
    18   dpkg-buildpackage 
    19   cd ../ 
     39        cd $DEBS* 
     40        dpkg-buildpackage -rfakeroot 
     41        if [ $DEBS = "midgard-core" ]; then 
     42                sudo dpkg -i ../*.deb 
     43        fi 
     44        cd -     
    2045done   
    2146 
    22 else 
    23  
    24 export CVSROOT=':pserver:anoncvs@cvs.tigris.org:/cvs' 
    25 export DEBEMAIL="pp@infoglob.pl" 
    26 export DEBFULLNAME="Piotr Pokora" 
    27  
    28 PWD=`pwd` 
    29  
    30 MGD_CVS=0 
    31  
    32 if [ $1 ] && [ "$1" == "cvs" ];then 
    33   MGD_CVS_VERSION=`./midgard-cvs-version` 
    34   MGD_CVS_VERSION=`echo $MGD_CVS_VERSION | sed 's/^.*cvs-//1'` 
    35   if [ ! -f "$PWD/last_cvs_version" ];then 
    36     echo "$MGD_CVS_VERSION" > "$PWD/last_cvs_version" 
    37   fi 
    38     LAST_CVS_VERSION="`cat ./last_cvs_version`" 
    39     LAST_CVS_VERSION=`echo $LAST_CVS_VERSION | sed 's/^.*cvs-//1'` 
    40   if [ $MGD_CVS_VERSION -gt $LAST_CVS_VERSION ];then 
    41     MGD_CVS=1 
    42     MID_VER="`cat ./last_cvs_version`" 
    43   else 
    44     exit 1 
    45   fi   
     47if [ ! -d "$DEBS_DIR" ]; then 
     48        mkdir "$DEBS_DIR" 
    4649fi 
    4750 
     51if [ ! -d "$DEBS_DIR/debs" ]; then  
     52        mkdir -p "$DEBS_DIR/debs" 
     53fi 
    4854 
    49 # uncomment for CVS snapshots 
    50 #cvs -z3 update midgard-cvs-version bootstrap core/midgard httpd/apache1 httpd/apache2 apis/php4 tools/datagard  
     55if [ ! -d "$DEBS_DIR/src" ]; then  
     56        mkdir -p "$DEBS_DIR/src" 
     57fi 
    5158 
    52 if [ ! -x "/usr/bin/dpkg-buildpackage" ];then 
    53  echo 
    54  echo "Please install dpkg-dev before making packages" 
    55  echo  
    56 fi  
     59mv *.deb ${DEBS_DIR}/debs/ 
     60mv *.dsc ${DEBS_DIR}/src/ 
     61mv *.tar.gz ${DEBS_DIR}/src/ 
     62mv *.changes ${DEBS_DIR}/src/ 
    5763 
    58 move_debs() 
    59 
    60   DEST_DIR="$1" 
    61   mv ../*.deb $DEST_DIR/debs/ 
    62   mv ../*.changes $DEST_DIR/debs/ 
    63 
     64# Create Packages.gz 
     65cd ${DEBS_DIR}/debs/ 
     66if [ -f "Packages.gz" ];then 
     67        rm Packages.gz 
     68fi 
     69dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz 
    6470 
    65 update_changelog() 
    66 
    67   if [ $MGD_CVS -eq 1 ];then 
    68     dch --preserve --check-dirname-level 0 -v $MID_VER 'CVS Snapshot' 
    69   fi   
    70 
     71# Create Sources.gz 
     72cd ../src 
     73if [ -f "Sources.gz" ];then 
     74        rm Sources.gz 
     75fi 
     76dpkg-scansources . /dev/null | gzip -9c > Sources.gz 
    7177 
    72 make_debs() 
    73 { 
    74   if [ $1 ] && [ "$1" == "release" ];then 
    75     chmod +x debian/rules 
    76     dpkg-buildpackage 
    77     if [ $? -ne 0 ];then 
    78       echo 
    79       echo "Can not build package!. Quiting" 
    80       echo 
    81       exit 1 
    82     fi                   
    83   else 
    84     chmod +x debian/rules 
    85     dpkg-buildpackage -b 
    86     if [ $? -ne 0 ];then 
    87       echo 
    88       echo "Can not build package!. Quiting" 
    89       echo 
    90       exit 1 
    91     fi                                
    92   fi   
    93 } 
    94  
    95  
    96  
    97 ./bootstrap 
    98  
    99 if [ ! -d "debs" ];then 
    100   mkdir debs 
    101 fi 
    102 rm debs/* 
    103  
    104 #make libmidgard, libmidgard-dev and repligard 
    105  
    106   cd ./core/midgard 
    107   update_changelog   
    108   make_debs $1 
    109   if [ $? -ne 0 ];then 
    110     echo 
    111     echo "Can not build libmidgard. Quiting" 
    112     echo 
    113     exit 1 
    114   fi 
    115   dpkg -i ../libmidgard-dev*.deb 
    116   move_debs "../../" 
    117   cd ../../ 
    118  
    119  
    120 #make libapache-mod-midgard 
    121  
    122   cd ./httpd/apache1 
    123   update_changelog 
    124   make_debs $1 
    125    
    126   if [ $? -ne 0 ];then 
    127     echo  
    128     echo "Can not build libapache-mod-midgard. Quiting" 
    129     echo 
    130     exit 1 
    131   fi 
    132  
    133   move_debs "../../"   
    134   cd ../../ 
    135  
    136 #make libapache2-mod-midgard 
    137  
    138   cd ./httpd/apache2 
    139   update_changelog 
    140   make_debs $1 
    141    
    142   if [ $? -ne 0 ];then 
    143     echo 
    144     echo "Can not build libapache2-mod-midgard. Quiting" 
    145     echo 
    146     exit 1 
    147   fi 
    148    
    149   move_debs "../../"   
    150   cd ../../                     
    151  
    152 #make php4-midgard 
    153  
    154   cd ./apis/php4 
    155   update_changelog 
    156   make_debs $1 
    157  
    158   cp debian/rules debian/rules.apache1 
    159   cp debian/control debian/control.apache1 
    160   cp debian/changelog  debian/changelog.apache1 
    161  
    162   cp debian/rules.apache2 debian/rules 
    163   cp debian/control.apache2 debian/control 
    164   cp debian/changelog.apache2 debian/changelog 
    165    
    166   update_changelog 
    167   make_debs $1 
    168    
    169   mv debian/rules.apache1 debian/rules 
    170   mv debian/control.apache1 debian/control 
    171   mv debian/changelog.apache2 debian/changelog 
    172  
    173   move_debs "../../" 
    174   cd ../../ 
    175  
    176  
    177 #make midgard-data 
    178  
    179 cd ./tools/datagard 
    180 update_changelog 
    181 dpkg-buildpackage -b 
    182   if [ $? -ne 0 ];then 
    183     echo 
    184     echo "Can not build midgard-data. Quiting" 
    185     echo 
    186     exit 1 
    187 fi 
    188 move_debs "../../" 
    189 cd ../../ 
    190  
    191 # Make Packages.gz 
    192 cd debs 
    193 if [ -f "Packages.gz" ];then 
    194   rm Packages.gz 
    195 fi   
    196 dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz 
    197 cd $PWD 
    198  
    199 echo 
    200 echo "Packages builded and moved to $PWD" 
    201 echo  
    202  
    203 fi