1 |
=head1 NAME |
2 |
|
3 |
Urlader - installer-less single-file independent executables |
4 |
|
5 |
=head1 SYNOPSIS |
6 |
|
7 |
use Urlader; |
8 |
|
9 |
=head1 DESCRIPTION |
10 |
|
11 |
Urlader (that's german for "bootloader" btw.) was created out of |
12 |
frustration over PAR again not working, again not being flexible enough |
13 |
for simple things, and again causing mysterious missing files issues on |
14 |
various platforms. |
15 |
|
16 |
That doesn't mean this module replaces PAR, in fact, you should stay with |
17 |
it for many reasons, user-friendlyness is one of them. |
18 |
|
19 |
However, if you want to make single-file distributions out of your perl |
20 |
programs (or python, or C or whatever), and you are prepared to fiddle a |
21 |
LOT, this module might provide a tiny step towards your goal. Well, if it |
22 |
ever gets finished. |
23 |
|
24 |
Also, I<nothing in this module is considered very stable yet>, and it's |
25 |
far from feature-complete. |
26 |
|
27 |
Having said all that, Urlader basically provides three services: |
28 |
|
29 |
=over 4 |
30 |
|
31 |
=item A simple archiver that packs a directory tree into a single file. |
32 |
|
33 |
=item A small C program that works on windows and unix, which unpacks an attached |
34 |
archive and runs a program. |
35 |
|
36 |
=item A perl module support module (I<this one>), that can be used to query |
37 |
the runtime environment, find out where to install updates and so on. |
38 |
|
39 |
=back |
40 |
|
41 |
=head1 EXAMPLE |
42 |
|
43 |
How can it be used to provide single-file executables? |
44 |
|
45 |
So simple, create a directory with everything that's needed, e.g.: |
46 |
|
47 |
# find bintree |
48 |
bintree/perl |
49 |
bintree/libperl.so.5.10 |
50 |
bintree/run |
51 |
bintree/pm/Guard.pm |
52 |
bintree/pm/auto/Guard/Guard.so |
53 |
|
54 |
# cat bintree/run |
55 |
@INC = ("pm", "."); # "." works around buggy AutoLoader |
56 |
use Guard; |
57 |
guard { warn "hello, world!\n" }; # just to show off |
58 |
exit 0; # tell the urlader that everything was fine |
59 |
|
60 |
Then pack it: |
61 |
|
62 |
# wget http://urlader.schmorp.de/prebuilt/1.0/linux-x86 |
63 |
# urlader-util --urlader linux-x86 --pack myprog ver1_000 bintree \ |
64 |
LD_LIBRARY_PATH=. ./perl run \ |
65 |
>myprog |
66 |
# chmod 755 myprog |
67 |
|
68 |
=head1 CONCEPTS |
69 |
|
70 |
=over 4 |
71 |
|
72 |
=item urlader |
73 |
|
74 |
A small (hopefully) and relatively portable (hopefully) binary that is |
75 |
prepended to a pack file to make it executable. |
76 |
|
77 |
You can build it yourself from sources (see F<prebuilt/Makefile> in the |
78 |
distribution) or use one of the precompiled ones at: |
79 |
|
80 |
http://urlader.schmorp.de/prebuilt/1.0/ |
81 |
|
82 |
The F<README> there has further information on the binaries provided. |
83 |
|
84 |
=item exe_id |
85 |
|
86 |
A string that uniquely identifies your program - all branches of it. It |
87 |
must consist of the characters C<A-Za-z0-9_-> only and should be a valid |
88 |
directory name on all systems you want to deploy on. |
89 |
|
90 |
=item exe_ver |
91 |
|
92 |
A string the uniquely identifies the contents of the archive, i.e. the |
93 |
version. It has the same restrictions as the C<exe_id>, and should be |
94 |
fixed-length, as Urlader assumes lexicographically higher versions are |
95 |
newer, and thus preferable. |
96 |
|
97 |
=item pack file (archive) |
98 |
|
99 |
This contains the C<exe_id>, the C<exe_ver>, a number of environment |
100 |
variable assignments, the program name to execute, the initial arguments |
101 |
it receives, and finally, a list of files (with contents :) and |
102 |
directories. |
103 |
|
104 |
=item override |
105 |
|
106 |
=back |
107 |
|
108 |
=head1 FUNCTIONS AND VARIABLES IN THIS MODULE |
109 |
|
110 |
=over 4 |
111 |
|
112 |
=cut |
113 |
|
114 |
package Urlader; |
115 |
|
116 |
use common::sense; |
117 |
|
118 |
BEGIN { |
119 |
our $VERSION = '0.2'; |
120 |
|
121 |
use XSLoader; |
122 |
XSLoader::load __PACKAGE__, $VERSION; |
123 |
} |
124 |
|
125 |
our $URLADER_VERSION; # only ste when running under urlader |
126 |
our $DATADIR; |
127 |
our $EXE_ID; |
128 |
our $EXE_VER; |
129 |
our $EXE_DIR; # %AppData%/urlader/EXE_ID |
130 |
our $EXECDIR; # %AppData%/urlader/EXE_ID/i-EXE_VER |
131 |
|
132 |
sub _get_env { |
133 |
$URLADER_VERSION = getenv "URLADER_VERSION"; |
134 |
$DATADIR = getenv "URLADER_DATADIR"; |
135 |
$EXE_ID = getenv "URLADER_EXE_ID"; |
136 |
$EXE_VER = getenv "URLADER_EXE_VER"; |
137 |
$EXE_DIR = getenv "URLADER_EXE_DIR"; # %AppData%/urlader/EXE_ID |
138 |
$EXECDIR = getenv "URLADER_EXECDIR"; # %AppData%/urlader/EXE_ID/i-EXE_VER |
139 |
} |
140 |
|
141 |
_get_env; |
142 |
|
143 |
sub set_exe_info($$) { |
144 |
_set_datadir unless defined getenv "URLADER_DATADIR"; |
145 |
&_set_exe_info; |
146 |
_get_env; |
147 |
} |
148 |
|
149 |
|
150 |
1; |
151 |
|
152 |
=back |
153 |
|
154 |
=head1 AUTHOR |
155 |
|
156 |
Marc Lehmann <schmorp@schmorp.de> |
157 |
http://home.schmorp.de/ |
158 |
|
159 |
=cut |
160 |
|