setup-linux.sh 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/bash
  2. #
  3. # Copyright 2014 wkhtmltopdf authors
  4. #
  5. # This file is part of wkhtmltopdf.
  6. #
  7. # wkhtmltopdf is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Lesser General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # wkhtmltopdf is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public License
  18. # along with wkhtmltopdf. If not, see <http:#www.gnu.org/licenses/>.
  19. if [ "$(id -u)" != "0" ]; then
  20. echo "This script must be run as root" 1>&2
  21. exit 1
  22. fi
  23. if [ $# -ne 1 ]; then
  24. echo "Usage: scripts/setup-linux.sh [user-to-grant-schroot-access]"
  25. exit 1
  26. fi
  27. # install required packages
  28. apt-get update
  29. apt-get install --assume-yes git-core xz-utils build-essential mingw-w64 nsis debootstrap schroot rinse
  30. # create the directory which will hold the chroot environments
  31. if [ -d /srv/chroot-wkhtmltopdf ]; then
  32. rm -fr /srv/chroot-wkhtmltopdf
  33. fi
  34. mkdir -p /srv/chroot-wkhtmltopdf
  35. # create chroots for Debian Wheezy
  36. debootstrap --arch=i386 --variant=buildd wheezy /srv/chroot-wkhtmltopdf/wheezy-i386 http://ftp.us.debian.org/debian/
  37. debootstrap --arch=amd64 --variant=buildd wheezy /srv/chroot-wkhtmltopdf/wheezy-amd64 http://ftp.us.debian.org/debian/
  38. # update packages and install build dependencies
  39. cat > /srv/chroot-wkhtmltopdf/wheezy-amd64/etc/apt/sources.list <<EOF
  40. deb http://ftp.debian.org/debian/ wheezy main contrib non-free
  41. deb http://ftp.debian.org/debian/ wheezy-updates main contrib non-free
  42. deb http://security.debian.org/ wheezy/updates main contrib non-free
  43. deb-src http://ftp.debian.org/debian/ wheezy main contrib non-free
  44. deb-src http://ftp.debian.org/debian/ wheezy-updates main contrib non-free
  45. deb-src http://security.debian.org/ wheezy/updates main contrib non-free
  46. EOF
  47. cp /srv/chroot-wkhtmltopdf/wheezy-amd64/etc/apt/sources.list /srv/chroot-wkhtmltopdf/wheezy-i386/etc/apt/sources.list
  48. chroot /srv/chroot-wkhtmltopdf/wheezy-amd64/ apt-get update
  49. linux32 chroot /srv/chroot-wkhtmltopdf/wheezy-i386/ apt-get update
  50. chroot /srv/chroot-wkhtmltopdf/wheezy-amd64/ apt-get dist-upgrade --assume-yes
  51. linux32 chroot /srv/chroot-wkhtmltopdf/wheezy-i386/ apt-get dist-upgrade --assume-yes
  52. chroot /srv/chroot-wkhtmltopdf/wheezy-amd64/ apt-get install --assume-yes xz-utils
  53. linux32 chroot /srv/chroot-wkhtmltopdf/wheezy-i386/ apt-get install --assume-yes xz-utils
  54. chroot /srv/chroot-wkhtmltopdf/wheezy-amd64/ apt-get build-dep --assume-yes libqt4-core
  55. linux32 chroot /srv/chroot-wkhtmltopdf/wheezy-i386/ apt-get build-dep --assume-yes libqt4-core
  56. # create chroots for Centos 5
  57. linux32 rinse --arch i386 --distribution centos-5 --directory /srv/chroot-wkhtmltopdf/centos-5-i386
  58. rinse --arch amd64 --distribution centos-5 --directory /srv/chroot-wkhtmltopdf/centos-5-amd64
  59. # update packages and install development tools and build dependencies
  60. wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  61. cp epel-release-5-4.noarch.rpm /srv/chroot-wkhtmltopdf/centos-5-amd64
  62. mv epel-release-5-4.noarch.rpm /srv/chroot-wkhtmltopdf/centos-5-i386
  63. chroot /srv/chroot-wkhtmltopdf/centos-5-amd64 yum update -y
  64. linux32 chroot /srv/chroot-wkhtmltopdf/centos-5-i386 yum update -y
  65. chroot /srv/chroot-wkhtmltopdf/centos-5-amd64 rpm -i /epel-release-5-4.noarch.rpm
  66. linux32 chroot /srv/chroot-wkhtmltopdf/centos-5-i386 rpm -i /epel-release-5-4.noarch.rpm
  67. echo "exclude = *.i?86">>/srv/chroot-wkhtmltopdf/centos-5-amd64/etc/yum.conf
  68. chroot /srv/chroot-wkhtmltopdf/centos-5-amd64 yum install -y gcc gcc-c++ make qt4-devel openssl-devel diffutils perl xz
  69. linux32 chroot /srv/chroot-wkhtmltopdf/centos-5-i386 yum install -y gcc gcc-c++ make qt4-devel openssl-devel diffutils perl xz
  70. rm /srv/chroot-wkhtmltopdf/centos-5-i386/epel-release-5-4.noarch.rpm
  71. rm /srv/chroot-wkhtmltopdf/centos-5-amd64/epel-release-5-4.noarch.rpm
  72. # create schroot configuration
  73. cat > /etc/schroot/chroot.d/wkhtmltopdf <<EOF
  74. [wkhtmltopdf-wheezy-i386]
  75. type=directory
  76. directory=/srv/chroot-wkhtmltopdf/wheezy-i386/
  77. description=Debian Wheezy i386 for wkhtmltopdf
  78. users=$1
  79. root-users=root
  80. personality=linux32
  81. [wkhtmltopdf-wheezy-amd64]
  82. type=directory
  83. directory=/srv/chroot-wkhtmltopdf/wheezy-amd64/
  84. description=Debian Wheezy amd64 for wkhtmltopdf
  85. users=$1
  86. root-users=root
  87. [wkhtmltopdf-centos5-i386]
  88. type=directory
  89. directory=/srv/chroot-wkhtmltopdf/centos-5-i386/
  90. description=CentOS 5 i386 for wkhtmltopdf
  91. users=$1
  92. root-users=root
  93. personality=linux32
  94. [wkhtmltopdf-centos5-amd64]
  95. type=directory
  96. directory=/srv/chroot-wkhtmltopdf/centos-5-amd64/
  97. description=CentOS 5 amd64 for wkhtmltopdf
  98. users=$1
  99. root-users=root
  100. EOF
  101. echo "Environments set up successfully."