Login Form






Lost Password?
No account yet? Register

Donate to A.R.T.

Polls

What OS are you using?
 

Advertisement

Syndicate

powered_by.png, 1 kB

Home
Sometimes I wonder where my head is Print E-mail
Written by scott   
Wednesday, 21 February 2007
Poking through an rpm that I “traffic” quite a bit today and saw a particularly nasty bit of code I'd put together. This is a pretty long thread, so I'll spare everyone loading down the main page with it. Suffice it to say, I'd like to immortalize my mistake in the website so I never do this again. If anyones interested I can go into RPM kung-foo like this in more detail later.


%triggerin -- j2sdk

# check /usr/lib/jvm

if [ -f /usr/lib/jvm/java*/bin/java ]; then

chpax -emsrpx /usr/lib/jvm/java*/bin/java

fi


if [ -f /usr/lib/jvm/java*/bin/javac ]; then

chpax -emsrpx /usr/lib/jvm/java*/bin/javac

fi


if [ -f /usr/lib/jvm/java*/jre/bin/java ]; then

chpax -emsrpx /usr/lib/jvm/java*/jre/bin/java

fi


if [ -f /usr/lib/jvm/java*/jre/bin/javac ]; then

chpax -emsrpx /usr/lib/jvm/java*/jre/bin/javac

fi


# check /usr/java

if [ -f /usr/java/j2sdk*/bin/java ]; then

chpax -emsrpx /usr/java/j2sdk*/bin/java

fi


if [ -f /usr/java/j2sdk*/bin/javac ]; then

chpax -emsrpx /usr/java/j2sdk*/bin/javac

fi


# because they hide them in lib

if [ -f /usr/lib/jvm/java*/bin/java ]; then

chpax -emsrpx /usr/lib/jvm/java*/bin/java

fi


if [ -f /usr/lib/jvm/java*/bin/javac ]; then

chpax -emsrpx /usr/lib/jvm/java*/bin/javac

fi


# generic catch all

if [ -d /usr/java ]; then

find /usr/java -name java -type f -exec chpax -emsrpx {} \;

find /usr/java -name javac -type f -exec chpax -emsrpx {} \;

fi


# generic catch all for /usr/lib/jvm

if [ -d /usr/lib/jvm ]; then

find /usr/lib/jvm -name java -type f -exec chpax -emsrpx {} \;

find /usr/lib/jvm -name javac -type f -exec chpax -emsrpx {} \;

fi


I then had duplicated this trigger 3 more times (I'll spare you), for java-1.4.2-sun, java-1.4.2-gcj-compat, and java-1.4.2-sun-devel. So all told about 200 lines to fix some PaX related flags with java. A clever soul will note that even I had figured out a better way to do it at the end when I wrote it. Except for some reason I just kept doing the same stupid routine 3 more times. Allow me to demonstrate by showing you what it looks like now:


# Java

%triggerin -- j2sdk java-1.4.2-sun java-1.4.2-gcj-compat java-1.4.2-sun-devel

killall -9 java >/dev/null 2>&1


if [ -d /usr/java ]; then

find /usr/java -name java -type f -exec chpax -emsrpx {} \; >/dev/null 2>&1

find /usr/java -name javac -type f -exec chpax -emsrpx {} \; >/dev/null 2>&1

fi


if [ -d /usr/lib/jvm ]; then

find /usr/lib/jvm -name java -type f -exec chpax -emsrpx {} \; >/dev/null 2>&1

find /usr/lib/jvm -name javac -type f -exec chpax -emsrpx {} \; >/dev/null 2>&1

fi


For anyone thats still bored enough to read down to the end of this thread, this is an example of an RPM trigger. The above detects (in one line!) when the packages j2sdk java-1.4.2-sun java-1.4.2-gcj-compa and java-1.4.2-sun-devel are installed/updated, and runs the following routine against them. Triggers make me happy.


You know the best part of all this was that the trigger right after this was a multi-package trigger that was the right way to do it all along. Staring at me.... mocking me....

Comments
Subject: Ha
Written by breun on 2007-02-22 05:38:27
Nice one!

Subject: I did it again with oinkmaster
Written by scott on 2007-02-22 14:21:15
Mike tells me to whip up an oinkmaster rpm, so I did what I normally do, which is to look to see if theres one out there alread. Google for "oinkmaster src.rpm" and wham, 7th hit on the page is my own site.

Only registered users can write comments.
Please login or register.

Powered by AkoComment 2.0.3!

 
< Prev   Next >
© 2008 atomicrocketturtle.com :: digital turtlist
Joomla! is Free Software released under the GNU/GPL License.
sheta@atomicrocketturtle.com
Fight Spam! Click Here!