Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Symlinks with PAR::Packer not working on Windows

by kaldor (Sexton)
on Jul 06, 2021 at 18:34 UTC ( #11134716=perlquestion: print w/replies, xml ) Need Help??

kaldor has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I've packed multiple scripts together as a single Windows executable, with "pp". I'm not able to use symbolic links to call the different scripts, does anyone know if it's supported or not? The documentation doesn't mention anything.

Thanks!

C:\test>mklink script1.exe pack.exe symbolic link created for script1.exe <<===>> pack.exe C:\test>script1.exe Usage: C:\test\script1.exe [ -Alib.par ] [ -Idir ] [ -Mmodule ] [ src. +par ] [ program.pl ] C:\test\script1.exe [ -B|-b ] [-Ooutfile] src.par

Replies are listed 'Best First'.
Re: Symlinks with PAR::Packer not working on Windows
by salva (Canon) on Jul 07, 2021 at 08:54 UTC
    I have not been putting too much effort into maintaining Win32::Packer lately, but anyway, it supports packing several scripts into just one installer.

    Well, actually, IMO, it follows a saner approach than pp for the distribution of Perl applications in Windows, so you may like to try it.

      Thanks, I didn't know it.

      The goal is cross-platform functionality, so I'll stick to pp unless major issues.

Re: Symlinks with PAR::Packer not working on Windows
by Anonymous Monk on Jul 06, 2021 at 20:32 UTC

    Hi

    What do you get if you  set PAR_GLOBAL_DEBUG=999 before you run script1.exe?

    A hardlink works fine for me :/

    What is "Windows" exactly? What is a minimal "pack.exe" exactly? And how exactly did you create "pack.exe"?

      Hi,

      as an example, I have 3 scripts that contain only :

      use 5.010; say $0;
      C:\test>pp -o pack.exe script1.pl script2.pl script3.pl

      Then I move pack.exe to another machine (running Windows Server 2016) :

      Renaming works :

      C:\test>rename pack.exe script1.exe C:\test>script1.exe C:\test\script1.exe C:\test>rename script1.exe pack.exe

      Hard-linking works :

      C:\test>mklink /h script1.exe pack.exe Hardlink created for script1.exe <<===>> pack.exe C:\test>script1.exe C:\test\script1.exe C:\test>del script1.exe

      Soft-linking doesn't :

      C:\test>mklink script1.exe pack.exe symbolic link created for script1.exe <<===>> pack.exe C:\test>set PAR_GLOBAL_DEBUG=999 C:\test>script1.exe Usage: C:\test\script1.exe [ -Alib.par ] [ -Idir ] [ -Mmodule ] [ src. +par ] [ program.pl ] C:\test\script1.exe [ -B|-b ] [-Ooutfile] src.par

        Do you get the same problem if you only pack one script?

        Also, it would be useful to output the contents of some of the PAR environment variables to see what PAR thinks it is dealing with, for example PAR_0, PAR_PROGNAME and PAR_GLOBAL_TEMP. See PAR::Environment. That's assuming it gets that far, of course.

        use 5.010; say $ENV{PAR_0}; say $ENV{PAR_PROGNAME}; say $ENV{PAR_GLOBAL_TEMP}; say $0;

        More generally, in the past when I've packed multiple scripts I usually packed the first (child) script as an exe, and then included that as an extra file resource when packing the parent script (using the --addfile argument). The parent script can use logic based on $ENV{PAR_0} to decide if it should call a perl script or a packed executable. Any packed resource will be under $ENV{PAR_TMP}/inc.

        This approach leads to duplication in what is packed because dependencies are packed separately in each exe. However, it is simpler to wrangle and duplication is not really an issue unless there are large dependencies.

Re: Symlinks with PAR::Packer not working on Windows
by Marshall (Canon) on Jul 07, 2021 at 01:30 UTC
    I don't have experience with pp, but a symlink is a directory entry on your machine. Your .exe won't have any idea about that. I didn't know (or would expect) that various scripts could "packed" into a single .exe. Each executable program would have its own .exe file. To the best of knowledge, there is no such thing as multiple exe's within one exe. Each script must have its own .exe.

      The .exe knows with what name it was called, that's how PAR::Packer knows which script to execute.

      Windows shortcuts are different from links, because they are regular files interpreted by Explorer or cmd.exe, which means that the .exe is called with its actual filename, whatever the shortcut name is.

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11134716]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-10-28 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (96 votes). Check out past polls.

    Notices?