From mulinux-return-4911-m.andreoli=tin.it@sunsite.auc.dk  Wed Oct 11 20:53:03 2000
Return-Path: <mulinux-return-4911-m.andreoli=tin.it@sunsite.auc.dk>
Received: from box.tin.it
	by server.sanvittore.it (fetchmail-4.3.9 POP3)
	for <michele/localhost> (single-drop); Wed, 11 Oct 2000 20:53:03 CEST
Received: from sunsite.auc.dk ([130.225.51.30]) by fep02-svc.tin.it
          (InterMail vM.4.01.02.27 201-229-119-110) with SMTP
          id <20001011143338.NDPG3089.fep02-svc.tin.it@sunsite.auc.dk>
          for <m.andreoli@tin.it>; Wed, 11 Oct 2000 16:33:38 +0200
Received: (qmail 14811 invoked by alias); 11 Oct 2000 14:33:00 -0000
Mailing-List: contact mulinux-help@sunsite.auc.dk; run by ezmlm
Precedence: bulk
X-No-Archive: yes
Reply-To: mulinux@sunsite.auc.dk
Delivered-To: mailing list mulinux@sunsite.auc.dk
Received: (qmail 14805 invoked from network); 11 Oct 2000 14:32:59 -0000
Sender: stepheni@holyrood.ed.ac.uk
Message-ID: <39E47A16.468E@ed.ac.uk>
Date: Wed, 11 Oct 2000 15:32:54 +0100
From: Stephen Isard <S.IsardDeleteThis@ed.ac.uk>
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.7 sun4u)
MIME-Version: 1.0
To: mulinux@sunsite.auc.dk
Subject: Re: recursive upx: was Thinking of creating a new addon
References: <20001006133605.C631@tin.it> <Pine.LNX.4.21.0010070334050.5793-100000@satin> <20001007131246.B622@tin.it> <20001008211021.A2167@pluto.spsselib.hiedu.cz> <20001010091524.A618@tin.it> <39E31970.2DE2@ed.ac.uk> <20001010164645.D624@tin.it>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Status: RO
Content-Length: 1893
Lines: 85

Michele,

> It can be an exercise for the user. I will write some kind, in
> the future.

Here is my solution to the exercise :-)

%% cut here

#!/bin/ash
# upx_tree by Stephen Isard, CSTR, University of Edinburgh,
# adapted from mufind by Andrea Manzini <linux@netbusiness.it>

case $1Z in
  -hZ|--helpZ|Z)
    echo "Usage: upx_tree <path>"
    echo "All executable files in the tree rooted at <path> will be"
    echo "compressed with upx"
    exit
  ;;
  *) P="$1" ;;
esac

/bin/ls $P -1UAR 2> /dev/null | sed -n "/:$/P" | tr -d ':' | while read
D ; do
    /bin/ls $D -1UA 2> /dev/null |  while read F; do
      if [ "$D" = '/' ] ; then
           FF="/$F"
      else
           FF="$D/$F"
      fi
      if file $FF | grep "executable" > /dev/null; then
        upx $FF
      fi
    done
done

%% cut here

I followed your suggestion about using the "file" command.  I've only
tested it on a RedHat system.  I took an old EXT.tgz that I had
downloaded, 

1458176 EXT.tgz

uncompressed it to EXT.tar

3104768 EXT.tar

untarred, applied upx_tree and re-tarred to make upEXT.tar

1835008 upEXT.tar

and compressed upEXT.tar with both bzip2 and gzip, to upEXT.tar.bz2 and
upEXT.tgz, respectively.

1444534 upEXT.tar.bz2
1417216 upEXT.tgz

So with bzip2 compression there is a saving of 13642 bytes, just under
1%, compared to the original, and with gzip a saving of 40960, just
under 3%.

Then I tried using their "best" flag (replace upx by upx --best in the
script above) and after re-tarring and compressing with gzip achieved

1394883 bupEXT.tgz

a saving of 63293 bytes, which is just over 4%.  Maybe that's enough to
be useful on some occasions?

Stephen Isard








uncompressed it to EXT.tar

---------------------------------------------------------------------
To unsubscribe, e-mail: mulinux-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: mulinux-help@sunsite.auc.dk

