|
| 1 | +#!/bin/bash |
| 2 | +# perl/build.sh $VERSION /outdir $OPTREVISION |
| 3 | +# $VERSION can be a released version or one of the perl development |
| 4 | +# branches, including "blead" (aka trunk), maint-5.xx |
| 5 | + |
| 6 | +set -ex |
| 7 | +source common.sh |
| 8 | + |
| 9 | +ROOT=$(pwd) |
| 10 | +VERSION=$1 |
| 11 | +# determine build revision |
| 12 | +LAST_REVISION="${3:-}" |
| 13 | + |
| 14 | +SRCURL=https://www.cpan.org/src/5.0/ |
| 15 | +GITURL=https://github.com/Perl/perl5.git |
| 16 | + |
| 17 | +SRCDIR="${ROOT}/perl" |
| 18 | +[ -e "${SRCDIR}" ] && rm -rf "${SRCDIR}" |
| 19 | + |
| 20 | +# use git for blead (aka trunk) or maint and CPAN for releases |
| 21 | +# I doubt maint will be used |
| 22 | +case $VERSION in |
| 23 | +blead|maint-*) |
| 24 | + BRANCH=${VERSION} |
| 25 | + VERSION=${VERSION}-$(date +%Y%m%d) |
| 26 | + |
| 27 | + # Setup perl checkout |
| 28 | + git clone --depth 1 --single-branch -b "${BRANCH}" "${GITURL}" "${SRCDIR}" |
| 29 | + |
| 30 | + REF="heads/${BRANCH}" |
| 31 | + REVISION=$(get_remote_revision "${GITURL}" "${REF}") |
| 32 | + ;; |
| 33 | +*) |
| 34 | + BASENAME="perl-$VERSION" |
| 35 | + FILE="${BASENAME}.tar.gz" |
| 36 | + ARCHIVEURL="${SRCURL}${FILE}" |
| 37 | + cd "${ROOT}" |
| 38 | + |
| 39 | + [ -e "${FILE}" ] && rm "${FILE}" |
| 40 | + curl -o "${FILE}" "${ARCHIVEURL}" |
| 41 | + |
| 42 | + # creates perl-X.XX.X aka $BASENAME |
| 43 | + [ -e "${BASENAME}" ] && rm -rf "${BASENAME}" |
| 44 | + tar xzf "${FILE}" |
| 45 | + mv "${BASENAME}" "${SRCDIR}" |
| 46 | + |
| 47 | + # patches older perls to build on modern systems |
| 48 | + perl -MDevel::PatchPerl -e 'Devel::PatchPerl->patch_source(@ARGV)' \ |
| 49 | + "${VERSION}" "${SRCDIR}" |
| 50 | + REVISION="${VERSION}" |
| 51 | + ;; |
| 52 | +esac |
| 53 | + |
| 54 | +FULLNAME=perl-${VERSION} |
| 55 | +if [[ -d "${2}" ]]; then |
| 56 | + OUTPUT=$2/${FULLNAME}.tar.xz |
| 57 | +else |
| 58 | + OUTPUT=${2-$OUTPUT} |
| 59 | +fi |
| 60 | +initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}" |
| 61 | + |
| 62 | +STAGING_DIR=/opt/compiler-explorer/${FULLNAME} |
| 63 | +rm -rf "${STAGING_DIR}" |
| 64 | +mkdir -p "${STAGING_DIR}" |
| 65 | + |
| 66 | +# Configure build |
| 67 | +# modern perls can use -Dmksymlinks to do an out of |
| 68 | +# tree build, but I don't trust it for older perls |
| 69 | +# |
| 70 | +# -de - -d use defaults, -e don't prompt to build Makefile etc |
| 71 | +# -s (silent) is also common here but may make diagnosis harder |
| 72 | +# -Dusedevel - required to build blead, harmless for other builds except |
| 73 | +# it sets -Dversiononly |
| 74 | +# -Uversiononly - installs a "perl" binary, not just perl$VERSION |
| 75 | +# -Dusethreads - enable threads, commonly set by vendors |
| 76 | +# -Dman1dir=none -Dman3dir=none - don't install man pages |
| 77 | +# -Duseshrplib - build libperl as a shared library |
| 78 | +# -Dlibperl - name of libperl shared object (otherwise just libperl.so) |
| 79 | +cd "${SRCDIR}" |
| 80 | +./Configure \ |
| 81 | + -de \ |
| 82 | + -Dusedevel \ |
| 83 | + -Uversiononly \ |
| 84 | + -Dprefix="${STAGING_DIR}" \ |
| 85 | + -Dusethreads \ |
| 86 | + -Dman1dir=none \ |
| 87 | + -Dman3dir=none \ |
| 88 | + -Duseshrplib \ |
| 89 | + -Dlibperl=libperl-${VERSION}.so |
| 90 | + |
| 91 | +# Build and install artifacts |
| 92 | +make -j $(nproc) |
| 93 | +make install |
| 94 | + |
| 95 | +# delete installed pod, perldiag.pod is used by diagnostics.pm |
| 96 | +find "${STAGING_DIR}" -name '*.pod' ! -name perldiag.pod -print0 | xargs -0 rm -- |
| 97 | + |
| 98 | +# make sure it works |
| 99 | +"${STAGING_DIR}/bin/perl" -V |
| 100 | + |
| 101 | +complete "${STAGING_DIR}" "${FULLNAME}" "${OUTPUT}" |
0 commit comments