xref: /openbsd/gnu/usr.bin/perl/README.synology (revision e0680481)
1*e0680481Safresh1# vim: syntax=pod
2*e0680481Safresh1
36fb12b70Safresh1If you read this file _as_is_, just ignore the funny characters you see.
46fb12b70Safresh1It is written in the POD format (see pod/perlpod.pod) which is specially
56fb12b70Safresh1designed to be readable as is. But if you have been into Perl you
66fb12b70Safresh1probably already know this.
76fb12b70Safresh1
86fb12b70Safresh1=head1 NAME
96fb12b70Safresh1
106fb12b70Safresh1perlsynology - Perl 5 on Synology DSM systems
116fb12b70Safresh1
126fb12b70Safresh1=head1 DESCRIPTION
136fb12b70Safresh1
146fb12b70Safresh1Synology manufactures a vast number of Network Attached Storage (NAS)
156fb12b70Safresh1devices that are very popular in large organisations as well as small
166fb12b70Safresh1businesses and homes.
176fb12b70Safresh1
186fb12b70Safresh1The NAS systems are equipped with Synology Disk Storage Manager (DSM),
196fb12b70Safresh1which is a trimmed-down Linux system enhanced with several tools for
206fb12b70Safresh1managing the NAS. There are several flavours of hardware: Marvell
21b8851fccSafresh1Armada (ARMv5tel, ARMv7l), Intel Atom (i686, x86_64), Freescale QorIQ
226fb12b70Safresh1(PPC), and more. For a full list see the
23eac174f2Safresh1L<Synology FAQ|https://kb.synology.com/en-global/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have>.
246fb12b70Safresh1
256fb12b70Safresh1Since it is based on Linux, the NAS can run many popular Linux
266fb12b70Safresh1software packages, including Perl. In fact, Synology provides a
27b8851fccSafresh1ready-to-install package for Perl, depending on the version of DSM
28*e0680481Safresh1the installed perl ranges from 5.8.6 on DSM-4.3 to 5.28.1 on DSM-7.1.
296fb12b70Safresh1
306fb12b70Safresh1There is an active user community that provides many software packages
316fb12b70Safresh1for the Synology DSM systems; at the time of writing this document
32*e0680481Safresh1they provide Perl version 5.28.1.
336fb12b70Safresh1
346fb12b70Safresh1This document describes various features of Synology DSM operating
356fb12b70Safresh1system that will affect how Perl 5 (hereafter just Perl) is
366fb12b70Safresh1configured, compiled and/or runs. It has been compiled and verified by
376fb12b70Safresh1Johan Vromans for the Synology DS413 (QorIQ), with feedback from
38*e0680481Safresh1H.Merijn Brand (DS213: ARMv5tel, RS815: Intel Atom x64, and DS218+:
39*e0680481Safresh1Celeron J3355).
406fb12b70Safresh1
416fb12b70Safresh1=head2 Setting up the build environment
426fb12b70Safresh1
43*e0680481Safresh1=head3 DSM 7
44*e0680481Safresh1
45*e0680481Safresh1For a comfortable development environment, Entware is currently the only
46*e0680481Safresh1viable solution. Just follow the detailed instructions on
47*e0680481Safresh1L<Install Entware on Synology NAS|https://github.com/Entware/Entware/wiki/Install-on-Synology-NAS>.
48*e0680481Safresh1supported architectures are armv5, armv7, mipsel, wl500g, x86_32, and x86_64.
49*e0680481Safresh1Check L<here|https://pkg.entware.net/binaries/> for supported platforms.
50*e0680481Safresh1
51*e0680481Safresh1That github link also shows what environments should be supported.
52*e0680481Safresh1
53*e0680481Safresh1It was tested on DSM-7.1 by H.Merijn Brand on a DS218+ and a DS220+ (both
54*e0680481Safresh1Intel x64).
55*e0680481Safresh1
56*e0680481Safresh1Entware comes with a precompiled 5.26.1 (Jan 2018) that allowes
57*e0680481Safresh1building shared XS code. Note that this installation does B<not> use
58*e0680481Safresh1a site_perl folder. The available C<cpan> works. If all required
59*e0680481Safresh1development packages are installed too, also for XS.
60*e0680481Safresh1
61*e0680481Safresh1Installing perl from the Community package center:
62*e0680481Safresh1
63*e0680481Safresh1=over 4
64*e0680481Safresh1
65*e0680481Safresh1=item *
66*e0680481Safresh1
67*e0680481Safresh1Using your favourite browser open the DSM management page and start
68*e0680481Safresh1the Package Center.
69*e0680481Safresh1
70*e0680481Safresh1=item *
71*e0680481Safresh1
72*e0680481Safresh1In Settings, add the following Package Sources:
73*e0680481Safresh1
74*e0680481Safresh1  Name:     Community
75*e0680481Safresh1  Location: https://synopackage.com/repository/spk/All
76*e0680481Safresh1
77*e0680481Safresh1=item *
78*e0680481Safresh1
79*e0680481Safresh1Still in Settings, in Channel Update, select Beta Channel.
80*e0680481Safresh1
81*e0680481Safresh1=back
82*e0680481Safresh1
83*e0680481Safresh1To complete the development environment, install make and gcc
84*e0680481Safresh1
85*e0680481Safresh1 ds220# opkg install make gcc
86*e0680481Safresh1
87*e0680481Safresh1Then, optionally, make sure you use the more recent bash and gawk.
88*e0680481Safresh1
89*e0680481Safresh1 ds220# opkg install bash gawk
90*e0680481Safresh1 ds220# cd /usr/bin
91*e0680481Safresh1 ds220# mv bash bash.syno
92*e0680481Safresh1 ds220# ln -s /opt/bin/bash .
93*e0680481Safresh1
94*e0680481Safresh1In order to have Configure find the required libraries
95*e0680481Safresh1
96*e0680481Safresh1 ds220# cd /opt/lib
97*e0680481Safresh1 ds220# ln -s libcrypt.so.?       libcrypt.so
98*e0680481Safresh1 ds220# ln -s libdl.so.?          libdl.so
99*e0680481Safresh1 ds220# ln -s libgdbm.so.?        libgdbm.so
100*e0680481Safresh1 ds220# ln -s libgdbm_compat.so.? libgdbm_compat.so
101*e0680481Safresh1 ds220# ln -s libm.so.?           libm.so
102*e0680481Safresh1 ds220# ln -s libpthread.so.?     libpthread.so
103*e0680481Safresh1 ds220# ln -s libutil.so.?        libutil.so
104*e0680481Safresh1
105*e0680481Safresh1=head3 DSM 6
106*e0680481Safresh1
107*e0680481Safresh1Using iPkg has been deprecated on DSM 6, but an alternative is available
108*e0680481Safresh1for DSM 6: entware/opkg. For instructions on how to use that, please read
109*e0680481Safresh1L<Install Entware-ng on Synology NAS|https://github.com/Entware-ng/Entware-ng/wiki/Install-on-Synology-NAS>
110*e0680481Safresh1
111*e0680481Safresh1That sadly does not (yet) work on QorIQ. At the moment of writing, the
112*e0680481Safresh1supported architectures are armv5, armv7, mipsel, wl500g, x86_32, and x86_64.
113*e0680481Safresh1Check L<here|https://pkg.entware.net/binaries/> for supported platforms.
114*e0680481Safresh1
115*e0680481Safresh1Entware-ng comes with a precompiled 5.24.1 (June 2017) that allowes
116*e0680481Safresh1building shared XS code. Note that this installation does B<not> use
117*e0680481Safresh1a site_perl folder. The available C<cpan> works. If all required
118*e0680481Safresh1development packages are installed too, also for XS.
119*e0680481Safresh1
1209f11ffb7Safresh1=head3 DSM 5
1219f11ffb7Safresh1
1226fb12b70Safresh1As DSM is a trimmed-down Linux system, it lacks many of the tools and
1236fb12b70Safresh1libraries commonly found on Linux. The basic tools like sh, cp, rm,
1246fb12b70Safresh1etc. are implemented using
12556d68f1eSafresh1L<BusyBox|https://en.wikipedia.org/wiki/BusyBox>.
1266fb12b70Safresh1
1276fb12b70Safresh1=over 4
1286fb12b70Safresh1
1296fb12b70Safresh1=item *
1306fb12b70Safresh1
1316fb12b70Safresh1Using your favourite browser open the DSM management page and start
1326fb12b70Safresh1the Package Center.
1336fb12b70Safresh1
1346fb12b70Safresh1=item *
1356fb12b70Safresh1
1366fb12b70Safresh1If you want to smoke test Perl, install C<Perl>.
1376fb12b70Safresh1
1386fb12b70Safresh1=item *
1396fb12b70Safresh1
1406fb12b70Safresh1In Settings, add the following Package Sources:
1416fb12b70Safresh1
14256d68f1eSafresh1  https://www.cphub.net
1436fb12b70Safresh1  http://packages.quadrat4.de
1446fb12b70Safresh1
145*e0680481Safresh1As these two are both discontinued, it is unlikely you will be able
146*e0680481Safresh1to set up a build environment on DSM 5.
147*e0680481Safresh1
1486fb12b70Safresh1=item *
1496fb12b70Safresh1
1506fb12b70Safresh1Still in Settings, in Channel Update, select Beta Channel.
1516fb12b70Safresh1
1526fb12b70Safresh1=item *
1536fb12b70Safresh1
1546fb12b70Safresh1Press Refresh. In the left panel the item "Community" will appear.
1556fb12b70Safresh1Click it. Select "Bootstrap Installer Beta" and install it.
1566fb12b70Safresh1
1576fb12b70Safresh1=item *
1586fb12b70Safresh1
1596fb12b70Safresh1Likewise, install "iPKGui Beta".
1606fb12b70Safresh1
1616fb12b70Safresh1The application window should now show an icon for iPKGui.
1626fb12b70Safresh1
1636fb12b70Safresh1=item *
1646fb12b70Safresh1
1656fb12b70Safresh1Start iPKGui. Install the packages C<make>, C<gcc> and C<coreutils>.
1666fb12b70Safresh1
1676fb12b70Safresh1If you want to smoke test Perl, install C<patch>.
1686fb12b70Safresh1
1696fb12b70Safresh1=back
1706fb12b70Safresh1
1716fb12b70Safresh1The next step is to add some symlinks to system libraries. For
1726fb12b70Safresh1example, the development software expect a library C<libm.so> that
1736fb12b70Safresh1normally is a symlink to C<libm.so.6>. Synology only provides the
1746fb12b70Safresh1latter and not the symlink.
1756fb12b70Safresh1
1766fb12b70Safresh1Here the actual architecture of the Synology system matters. You have
1776fb12b70Safresh1to find out where the gcc libraries have been installed. Look in /opt
1786fb12b70Safresh1for a directory similar to arm-none-linux-gnueab or
1796fb12b70Safresh1powerpc-linux-gnuspe. In the instructions below I'll use
1806fb12b70Safresh1powerpc-linux-gnuspe as an example.
1816fb12b70Safresh1
1826fb12b70Safresh1=over 4
1836fb12b70Safresh1
1846fb12b70Safresh1=item *
1856fb12b70Safresh1
1866fb12b70Safresh1On the DSM management page start the Control Panel.
1876fb12b70Safresh1
1886fb12b70Safresh1=item *
1896fb12b70Safresh1
1906fb12b70Safresh1Click Terminal, and enable SSH service.
1916fb12b70Safresh1
1926fb12b70Safresh1=item *
1936fb12b70Safresh1
1946fb12b70Safresh1Close Terminal and the Control Panel.
1956fb12b70Safresh1
1966fb12b70Safresh1=item *
1976fb12b70Safresh1
1986fb12b70Safresh1Open a shell on the Synology using ssh and become root.
1996fb12b70Safresh1
2006fb12b70Safresh1=item *
2016fb12b70Safresh1
2026fb12b70Safresh1Execute the following commands:
2036fb12b70Safresh1
2046fb12b70Safresh1  cd /lib
2056fb12b70Safresh1  ln -s libm.so.6 libm.so
2066fb12b70Safresh1  ln -s libcrypt.so.1 libcrypt.so
2076fb12b70Safresh1  ln -s libdl.so.2 libdl.so
208b8851fccSafresh1  cd /opt/powerpc-linux-gnuspe/lib  (or
209b8851fccSafresh1                                    /opt/arm-none-linux-gnueabi/lib)
2106fb12b70Safresh1  ln -s /lib/libdl.so.2 libdl.so
2116fb12b70Safresh1
2126fb12b70Safresh1=back
2136fb12b70Safresh1
2146fb12b70Safresh1B<WARNING:> When you perform a system software upgrade, these links
2156fb12b70Safresh1will disappear and need to be re-established.
2166fb12b70Safresh1
2176fb12b70Safresh1=head2 Compiling Perl 5
2186fb12b70Safresh1
2196fb12b70Safresh1When the build environment has been set up, building and testing Perl
2206fb12b70Safresh1is straightforward. The only thing you need to do is download the
2216fb12b70Safresh1sources as usual, and add a file Policy.sh as follows:
2226fb12b70Safresh1
2236fb12b70Safresh1  # Administrivia.
2246fb12b70Safresh1  perladmin="your.email@goes.here"
2256fb12b70Safresh1
2266fb12b70Safresh1  # Install Perl in a tree in /opt/perl instead of /opt/bin.
2276fb12b70Safresh1  prefix=/opt/perl
2286fb12b70Safresh1
229*e0680481Safresh1  # Select the compiler. Note that there is no 'cc' alias or link
230*e0680481Safresh1  # on older DSM versions
2316fb12b70Safresh1  cc=gcc
232*e0680481Safresh1  awk=/opt/bin/gawk
2336fb12b70Safresh1
234*e0680481Safresh1  # Build flags. Optional
2356fb12b70Safresh1  ccflags="-DDEBUGGING"
2366fb12b70Safresh1
2376fb12b70Safresh1  # Library and include paths.
2386fb12b70Safresh1  locincpth="/opt/include"
239*e0680481Safresh1  loclibpth="/opt/lib /usr/local/lib /usr/lib"
240*e0680481Safresh1  libpth="/opt/lib /usr/local/lib /usr/lib"
2416fb12b70Safresh1
2426fb12b70Safresh1You may want to create the destination directory and give it the right
2436fb12b70Safresh1permissions before installing, thus eliminating the need to build Perl
2446fb12b70Safresh1as a super user.
2456fb12b70Safresh1
2466fb12b70Safresh1In the directory where you unpacked the sources, issue the familiar
2476fb12b70Safresh1commands:
2486fb12b70Safresh1
249*e0680481Safresh1  $ bash ./Configure -Dusedevel -Duseshrplib -Duse64bitall -des
250*e0680481Safresh1  $ make -j2
251*e0680481Safresh1  $ env TEST_JOBS=2 make test_harness
252*e0680481Safresh1  $ make install
2536fb12b70Safresh1
2546fb12b70Safresh1=head2 Known problems
2556fb12b70Safresh1
2566fb12b70Safresh1=head3 Configure
2576fb12b70Safresh1
258*e0680481Safresh1The GNU C-compiler might spit out unexpected stuff under -v, which
259*e0680481Safresh1causes the analysis of cppsymbols to fail because of unmatched quotes.
260*e0680481Safresh1
261*e0680481Safresh1You'll note if config.sh fails with a syntax error.
2626fb12b70Safresh1
2636fb12b70Safresh1=head3 Build
2646fb12b70Safresh1
2656fb12b70Safresh1=over 4
2666fb12b70Safresh1
2676fb12b70Safresh1=item Error message "No error definitions found".
2686fb12b70Safresh1
2696fb12b70Safresh1This error is generated when it is not possible to find the local
2706fb12b70Safresh1definitions for error codes, due to the uncommon structure of the
2716fb12b70Safresh1Synology file system.
2726fb12b70Safresh1
2736fb12b70Safresh1This error was fixed in the Perl development git for version 5.19,
2746fb12b70Safresh1commit 7a8f1212e5482613c8a5b0402528e3105b26ff24.
2756fb12b70Safresh1
2766fb12b70Safresh1=back
2776fb12b70Safresh1
2786fb12b70Safresh1=head3 Failing tests
2796fb12b70Safresh1
2806fb12b70Safresh1=over 4
2816fb12b70Safresh1
282b8851fccSafresh1=item F<ext/DynaLoader/t/DynaLoader.t>
2836fb12b70Safresh1
2846fb12b70Safresh1One subtest fails due to the uncommon structure of the Synology file
285b8851fccSafresh1system. The file F</lib/glibc.so> is missing.
2866fb12b70Safresh1
287b8851fccSafresh1B<WARNING:> Do not symlink F</lib/glibc.so.6> to F</lib/glibc.so> or
2886fb12b70Safresh1some system components will start to fail.
2896fb12b70Safresh1
2906fb12b70Safresh1=back
2916fb12b70Safresh1
292*e0680481Safresh1=head2 Smoke testing Perl
2936fb12b70Safresh1
2946fb12b70Safresh1If building completes successfully, you can set up smoke testing as
2956fb12b70Safresh1described in the Test::Smoke documentation.
2966fb12b70Safresh1
2976fb12b70Safresh1For smoke testing you need a running Perl. You can either install the
2986fb12b70Safresh1Synology supplied package for Perl 5.8.6, or build and install your
2996fb12b70Safresh1own, much more recent version.
3006fb12b70Safresh1
3016fb12b70Safresh1Note that I could not run successful smokes when initiated by the
3026fb12b70Safresh1Synology Task Scheduler. I resorted to initiating the smokes via a
3036fb12b70Safresh1cron job run on another system, using ssh:
3046fb12b70Safresh1
3056fb12b70Safresh1  ssh nas1 wrk/Test-Smoke/smoke/smokecurrent.sh
3066fb12b70Safresh1
3076fb12b70Safresh1=head3 Local patches
3086fb12b70Safresh1
3096fb12b70Safresh1When local patches are applied with smoke testing, the test driver
3106fb12b70Safresh1will automatically request regeneration of certain tables after the
3116fb12b70Safresh1patches are applied. The Synology supplied Perl 5.8.6 (at least on the
3126fb12b70Safresh1DS413) B<is NOT capable> of generating these tables. It will generate
3136fb12b70Safresh1opcodes with bogus values, causing the build to fail.
3146fb12b70Safresh1
3156fb12b70Safresh1You can prevent regeneration by adding the setting
3166fb12b70Safresh1
3176fb12b70Safresh1  'flags' => 0,
3186fb12b70Safresh1
3196fb12b70Safresh1to the smoke config, or by adding another patch that inserts
3206fb12b70Safresh1
3216fb12b70Safresh1  exit 0 if $] == 5.008006;
3226fb12b70Safresh1
3236fb12b70Safresh1in the beginning of the C<regen.pl> program.
3246fb12b70Safresh1
3256fb12b70Safresh1=head2 Adding libraries
3266fb12b70Safresh1
3276fb12b70Safresh1The above procedure describes a basic environment and hence results in
3286fb12b70Safresh1a basic Perl. If you want to add additional libraries to Perl, you may
3296fb12b70Safresh1need some extra settings.
3306fb12b70Safresh1
3316fb12b70Safresh1For example, the basic Perl does not have any of the DB libraries (db,
3326fb12b70Safresh1dbm, ndbm, gdsm). You can add these using iPKGui, however, you need to
3336fb12b70Safresh1set environment variable LD_LIBRARY_PATH to the appropriate value:
3346fb12b70Safresh1
3356fb12b70Safresh1  LD_LIBRARY_PATH=/lib:/opt/lib
3366fb12b70Safresh1  export LD_LIBRARY_PATH
3376fb12b70Safresh1
3386fb12b70Safresh1This setting needs to be in effect while Perl is built, but also when
3396fb12b70Safresh1the programs are run.
3406fb12b70Safresh1
3416fb12b70Safresh1=head1 REVISION
3426fb12b70Safresh1
343*e0680481Safresh1July 2022, for DSM 5.1.5022 and DSM 6.1-15101-4, and DSM-7.1-42661-3.
3446fb12b70Safresh1
3456fb12b70Safresh1=head1 AUTHOR
3466fb12b70Safresh1
3476fb12b70Safresh1Johan Vromans <jvromans@squirrel.nl>
348*e0680481Safresh1H. Merijn Brand <cpan@tux.freedom.nl>
3496fb12b70Safresh1
3506fb12b70Safresh1=cut
351