OS2 World.Com Forum
2012.05.26, 03:09:14 *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Firefox D&D install !!!  (Read 1326 times)
sXwamp
Full Member
***
Posts: 223



View Profile WWW
« on: 2011.12.04, 05:43:42 »

 
I need help with this Rexx install script for Firefox. I got sick of installing Firefox manually, so I wrote this script. Just drop any Firefox zip file on the object and it automatically unzips it and installs firefox. It's still pretty ugly, but it works for me !

http://www.os2notes.com/os2firefoxdd.html




Also, for the Rexx programming guru's out there, can someone tell me how to parse the name from 'firefox-8.0.1.en-US.os2' to 'Firefox-8.0.1' for the name of the installation directory.

And I need a way to delete all the files and directories in a firefox directory, except 'firefox.exe', 'firefox!K.exe', and 'firefox.ico' using a Rexx script.

Greggory

« Last Edit: 2011.12.04, 13:32:05 by sXwamp » Logged
ivan
Hero Member
*****
Posts: 562


View Profile
« Reply #1 on: 2011.12.04, 18:18:51 »

Hi Greggory,

Have you had a look at Lars Erdmann's installer script on hobbes?  It might help you d what you want.

ivan
Logged
RobertM
Global Moderator
Hero Member
*****
Posts: 2017



View Profile WWW
« Reply #2 on: 2011.12.06, 01:13:16 »

Also, for the Rexx programming guru's out there, can someone tell me how to parse the name from 'firefox-8.0.1.en-US.os2' to 'Firefox-8.0.1' for the name of the installation directory.

Hi Greggory, assuming the naming convention is the same for each new one, it would be:

Code:
/* (assign file name to a var, such as fName for this example - using "Parse Arg" probably) */
Parse Var fName with fDir".en-US"JunkVar

And that's it! fDir now contains the directory up to but not including everything from ".en-US" onwards.

Now, if the file name variable (fName) contains the directory as well, there are multiple ways of "stripping" that out. Again, assuming a standardized naming convention, the script would look something like this:

Code:
/* (assign file name to a var, such as fName for this example - using "Parse Arg" probably) */
Parse Var fName with JunkVar1"firefox-"fDir".en-US"JunkVar2
fDir="firefox-"||fDir

Of course, you still need to append the actual base path/drive letter to the variable for the install... but that's easy.



And I need a way to delete all the files and directories in a firefox directory, except 'firefox.exe', 'firefox!K.exe', and 'firefox.ico' using a Rexx script.

Greggory

This is a little tiny bit more complex. But not too much more complex. Here's the simple but slower (runtime-wise) method:
First, build a directory tree of that sub-directory, then step through it. Delete all files that don't match those values.

Code:
/* Some script or function call - fDir assumed to be directory of Firefox and its sub-directories */
/* fDir is assumed to have NO trailing slash... ie: it should look like "f:\Apps\Firefox" - and NOT like "f:\Apps\Firefox\" */

/* Create Match list of do-not-deletes */
    NoDel.1='firefox.exe'
    NoDel.2='firefox!K.exe'
    NoDel.3='firefox.ico'
    NoDel.0=3  /* Set stem array length */


/* Read directory and all sub-directories and create file list in stem array filelist. */
/* We only care about the fully qualified path names, so use "O" option to drop dates, times, attribs, etc */
    rtc=SysFileTree(fDir||"\*","filelist","SO",)   

/* Create worker loops */
    Do A=1 to filelist.0    /* Loop through file list using count in stem base */
        /* Set delete flag to "Y"(es) */
        delfile="Y"
        Do B=1 to NoDel.0    /* Compare to each value in NoDel array */
            if Pos(Translate(NoDel.B),Translate(filelist.A))>0 then   /* found a match - using upper case to ensure proper matching */
            Do
                delfile="N"    /* Do NOT delete file */
                Leave         /* We can leave the inner loop and return to the "Do A" loop */
            End
        End
        if delfile="Y" then
        Do             /* unneeded Do/End pair, but neater and easier to read */
            rtc=SysFileDelete(filelist.B)    /* delete file */
            /* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
        End
    End


That should do it... a bit sloppily perhaps, but it will work very well.

Best,
Rob
Logged

|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|

sXwamp
Full Member
***
Posts: 223



View Profile WWW
« Reply #3 on: 2011.12.06, 02:39:46 »

Hi Robert,

Perfect thanks, someone else sent me the first part on how to format the name.  But I was having issues on the second part -- now I'm all set. Guess I should add Thunderbird and Seamonkey to the list too !!!

Cheers,

Greggory
« Last Edit: 2011.12.06, 02:52:00 by sXwamp » Logged
sXwamp
Full Member
***
Posts: 223



View Profile WWW
« Reply #4 on: 2011.12.06, 02:48:49 »

Hi Greggory,

Have you had a look at Lars Erdmann's installer script on hobbes?  It might help you d what you want.

ivan

Thanks, yes I'm going to see if he'll add this to his code or add his to my script.

Greggory
Logged
jep
Global Moderator
Sr. Member
*****
Posts: 402


View Profile
« Reply #5 on: 2011.12.06, 12:58:49 »

Also, for the Rexx programming guru's out there, can someone tell me how to parse the name from 'firefox-8.0.1.en-US.os2' to 'Firefox-8.0.1' for the name of the installation directory.

PARSE VALUE FILESPEC( full_path_name, 'N' ) WITH ff_name'.en-'.

And I need a way to delete all the files and directories in a firefox directory, except 'firefox.exe', 'firefox!K.exe', and 'firefox.ico' using a Rexx script.

Greggory

A shortend version of the code RobertM provided.
Code:
/* List files and delete each of them */

/* Create Match list of do-not-deletes, upper case! */
    NoDel.1='FIREFOX.EXE'
    NoDel.2='FIREFOX!K.EXE'
    NoDel.3='FIREFOX.ICO'
    NoDel.0=3  /* Set stem array length */

/* Read directory and all sub-directories and create file list in stem array filelist, take care of possible trailing back slash */
/* We only care about the fully qualified path names and in subfolders as well, so use "O" option to drop dates, times, attribs, etc */
    rtc = SysFileTree( STRIP( fDir, 'T', '\' )||"\*", "filelist", "SFO" )  

/* Create worker loops */
    Do A = 1 to filelist.0    /* Loop through file list using count in stem base */
        Do B = 1 to NoDel.0    /* Compare to each value in NoDel array */
            If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then   /* found a match - using upper case to ensure proper matching */
            Iterate A /* Jump to the next file in the list and don't process this one! */
        End
        rtc = SysFileDelete( filelist.A /* corrected from B to A */ )    /* delete file */
        /* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
/*        If rtc = 0 Then Say FileSpec( filelist.A, 'N' ) 'deleted' */
    End

Another way to do this:
Code:
           If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then   /* found a match - using upper case to ensure proper matching */
is to write
Code:
           If NoDel.B = Translate( FileSpec( filelist.A, 'N' ) ) Then
which will match files with the whole file name (no path) so that we don't get a positive match with
nofirefox.exe that we'd get with Pos( ... )

Compare this example:
filelist.A = 'C:\path\Firefox-8.0.1\nofirefox.exe'

Pos( NoDel.B, Translate( filelist.A ) ) > 0 ---> POS( FIREFOX.EXE, C:\PATH\FIREFOX-8.0.1\NOFIREFOX.EXE ) >0 that is 24 > 0 which equals TRUE
while the comparison
NoDel.B = Translate( FileSpec( filelist.A, 'N' ) ) ---> FIREFOX.EXE = NOFIREFOX.EXE equals FALSE


Each archive I've seen contain the folder "firefox", "thunderbird" etc. depending on content so you could probably use unzip32.dll directly in rexx to find out what package you're actually handling and unzip files accordingly. I found unzip32.dll useful once I tried it, but the documentation in Tips & Tricks is a must.
You could probably replace "firefox" in the array NoDel.1 to 3 with names from the path in the .zip-file (list with unzip32.dll). That way you could use one script to install Firefox, Thunderbird and Seamonkey. Smiley

//Jan-Erik
« Last Edit: 2011.12.06, 17:13:07 by jep » Logged
sXwamp
Full Member
***
Posts: 223



View Profile WWW
« Reply #6 on: 2011.12.06, 14:01:25 »

Thanks Robert and Jep,

This code above from Robert and modified code from Jep only deletes one file and ends.  I added a loop around the code to test it to see what happens. Both deletes all the files, but the last three files left are:

application.ini
blocklist.xml
chrome.manifest

Any tips or ideas what I'm going wrong Huh

There must be a logic error somewhere. I did have some progress messing around with it - the code below deletes all the file but the first item in the NoDel list - the other two get deleted.

The only thing I changed from Jeps code is below:


I changed:         rtc = SysFileDelete( filelist.B )    /* delete file */

to           :         rtc = SysFileDelete( filelist.A )    /* delete file */



Code:
CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir'

fDir ='Z:\Unzip\firefox-8.0.1.en-US.os2\firefox'

/* List files and delete each of them */

/* Create Match list of do-not-deletes, upper case! */
    NoDel.1='FIREFOX!K.EXE'
    NoDel.2='FIREFOX.EXE'
    NoDel.3='FIREFOX.ICO'
    NoDel.0=3  /* Set stem array length */

/* Read directory and all sub-directories and create file list in stem array filelist, take care of possible trailing back slash */
/* We only care about the fully qualified path names and in subfolders as well, so use "O" option to drop dates, times, attribs, etc */
    rtc = SysFileTree( STRIP( fDir, 'T', '\' )||"\*", "filelist", "SFO" )  

/* Create worker loops */
    Do A = 1 to filelist.0    /* Loop through file list using count in stem base */
        Do B = 1 to NoDel.0    /* Compare to each value in NoDel array */
            If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then   /* found a match - using upper case to ensure proper matching */
            Iterate A /* Jump to the next file in the list and don't process this one! */
 
        rtc = SysFileDelete( filelist.A )    /* delete file */

End

        /* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
        /* If rtc = 0 Then Say FileSpec( filelist.A, 'N' ) 'deleted' */
    End


All most there, need some more help please !


Thanks again,

Greggory
« Last Edit: 2011.12.06, 16:26:14 by sXwamp » Logged
jep
Global Moderator
Sr. Member
*****
Posts: 402


View Profile
« Reply #7 on: 2011.12.06, 17:11:39 »

Thanks Robert and Jep,

This code above from Robert and modified code from Jep only deletes one file and ends.  I added a loop around the code to test it to see what happens. Both deletes all the files, but the last three files left are:

I can't see any additional loop? But the required addition by you is there
fDir ='Z:\Unzip\firefox-8.0.1.en-US.os2\firefox'

application.ini
blocklist.xml
chrome.manifest

Any tips or ideas what I'm going wrong Huh
Do any of these files have the read only flag set (settings notebook)?!
If so, then you'll have to use e.g.
'attrib "'||filelist.A||' -r -a -s -h'

Another possible problem may be if there's any application that has opened those files.
Output the return code from SysFileDelete (error checking)
If rtc <> 0 THEN
  SAY 'Could not delete' filelist.A', error code:' rtc

There must be a logic error somewhere. I did have some progress messing around with it - the code below deletes all the file but the first item in the NoDel list - the other two get deleted.

The only thing I changed from Jeps code is below:


I changed:         rtc = SysFileDelete( filelist.B )    /* delete file */

to           :         rtc = SysFileDelete( filelist.A )    /* delete file */

My fault! Of course it should be filelist.A and the End instruction has to be moved before the SysFileDelete so that it do the check for all (3) items in list before it delete the file.

See my corrections and additions with attrib etc.
Code:
CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
CALL RxFuncAdd 'SysRmDir', 'RexxUtil', 'SysRmDir'

fDir ='Z:\Unzip\firefox-8.0.1.en-US.os2\firefox'

/* List files and delete each of them */

/* Create Match list of do-not-deletes, upper case! */
    NoDel.1='FIREFOX!K.EXE'
    NoDel.2='FIREFOX.EXE'
    NoDel.3='FIREFOX.ICO'
    NoDel.0=3  /* Set stem array length */

/* Read directory and all sub-directories and create file list in stem array filelist, take care of possible trailing back slash */
/* We only care about the fully qualified path names and in subfolders as well, so use "O" option to drop dates, times, attribs, etc */
    rtc = SysFileTree( STRIP( fDir, 'T', '\' )||"\*", "filelist", "SFO" )  

/* Create worker loops */
    Do A = 1 to filelist.0    /* Loop through file list using count in stem base */
        'attrib "'||filelist.A||' -r -a -s -h' /* turn off read only, archive, s...omething */
        Do B = 1 to NoDel.0    /* Compare to each value in NoDel array */
            If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then   /* found a match - using upper case to ensure proper matching */
            Iterate A /* Jump to the next file in the list and don't process this one! */
        End /* Has to be placed before code that delete the file */
        rtc = SysFileDelete( filelist.A )    /* delete file */
        /* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
        If rtc = 0 Then Say FileSpec( filelist.A, 'N' ) 'deleted'
        Else SAY 'Could not delete' filelist.A', error code:' rtc
    End
<snip>

//Jan-Erik
« Last Edit: 2011.12.08, 09:12:14 by jep » Logged
sXwamp
Full Member
***
Posts: 223



View Profile WWW
« Reply #8 on: 2011.12.07, 13:53:24 »


I got it done Grin

http://www.os2notes.com/os2firefoxdd.html


Thanks Andre, Robert, and Jan-Erik - for all the help !!!


Greggory
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!