For my job I need to do the same few repetitive actions on about 35 Windows PCs. It's a kind of work that's quite tricky to do using the normal Windows GUI, but that is quite easy to script in Perl. There's still one problem: none of all these PCs has Perl, and I'm not going to install it for a simple, one time task.
So I was thinking of building a binary package from the script. I've always been quite impressed with Graciliano M. P.'s work on TinyPerl. So I decided to try to use it for this task.
I found it works pretty well, though there are a few warts:
$0
has the value "-e", which makes it impossible for the script to find out its own directory, as I haven't found any other way to find that out
glob
makes it crash. I suspect there's an incompatibility between the DLL of File::Glob
and tinyperl.exe
, because it crashes also when you just use tinyperl.exe
instead of plain perl.exe
, and not just when running the packed script.
perltobin
. You can allegedly use it for a vast array of platforms, provided you have a C compiler... or you can use the "binary" package for ActivePerl on Windows, either 5.6.x or 5.8.x, which doesn't require a C compiler at all — the pre-compiled to-be-linked-in library is included in the distribution.glob
works, though you need to explicitely invoke File::Glob
to include the necessary files that appears to be caused because Module::Dependency doesn't seem to catch it by default.
$0
is set to the path of the executable file, so it can deduce its own file path
PAR
quite daunting, so this has always been a bit of a showstopper to me. Would Cava Packager suit your needs?
I'm currently testing it for deploying some wxPerl applications. It is working quite well for me so far.
Thought it might be worth mentioning.
Re:Cava Packager
bart on 2007-11-05T11:33:09
Thanks. I had never heard of Cava Packer before, so I'm glad you brought it to my attention.I'm not sure what to think of it, so here's a list of my impressions:
- I definitely don't like the fact that a program that is written in Perl, requires installation as administrator. WTF?
- Though the GUI looks nice, it's also too hard to use. The first time I tried to use it, I really needed to follow the walkthrough example from the help file to get my first executable file compiled. I was totally lost without it. Not good. GUI's are supposed to make things simpler, aren't they?
The root of my confusion is the requirement of a "project", where it is initially not clear what it is for. It doesn't use a default project (containing only the files for this one script) if you just to want to produce one exectutable for one script.
- I don't like the file layout of the result: there's a
bin
directory for the executables, and alib
directory for the libraries (it doesn't combine the libraries into a single archive, which is not necessarily a bad thing). The exe file is burried in thebin
directory.That may be the custom in Linux Land, but people using Windows expect the executable to be in the root directory of the location of the app. If you plan to be able to run executables without installation, the root is the most sensible location, IMO.
- The packer renames the DLLs while copying to their new location, which isn't a bad idea in itself: I've had the experience in Win95 (loooong time ago) that it was simply impossible to load 2 different executables (and DLLs, which are executables too) with the same name, at the same time.
I think that is the reason for the need of for projects, so different executables can reuse the same renamed DLLS.
What isn't so nice is the opaqueness of the names, and the lack of information of which DLL got renamed to what. Maybe the info is there, but I haven't seen it.
The ZIP packager packages a ZIP, file, which includes simply everything that's in its
build
directory. That includes files that may have been generated by the script itself in a test run. And I've got the impression it may contain quite a bit more files than needed.But, all in all, this doesn't look like a bad packager. Quite the contrary.
Re:Cava Packager
tunaboy on 2007-11-05T14:57:17
From what I have experienced, the developer(s) of Cava are very receptive to feedback. I would pass on your list to them: support@cava.co.uk
I believe the renaming of DLLs and library files is part of the "source code hiding" effort. I could be wrong for the motiviation behind the renaming, though.
If you browse the list of "Scanned Modules" and double click one, there is a Packaged Location option which you can change to include modules in a "Standard @INC Folder" (and you can save this as a global default for all projects I believe). Modules included in this manner are not renamed, if I remember correctly, and placed in the inc subdirectory of the lib directory.
I am working on my own list of feedback to send, and I am sure yours would be appreciated.
Re:Cava Packager
wallasey on 2007-11-05T18:38:18
Hi, I'm the developer behind Cava Packager.Installing as Admin - that's an error on my part with the installer. The application certainly does not need admin privileges. I'll ensure the next upload has this requirement removed.
I am aware that the GUI has become confusing. I should have realised this when I decided it needed a 'quick start' guide. I'll be fixing that by adding a 'new project' wizard in the short term that takes you through minimum steps necessary to package a script, followed up by a redesign of the whole thing.
Having read your comments on the file layout - I think you are right. My only requirement was that the executable should not be in the same directory as perl58.dll. As you say, it would make sense to have the executable(s) in the root of the build tree.
The mapping of file names isn't intentionally opaque. It just didn't occur to me that there would be a practical reason to need to know the mappings. I'll output mappings to logs in the next version.
All the files in the build directory are required. (Or at least the scanning process thinks they are required.) The first action on each build is to completely clear out the directories. Scanning does not write any files. If your script requires utf8 or POSIX somewhere in its dependencies, you will get a huge number of files. I guess providing mappings between 'real' file names and packaged names would make this whole aspect less opaque.
With regard to keeping the files separate, and not archiving them into a single file - that was the main reason for starting the project. PAR / pp gives a perfectly good archived/packed solution - I wanted a portable (between machines) tree that could run off a USB without the need for temp files. Working with wxPerl also means relatively huge DLLs - though I could live with the slow first time startup if that were the only drawback for my particular requirement.
You can package in a completely transparent way, without any renaming or attempting to obfuscate the source files on disk. I'd agree that it isn't immediately clear that this is an option.
Going back to your original question, my advice would be to start with PAR::Packer.
if
pp -o your.exe yourscript.pl
works for you, perhaps you could learn to live with the temp dirs?Thanks for the constructive comments.
Mark
Re:Temp files
bart on 2007-11-04T21:03:24
And, even if they do, I don't quite see what's to get upset about that.I consider it quite unprofessional. For example, it would be enough to stop me from thinking of building a program for distribution on CD-ROM, that is to be run directly from the CD, with it.I'd stick with PAR if I were you.I've only briefly tested PAR, and not recently, but just to be fair, I might test it again to compare it with the others.And I'm trying to remember which win32 utility we used to use for deploying software to 20+ Windows load generating machines during performance testing, but I really can't seem to squeeze it out of my head...Of, I would be so grateful if you could think of what it was... I've found a few possible solutions, but fewer options than I would have expected, and none that really pleases me::/ Tips for other solutions are most welcome.
- I can put it in a Startup script, assigned to the computer in a Group Policy in Active Directory, so it runs when the computer boots
- I can pretend that it's a program installer by producing a ZAP file that can be attached to a Group Policy in Active Directory, to be run at logon. Oddly enough (IMO), you can attach installers (MSI files, or ZAP) to group policies, but no ordinary executables. In that case, a ZAP file wrapper looks like the easier solution to me.
Re:Temp files
bart on 2007-11-20T10:53:32
Meh,.ZAP files don't work for installation deployment in Active Directory. It requires that it's an .MSI file. I just though I'd add it here so people searching with Google for a solution for the same problem won't get their hopes up too high.