Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Update par packer executable

by Dirk80 (Monk)
on Feb 28, 2012 at 15:45 UTC ( #956693=perlquestion: print w/ replies, xml ) Need Help??
Dirk80 has asked for the wisdom of the Perl Monks concerning the following question:

Hello wise monks,

I created some par packed executables with the command line tool "pp" as follows in a MSWin32 environment:

pp -a "additional_stuff" -o hello_world.exe hello_world.pl

Now I noticed that inside the "hello_world.exe" there are a lot of files which I want to get rid of.

That's why I wrote the following script:

#!/usr/bin/perl use strict; use warnings; use Archive::Zip qw( :ERROR_CODES ); my $zip_name = 'hello_world.exe'; my $zip = Archive::Zip->new( $zip_name ); die "ERROR: Could not open \"$zip_name\"!!!" unless defined $zip; my @metadata_file_members = $zip->membersMatching( '\.metadata' ); $zip->removeMember($_) for ( @metadata_file_members ); $zip->overwrite();

The updated "hello_world.exe" now does NOT contain the .metadata files I wanted to get rid of. So this works fine. But now I have the problem that I have a normal zip file and not a self extracting file as before.

I looked into the examples of Archive::Zip and found "selfex.pl". Here I got the idea of how it could be done. But to be honest I have no plan how to create the par packed executable as it was before.

I've seen in the "script/main.pl" file within the par packed executable that this code could be the right place to look. But as said before I don't know how to create exactly such a self extracting executable as it was before.

Main question: How can I remove some files from a par packed executable?

Thank you a lot for you help.

Greetings,

Dirk

Comment on Update par packer executable
Select or Download Code
Re: Update par packer executable
by Anonymous Monk on Feb 28, 2012 at 16:26 UTC

    Main question: How can I remove some files from a par packed executable?

    Why?

    I'd recommend you don't, a lot of the files are there to make PAR and your program work :)

    But if you insist, you should look inside PAR::Packer

      The files I want to remove are files from myself which I added with the "-a" option. So the files I want to remove have nothing to do with the files which PAR needs to get the program work.

        That begs the question, "why did you add these files if they are unnecessary"?

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics
Re: Update par packer executable
by CountZero (Bishop) on Feb 28, 2012 at 18:49 UTC
    What files in the packed file you want to remove? Perhaps it is a better idea not to include them to start with?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics

      Of course you are right that the better idea is not to include them.

      Because I have several executables this way I thought it would be nice to solve that problem with a script. So I started to use Archive::Zip and this lead me to the problem with the self extractable zip file.

      So now to be honest I'm very interested in the technique how to solve that problem. You are right that I could solve it easily if I'd rebuild the executables again without the files I want to remove now.

Re: Update par packer executable
by Anonymous Monk on Feb 28, 2012 at 23:12 UTC
    This ought to work
    copy hello_world.exe hello_world.par HelloDirk80.pl hello_world.par pp -o hello_again_world.exe hello_world.par

      Thank you alot. That's working. And the interesting fact I take from that is that if a par packed executable is copied to a "par" it can be changed easily with Archive::Zip and then packed again to an executable.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (14)
As of 2014-09-18 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (117 votes), past polls