source: MondoRescue/branches/stable/tools/build2pkg@ 721

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

TAG removed from source tar ball (was an error)
Debian build working for the first time. Needs probably more work but is encouraging

  • 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
10umask 022
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
58 if [ _"$dtype" = _"rpm" ]; then
59 if [ _"$p" = _"mondo-doc" ]; then
60 ar="noarch"
61 else
62 ar=$ARCH
63 fi
64 pkg1="${TOPBUILDDIR}/RPMS/${ar}/$pv${suf}.${ar}.rpm"
65 #rm -f $pkg1
66
67 pkg="$pkg $pkg1"
68
69 log=$TMP/$p-rpm.log
70
71 if [ "$dfam" = "mandriva" ]; then
72 echo "Generating bzip2 files (mandriva)"
73 gzip -cd $src | bzip2 -c3 > SOURCES/$pv.tar.bz2
74 else
75 ln -sf $src SOURCES/
76 fi
77 echo "Generating $p RPMS"
78 cd SPECS
79 tar xfz $src $pv/distributions/${ddir}-$dver/$p.spec
80 mv $pv/distributions/${ddir}-$dver/$p.spec .
81 rm -rf $pv
82
83 rpmbuild -ba $p.spec 2> $log 1> $log
84 if [ $? != 0 ]; then
85 cat $log
86 status=-1
87 else
88 egrep '^Wrote:' $log
89 rpmlint `egrep '^Wrote:' $log | cut -d: -f2`
90 fi
91 rm -rf ${TOPBUILDDIR}/BUILD/*
92 cd ..
93 elif [ _"$dtype" = _"ebuild" ]; then
94 log=$TMP/$p-gentoo.log
95 ln -sf $src .
96 tar xfz $src $pv/distributions/${ddir}-$dver/$p-${VER}-r$TAG.ebuild
97 if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then
98 echo "Adding $TOPBUILDDIR/portage to /etc/make.conf"
99 echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf
100 fi
101
102 mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p
103 mv $pv/distributions/${ddir}-$dver/$p-${VER}-r$TAG.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p
104 rm -rf $pv
105
106 cd ${TOPBUILDDIR}/portage/sys-apps/$p
107 ebuild $p-${VER}-r$TAG.ebuild digest 2> $log 1> $log
108 if [ $? != 0 ]; then
109 cat $log
110 status=-1
111 fi
112 ebuild $p-${VER}-r$TAG.ebuild unpack 2>> $log 1>> $log
113 if [ $? != 0 ]; then
114 cat $log
115 status=-1
116 fi
117 ebuild $p-${VER}-r$TAG.ebuild compile 2>> $log 1>> $log
118 if [ $? != 0 ]; then
119 cat $log
120 status=-1
121 fi
122 #ebuild $p-${VER}-r$TAG.ebuild install 2>> $log 1>> $log
123 if [ $? != 0 ]; then
124 cat $log
125 status=-1
126 fi
127 elif [ _"$dtype" = _"deb" ]; then
128 log=$TMP/$p-deb.log
129 export TMPDIR=/tmp
130 cd $TOPBUILDDIR
131 tar xfz $src
132 cd ${pv}
133 # point to the right debian conf
134 ln -s distributions/${ddir}-$dver debian
135 dpkg-buildpackage -us -uc -rfakeroot
136 # Et voila !
137 else
138 echo "Unknown"
139 fi
140done
141echo "Packages handled : $pkg"
142
143rm -rf $TMP
144
145if [ $status = 0 ]; then
146 if [ _"$dtype" = _"rpm" ]; then
147 echo "Installing RPMS as root"
148 su - -c "$opt rpm -Uvh --force $pkg"
149 fi
150fi
Note: See TracBrowser for help on using the repository browser.