source: branches/2.0.9/tools/build2pkg @ 756

Last change on this file since 756 was 756, checked in by Bruno Cornec, 14 years ago

merge -r754:755 $SVN_M/branches/stable

  • Property svn:executable set to *
File size: 3.1 KB
Line 
1#!/bin/bash
2#
3# Creates packages from build repository
4#
5# $Id$
6#
7# Syntax: build2pkg [version-tag [pkg list]]
8#
9
10exec > /tmp/build2pkg.log 2>&1
11
12dname=`dirname $0`
13prem=`echo $dname |cut -c1`
14if [ ${prem} == "/" ]; then
15    export TOOLHOME=$dname
16else
17    export TOOLHOME=${PWD}/$dname
18fi
19
20. $TOOLHOME/common-env
21. $TOOLHOME/distro-env
22
23# We need to get $VER and $TAG
24if [ "$1" = "" ]; then
25    LAST=`cat ${TOPDIR}/LAST`
26else
27    LAST=$1
28    shift
29fi
30VER=`echo $LAST | cut -d- -f1`
31TAG=`echo $LAST | cut -d- -f2`
32echo "Working on ${VER}-$TAG"
33   
34if [ "$1" = "" ]; then
35    c="mondo-doc mindi mondo"
36else
37    if [ "$1" = "all" ]; then
38        c="mindi-kernel mondo-doc mindi mondo"
39    else
40        c=$1
41    fi
42fi
43
44status=0
45
46#
47# Define on which distro we are to generate the right packages
48#
49
50export pkg=""
51echo "Working under $TOPBUILDDIR"
52cd $TOPBUILDDIR
53
54for p in $c; do
55    # s= stable; t = trunk; 1-9 = official version
56    src=${TOPDIR}/${VER}-$TAG/$p-[1-9st]*.tar.gz
57    pv=`basename $src .tar.gz`
58    PVER=`echo $pv | sed "s|^$p-||" | cut -d- -f1`
59
60    if [  _"$dtype" = _"rpm" ]; then
61        if [ _"$p" = _"mondo-doc" ]; then
62            ar="noarch"
63        else
64            ar=$ARCH
65        fi
66        pkg1="${TOPBUILDDIR}/RPMS/${ar}/$pv${suf}.${ar}.rpm"
67        #rm -f $pkg1
68
69        pkg="$pkg $pkg1"
70
71        log=$TMP/$p-rpm.log
72
73        if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
74            echo "Generating bzip2 files ($dfam)"
75            gzip -cd $src | bzip2 -c3 > SOURCES/$pv.tar.bz2
76        else
77            ln -sf $src SOURCES/
78        fi
79        echo "Generating $p RPMS"
80        cd SPECS
81        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p.spec
82        mv $p-${PVER}/distributions/${ddir}-$dver/$p.spec .
83        rm -rf $p-${PVER}
84
85        rpmbuild -ba $p.spec 2> $log 1> $log
86        if [ $? != 0 ]; then 
87            cat $log
88            status=-1
89        else
90            egrep '^Wrote:' $log
91            if [ -f /usr/bin/rpmlint ]; then
92                /usr/bin/rpmlint `egrep '^Wrote:' $log | cut -d: -f2`
93            else
94                echo "No rpmlint found, please install it"
95            fi
96        fi
97        rm -rf ${TOPBUILDDIR}/BUILD/*
98        cd ..
99    elif [  _"$dtype" = _"ebuild" ]; then
100        log=$TMP/$p-gentoo.log
101        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
102        if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
103            echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
104            echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
105        fi
106
107        mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
108        mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
109        rm -rf $p-${PVER}
110
111        cd ${TOPBUILDDIR}/portage/sys-apps/$p
112        ebuild $p-${PVER}.ebuild digest 2> $log 1> $log
113        if [ $? != 0 ]; then 
114            cat $log
115            status=-1
116        fi
117        ebuild $p-${PVER}.ebuild install 2>> $log 1>> $log
118        if [ $? != 0 ]; then 
119            cat $log
120            status=-1
121        fi
122    elif [  _"$dtype" = _"deb" ]; then
123        log=$TMP/$p-deb.log
124        export TMPDIR=/tmp
125        cd $TOPBUILDDIR
126        tar xfz $src
127        cd ${p}-${PVER}
128        # point to the right debian conf
129        ln -s distributions/${ddir}-$dver debian
130        dpkg-buildpackage -us -uc -rfakeroot
131        # Et voila !
132    else
133        echo "Unknown"
134    fi
135done
136echo "Packages handled : $pkg"
137
138rm -rf $TMP
139
140if [ $status = 0 ]; then
141    if [  _"$dtype" = _"rpm" ]; then
142        echo "Installing RPMS as root"
143        su - -c "$opt rpm -Uvh --force $pkg"
144    fi
145fi
Note: See TracBrowser for help on using the repository browser.