source: trunk/tools/build2pkg @ 923

Last change on this file since 923 was 923, checked in by Bruno Cornec, 13 years ago
  • Now using mindi.conf.dist as an initial set of values
  • usr.bin useless in restore-scripts
  • fixes on build process to allow mondo compilation
  • Property svn:executable set to *
File size: 3.0 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 mindi-busybox mondo"
35else
36    if [ "$1" = "all" ]; then
37        c="mindi-kernel mondo-doc mindi mindi-busybox 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
66        log=$MONDOTMP/$p-rpm.log
67
68        if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
69            echo "Using bzip2 files ($dfam)"
70            ln -sf ${TOPDIR}/${VER}-$TAG/$pv.tar.bz2 SOURCES/
71        else
72            echo "Using gzip files ($dfam)"
73            ln -sf $src SOURCES/
74        fi
75        echo "Generating $p RPMS"
76        cd SPECS
77        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p.spec
78        mv $p-${PVER}/distributions/${ddir}-$dver/$p.spec .
79        rm -rf $p-${PVER}
80
81        export LANGUAGE=C
82        rpmbuild -ba $p.spec 2>&1 | tee $log
83        if [ $? != 0 ]; then 
84            status=-1
85        else
86            export pkg1="`egrep '^Wrote:' $log | grep -v debug | cut -d: -f2`"
87            if [ -f /usr/bin/rpmlint ]; then
88                /usr/bin/rpmlint $pkg1
89            else
90                echo "No rpmlint found, please install it"
91            fi
92            export pkg="$pkg `ls $pkg1 | grep -v src.rpm`"
93        fi
94        rm -rf ${TOPBUILDDIR}/BUILD/*
95        cd ..
96    elif [  _"$dtype" = _"ebuild" ]; then
97        tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
98        if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
99            echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
100            echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
101        fi
102
103        mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
104        mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
105        rm -rf $p-${PVER}
106
107        cd ${TOPBUILDDIR}/portage/sys-apps/$p
108        ebuild $p-${PVER}.ebuild digest
109        if [ $? != 0 ]; then 
110            status=-1
111        fi
112        ebuild $p-${PVER}.ebuild package
113        if [ $? != 0 ]; then 
114            status=-1
115        fi
116    elif [  _"$dtype" = _"deb" ]; then
117        cd $TOPBUILDDIR
118        tar xfz $src
119        cd ${p}-${PVER}
120        # point to the right debian conf
121        ln -s distributions/${ddir}-$dver debian
122        dpkg-buildpackage -us -uc -rfakeroot
123        # Et voila !
124    else
125        echo "Unknown"
126    fi
127done
128echo "Packages handled : $pkg"
129
130rm -rf $MONDOTMP
131
132if [ $status = 0 ]; then
133    if [  _"$dtype" = _"rpm" ]; then
134        echo "Installing RPMS as root"
135        su - -c "$opt rpm -Uvh --force $pkg"
136    fi
137fi
138) 2>&1 | tee /tmp/build2pkg.log
Note: See TracBrowser for help on using the repository browser.