El Foro

Nox (Retail CD) script

Autor Respuestas
horsemanoffaith Thursday 17 January 2013 at 3:51
horsemanoffaithAnonymous

You asked me to create a new topic about my script, so here it is. Please let me know if there is anything I can do to shorten it. This works perfectly on my Ubuntu 12.04.01 LTS 64-bit distro.

#!/bin/bash
# Date : (2013-01-09 10-09)
# Last revision : (2013-01-09-10-09)
# Wine version used : 1.4.1
# Distribution used to test : Ubuntu 12.04.01 LTS 64-bit
# Author : horsemanoffaith

[ "$PLAYONLINUX" = "" ] && exit
source "$PLAYONLINUX/lib/sources"
  
TITLE="Nox"
PREFIX="Nox"
WORKING_WINE_VERSION="1.4.1"
  
POL_SetupWindow_Init
POL_Debug_Init
  
POL_SetupWindow_presentation "$TITLE" "Westwood Studios / Electronic Arts" "http://www.ea.com" "horsemanoffaith" "$PREFIX"
  
POL_Wine_SelectPrefix "$PREFIX"
POL_System_SetArch "x86"
POL_Wine_PrefixCreate "$WORKING_WINE_VERSION"

POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "setup.exe"
POL_SetupWindow_message "$(eval_gettext 'Warning- once installation is complete, please select the RETURN TO WINDOWS radio button and click OK. Nox WILL NOT run without the update patch. This patch will be applied after the NOX window is closed.')" "$TITLE"

cd "$CDROM"
POL_Wine start /unix "autorun.exe"
POL_SetupWindow_message "$(eval_gettext 'Please click NEXT once Nox install is complete')" "$TITLE"

cd "$HOME"
POL_SetupWindow_wait "$(eval_gettext 'Downloading NoxEng1.2 Update')" "$TITLE"
POL_Download "http://ubuntuone.com/7RYmf1uj6SAU7otuOIjwNZ"
mv "7RYmf1uj6SAU7otuOIjwNZ" "NoxEng12.exe"

POL_SetupWindow_message "$(eval_gettext 'Creating temporary folders')" "$TITLE"
mkdir "nox"
cd "$HOME/nox"
mkdir "music"
mkdir "movies"

cd "$CDROM"
POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "setup.exe"
POL_SetupWindow_message "$(eval_gettext 'Please wait while music and movie files are transferred')" "$TITLE"
cp -R "$CDROM/install/music"/* "$HOME/nox/music"
cp -R "$CDROM/install/movies"/* "$HOME/nox/movies"
cp "$CDROM/install/nox.ico" "$REPERTOIRE/icones/32"
cp "$CDROM/install/nox.ico" "$REPERTOIRE/icones/full_size"

cd "$REPERTOIRE/wineprefix/Nox/drive_c/Westwood/Nox"
mkdir "music"
mkdir "movies"

cd "$HOME"
mv "nox/music" ".PlayOnLinux/wineprefix/Nox/drive_c/Westwood/Nox"
mv "nox/movies" ".PlayOnLinux/wineprefix/Nox/drive_c/Westwood/Nox"
rmdir "nox"


POL_SetupWindow_message "$(eval_gettext 'Regretfully, the NoxEng12.exe patch must be applied manually. Please navigate to your PlayOnLinux main screen and click CONFIGURE. On your PlayOnLinux configuration screen, please select Nox, then click on the MISCELLANEOUS tab. Click on the RUN A .EXE FILE IN THIS VIRTUAL DRIVE button and navigate to your home directory. Find the NoxEng12.exe file, select it, then click Open. This will install the patch for you. Please click NEXT when this step is complete.')" "$TITLE"

rm "NoxEng12.exe"

Set_OS winxp
 
POL_SetupWindow_VMS "4"

POL_Shortcut "NOX.EXE" "$TITLE"

POL_SetupWindow_message "$TITLE has been successfully installed!" "$TITLE"

POL_SetupWindow_Close
 
exit
petch Friday 18 January 2013 at 8:16
petch
Developer

Hi horsemanoffaith,

I don't think the script can be made much shorter, so I'll just give some general comments:

POL_System_SetArch "x86"

I think this is the default, but ok


POL_SetupWindow_message "$(eval_gettext 'Warning- once installation is complete, please select the RETURN TO WINDOWS radio button and click OK. Nox WILL NOT run without the update patch. This patch will be applied after the NOX window is closed.')" "$TITLE"

Well, this is a general rule in PlayOnLinux not to run the program directly from the installer (and POL 4.1.x displays it one upon first installation), but ok


POL_Wine start /unix "autorun.exe"
POL_SetupWindow_message "$(eval_gettext 'Please click NEXT once Nox install is complete')" "$TITLE"

You should use POL_Wine_WaitExit "$TITLE" (one less click for the user), or even
POL_Wine_WaitBefore "$TITLE"
POL_Wine "autorun.exe"

if it works (recommended form).


cd "$HOME"
POL_SetupWindow_wait "$(eval_gettext 'Downloading NoxEng1.2 Update')" "$TITLE"
POL_Download "http://ubuntuone.com/7RYmf1uj6SAU7otuOIjwNZ"

- POL_Download will quickly overwrite the message, so it's mostly useless
- it's always recommended to specify a MD5 hash with POL_Download to validate it
- I guess it's your Ubuntuone account, is it ok to host this file there, and for how long will it be there?
- $HOME is not appropriate for temporary stuff, use $POL_USER_ROOT/tmp for that


cd "$HOME"
POL_SetupWindow_wait "$(eval_gettext 'Downloading NoxEng1.2 Update')" "$TITLE"
POL_Download "http://ubuntuone.com/7RYmf1uj6SAU7otuOIjwNZ"

- if you really want to change current display, use POL_SetupWindow_wait (non blocking). That said, mkdirs are fast, you could drop that altogether
- and again, $HOME is not the right place for temporary stuff


cp -R "$CDROM/install/music"/* "$HOME/nox/music"
cp -R "$CDROM/install/movies"/* "$HOME/nox/movies"

- Consider using POL_System_CopyDirectory, along with a POL_RequiredVersion "4.0.18" (to put right after POL_SetupWindow_Init) since it's only available starting from that version. Agree, it's not documented :/
- Why aren't you copying the files directly into the virtual drive without this intermediary temp location?
- How comes the installer doesn't copy those files over?


cp "$CDROM/install/nox.ico" "$REPERTOIRE/icones/32"
cp "$CDROM/install/nox.ico" "$REPERTOIRE/icones/full_size"

I think files should really be PNGs; Best (and standard) way is to prepare the icon files and to put them on the server, I'll help you with that if needed.
Also, $REPERTOIRE is deprecated, use $POL_USER_ROOT instead.


POL_SetupWindow_message "$(eval_gettext 'Regretfully, the NoxEng12.exe patch must be applied manually. Please navigate to your PlayOnLinux main screen and click CONFIGURE. On your PlayOnLinux configuration screen, please select Nox, then click on the MISCELLANEOUS tab. Click on the RUN A .EXE FILE IN THIS VIRTUAL DRIVE button and navigate to your home directory. Find the NoxEng12.exe file, select it, then click Open. This will install the patch for you. Please click NEXT when this step is complete.')" "$TITLE"

Really, what happens you if do POL_Wine NoxEng12.exe? I don't understand why it could be made to work, short of bugs.


POL_SetupWindow_message "$TITLE has been successfully installed!" "$TITLE"

Personally I don't like those "last messages", a matter of taste I suppose.

Regards, Pierre.

Editado por: petch

horsemanoffaith Monday 4 February 2013 at 2:43
horsemanoffaithAnonymous

Pierre,

      I updated my script, which I will share with you after I write this post.

      I deleted the default architecture line and changed from the autorun.exe to the setup.exe file. I tried the suggestions you made with both POL_Wine_WaitExit and POL_Wine_WaitBefore, but for some reason I was unable to get POL to wait until after the main files were installed. I had to put in a POL_SetupWindow_message to stop the installer from moving forward while the system was installing the main game files. I also deleted any instances of $HOME and $REPETOIRE from the script. 
      I am not aware of how to make an MD5 hash for the file that I am hosting, so any advice would be helpful. Also, if this becomes an official POL script, can the file be moved to the POL servers? I'll be happy to continue hosting the file (forever, as far as I'm concerned- I don't use cloud storage all that much) if that's not the case.
      I was also able to figure out how to transfer the files from the CD-ROM directly into the virtual drive, as well as executing the NoxEng1.2 patch. I'm not exactly sure why the installer does not copy the music and movie files during the installation, but for some reason it simply does not do so. I purposefully left the icon portion of the script out so that the icons can be prepared properly.
      Please let me know what you think of the new script!

      horsemanoffaith



Edited script:
#!/bin/bash
# Date : (2013-02-03 17-48)
# Last revision : (2013-02-03-17-48)
# Wine version used : 1.4.1
# Distribution used to test : Ubuntu 12.04.01 LTS 64-bit
# Author : horsemanoffaith

[ "$PLAYONLINUX" = "" ] && exit
source "$PLAYONLINUX/lib/sources"

TITLE="Nox"
PREFIX="Nox"

POL_SetupWindow_Init
POL_RequiredVersion "4.0.18"
POL_Debug_Init

POL_SetupWindow_presentation "$TITLE" "Westwood Studios / Electronic Arts" "http://www.ea.com" "horsemanoffaith" "$PREFIX"

POL_Wine_SelectPrefix "$PREFIX"

POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "setup.exe"

cd "$CDROM"
POL_Wine "setup.exe"
POL_SetupWindow_message "$(eval_gettext 'Please click NEXT once Nox install is complete')" "$TITLE"

mkdir "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox/music"
mkdir "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox/movies"

POL_System_CopyDirectory "$CDROM/install/music" "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox/music"
POL_System_CopyDirectory "$CDROM/install/movies" "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox/movies"

cd "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox"
POL_Download "http://ubuntuone.com/7RYmf1uj6SAU7otuOIjwNZ"
mv "7RYmf1uj6SAU7otuOIjwNZ" "NoxEng12.exe"
POL_Wine "NoxEng12.exe"

Set_OS winxp

POL_Shortcut "NOX.EXE" "$TITLE"

POL_SetupWindow_Close

exit

Editado por: horsemanoffaith

petch Monday 4 February 2013 at 9:35
petch
Developer

Hi horsemanoffaith,


      I deleted the default architecture line [...]

Quote from horsemanoffaith


But you also removed POL_Wine_PrefixCreate "$WORKING_WINE_VERSION", but this
statement is necessary, that's what creates the virtual drive if it
doesn't already exist.


I tried the suggestions you made with both POL_Wine_WaitExit and POL_Wine_WaitBefore, but for some reason I was unable to get POL to wait until after the main files were installed.

Quote from horsemanoffaith


This is most probably related to lack of POL_Wine_PrefixCreate, and the use of system Wine by default in this case; System Wine is not in the $PATH on Ubuntu, and it breaks some functionality; There's some code to try to find it in hardcoded places in PlayOnLinux 4.1.x, but I've recently found a small bug that could very well make it miss it.
Anyway, using a non-system Wine should fix your problem


I am not aware of how to make an MD5 hash for the file that I am hosting, so any advice would be helpful.

Quote from horsemanoffaith


Just run the md5sum command on it, and it will display its MD5 hash (the 32 hexadecimal characters thing)


Also, if this becomes an official POL script, can the file be moved to the POL servers?

Quote from horsemanoffaith


It may depend on file licensing, it must be redistributable. Otherwise from technical point of view there should be no problem, we do that for lots of files already.

Regards,
Pierre.

horsemanoffaith Thursday 7 February 2013 at 7:20
horsemanoffaithAnonymous

I put the POL_Wine_PrefixCreate and "$WORKING_WINE_VERSION" back in, moved the "POL_Wine_WaitExit" line from before the POL_Wine "setup.exe" to after, and put in an md5 checksum. Here's the edited script.

#!/bin/bash
# Date : (2013-02-06 20-20)
# Last revision : (2013-02-06 20-20)
# Wine version used : 1.4.1
# Distribution used to test : Ubuntu 12.04.01 LTS 64-bit
# Author : horsemanoffaith

[ "$PLAYONLINUX" = "" ] && exit
source "$PLAYONLINUX/lib/sources"

TITLE="Nox"
PREFIX="Nox"
WORKING_WINE_VERSION= "1.4.1"

POL_SetupWindow_Init
POL_RequiredVersion "4.0.18"
POL_Debug_Init

POL_SetupWindow_presentation "$TITLE" "Westwood Studios / Electronic Arts" "http://www.ea.com" "horsemanoffaith" "$PREFIX"

POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "$WORKING_WINE_VERSION"

POL_SetupWindow_cdrom
POL_SetupWindow_check_cdrom "setup.exe"

cd "$CDROM"
POL_Wine "setup.exe"
POL_Wine_WaitExit "$TITLE"

mkdir "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox/music"
mkdir "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox/movies"

POL_System_CopyDirectory "$CDROM/install/music" "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox/music"
POL_System_CopyDirectory "$CDROM/install/movies" "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox/movies"

cd "$POL_USER_ROOT/wineprefix/Nox/drive_c/Westwood/Nox"
POL_Download "http://ubuntuone.com/7RYmf1uj6SAU7otuOIjwNZ" "3080102586633a684fd64ea19f52f024"
mv "7RYmf1uj6SAU7otuOIjwNZ" "NoxEng12.exe"
POL_Wine "NoxEng12.exe"

Set_OS winxp

POL_Shortcut "NOX.EXE" "$TITLE"

POL_SetupWindow_Close

exit
petch Thursday 7 February 2013 at 9:24
petch
Developer

Hi,
The script looks ok to me, you can submit it to the repository if you want and request signing when you're done.
I'll use the same graphic resources as the other Nox script, unless you prefer providing yours?

Regards,
Pierre;
horsemanoffaith Friday 8 February 2013 at 5:11
horsemanoffaithAnonymous

     Okay, that sounds great! When you say graphic resources, are you talking about icons? If so, that would be fantastic. I just pulled the icons off the CD-ROM and stuck them in the icones folder so that POL would use them. Also, how do I go about getting the update file (NoxEng12.exe) to you so that it's on your servers? BTW, this file came from one of the sites that host patches, so I'm pretty sure it would be redistributable. There were no warnings that the file couldn't be copied or shared from the site I got it from. Please let me know if there is anything else I need to do to get this script posted.
     I am also working on a script for Zoo Tycoon 2: Zookeeper Edition for CD only. I have it working on my version of POL with a manual script, but every time I try to do an automated script, it fails. I'll post that one here once I get it working.
horsemanoffaith Friday 8 February 2013 at 7:09
horsemanoffaithAnonymous

By the way, how do I submit it to the repository?
petch Friday 8 February 2013 at 10:45
petch
Developer

I also mean left

and top

resources used during installation.
But if you have a better icon than

that could also be interesting.

I you confirm the patch has MD5 hash 3080102586633a684fd64ea19f52f024, I uploaded it to http://files.playonlinux.com/NoxEng12.exe

To submit a script, click on "Supported software" at the left on this page, then "New installer". When you're done, there should be a link to request script signing.
horsemanoffaith Saturday 9 February 2013 at 4:42
horsemanoffaithAnonymous

Wow, those graphics are great! Those would be awesome for the cd script installer! Unfortunately, the icon you have is the only one that I've ever seen for Nox. I can confirm that the MD5 hash you posted is correct. I would assume that I would have to edit my script to reflect the new location of NoxEng12.exe, unless you want me to post it as-is and you can make the edits for the graphics and the patch file. Thanks for your help! I will try to get the script for Zoo Tycoon 2: Zookeeper Edition working as soon as I can!
petch Saturday 9 February 2013 at 8:35
petch
Developer

Silly me, I didn't notice the hash was already in your script 8)

Ok;
For the installation resources, just adding
POL_GetSetupImages "http://files.playonlinux.com/resources/setups/$PREFIX/top.jpg" "http://files.playonlinux.com/resources/setups/$PREFIX/left.jpg" "$TITLE"

before the POL_SetupWindow_Init line should be enough;
For the icon, add "$TITLE.png" as third parameter to POL_Shortcut, like in
POL_Shortcut "NOX.EXE" "$TITLE" "$TITLE.png"

with those changes and the new download URL for the patch, the script should be ready for the repository :)
horsemanoffaith Saturday 9 February 2013 at 23:25
horsemanoffaithAnonymous

Coolness! I will do a test-run on my computer and if it works, I will upload the script to the repository!!
horsemanoffaith Sunday 10 February 2013 at 8:23
horsemanoffaithAnonymous

Hey, I was working on a script for Zoo Tycoon 2: Zookeeper Collection, and I found a problem with my script for Nox. In the WORKING_WINE_VERSION, there is a space between the = and the first ". That space causes the PlayOnLinux to revert to the system version. I've already submitted my script to the repository, but it needs to be changed. It said that once I submitted the script that I could not edit it anymore. Just wanted to give you a heads up!
petch Sunday 10 February 2013 at 10:38
petch
Developer

Hi,

In the WORKING_WINE_VERSION, there is a space between the = and the first ". That space causes the PlayOnLinux to revert to the system version.

Quote from horsemanoffaith

Well, a space here make Bash interpret the command

WORKING_WINE_VERSION= "1.4.1"

be interpreted as `run the command "1.4.1" with the variable $WORKING_WINE_VERSION temporarily set to en empty string', which is not what you wanted. Fixed.

I also had to change script name, because it must match the value of the $TITLE variable.

Editado por: petch

horsemanoffaith Sunday 10 February 2013 at 20:17
horsemanoffaithAnonymous

Thanks for all your help, Petch! This has been a great learning experience for me!
petch Sunday 10 February 2013 at 20:52
petch
Developer