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 | |
---|
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/$p.spec |
---|
80 | mv $pv/distributions/$ddir/$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 | fi |
---|
88 | cd .. |
---|
89 | elif [ _"$dtype" = _"ebuild" ]; then |
---|
90 | log=/tmp/$p-gentoo.log |
---|
91 | ln -sf $src . |
---|
92 | tar xfz $src $pv/distributions/$ddir/$p-${VER}-r$TAG.ebuild |
---|
93 | if [ _"`grep $TOPBUILDDIR/portage /etc/make.conf`" = _"" ]; then |
---|
94 | echo "Adding $TOPBUILDDIR/portage to /etc/make.conf" |
---|
95 | echo "PORTDIR_OVERLAY=\"$TOPBUILDDIR/portage\"" >> /etc/make.conf |
---|
96 | fi |
---|
97 | |
---|
98 | mkdir -p ${TOPBUILDDIR}/portage/sys-apps/$p |
---|
99 | mv $pv/distributions/$ddir/$p-${VER}-r$TAG.ebuild ${TOPBUILDDIR}/portage/sys-apps/$p |
---|
100 | rm -rf $pv |
---|
101 | |
---|
102 | cd ${TOPBUILDDIR}/portage/sys-apps/$p |
---|
103 | ebuild $p-${VER}-r$TAG.ebuild digest 2> $log 1> $log |
---|
104 | if [ $? != 0 ]; then |
---|
105 | cat $log |
---|
106 | status=-1 |
---|
107 | fi |
---|
108 | ebuild $p-${VER}-r$TAG.ebuild unpack 2>> $log 1>> $log |
---|
109 | if [ $? != 0 ]; then |
---|
110 | cat $log |
---|
111 | status=-1 |
---|
112 | fi |
---|
113 | ebuild $p-${VER}-r$TAG.ebuild compile 2>> $log 1>> $log |
---|
114 | if [ $? != 0 ]; then |
---|
115 | cat $log |
---|
116 | status=-1 |
---|
117 | fi |
---|
118 | #ebuild $p-${VER}-r$TAG.ebuild install 2>> $log 1>> $log |
---|
119 | if [ $? != 0 ]; then |
---|
120 | cat $log |
---|
121 | status=-1 |
---|
122 | fi |
---|
123 | elif [ _"$dtype" = _"deb" ]; then |
---|
124 | log=/tmp/$p-deb.log |
---|
125 | cd $TOPBUILDDIR |
---|
126 | tar xfz $src |
---|
127 | cd ${pv}* |
---|
128 | ln -s distributions/debian debian |
---|
129 | # update debian/changelog |
---|
130 | pkg-buildpackage -us -uc -rfakeroot |
---|
131 | # Et voila ! |
---|
132 | else |
---|
133 | echo "Unknown" |
---|
134 | fi |
---|
135 | done |
---|
136 | echo "Packages handled : $pkg" |
---|
137 | |
---|
138 | if [ $status = 0 ]; then |
---|
139 | if [ _"$dtype" = _"rpm" ]; then |
---|
140 | echo "Installing RPMS as root" |
---|
141 | su - -c "$opt rpm -Uvh --force $pkg" |
---|
142 | fi |
---|
143 | fi |
---|