Ravenports generated: 25 Nov 2019 17:36
[ravenports.git] / bucket_9B / autoselect-perl
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               autoselect-perl
4 VERSION=                2
5 REVISION=               1
6 KEYWORDS=               lang
7 VARIANTS=               standard
8 SDESC[standard]=        Dynamic links to the latest installed perl
9 HOMEPAGE=               none
10 CONTACT=                nobody
11
12 DOWNLOAD_GROUPS=        none
13 SPKGS[standard]=        single
14
15 OPTIONS_AVAILABLE=      none
16 OPTIONS_STANDARD=       none
17
18 LICENSE=                ISCL:single
19 LICENSE_FILE=           ISCL:{{FILESDIR}}/LICENSE_ISC
20 LICENSE_SCHEME=         solo
21
22 INVALID_RPATH=          yes
23
24 SUB_FILES=              autoselect.c
25 SUB_LIST=               ALPHA=5.30
26                         ALPHA_FULL=5.30.1
27                         BRAVO=5.28
28                         BRAVO_FULL=5.28.2
29
30 post-patch:
31         @${MKDIR} ${WRKSRC}
32         ${CP} ${WRKDIR}/autoselect.c ${WRKSRC}
33
34 do-build:
35         (cd ${WRKSRC} && ${CC} ${CFLAGS} ${LDFLAGS} -o generic autoselect.c)
36
37 do-install:
38 .for prog in perl perl5 corelist cpan enc2xs encguess h2ph h2xs \
39         instmodsh json_pp libnetcfg perlbug perldoc perlivp perlthanks \
40         piconv pl2pm pod2html pod2man pod2text pod2usage podchecker \
41         podselect prove ptar ptardiff ptargrep shasum splain xsubpp zipdetails
42         ${INSTALL_PROGRAM} ${WRKSRC}/generic ${STAGEDIR}${PREFIX}/bin/${prog}
43 .endfor
44
45 [FILE:913:descriptions/desc.single]
46 This package provides:
47   bin/perl         bin/instmodsh    bin/pl2pm        bin/ptar
48   bin/perl5        bin/json_pp      bin/pod2html     bin/ptardiff         
49   bin/corelist     bin/libnetcfg    bin/pod2man      bin/ptargrep
50   bin/cpan         bin/perlbug      bin/pod2text     bin/shasum
51   bin/enc2xs       bin/perldoc      bin/pod2usage    bin/splain
52   bin/encguess     bin/perlivp      bin/podchecker   bin/xsubpp
53   bin/h2ph         bin/perlthanks   bin/podselect    bin/zipdetails
54   bin/h2xs         bin/piconv       bin/prove
55
56 It automatically selects the latest version of perl available.
57 For example, if perl 5.26 and perl 5.28 are both installed,
58 bin/perl executes bin/perl5.28 with the same arguments.  If
59 perl 5.28 is then deinstalled, the linkage will automatically
60 adjust to perl 5.26. 
61
62 The priority check can be overridden by setting AUTOPERL=<perl version>
63 in the environment, e.g. AUTOPERL=5.26.
64
65
66 [FILE:0:distinfo]
67
68
69 [FILE:281:manifests/plist.single]
70 bin/
71  corelist
72  cpan
73  enc2xs
74  encguess
75  h2ph
76  h2xs
77  instmodsh
78  json_pp
79  libnetcfg
80  perl
81  perl5
82  perlbug
83  perldoc
84  perlivp
85  perlthanks
86  piconv
87  pl2pm
88  pod2html
89  pod2man
90  pod2text
91  pod2usage
92  podchecker
93  podselect
94  prove
95  ptar
96  ptardiff
97  ptargrep
98  shasum
99  splain
100  xsubpp
101  zipdetails
102
103
104 [FILE:742:files/LICENSE_ISC]
105 Copyright (c) 2018, The Ravenports Project.
106
107 Permission to use, copy, modify, and/or distribute this software for any
108 purpose with or without fee is hereby granted, provided that the above
109 copyright notice and this permission notice appear in all copies.
110
111 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
112 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
113 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
114 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
115 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
116 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
117 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
118
119
120 [FILE:2068:files/autoselect.c.in]
121 /*
122  * This program will determine the latest version of perl
123  * installed by checking %%PREFIX%%/bin/perl<x> where <x> checks
124  * all possible versions.
125  * 
126  * If no version is present, an error message will be displayed,
127  * otherwise the versioned counterpart of the perl command
128  * requested will be will be executed with the same arguments
129  * provided to this one.  If the versioned command isn't present, an
130  * error message will be provided as a fallback.
131  */
132
133 #include <stdio.h>
134 #include <stdlib.h>
135 #include <string.h>
136 #include <unistd.h>
137
138
139 int
140 main(int argc, char **argv)
141 {
142         int x;
143         char *cmd;
144         char *override;
145         char recommand[1024];
146         char *plver   = NULL;
147         char *PERL_A  = "%%PREFIX%%/bin/perl%%ALPHA_FULL%%";
148         char *PERL_B  = "%%PREFIX%%/bin/perl%%BRAVO_FULL%%";
149         char *ALPHA   = "%%ALPHA_FULL%%";
150         char *BRAVO   = "%%BRAVO_FULL%%";
151         char *A_SHORT = "%%ALPHA%%";
152         char *B_SHORT = "%%BRAVO%%";
153         char *perl5   = "perl5";
154
155         override = getenv("AUTOPERL");
156         if (override != NULL) {
157                 if (strcmp (override, A_SHORT) == 0) {
158                         plver = ALPHA;
159                 } else if (strcmp (override, B_SHORT) == 0) {
160                         plver = BRAVO;
161                 }
162         }
163         if (plver == NULL) {
164                 if (access(PERL_A, F_OK) != -1) {
165                         plver = ALPHA;
166                 } else if (access(PERL_B, F_OK) != -1) {
167                         plver = BRAVO;
168                 } else {
169                         /* no versions of perl are installed */
170                         printf ("There are no versions of perl installed at %%PREFIX%%/bin\n");
171                         exit (1);
172                 }
173         }
174
175         /*
176          * Get the last path element of the program name being executed
177          */
178         cmd = strrchr(argv[0], '/');
179         if (cmd != NULL)
180                 cmd++;
181         else
182                 cmd = argv[0];
183
184         /*
185          * special case, cmd of perl5 transforms to perl
186          */
187         if (strcmp (cmd, perl5) == 0)
188                 snprintf(recommand, 1024, "%%PREFIX%%/bin/perl%s", plver);
189         else
190                 snprintf(recommand, 1024, "%%PREFIX%%/bin/%s%s", cmd, plver);
191
192         argv[0] = recommand;
193         execv(recommand, argv);
194
195         /*
196          * Execution failed, so write out an error message
197          */
198         printf ("Command execution failed: %s\n", recommand);
199         printf ("               arguments:");
200         for (x = 1; x < argc; x++)
201                 printf (" %s", argv[x]);
202         printf ("\n");
203         exit (1);
204 }
205