Add yt-dlp v2021.09.02
[sunny256-utils.git] / build-perl
blob40c14fb538589bce0d94d73a8706f01ad01f0d8d
1 #!/usr/bin/env bash
3 #=======================================================================
4 # build-perl
5 # File ID: e11bba20-382d-11e4-a75c-c80aa9e67bbd
7 # Compile and install Perl.
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
13 progname=build-perl
14 VERSION=0.1.0
16 ARGS="$(getopt -o "\
20 " -l "\
21 help,\
22 quiet,\
23 verbose,\
24 version,\
25 " -n "$progname" -- "$@")"
26 test "$?" = "0" || exit 1
27 eval set -- "$ARGS"
29 opt_help=0
30 opt_quiet=0
31 opt_verbose=0
32 while :; do
33 case "$1" in
34 -h|--help) opt_help=1; shift ;;
35 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
36 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
37 --version) echo $progname $VERSION; exit 0 ;;
38 --) shift; break ;;
39 *) echo $progname: Internal error >&2; exit 1 ;;
40 esac
41 done
42 opt_verbose=$(($opt_verbose - $opt_quiet))
44 if test "$opt_help" = "1"; then
45 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
46 cat <<END
48 Compile and install Perl.
50 Usage: $progname [options]
52 Options:
54 -h, --help
55 Show this help.
56 -q, --quiet
57 Be more quiet. Can be repeated to increase silence.
58 -v, --verbose
59 Increase level of verbosity. Can be repeated.
60 --version
61 Print version information.
63 END
64 exit 0
67 # FIXME: Get rid of hardcoded directories and username
68 # FIXME: Set up a common sync source for the build-* scripts
70 cd /home/sunny/src/other/perl || exit 1
71 export perldir="perl-$(git desc --long)"
72 export destdir="/usr/local/varprg/$perldir"
73 sudo rmdir $destdir 2>/dev/null
74 sudo mkdir $destdir &&
75 sudo chown sunny.sunny $destdir &&
76 git clean -fxd &&
77 git co -f &&
78 ./Configure -de -Dusedevel -Dprefix=$destdir &&
79 make &&
80 make test &&
81 make install &&
82 cd /usr/local/prg &&
83 (test -L perl && sudo rm perl || true) &&
84 sudo ln -sv ../varprg/$perldir perl &&
85 cd ../varprg/$perldir/bin &&
86 (test -x perl || ln -sv perl5.* perl) &&
87 /usr/local/prg/perl/bin/perl --version ||
88 sudo rmdir $destdir