source: branches/stable/tools/build2pkg @ 763

Last change on this file since 763 was 763, checked in by bruno, 13 years ago
  • Remove Berlios references where obsolete
  • Improve mindi patch for LVM on Debian
  • bzip2 now created during svn2build, and used later by othe scripts (rationale: done once and used now a lot)
  • Fix a patch for mkannounce
  • 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
10(
11dname=`dirname $0`
12prem=`echo $dname |cut -c1`
13if [ ${prem} == "/" ]; then
14    export TOOLHOME=$dname
15else
16    export TOOLHOME=${PWD}/$dname
17fi
18
19. $TOOLHOME/common-env
20. $TOOLHOME/distro-env
21
22# We need to get $VER and $TAG
23if [ "$1" = "" ]; then
24    LAST=`cat ${TOPDIR}/LAST`
25else
26    LAST=$1
27    shift
28fi
29VER=`echo $LAST | cut -d- -f1`
30TAG=`echo $LAST | cut -d- -f2`
31echo "Working on ${VER}-$TAG"
32   
33if [ "$1" = "" ]; then
34    c="mondo-doc mindi mondo"
35else
36    if [ "$1" = "all" ]; then
37        c="mindi-kernel mondo-doc mindi mondo"
38    else
39        c=$1
40    fi
41fi
42
43status=0
44
45#
46# Define on which distro we are to generate the right packages
47#
48
49export pkg=""
50echo "Working under $TOPBUILDDIR"
51cd $TOPBUILDDIR
52
53for p in $c; do
54    # s= stable; t = trunk; 1-9 = official version
55    src=${TOPDIR}/${VER}-$TAG/$p-[1-9st]*.tar.gz
56    pv=`basename $src .tar.gz`
57    PVER=`echo $pv | sed "s|^$p-||" | cut -d- -f1`
58
59    if [  _"$dtype" = _"rpm" ]; then
60        if [ _"$p" = _"mondo-doc" ]; then
61            ar="noarch"
62        else
63            ar=$ARCH
64        fi
65        pkg1="${TOPBUILDDIR}/RPMS/${ar}/$pv${suf}.${ar}.rpm"
66        #rm -f $pkg1
67
68        pkg="$pkg $pkg1"
69
70        log=$TMP/$p-rpm.log
71
72        if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
73            echo "Using bzip2 files ($dfam)"
74            ln -sf $pv.tar.bz2 SOURCES/
75        else
76            echo "Using gzip files ($dfam)"
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>&1 | tee $log
86        if [ $? != 0 ]; then 
87            status=-1
88        else
89            if [ -f /usr/bin/rpmlint ]; then
90                /usr/bin/rpmlint `egrep '^Wrote:' $log | cut -d: -f2`
91            else
92                echo "No rpmlint found, please install it"
93            fi
94        fi
95        rm -rf ${TOPBUILDDIR}/BUILD/*
96        cd ..
97    elif [  _"$dtype" = _"ebuild" ]; then
98        log=$TMP/$p-gentoo.log
99        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
100        if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
101            echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
102            echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
103        fi
104
105        mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
106        mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
107        rm -rf $p-${PVER}
108
109        cd ${TOPBUILDDIR}/portage/sys-apps/$p
110        ebuild $p-${PVER}.ebuild digest 2> $log 1> $log
111        if [ $? != 0 ]; then 
112            cat $log
113            status=-1
114        fi
115        ebuild $p-${PVER}.ebuild install 2>> $log 1>> $log
116        if [ $? != 0 ]; then 
117            cat $log
118            status=-1
119        fi
120    elif [  _"$dtype" = _"deb" ]; then
121        log=$TMP/$p-deb.log
122        export TMPDIR=/tmp
123        cd $TOPBUILDDIR
124        tar xfz $src
125        cd ${p}-${PVER}
126        # point to the right debian conf
127        ln -s distributions/${ddir}-$dver debian
128        dpkg-buildpackage -us -uc -rfakeroot
129        # Et voila !
130    else
131        echo "Unknown"
132    fi
133done
134echo "Packages handled : $pkg"
135
136rm -rf $TMP
137
138if [ $status = 0 ]; then
139    if [  _"$dtype" = _"rpm" ]; then
140        echo "Installing RPMS as root"
141        su - -c "$opt rpm -Uvh --force $pkg"
142    fi
143fi
144) 2>&1 | tee /tmp/build2pkg.log
Note: See TracBrowser for help on using the repository browser.