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