Hi everyone,
any ideas how to achieve that task?
It seems that UPX does not have a commandline switch to do that (At least I didn't find it).
Then I tried to get a (recursive) list of *.dll and *.exe files (with DIR) but struggled to get it working in an universal plattform independant way (To later call UPX with each item of the list.)
Any ideas?
In a batch file, it's:
"If you're not part of the solution, you're part of the precipitate."
Bump that up to "nrv2e" in the latest versions of UPX.
Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!
It's taken straight from what John uses. He had a rant about this somewhere...
"If you're not part of the solution, you're part of the precipitate."
No, I use nrv2e now for releases. It was UPX's LZMA I was ranting about because it's got compatibility issues (it breaks more DLLs than nrv2d/2e).
Sometimes, the impossible can become possible, if you're awesome!
posting early, getting some more releases out?
Working on Toucan now
Sometimes, the impossible can become possible, if you're awesome!
Excellent, although I just realised how sad it is for me to have an intuitive knowledge of when you should be posting.
Well, I just got served
"If you're not part of the solution, you're part of the precipitate."
also with the version 3.01 of UPX?
I didn't have an problems yet using "--lzma". maybe I was lucky
lzma compression isn't as "safe" as nrv2e and can cause issues for some people on some machines. The nrv2e compression causes less problems. John had a good post in one of my portable game threads in the Beta forum (that's the one he's referring to above).
Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!
So that's how for works! Oh, and %%e doesn't work (but %e does). I have work to do.
Vintage!
I think you double the % in a cmd file, but just use one from the command line ... or something like that.
MC
I put it in a batch file called upax.bat, so I just
cd
to the App\Whatever directory and typeupax
"If you're not part of the solution, you're part of the precipitate."
Nope. I first tried it on the command line and it said %%e was unexpected. %e works just fine both directly typed onto the command line and in a batch file.
Vintage!
%e for commandline, %%e for a batch file.
http://www.ss64.com/nt/for.html
A quick test shows you are right. It's messed up.
Vintage!
It's not really "messed up", if you know about batch files using parameters they receive on the command line.
A batch file can use the first parameter as %1, second as %2, etc. Without doubling the % sign, the command interpreter thinks it's supposed to evaluate the % sign as a parameter, not pass it on to the command.
"Niceness is the greatest human flaw, except for all the others."
--Brendan Moody
and how to call it from within a NSIS script?
hmnis edit when you install it it has an nsis script for repackaging the program and it includes a function within the script to call and compress with upx
your friendly neighbourhood moderator Zach Thibeau
Depends on how you want to generate the file list. If you are drag-and-dropping files on the EXE, then use GetParameters and pass it to upx -
If you need to search a list of files, use FindFirst/FindNext/FindClose to concatenate your file list and pass it to UPX like above.
yes you're right.
But how to call that recursive call above?
http://nsis.sourceforge.net/RecFind:_Recursive_FindFirst%2C_FindNext%2C_...
Then you can test the extension from ${GetFileExt}, and if it matches your set of criteria (EXE or DLL, etc), UPX each file individually.
I thought about the file list approach again last night, and it would fail miserably if the directory structure and number of files was large. I can't imagine how big that string would be....
that gave me an idea how to do it.
In fact I only need the list of recursive folders as I could call "UPX ... \*.exe" and/or "UPX ... \*.dll"
I thought about this some more, and I think this is better and faster than using NSIS to search the directories and call UPX. Just use good old commandline FOR to do it for you (like above) -
You can use
'cmd /c'
if you want the console window to close when it's done.I would recommend expanding the extensions you're compressing or use *.* as you're missing out on a lot of squishing opportunities.
Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!
Oh BuddhaChu, I love it when you get all technical!
~Lurk~
Smells like sarcasm...
Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!
Those are the only ones I have, otherwise it's too slow.
"If you're not part of the solution, you're part of the precipitate."
Recursive compressing is nice and all but what about the odd .exe or .dll that doesn't work after compression? Anybody have a way to recursively search for files and then for each file first compress it then test it then if upx returns bad for the compressed file decompress that one and move on to the next (e.g. using upx -t filename)? Also, I have yet to actually encounter such a file where upx "breaks" the file. Can anybody point me to such a file (or send me one) so I can play around with it myself? I've heard that a lot of the Windows files won't work compressed so I can try that...
Quamquam omniam nescio, nec nihil scio.
If I remember correctly, the following app incorporated some kind of testing in it to help eliminate files that "didn't play nice" with compression.
https://portableapps.com/apps/utilities/appcompactor
Yep, testing was added to version PR2 of the beta of the above app.
https://portableapps.com/node/12241#comment-72276
From the beta release notes (scroll up in the above thread):
ENHANCEMENT: UPXed files are tested to ensure they decompress
Cancer Survivors -- Remember the fight, celebrate the victory!
Help control the rugrat population -- have yourself spayed or neutered!
The AppCompactor uses UPX to compress each EXE/DLL/etc and then it uses UPX to test it (UPX -t as you mentioned). Some files can still slip through the cracks but those are relatively few, often some plugins. That's why we encourage NRV2E (the method with the least issues) and testing of the compressed app.
Sometimes, the impossible can become possible, if you're awesome!