2 # Build FusionForge packages and create a local repo
4 # Copyright (C) 2011 Roland Mas
5 # Copyright (C) 2011 Olivier Berger - Institut Telecom
6 # Copyright (C) 2014 Inria (Sylvain Beucler)
8 # This file is part of FusionForge. FusionForge is free software;
9 # you can redistribute it and/or modify it under the terms of the
10 # GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the Licence, or (at your option)
14 # FusionForge is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 . $(dirname $0)/common-backports
26 # Debian and Fedora/CentOS/RHEL *package building* are so different
27 # that there's nothing to factour out, so they are in separate functions.
30 export DEBIAN_FRONTEND=noninteractive
32 # Install build dependencies
33 apt-get -y install mini-dinstall dput devscripts fakeroot
34 apt-get -y install build-essential \
35 $(grep Build-Depends /usr/src/fusionforge/src/debian/control.in | sed -e 's/Build-Depends: //' -e 's/(.*)//')
36 if grep -q ^8 /etc/debian_version; then
37 apt-get -y install php5-cli # debian/gen_control.sh
39 apt-get -y install php-cli # debian/gen_control.sh
42 # Populate a local Debian packages repository for APT managed with mini-dinstall
43 #rm -rf /usr/src/debian-repository
44 mkdir -p /usr/src/debian-repository
46 cat >/root/.mini-dinstall.conf <<-EOF
48 archivedir = /usr/src/debian-repository
54 release_signscript = /usr/src/fusionforge/autoinstall/mini-dinstall-sign.sh
57 mail_on_success = false
62 export GNUPGHOME=/usr/src/gnupg
63 if [ ! -e $GNUPGHOME ]; then
64 mkdir -m 700 $GNUPGHOME
65 # Quick 'n Dirty hack to get entropy on VMs
66 # https://bugs.launchpad.net/ubuntu/+source/gnupg/+bug/706011
67 # (don't do this for a public repo!)
68 apt-get install -y rng-tools
69 echo HRNGDEVICE=/dev/urandom >> /etc/default/rng-tools
70 service rng-tools restart
71 gpg --batch --gen-key <<-EOF
76 Name-Real: FusionForge
82 gpg --export FusionForge -a > /usr/src/debian-repository/key.asc
83 apt-key add /usr/src/debian-repository/key.asc
87 # Configure debian package building tools so as to use the local repo
88 if [ ! -f /root/.dput.cf ]; then
89 cat > /root/.dput.cf <<-EOF
92 incoming = /usr/src/debian-repository/mini-dinstall/incoming
95 allow_unsigned_uploads = yes
96 post_upload_command = mini-dinstall -b
97 allowed_distributions = local
101 if [ ! -f /root/.devscripts ]; then
102 cat > /root/.devscripts <<-EOF
103 DEBRELEASE_UPLOADER=dput
104 DEBUILD_DPKG_BUILDPACKAGE_OPTS=-i
108 # Finally, build the FusionForge packages
110 cd $(dirname $0)/../src/
111 cp -a debian/changelog $f
113 version=$(dpkg-parsechangelog | sed -n 's/^Version: \([0-9.]\+\(\~\(rc\|beta\|alpha\)[0-9]\)\?\).*/\1/p')+autobuilt$(date +%Y%m%d%H%M)
114 make dist VERSION=$version
115 mv fusionforge-$version.tar.bz2 ../fusionforge_$version.orig.tar.bz2
118 tar xf fusionforge_$version.orig.tar.bz2
119 cd fusionforge-$version/
120 debian/rules debian/control # re-gen debian/control
121 if gitid=$(git show --format="%h" -s 2> /dev/null) ; then
122 msg="Autobuilt from Git revid $gitid."
126 dch --newversion $version-1 --distribution local --force-distribution "$msg"
127 debuild -us -uc -tc # using -tc so 'git status' is readable
128 # Install built packages into the local repo
132 mv $f src/debian/changelog
134 # Declare the repo so that packages become installable
135 echo 'deb file:///usr/src/debian-repository local/' > /etc/apt/sources.list.d/local.list
141 # Install build dependencies
143 yum install -y make gettext tar bzip2 rpm-build createrepo
144 yum install -y php-cli # rpm/gen_spec.sh
147 cd /usr/src/fusionforge/src/
148 base_version=$(make version)
149 snapshot=$(date +%Y%m%d%H%M)
150 version=$base_version+$snapshot
151 rpm/gen_spec.sh $base_version $snapshot
152 make dist VERSION=$version
153 mkdir -p ../build/SOURCES/ ../build/SPECS/
154 mv fusionforge-$version.tar.bz2 ../build/SOURCES/fusionforge-$version.tar.bz2
155 chown -h root: ../build/SOURCES/fusionforge-$version.tar.bz2
156 cp fusionforge.spec ../build/SPECS/
157 rpmbuild ../build/SPECS/fusionforge.spec --define "_topdir $(pwd)/../build" -ba
159 (cd ../build/RPMS/ && createrepo .)
160 cat <<-EOF > /etc/yum.repos.d/local.repo
163 baseurl=file:///usr/src/fusionforge/build/RPMS/
169 function build_suse_rpm {
172 suse_install_rpms make gettext-runtime gettext-tools tar bzip2 rpm-build createrepo php5
175 cd $(dirname $0)/../src/
176 base_version=$(make version)
177 snapshot=$(date +%Y%m%d%H%M)
178 version=$base_version+$snapshot
179 rpm/gen_spec.sh $base_version $snapshot
180 make dist VERSION=$version
181 mkdir -p ../build/SOURCES/ ../build/SPECS/
182 mv fusionforge-$version.tar.bz2 ../build/SOURCES/fusionforge-$version.tar.bz2
183 chown -h root: ../build/SOURCES/fusionforge-$version.tar.bz2
184 cp fusionforge.spec ../build/SPECS/
185 rpmbuild ../build/SPECS/fusionforge.spec --define "_topdir $(pwd)/../build" -ba
187 (cd ../build/RPMS/ && createrepo .)
188 repopath=$(readlink ../build/RPMS/)
189 cat <<-EOF | sed 's,@PATH@,$repopath,g' > /etc/zypp/repos.d/local.repo
192 baseurl=file://@PATH@
198 if [ -e /etc/debian_version ]; then
200 elif [ -e /etc/redhat-release ]; then
202 elif [ -e /etc/SuSE-release ]; then
205 echo "Automated package building is not supported for this distribution."
206 echo "See https://fusionforge.org/plugins/mediawiki/wiki/fusionforge/index.php/Installing/FromSource"
207 echo "for instructions"