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 ${srcdir}/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 | sed 's,@PATH@,$srcdir,g'
48 archivedir = /usr/src/debian-repository
50 architectures = "all, amd64"
55 release_signscript = @PATH@/autoinstall/mini-dinstall-sign.sh
58 mail_on_success = false
63 export GNUPGHOME=/usr/src/gnupg
64 if [ ! -e $GNUPGHOME ]; then
65 mkdir -m 700 $GNUPGHOME
66 # Quick 'n Dirty hack to get entropy on VMs
67 # https://bugs.launchpad.net/ubuntu/+source/gnupg/+bug/706011
68 # (don't do this for a public repo!)
69 apt-get install -y rng-tools
70 echo HRNGDEVICE=/dev/urandom >> /etc/default/rng-tools
71 service rng-tools restart
72 gpg --batch --gen-key <<-EOF
77 Name-Real: FusionForge
83 gpg --export FusionForge -a > /usr/src/debian-repository/key.asc
84 apt-key add /usr/src/debian-repository/key.asc
88 # Configure debian package building tools so as to use the local repo
89 if [ ! -f /root/.dput.cf ]; then
90 cat > /root/.dput.cf <<-EOF
93 incoming = /usr/src/debian-repository/mini-dinstall/incoming
96 allow_unsigned_uploads = yes
97 post_upload_command = mini-dinstall -bv
98 allowed_distributions = local
102 if [ ! -f /root/.devscripts ]; then
103 cat > /root/.devscripts <<-EOF
104 DEBRELEASE_UPLOADER=dput
105 DEBUILD_DPKG_BUILDPACKAGE_OPTS=-i
109 # Finally, build the FusionForge packages
111 cd $(dirname $0)/../src/
112 cp -a debian/changelog $f
114 version=$(dpkg-parsechangelog | sed -n 's/^Version: \([0-9.]\+\(\~\(rc\|beta\|alpha\)[0-9]\)\?\).*/\1/p')+autobuilt$(date +%Y%m%d%H%M)
115 make dist VERSION=$version
116 mv fusionforge-$version.tar.bz2 ../fusionforge_$version.orig.tar.bz2
119 tar xf fusionforge_$version.orig.tar.bz2
120 cd fusionforge-$version/
121 debian/rules debian/control # re-gen debian/control
122 if gitid=$(git show --format="%h" -s 2> /dev/null) ; then
123 msg="Autobuilt from Git revid $gitid."
127 dch --newversion $version-1 --distribution local --force-distribution "$msg"
128 debuild -us -uc -tc # using -tc so 'git status' is readable
129 # Install built packages into the local repo
133 mv $f src/debian/changelog
135 # Declare the repo so that packages become installable
136 echo 'deb file:///usr/src/debian-repository local/' > /etc/apt/sources.list.d/local.list
142 # Install build dependencies
144 yum install -y make gettext tar bzip2 rpm-build createrepo
145 yum install -y php-cli # rpm/gen_spec.sh
148 cd $(dirname $0)/../src/
149 base_version=$(make version)
150 snapshot=$(date +%Y%m%d%H%M)
151 version=$base_version+$snapshot
152 rpm/gen_spec.sh $base_version $snapshot
153 make dist VERSION=$version
154 mkdir -p ../build/SOURCES/ ../build/SPECS/
155 mv fusionforge-$version.tar.bz2 ../build/SOURCES/fusionforge-$version.tar.bz2
156 chown -h root: ../build/SOURCES/fusionforge-$version.tar.bz2
157 cp fusionforge.spec ../build/SPECS/
158 rpmbuild ../build/SPECS/fusionforge.spec --define "_topdir $(pwd)/../build" -ba
160 (cd ../build/RPMS/ && createrepo .)
161 repopath=$(readlink -f ../../build/RPMS/)
162 cat <<-EOF | sed 's,@PATH@,$repopath,g' > /etc/yum.repos.d/local.repo
165 baseurl=file://@PATH@
171 function build_suse_rpm {
174 suse_install_rpms make gettext-runtime gettext-tools tar bzip2 rpm-build createrepo php7
177 cd $(dirname $0)/../src/
178 base_version=$(make version)
179 snapshot=$(date +%Y%m%d%H%M)
180 version=$base_version+$snapshot
181 rpm/gen_spec.sh $base_version $snapshot
182 make dist VERSION=$version
183 mkdir -p ../build/SOURCES/ ../build/SPECS/
184 mv fusionforge-$version.tar.bz2 ../build/SOURCES/fusionforge-$version.tar.bz2
185 chown -h root: ../build/SOURCES/fusionforge-$version.tar.bz2
186 cp fusionforge.spec ../build/SPECS/
187 rpmbuild ../build/SPECS/fusionforge.spec --define "_topdir $(pwd)/../build" -ba
189 (cd ../build/RPMS/ && createrepo .)
190 repopath=$(readlink ../build/RPMS/)
191 cat <<-EOF | sed 's,@PATH@,$repopath,g' > /etc/zypp/repos.d/local.repo
194 baseurl=file://@PATH@
200 if [ -e /etc/debian_version ]; then
202 elif [ -e /etc/redhat-release ]; then
204 elif [[ ! -z `cat /etc/os-release | grep 'SUSE'` ]]; then
207 echo "Automated package building is not supported for this distribution."
208 echo "See https://fusionforge.org/plugins/mediawiki/wiki/fusionforge/index.php/Installing/FromSource"
209 echo "for instructions"