source: devel/pb/t/pbtest @ 1581

Last change on this file since 1581 was 1581, checked in by bruno, 7 years ago

Adding pbcl for afio

  • Property svn:executable set to *
File size: 9.4 KB
Line 
1#!/bin/bash
2#
3# Project Builder test suite
4#
5# $Id$
6#
7# Copyright B. Cornec 2007-2012
8# Provided under the GPL v2
9
10# First create a dummy account for testing
11# In order for this script to run well, you hould have sudo access
12
13# You may have multiple distros here
14TESTVEDIST="fedora-16-x86_64 mageia-1-i386 debian-6.0-x86_64 ubuntu-11.04-i386"
15# Only one VM is tested for now.
16TESTVMDIST="fedora-16-i386"
17TESTVMISO="/users/bruno/iso/Fedora-16-i386-DVD.iso"
18
19# Sub finction to handle execution as pbtest
20sudopbtest() {
21
22cmd=$1
23
24echo "INFO pbtest: Now running $cmd"
25sudo su - pbtest -c "$cmd"
26}
27
28
29sudo rm -rf ~pbtest/* ~pbtest/.??*
30sudo userdel pbtest
31sudo groupdel pbtest
32sudo useradd pbtest
33sudo grep -q pbtest /etc/sudoers
34if [ $? -ne 0 ]; then
35    cat > /tmp/sudoers << EOF
36pbtest localhost=NOPASSWD:/usr/sbin/chroot
37pbtest localhost=NOPASSWD:/bin/cp
38EOF
39    sudo cat /etc/sudoers /tmp/sudoers > /tmp/sudoers2
40    sudo chmod 440 /tmp/sudoers2
41    sudo chown root:root /tmp/sudoers2
42    sudo mv /tmp/sudoers2 /etc/sudoers
43    rm -f /tmp/sudoers /tmp/sudoers2
44fi
45# Force pbtest account
46sudo perl -pi -e 's|^pbtest:.*|pbtest:$2a$08$2Q.tEty4v/fU0RyPeDelk.AjLAtXUXU3DpSs/l/8YrFmau1LJRCqC:15483:0:99999:7:::|' /etc/shadow
47PBTEST="`echo ~pbtest`"
48
49#Taken from Lab document originally
50# SVN repo setup
51sudopbtest "svnadmin create $PBTEST/svn"
52cat > /tmp/authz << EOF
53[/]
54pbtest = rw
55* = r
56EOF
57sudo mv /tmp/authz ~pbtest/svn/conf/authz
58cat > /tmp/passwd << EOF
59[users]
60pbtest = pbtest
61EOF
62sudo mv /tmp/passwd ~pbtest/svn/conf/passwd
63cat > /tmp/svnserve.conf << EOF
64[general]
65password-db = $PBTEST/svn/conf/passwd
66authz-db = authz
67anon-access = read
68auth-access = write
69realm = pb
70EOF
71sudo mv /tmp/svnserve.conf ~pbtest/svn/conf/svnserve.conf
72sudo chown pbtest:pbtest ~pbtest/svn/conf/authz ~pbtest/svn/conf/passwd ~pbtest/svn/conf/svnserve.conf
73sudopbtest "killall svnserve ; svnserve -d -r ~pbtest/svn"
74sudopbtest "mkdir pb ftp ve .ssh; chmod 700 .ssh"
75
76sudopbtest "pb --version"
77sudopbtest "pbdistrocheck"
78sudopbtest "pb clean"
79sudopbtest "pb -p afio getconf"
80
81cat > /tmp/.pbrc << EOF
82# Projects
83pbconfurl afio = svn://localhost/pb/afio/pbconf
84pbdefdir default = \$ENV{'HOME'}/pb
85pbconfurl projtest = dir://\$ENV{'HOME'}/projtest
86pbconfdir projtest = \$ENV{'HOME'}/projtest/pbconf
87pburl projtest = svn+ssh://svn.project-builder.org/svn/pb
88pbconfurl pb = svn://svn.project-builder.org/pb/pbconf
89pbconfdir pb = \$ENV{'HOME'}/pb/pbconf
90pburl pb = svn://svn.project-builder.org/pb
91pburl mondorescue = svn://svn.mondorescue.org/mondorescue/branches
92#
93pbpackager default = Big Chief <bigchief@hp.com>
94vmport pb = 2200
95pbparallel pb = 6
96vepath default = \$ENV{'HOME'}/ve
97vmtype default = kvm
98vmcmd default = qemu-kvm
99vmpath default = \$ENV{'HOME'}/tmp
100vmsize fedora = 10G
101vmmonport default = 4000
102EOF
103sudo mv /tmp/.pbrc ~pbtest/.pbrc
104
105cat > /tmp/.pbrc << EOF
106vetype default = chroot
107verpmtype default = rpmbootstrap
108vedebtype default = debootstrap
109verebuild default = false
110veopt default =
111vesnap default = false
112velogin default = pbtest
113EOF
114echo "velist default = `echo $TESTVEDIST | sed 's/ */,/g'`" >> /tmp/.pbrc
115sudo mv /tmp/.pbrc ~pbtest/ve/.pbrc
116sudo chown pbtest:pbtest ~pbtest/.pbrc ~pbtest/ve/.pbrc
117
118sudopbtest "ssh-keygen -f .ssh/id_rsa -t rsa -b 768 -v -N ''"
119sudopbtest "cp .ssh/id_rsa.pub .ssh/authorized_keys ; chmod 600 .ssh/authorized_keys ; chmod 600 .ssh/id_rsa.pub"
120sudopbtest "ssh localhost touch ftp/README"
121
122# Create SVN conf files - doesn't work fully as it asks for a password - solved with PBVCSOPT
123sudopbtest "svn info"
124cat > /tmp/servers << EOF
125[global]
126store-passwords = yes
127store-plaintext-passwords = yes
128store-auth-creds = yes
129EOF
130sudo mv /tmp/servers ~pbtest/.subversion/servers
131sudo chown pbtest:pbtest ~pbtest/.subversion/servers
132
133VCSOPT='--username pbtest --password pbtest'
134
135sudopbtest "svn import pb svn://localhost/pb -m 'Initial creation of pb repo' $VCSOPT"
136sudopbtest "cd pb ; svn co svn://localhost/pb ."
137sudopbtest "cd pb ; touch README ; svn add README ; svn ci --username pbtest --password pbtest -m 'add readme' README"
138sudopbtest "export PBVCSOPT=\"$VCSOPT\" ; pb -p afio -r 2.5 newproj afio"
139
140grep -vE '^defpkgdir|^projver|^projtag|^pburl|^pbrepo|^shh' ~pbtest/pb/afio/pbconf/2.5/afio.pb > /tmp/afio.pb
141cat >> /tmp/afio.pb << EOF
142defpkgdir afio = dummy
143projver afio = 2.5
144projtag afio = 1
145pburl afio = ftp://ftp.project-builder.org/src/afio-2.5.tar.gz
146pbrepo afio = ftp://ftp.project-builder.org
147sshhost afio = localhost
148sshlogin afio = pbtest
149sshdir afio = \$ENV{'HOME'}/ftp
150EOF
151sudo mv /tmp/afio.pb ~pbtest/pb/afio/pbconf/2.5/afio.pb
152sudo perl -pi -e 's|testver afio = true|testver afio = false|' ~pbtest/pb/afio/pbconf/2.5/afio.pb
153sudo chown pbtest:pbtest ~pbtest/pb/afio/pbconf/2.5/afio.pb
154
155grep -vE 'PBSRC|PBDESC|PBSUMMARY|PBURL|PBLOG' ~pbtest/pb/afio/pbconf/2.5/pbfilter/all.pbf > /tmp/all.pbf
156cat >> /tmp/all.pbf << EOF
157filter PBSRC = src/%{name}-%{version}.tar.gz
158filter PBDESC = afio is a cpio compatible archiver with extended features$/It can compress on a file by file basis.
159filter PBSUMMARY = afio is a cpio compatible archiver with extended features
160filter PBURL = http://www.boutell.com/lsm/lsmbyid.cgi/000462
161filter PBLOG = no
162EOF
163sudo mv /tmp/all.pbf ~pbtest/pb/afio/pbconf/2.5/pbfilter/all.pbf
164sudo chown pbtest:pbtest ~pbtest/pb/afio/pbconf/2.5/pbfilter/all.pbf
165
166grep -vE 'PBGRP|PBLIC' ~pbtest/pb/afio/pbconf/2.5/pbfilter/rpm.pbf > /tmp/rpm.pbf
167cat >> /tmp/rpm.pbf << EOF
168filter PBGRP = Applications/Archiving
169filter PBLIC = Afio
170EOF
171sudo mv /tmp/rpm.pbf ~pbtest/pb/afio/pbconf/2.5/pbfilter/rpm.pbf
172sudo chown pbtest:pbtest ~pbtest/pb/afio/pbconf/2.5/pbfilter/rpm.pbf
173
174# First build
175sudopbtest "pb -p afio -r 2.5 sbx2build"
176
177sudo perl -pi -e 's|%configure||' ~pbtest/pb/afio/pbconf/2.5/afio/rpm/afio.spec
178sudo perl -pi -e 's|make %{?_smp_mflags}|make %{?_smp_mflags}\nchmod 644 script*/*|' ~pbtest/pb/afio/pbconf/2.5/afio/rpm/afio.spec
179sudo perl -pi -e 's|make DESTDIR=$RPM_BUILD_ROOT install|kdir -p $RPM_BUILD_ROOT%{_bindir}\nmkdir -p $RPM_BUILD_ROOT%{_mandir}/man1\ninstall -p -m 755 afio $RPM_BUILD_ROOT%{_bindir}\ninstall -p -m 644 afio.1 $RPM_BUILD_ROOT%{_mandir}/man1|' ~pbtest/pb/afio/pbconf/2.5/afio/rpm/afio.spec
180sudo perl -pi -e 's|%doc ChangeLog|%doc HISTORY PORTING README SCRIPTS ANNOUNCE-2.5 perl.artistic.license|' ~pbtest/pb/afio/pbconf/2.5/afio/rpm/afio.spec
181sudo perl -pi -e 's|%doc INSTALL COPYING README AUTHORS NEWS|%doc afio.lsm script1 script2 script3 script4\n%{_bindir}/%{name}\n%{_mandir}/man1/%{name}.1*|' ~pbtest/pb/afio/pbconf/2.5/afio/rpm/afio.spec
182sudopbtest "pb -p afio sbx2pkg"
183rpm -qilvp ~pbtest/pb/afio/build/RPMS/x86_64/afio-2.5*
184
185cat > /tmp/pbcl << EOF
186# $Id$
187
188AFIO CHANGES
189
1902.5 (2009-12-03)
191- First packages created
192EOF
193sudo mv /tmp/pbcl ~pbtest/pb/afio/pbconf/2.5/afio/pbcl
194sudo chown pbtest:pbtest ~pbtest/pb/afio/pbconf/2.5/afio/pbcl
195svn add ~pbtest/pb/afio/pbconf/2.5/afio/pbcl
196svn ci -m 'Adding pbcl for afio' $VCSOPT
197
198sudo perl -pi -e 's|,\s*PBDEP||' ~pbtest/pb/afio/pbconf/2.5/afio/deb/control
199sudo perl -pi -e 's|Recommends: PBREC||' ~pbtest/pb/afio/pbconf/2.5/afio/deb/control
200sudo perl -pi -e 's|Suggests: PBSUG||' ~pbtest/pb/afio/pbconf/2.5/afio/deb/control
201cat > /tmp/afio.docs << EOF
202HISTORY
203PORTING
204README
205SCRIPTS
206ANNOUNCE-2.5
207perl.artistic.license
208afio.lsm
209script1
210script2
211script3
212script4
213EOF
214sudo mv /tmp/afio.docs ~pbtest/pb/afio/pbconf/2.5/afio/deb/afio.docs
215sudo chown pbtest:pbtest ~pbtest/pb/afio/pbconf/2.5/afio/deb/afio.docs
216
217sudo perl -pi -e 's|config.status: configure|config.status: Makefile|' ~pbtest/pb/afio/pbconf/2.5/afio/deb/rules
218sudo perl -pi -e 's|dh_installchangelogs ChangeLog|dh_installchangelogs debian/changelog|' ~pbtest/pb/afio/pbconf/2.5/afio/deb/rules
219sudo perl -pi -e 's|$(MAKE) install|mkdir -p $(CURDIR)/debian/$(PACKAGE_NAME)/usr/bin $(CURDIR)/debian/$(PACKAGE_NAME)/usr/share/man/man1|' ~pbtest/pb/afio/pbconf/2.5/afio/deb/rules
220sudo perl -pi -e 's|# - copy html manual to temporary location for renaming|install -p -m 755 afio $(CURDIR)/debian/$(PACKAGE_NAME)/usr/bin ; nstall -p -m 644 afio.1 $(CURDIR)/debian/$(PACKAGE_NAME)/usr/share/man/man1|' ~pbtest/pb/afio/pbconf/2.5/afio/deb/rules
221sudo sed -i -e '/\.\/configure /d' ~pbtest/pb/afio/pbconf/2.5/afio/deb/rules
222
223#dpkg -I ~ftp/pub/afio/test/debian/5.0/afio_2.5-0.20091204131057_i386.deb
224#dpkg -x ~ftp/pub/afio/test/debian/5.0/afio_2.5-0.20091204131057_i386.deb /tmp/x ;  ls -lR /tmp/x
225
226for d in $TESTVEDIST; do
227    sudopbtest "pb -p pb -m $d newve"
228    sudopbtest "pb -p pb -m $d sbx2setupve"
229    sudopbtest "pb -p pb -m $d snapve"
230    sudopbtest "pb -p afio -m $d sbx2ve"
231    # Cleaning VE to use the snapshot
232    dd=`echo $d | cut -d'-' -f1`
233    sudo rm -rf ~pbtest/tmp/$dd
234    sudopbtest "pb -p afio -S -m $d sbx2ve"
235done
236
237sudopbtest "pb -p afio -r 2.5 -V 2.6 newver"
238sudopbtest "pb -p afio clean"
239
240# test also with pb
241sudopbtest "pb -p pb -r devel sbx2pkg"
242sudopbtest "pb -p pb build2ssh"
243sudopbtest "pb -p pb pkg2ssh"
244
245
246#qemu-kvm \
247#-m 1024 \
248#-kernel /pub/mageia/distrib/cauldron/i586/isolinux/alt0/vmlinuz \
249#-initrd /pub/mageia/distrib/cauldron/i586/isolinux/alt0/all.rdz \
250#-append "ramdisk_size=128000 root=/dev/ram3 kickstart=http://192.168.8.55/pub/ks/guerrero/ks.pl automatic=method:http,server:192.168.8.55,directory:/pub/mageia/distrib/cauldron/i586,network:dhcp" \
251#-drive file=/users/qemu/mageia-2-i386.qemu,if=virtio,media=disk \
252#-redir tcp:2200:10.0.2.15:22
253#sudopbtest "pb -p projtest -m $TESTVMDIST -i $TESTVMISO newvm"
254#sudopbtest "pb -p projtest -m $TESTVMDIST sbx2setupvm"
255#sudopbtest "pb -p projtest -m $TESTVMDIST sbx2vm"
256
257# test also with MOndoRescue
258pb -p mondorescue -r branches/3.0 cms2pkg
259
260# cleanup
261sudopbtest "killall svnserve"
262
Note: See TracBrowser for help on using the repository browser.