#!/bin/bash
#
# Copyright 2014 wkhtmltopdf authors
#
# This file is part of wkhtmltopdf.
#
# wkhtmltopdf is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# wkhtmltopdf is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with wkhtmltopdf. If not, see .
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [ $# -ne 1 ]; then
echo "Usage: scripts/setup-linux.sh [user-to-grant-schroot-access]"
exit 1
fi
# install required packages
apt-get update
apt-get install --assume-yes git-core xz-utils build-essential mingw-w64 nsis debootstrap schroot rinse
# create the directory which will hold the chroot environments
if [ -d /srv/chroot-wkhtmltopdf ]; then
rm -fr /srv/chroot-wkhtmltopdf
fi
mkdir -p /srv/chroot-wkhtmltopdf
# create chroots for Debian Wheezy
debootstrap --arch=i386 --variant=buildd wheezy /srv/chroot-wkhtmltopdf/wheezy-i386 http://ftp.us.debian.org/debian/
debootstrap --arch=amd64 --variant=buildd wheezy /srv/chroot-wkhtmltopdf/wheezy-amd64 http://ftp.us.debian.org/debian/
# update packages and install build dependencies
cat > /srv/chroot-wkhtmltopdf/wheezy-amd64/etc/apt/sources.list <>/srv/chroot-wkhtmltopdf/centos-5-amd64/etc/yum.conf
chroot /srv/chroot-wkhtmltopdf/centos-5-amd64 yum install -y gcc gcc-c++ make qt4-devel openssl-devel diffutils perl xz
linux32 chroot /srv/chroot-wkhtmltopdf/centos-5-i386 yum install -y gcc gcc-c++ make qt4-devel openssl-devel diffutils perl xz
rm /srv/chroot-wkhtmltopdf/centos-5-i386/epel-release-5-4.noarch.rpm
rm /srv/chroot-wkhtmltopdf/centos-5-amd64/epel-release-5-4.noarch.rpm
# create schroot configuration
cat > /etc/schroot/chroot.d/wkhtmltopdf <