source: MondoRescue/branches/2.0.9/tools/build2pkg@ 779

Last change on this file since 779 was 779, checked in by Bruno Cornec, 18 years ago

Build process updated from stable.

  • Property svn:executable set to *
File size: 3.0 KB
RevLine 
[553]1#!/bin/bash
2#
3# Creates packages from build repository
4#
5# $Id$
6#
7# Syntax: build2pkg [version-tag [pkg list]]
8#
9
[758]10(
[553]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=""
[572]50echo "Working under $TOPBUILDDIR"
[553]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`
[754]57 PVER=`echo $pv | sed "s|^$p-||" | cut -d- -f1`
[553]58
59 if [ _"$dtype" = _"rpm" ]; then
[556]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"
[553]66 #rm -f $pkg1
67
68 pkg="$pkg $pkg1"
69
[659]70 log=$TMP/$p-rpm.log
[553]71
[733]72 if [ "$dfam" = "mandriva" ] || [ "$dfam" = "suse" ]; then
[779]73 echo "Using bzip2 files ($dfam)"
74 ln -sf $pv.tar.bz2 SOURCES/
[553]75 else
[779]76 echo "Using gzip files ($dfam)"
[553]77 ln -sf $src SOURCES/
78 fi
[568]79 echo "Generating $p RPMS"
[553]80 cd SPECS
[754]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}
[553]84
[762]85 rpmbuild -ba $p.spec 2>&1 | tee $log
[553]86 if [ $? != 0 ]; then
87 status=-1
[690]88 else
[733]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
[553]94 fi
[596]95 rm -rf ${TOPBUILDDIR}/BUILD/*
[553]96 cd ..
[572]97 elif [ _"$dtype" = _"ebuild" ]; then
[756]98 tar xfz $src $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild
[572]99 if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
100 echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
101 echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
102 fi
[556]103
[572]104 mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
[754]105 mv $p-${PVER}/distributions/${ddir}-$dver/$p-${PVER}.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p/$p-${PVER}.ebuild
106 rm -rf $p-${PVER}
[572]107
108 cd ${TOPBUILDDIR}/portage/sys-apps/$p
[779]109 ebuild $p-${PVER}.ebuild digest
[556]110 if [ $? != 0 ]; then
111 status=-1
112 fi
[779]113 ebuild $p-${PVER}.ebuild package
[572]114 if [ $? != 0 ]; then
115 status=-1
116 fi
[574]117 elif [ _"$dtype" = _"deb" ]; then
[721]118 export TMPDIR=/tmp
[574]119 cd $TOPBUILDDIR
120 tar xfz $src
[754]121 cd ${p}-${PVER}
[659]122 # point to the right debian conf
123 ln -s distributions/${ddir}-$dver debian
124 dpkg-buildpackage -us -uc -rfakeroot
[574]125 # Et voila !
[556]126 else
127 echo "Unknown"
[553]128 fi
129done
[556]130echo "Packages handled : $pkg"
[553]131
[659]132rm -rf $TMP
133
[553]134if [ $status = 0 ]; then
135 if [ _"$dtype" = _"rpm" ]; then
[556]136 echo "Installing RPMS as root"
[553]137 su - -c "$opt rpm -Uvh --force $pkg"
138 fi
139fi
[758]140) 2>&1 | tee /tmp/build2pkg.log
Note: See TracBrowser for help on using the repository browser.