Skip to content

Commit 313da25

Browse files
committed
initial commit of resources
1 parent acdeb29 commit 313da25

15 files changed

+628
-0
lines changed

Dockerfile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
FROM debian:bookworm as perl-build
2+
3+
WORKDIR /app
4+
ENV DEBIAN_FRONTEND=noninteractive \
5+
DEBCONF_NONINTERACTIVE_SEEN=true
6+
7+
# Install necessary packages
8+
RUN apt-get update -y && \
9+
apt-get install apache2 \
10+
apache2-utils \
11+
bc \
12+
build-essential \
13+
curl \
14+
dos2unix \
15+
gcc \
16+
krb5-doc \
17+
krb5-config \
18+
krb5-user \
19+
libexpat1-dev \
20+
libexpat1-dev\
21+
libgeoip-dev \
22+
libgmp3-dev \
23+
libgssapi-krb5-2 \
24+
libimlib2 \
25+
libimlib2-dev \
26+
libkrb5-3 \
27+
libkrb5support0 \
28+
libmagic-dev \
29+
libmagic-ocaml-dev \
30+
libmagic1 \
31+
libmagick++-6-headers \
32+
libmagick++-6.q16-dev \
33+
libmagick++-dev \
34+
libmagickcore-6-headers \
35+
libmagickcore-6.q16-dev \
36+
libmagickcore-dev \
37+
libmagickwand-6-headers \
38+
libmagickwand-6.q16-dev \
39+
libmagickwand-dev \
40+
libmagics++-dev \
41+
libmagics++-metview-dev \
42+
libmaxminddb-dev \
43+
libmaxminddb0 \
44+
libmysqlclient-dev \
45+
libpq-dev \
46+
libsqlite3-0 \
47+
libsqlite3-dev \
48+
libssl-dev \
49+
make \
50+
mmdb-bin \
51+
openssl \
52+
postgresql-server-dev-all \
53+
sudo \
54+
zlib1g \
55+
zlib1g-dev \
56+
-y
57+
58+
COPY . /app
59+
60+
RUN ./build.sh
61+
62+
FROM debian:bookworm
63+
64+
WORKDIR /app
65+
ENV DEBIAN_FRONTEND=noninteractive \
66+
DEBCONF_NONINTERACTIVE_SEEN=true
67+
68+
69+
# Add required packages
70+
RUN apt-get update -y && \
71+
apt-get install curl sudo mysql-client sqlite3 vim -y
72+
73+
COPY --from=perl-build scot.perl.install.tar.gz /app/scot.perl.install.tar.gz
74+
75+
# Unzip and install scot-perl
76+
RUN tar -xzf /app/scot.perl.install.tar.gz && \
77+
apt-get install ./scot-perl-install/scot-perl.5.38.2.deb -y --fix-missing

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
11
# scot4-perl-builder
2+
23
Builds the custom perl binary and related container image for flair and scot4-inbox
4+
5+
# manual interventions
6+
7+
There are several modules that may break as authors abandon their releases.
8+
9+
- Test::mysqld = filed a bug report https://github.com/kazuho/p5-test-mysqld/issues/38
10+
- cpanm --force and hope for the best
11+
- had to cpanm --look
12+
- delete t/05-*
13+
- perl Build.PL
14+
- ./Build && ./Build test && ./Build install
15+
16+
- Crypt::Curve25519 - compilation fails - author unresponsive
17+
- https://github.com/ajgb/crypt-curve25519/issues/9
18+
- Solution:
19+
- sudo -E cpanm --look Crypt::Curve25519
20+
- grep -rl fmul | xargs sed -i 's/fmul/fixedvar/g'
21+
- perl Makefile.PL
22+
- make
23+
- make test
24+
- make install
25+
- exit

build.sh

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
#!/bin/bash
2+
3+
function set_ascii_color {
4+
red="\033[0;31m"
5+
green="\033[0;32m"
6+
yellow="\033[0;33m"
7+
nc="\033[0m"
8+
}
9+
10+
function output {
11+
echo -e $1 $2 ${nc}
12+
}
13+
14+
set_ascii_color
15+
pwd=$(pwd)
16+
build="$pwd/build"
17+
resources="$pwd/resources"
18+
perl_ver="5.38.2"
19+
perl_build="$build/perl-$perl_ver"
20+
perl_tarfile="$resources/perl-$perl_ver.tar.gz"
21+
22+
output ${green} "---- SCOT PERL builder packager "
23+
output ${green} "---- pwd = $pwd"
24+
output ${green} "---- resources = $resources"
25+
output ${green} "---- build = $build"
26+
27+
function install_prereqs {
28+
output ${yellow} "Installing Apt Prerequisites"
29+
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libmagic-dev libexpat1-dev build-essential curl mysql-server libmysqlclient-dev postgresql postgresql-contrib libpq-dev krb5-config libkrb5-dev
30+
}
31+
32+
function build_perl {
33+
output ${yellow} "Extracting PERL for building"
34+
if [[ ! -d $perl_build ]]; then
35+
mkdir -p $perl_build;
36+
fi
37+
tar xzf $perl_tarfile -C $build
38+
39+
if [[ -r $perl_build/Makefile ]];then
40+
output ${yellow} "Cleaning Perl Previous Perl Build"
41+
cd $perl_build
42+
make clean
43+
cd $pwd
44+
fi
45+
46+
output ${yellow} "Configuring..."
47+
cd $perl_build
48+
./Configure -des -Dprefix=/opt/perl -Dotherlibdirs=/opt/perl/lib/perl5
49+
50+
output ${yellow} "Building..."
51+
make
52+
53+
output ${yellow} "Testing..."
54+
make test
55+
56+
output ${yellow} "Installing..."
57+
if [[ -d /opt/perl ]]; then
58+
sudo mv /opt/perl /opt/perl.bak
59+
fi
60+
61+
sudo make install
62+
cd $pwd
63+
}
64+
65+
function install_cpanm {
66+
output ${yellow} "Installing CPANMinus"
67+
curl -k -L https://cpanmin.us | /opt/perl/bin/perl - --sudo App::cpanminus
68+
}
69+
70+
function install_modules {
71+
output ${yellow} "Manually installing Crypt::Curve25519"
72+
tar xzf $resources/Crypt-Curve25519-0.06.tar.gz -C $build
73+
cd $build/Crypt-Curve25519-0.06
74+
grep -rl "fmul" ./ | xargs sed -i 's/fmul/fixedvar/g'
75+
/opt/perl/bin/perl Makefile.PL
76+
make
77+
make test
78+
sudo -E make install
79+
cd $pwd
80+
81+
output ${yellow} "Installing GSSAPI to see why it fails"
82+
/opt/perl/bin/cpanm -v --sudo GSSAPI
83+
84+
output ${yellow} "Installing Modules with problematic network configs"
85+
# Install Net::HTTP while disabling specific tests that conflict w/ ssl cert
86+
NO_NETWORK_TESTING=1 /opt/perl/bin/cpanm --sudo Net::HTTP
87+
88+
# Install LWP::Protocol::https while disabling specific tests that get blocked by IT Policy
89+
NO_NETWORK_TESTING=1 /opt/perl/bin/cpanm --sudo LWP::Protocol::https
90+
91+
output ${yellow} "Installing WWW::Mechanize without tests due to hanging test"
92+
NO_NETWORK_TESTING=1 /opt/perl/bin/cpanm -n --force --sudo WWW::Mechanize
93+
94+
output ${yellow} "Installing Test::mysqld without tests due to hanging test"
95+
NO_NETWORK_TESTING=1 /opt/perl/bin/cpanm -n --force --sudo Test::mysqld
96+
97+
output ${yellow} "Installing Modules in cpanfile"
98+
# Install modules from cpanfile
99+
sudo -E /opt/perl/bin/cpanm --cpanfile $resources/cpanfile --installdeps .
100+
101+
output ${yellow} "Force installing XML::RSS:Parser::Lite due to failing test"
102+
# has a failing test that does not affect operation
103+
/opt/perl/bin/cpanm -v --force --sudo XML::RSS::Parser::Lite
104+
105+
output ${yellow} "Re-installing Lingua::EN::StopWords due to intermittent failures"
106+
# Try installing Lingua::EN::StopWords again due to intermittent failures
107+
NO_NETWORK_TESTING=1 /opt/perl/bin/cpanm -v --sudo Lingua::EN::StopWords
108+
109+
output ${yellow} "Verbosely Trying to install LWP::ConsoleLogger::Easy"
110+
NO_NETWORK_TESTSING=1 /opt/perl/bin/cpanm -force -sudo LWP::ConsoleLogger::Easy
111+
112+
output ${yellow} "Manually installing File::Magic"
113+
tar xzf $resources/File-Magic-0.01.tar.gz -C $build
114+
cd $build/File-Magic-0.01
115+
/opt/perl/bin/perl Makefile.PL
116+
make
117+
make test
118+
sudo -E make install
119+
cd $pwd
120+
}
121+
122+
function verify_modules {
123+
output ${yellow} "Verifying Modules"
124+
modules=$(cat $resources/cpanfile | cut -d\' -f 2)
125+
modules="$modules File::Magic"
126+
missing=''
127+
128+
for m in $modules; do
129+
/opt/perl/bin/perl -e "use $m;" 2>/dev/null
130+
if [[ "$?" != 0 ]]; then
131+
if [[ "$m" == "MooseX::AttributeShortcuts" ]];then
132+
echo "ignoring known error in $m"
133+
else
134+
missing="$missing $m"
135+
fi
136+
fi
137+
done
138+
139+
failed=''
140+
if [[ "$missing" != "" ]]; then
141+
output ${red} "The Following Modules appear to be missing:"
142+
for x in $missing; do
143+
output ${red} " $x"
144+
fm = $(retry_module $x)
145+
if [[ "$fm" != "" ]]; then
146+
failed="$failed $fm"
147+
output ${red} "Retry of $x failed"
148+
else
149+
output ${green} "Retry of $x worked"
150+
fi
151+
done
152+
153+
if [[ "$failed" != "" ]]; then
154+
output ${red} "The Following Modules failed Retry"
155+
for y in $failed; do
156+
output ${red} " $y"
157+
done
158+
output ${red} "Exiting build due to missing packages..."
159+
exit 1
160+
fi
161+
else
162+
output ${green} "All modules installed"
163+
fi
164+
}
165+
166+
function retry_module {
167+
module = "$1"
168+
/opt/perl/bin/cpanm -v --sudo $module
169+
/opt/perl/bin/perl -e "use $module;" 2>/dev/null
170+
if [[ "$?" != 0 ]]; then
171+
echo $module;
172+
fi
173+
}
174+
175+
function copy_perl_for_debbuild {
176+
output ${yellow} "Copying Installed Perl to Debian build"
177+
mkdir -p $build/scot-perl/opt
178+
cp -rp /opt/perl $build/scot-perl/opt
179+
# tar -cf - /opt/perl | (cd $build/scot-perl; tar -xf -)
180+
}
181+
182+
function build_deb_install_file {
183+
output ${yellow} "Building DEB install file"
184+
local files=$(find /opt/perl)
185+
for file in $files; do
186+
if [[ ! -d $file ]]; then
187+
local dir=$(dirname $file)
188+
local name=$(basename $file)
189+
echo "$name $dir" >> $build/scot-perl/DEBIAN/install
190+
fi
191+
done
192+
}
193+
194+
function build_deb {
195+
output ${yellow} "Updating permissions of build dir"
196+
chmod -R 775 $build
197+
output ${yellow} "Packaging"
198+
if [[ ! -d $build/deb_build ]];then
199+
mkdir -p $build/deb_build
200+
fi
201+
cd $build
202+
dpkg-deb --build scot-perl
203+
cd $pwd
204+
cp $build/scot-perl.deb $build/scot-perl-install/scot-perl.$perl_ver.deb
205+
}
206+
207+
function wrap {
208+
output ${yellow} "Wrapping"
209+
tar czvf scot.perl.install.tar.gz -C $build ./scot-perl-install
210+
}
211+
212+
function usage {
213+
output ${yellow} "Usage: $0 [-v] [-r]"
214+
output ${green} " -v verify perl modules only"
215+
output ${green} " -r rebuild deb from current /opt/perl state"
216+
}
217+
218+
function replace_old_js {
219+
siteperl="/opt/perl/lib/site_perl/$perl_ver"
220+
miniondir="$siteperl/Mojolicious/Plugin/Minion/resources/public/minion"
221+
cp $resources/moment.min.js $miniondir/moment/moment.js
222+
cp $resoutces/bootstrap.min.js $miniondir/bootstrap/bootstrap.js
223+
cp $resoutces/bootstrap.min.css $miniondir/bootstrap/bootstrap.css
224+
cp $resources/jquery-3.6.4.min.js $siteperl/Mojolicious/resources/public/mojo/jquery/jquery.js
225+
}
226+
227+
while getopts "mprv" arg; do
228+
case $arg in
229+
m)
230+
echo "Rebuilding Modules..."
231+
install_modules
232+
exit 0
233+
;;
234+
p)
235+
echo "Installing Prerequisite Debian packages..."
236+
install_prereqs
237+
exit 0
238+
;;
239+
v)
240+
echo "Verify Modules..."
241+
verify_modules
242+
exit 0
243+
;;
244+
r)
245+
echo "Rebuilding..."
246+
copy_perl_for_debbuild
247+
build_deb_install_file
248+
build_deb
249+
wrap
250+
exit 0
251+
;;
252+
*)
253+
usage
254+
exit 0
255+
;;
256+
esac
257+
done
258+
259+
# attempt to suppress warning
260+
# that is filling logs
261+
export no_proxy=$NO_PROXY
262+
263+
install_prereqs
264+
build_perl
265+
install_cpanm
266+
install_modules
267+
verify_modules
268+
replace_old_js
269+
copy_perl_for_debbuild
270+
build_deb_install_file
271+
build_deb
272+
wrap
273+
274+
mkdir -p cpanm-logs
275+
cp -r /root/.cpanm/work cpanm-logs

build/scot-perl-install/install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
echo "### SCOT Perl installer helper ###"
4+
5+
sudo apt install ./scot-perl.5.38.2.deb
6+
7+

build/scot-perl/DEBIAN/control

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Package: scot-perl
2+
version: 5.38.2
3+
Section: custom
4+
Priority: optional
5+
Architecture: all
6+
Essential: no
7+
Installed-Size: 218452
8+
Maintainer: Todd Bruner <tbruner@sandia.gov>
9+
Description: Perl 5.38.2 and Libraries necessary to run SCOT and VAST
10+
Depends: build-essential, libssl-dev, libpq-dev, libexpat1-dev, zlib1g, zlib1g-dev, libgssapi-krb5-2, libkrb5support0, libkrb5-3, krb5-doc, libimlib2-dev, libimlib2, libmagic-dev, libmagic1, apache2, apache2-utils, bc, libgmp3-dev, libmagickcore-6-headers, libmagick++-6-headers, libmagickwand-6-headers, libmagic-dev, libmagick++-6.q16-dev, libmagickcore-6.q16-dev, libmagickcore-dev, libmagick++-dev, libmagickwand-6.q16-dev, libmagickwand-dev, libmagic-ocaml-dev, libmagics++-dev, libmagics++-metview-dev, mmdb-bin, libgeoip-dev, libmaxminddb0, libmaxminddb-dev, libmysqlclient-dev, postgresql-server-dev-all, libsqlite3-0, libsqlite3-dev

0 commit comments

Comments
 (0)