Testing: Multi Distribuition Bmax/Dep Installer

Archives Forums/Linux Discussion/Testing: Multi Distribuition Bmax/Dep Installer

dawlane(Posted 2013) [#1]
Something weird is happening to this forum again.


dawlane(Posted 2013) [#2]
Greeting to all.

WARNING: I know some of you will just skip the stuff below and just jump straight in and try to run the code. But remember this is a script and can do serious damage to your system if something isn't right when run with elevated privileges . SO YOU HAVE BEEN WARNED. If any thing try it on a virtual machine like virtualbox first before using it on working system. I don't know how this script would react if run on in a multi-user environment like a server ( as unlike some around here I haven't got access to one ) so if you know what you are doing and are better than me at scripting in bash ( which more than likely you will be ) then have a go. You should always consider anything post in this thread as a work in progress and treat such code as alpha/beta testing. It should also be note that a package removed may remove more than just the named packages so if you are on real hardware be careful.

As some of you know from previous posts I've been working on an install script that will install the dependencies for using Blitz Max. And I think it's at a point where it should be useful to take some of the pain out of getting things building with BlitzMax on Linux.

Don't forget some of the graphic drivers that come with the distributions are the free versions and may not be up to the task of working with applications written in BlitzMax. So if there is a problem you will have to install the proprietary drivers from the graphics cards hardware vendor.
SIDE NOTE: If any out there are using a dual monitor set up. Blitz Max applications don't seem to like twin view. On my system I had to set it up as separate screens and do a bit of xorg.conf modification.

So far I have got those listed below to work: 32/64bit Desktop versions only.
Debian 7.x
*ubuntu 12.04, 12.10, 13.04
Linux Mint 13, 14, 15 ( ubuntu ) the debian version is known as LMDE
openSUSE 12.3
Fedora 18
Mageia 2, 3 (64bit version has to have PNG MMX assembly disabled to get the gnu compiler to compile).
PCLinuxOS (64bit version has to have PNG MMX assembly disabled to get the gnu compiler to compile).
Arch Linux (64bit version has to have PNG MMX assembly disabled to get the gnu compiler to compile).

Remember BRL recommend ubuntu and if your using a different distribution that differs significantly from Ubuntu then support could be sketchy.

There are three scripts that can possibly be used.
1) The main install script named bmax-install
2) A installation script for BlitzMax named just max. And relies on bmax-install to work.
3) A patching script named patcher_148 to automatically fix version 1.48 for a few issues that have arisen with the latest distributions. This script can be run independently with an extracted copy of BlitzMax and should be placed in the same directory as BlitzMax not in the BlitzMax directory it's self.

To find your way around these files the, important sections have got a #*name field so you can jump to that location in the script using the editors FIND function. To get to the list of these use #*quick

A description of what the files are meant to do.

Bmax-install
This is what does all the work of installing the dependencies. It first checks the system to get the distribution name and release number if lsb_release is supported else it will try just for a name for a time being.
It then uses these to select the package manager and a list of packages to install for that distribution.
Before calling the actual package manager it calls a function where code should be placed for any special house keeping that needs to be done ( like adding an architecture to dpkg on debian 64bit ) before the package manager is finally run.
There is also a function to call anything that needs to be done after package installation. Note linking 32bit libraries for a 64bit distribution are done separately and don't use that function.
After the packages have been installed and depending on which option was selected and if the there is a file named “max”. Then it will run that file to install or remove Blitz Max to/from /opt else it will exit.
There is also an option to remove packages, but I wouldn't recommend that as you never no what else will get removed.
If the install was interrupted there is an option (-l) to remove any broken links. This has been disabled and can be enabled by removing the comment marker for that option in the script. It's been disabled as it it will remove any broken link not just those made by this script. And I can't say if it will work on all distributions.

max
This files job is just to install Blitz Max to /opt directory and make links in /usr/local/bin and well as adding a menu and desktop launcher if you are using a full desktop environment (e.g gnome/KDE). It will also relocate the modules directory to the installers home. This file should only be run in conjunction with bmax-install as it could be unpredictable otherwise. This file will also call the patch file if there is one.

patcher_148
This files job is to fix the sound and link issue in Blitz Max version 1.48. To cut it short it patches appstub, threads, freeaudioaudio, freeaudio, alsadevice.cpp and adds pulseaudiodevice.cpp.
And makes the default audio driver selected pulseaudio. You can also pass arguments for addition patches that can be added to a script. New functions in this script should have the format "patch_function_name".
Currently the only argument you can pass is png_no_mmx_code.

NOTE: If there is an error in the script or it does something that it not meant to do then please post.....
1) script version number
2) distribution listing year and revision (line 53 in bmax-install)
3) what Linux distribution it is with release number
4) which script and the line the error occurred in. e.g bmax-install line 500, max line 10, patcher line 5.
5) a console output.
And list any thing that it's doing/not doing e.g. menu item not being see etc. And any one posting “It's not working” see the line below.
NOTE: If you cannot be bothered to do those items above then I cannot be bothered to help or fix it.
The only exception to the above is if you run a BlitzMax compiled application and you get a error. You should recompile the application in debug mode. And then try again and see what information it outputs. Also try to run the applications from the terminal console to get out put and you should try ldd to get information on required libraries. e.g. ldd /opt/BlitzMax/MaxIDE
It is possible that during a release change that things will break.

NOTE: If you want to help by posting package list names. Please post
1) distribution and release
2) the package manager used
3) the highest know package that will automatically select the other packages in a group that Blitz Max uses.
For examples g++ will select gcc which will select libc6-dev.
And libglu1-mesa-dev will select libX11-dev etc.
4) and any special things that need to be done to get multi-arch support enabled.

If I see and full update code I will test it and if it works I will and if possible update this first post to reflect the new script.

There is also a few rules that should be followed if any one should decide to repost these scripts in there entirety with there own alterations. The details are at the top of each script.

EDIT:
OK there was three code boxes, but when I updated the code from v0.3m to the latest version (0.4) some thing weird started to happen to the post. Guess there is a limit to how big a post can get :o.

So now the files are supplied in zip file format. This was not something that I want to do, but doing it this way makes sure that there should be no problems with copy and pasting code.
bmax-install-0.5-3.zip

Below are links to text file that are contained within the zip file. Make a directory and use right click and "save as" and put them there or the web browser will open them up.
README
adding-a-distro
adding-a-patch
bmax-install
max
patcher_148
distribution-notes

Using the script files.

Make sure that the file permissions for bmax-install are set the execute. If you do not wish to install BlitzMax to /opt then rename or remove it doing this means that you will have to patch and move the BlitzMax directory and make your own links etc.

Now place a copy of the tar.gz archive of BlitzMax 1.48 into the same directory as these files.
If you would like an icon to be installed then place a png file renamed name icon.png in the directory where the scripts are. It will be detected and copied to the BlitzMax directory.

Tip: If you haven't got one then one way is to open the BlitzMax archive and extract the B-Max.png found in sample/breakout/media. Resize it to 48x48 in an image editing tool and export it as icon.png to the scripts location.

Now open a terminal and change directory to it
cd Desktop/bmax-install

Before the script is run make sure the system is up to date. Use the distributions graphic update tool for this unless you know how to do it from the command line.

You now needed to run the script with root privileges. This depends on the distribution on how this is achieved. In some this is just running the script like ` sudo ./bmax-install ` in others you have to execute the su command then the script can be run like so ` ./bmax-install. `

Now type: ./bmax-install -h

You will then see all the options. The default is just to get the required packages so you can move BlitzMax and patch manually, but you will have to do any system links yourself other than those that are created by default for the 64bit version of Linux.

The options:
-i : Installs all the packages and places BlitzMax into /opt and sets up links so that who ever did the install is the only one who can use it.
-u : Removes all the packages,links and BliztMax. But not build tools g++ and multiarch libs for the 64bit.
-p : Just installs the packages and any links for the 64bit version of Linux.
-r : Just removes the packages and any links for the 64bit version of Linux.
-m : Just installs BlitzMax to /opt and set up links same as -i
-n : Just removes BlitzMax.
-l : Removes any broken system links. This is disabled by default and can be enabled by removing the # comment marker in the install part of the code.

So typing: sudo ./bmax-install.sh -i
will install everything. If all files a present and named correctly.

Once the script has been run and every thing has installed and you included the max install script then you will be able to start BlitzMax IDE from the command line using MaxIDE or maxide or use the link on your desktop. You can also use bmk from the command line too. Don't forget that you need to rebuild the modules, but make sure that if you used the super user (su) command that you make your self back to a normal user. Typing “exit” usually does this. If you don't and you use the command line then you will have problems later building modules or code.

As always constructive suggestions welcome.


Blitzplotter(Posted 2013) [#3]
I'd like to reiterate dawlane's point:

But remember this is a script and can do serious damage to your system if something isn't right when run with elevated privileges . SO YOU HAVE BEEN WARNED. If any thing try it on a virtual machine like virtualbox first before using it on working system.


If any thing try it on a virtual machine like virtualbox
I'm gonna give it a whirl within VMWare Player with Mint 15, I like Murray Mint's and yesterday Andy Murray was Mint! I'm sure I've got a Mint Installation on one of my VM's already.

I don't even know what native package manager Mint uses, I'll soon find out. Installing VMWare tools in Mint is a little more of a winding path in Mint than Debian, I do like to be able to 'full-screen' my VMWare Linux installs. Okay, Mint playing in lurvly 1920x1200, now on with Dawlane's Installation script:




Blitzplotter(Posted 2013) [#4]
Hi,

My bash scripting is a bit rusty - don't you need open parentheses within case / esac select statements?

removed some double semi-colons & added some open parentheses to get the script to run? Line 567 has some double semi-colons. I am currently using:

1)0.31
Linux Mint version 15 within VMWare Player: Please see screen grab (coming):


dawlane(Posted 2013) [#5]
My bash scripting is a bit rusty - don't you need open parentheses within case / esac select statements?

Read is http://wiki.bash-hackers.org/syntax/ccmd/case
The thing with bash is that there's more than one way to do the same job.

Line 567 has some double semi-colons
oops missed that. Serves me right for making a minor alteration late at night just be for posting. I shall update it, but I don't think that deserves a version update. I will have to double check and make sure that there are no double types.

Edit: Got to get a new keyboard as the one I'm using at the moment is awful to use. Had a little accident with a cup of coffee.


Blitzplotter(Posted 2013) [#6]
Here is the code I've modified so far - it has a version 0.31 in it - obviously this can be scrubbed.

Thanks for the link to bash scripting for rusty folk ;)

[EDIT]

Confession - as you can see from the screengrab the directory I'm working from is something other than 'bmax-install', so I didn't follow this step to the letter - my bad. Moving my files around now to adhere to the instructions.

Now script creation.

Make a directory on you desktop and call it bmax-install and within this directory make an empty text file ( or more if you want to automatically install and patch BlitzMax) with no extensions and named it...

bmax-install






[EDIT] coffee + keyboard = sticky keys.....


dawlane(Posted 2013) [#7]
@Blitzploter: you was right about your bash script being rusty. You removed the ;; at the end of each statement that singles that, that condition has ended.

e.g. Your code
case "${option}" in
i) INSTALL=0;
u) INSTALL=1;
p) INSTALL=2;
r) INSTALL=3;
m) INSTALL=4;
n) INSTALL=5;
l) INSTALL=6;
h) usage; exit 0;
*?) usage; exit 0;
esac

Should be
case "${option}" in
i) INSTALL=0;;
u) INSTALL=1;;
p) INSTALL=2;;
r) INSTALL=3;;
m) INSTALL=4;;
n) INSTALL=5;;
l) INSTALL=6;;
h) usage; exit 0;;
*?) usage; exit 0;;
esac

The only mistakes I did was to add one too many ; the the return statement that was out side of case/esac that what would have stopped it in its tracks and two functions for different package managers that had the same name ( copy & paste maybe quick but it's a bugger to find buggs in a script ). The opening parentheses are optional on a case and you must ensure that there is a space before/after certain commands or bash get confused. You wouldn't believe the trouble that caused me.
Edit: And just forgot it to add a -f option for the if statement when seeing if the max file exists.
Thing is this is fixed on the current version that I'm working on at the moment, currently trying to add support for Mageia 3. But the 64bit version doesn't like the version of png that comes with BlitzMax. It's a MMX instruction issue and the gcc compiler doesn't like it. So I've touched up the first script and give it a letter "m" for minor fix.

Copy and paste the bmax-install script again in the first post I did and try again.


dawlane(Posted 2013) [#8]
If I see and full update code I will test it and if it works I will and if possible update the first post.


Blitzplotter(Posted 2013) [#9]
Ahhh, thanks for the feedback - was about to delve into some B3D, but I'll crack open my Mint again ;) PS - its only been 6 years since I did some bash scripting - just needed to blow away those cobwebs ;)

You wouldn't believe the trouble that caused me.
I think I'd forgotten the fun you could have with bash scripting, its all flooding back.

looking promising, Mint reports:

BMAX-INSTALL: apt-get is installing packages. Please wait...


dawlane(Posted 2013) [#10]
It's been longer for me had to dig out my copy of "Unix in a Nutshell" for references and scan the net. I don't think that I have missed any thing with the fixes, but just check to make sure.


Blitzplotter(Posted 2013) [#11]
Tried to find a scripting reference I used 7 years ago, typically it was on the shelf at the top of the stairs until last week - did you think I could find it this morning though?

I'd to 'chmod u+x bmax-install' to get it to execute.

Success - good work dawlane!

I've gotta have a quick peek at line 237 & 154 of max now though....




dawlane(Posted 2013) [#12]
Thing is with bash some things that will work with one version; isn't guaranteed to work on another. One version ignores scripting errors while another will choke and die.

The EOF error usually happens if then end EOF has any characters in front of it. Think I put a comment there about it.
Edit: I did but not a like I did below.

e.g.
cat > testfile <<EOF
ehco "yes";
EOF # NOTE DON'T put any thing before this on this line or it fails ( or after? )

Think I should have kept it as echo "blah" >> testfile.
If you want some to blame then blame Derron for suggesting it ;)


Blitzplotter(Posted 2013) [#13]
If you want some to blame then blame Derron for suggesting it ;)
Heh heh - have just been trying to debug (with limited success....) ;)


dawlane(Posted 2013) [#14]
Replace the
cat > $INSTALLER/.local/share/applications/MaxIDE.desktop <EOF
everything in side.
EOF

with this


I hope to god the the patcher_148 file works as it uses the same bloody thing. I think I didn't update the original for that it's in another thread.
I didn't it's here http://www.blitzbasic.com/Community/post.php?topic=100580&post=1191226 if that fails.

If you try again and it says something about max being installed use option -n and then try again with option -m.


dawlane(Posted 2013) [#15]
Updated max and patcher_148 and KILLED THE CATS ..... as they looked like the was causing a few problems. At the moment can't add bmax-install v0.4 yet with Mageia 3 added to it as the 64bit version gcc on that version hates MMX. See here http://www.blitzbasic.com/Community/posts.php?topic=100741


Blitzplotter(Posted 2013) [#16]
Thanks Dawlane, will give it a whirl later , am on android just now.


dawlane(Posted 2013) [#17]
OK tried to update the scripts in the first post but something weird started to happen. Only got half of the post and for some reason a second post was added that broke the formatting of the script so now I've had to add this as a zip file which I didn't really want to do. I guess that the must be a limit to how big a post can be.

New version bmax-install-0.4.zip
Mageia 2, 3 added.

Edit: updated the contents of the zip file to include a few instruction if any one wants to add a few distributions of patches. And placed links to on the opening post to individual files.


Blitzplotter(Posted 2013) [#18]
Oh, will give that a quick whirl. Mint is better than I gave it credit for - I nievely thought zip extension - I'[ll windows that first then, but then I thought, soddit - why not try it within my VMWare Mint - whaddya know - it extracts it despite the .zip, sweet.

I'm so getting more sold on the recent Linux derivatives - the GUI file manipulation in tandem with the terminal oriented stuff is just cool.


dawlane(Posted 2013) [#19]
it extracts it despite the .zip, sweet.
That's because zip file format is like treading in dog poop.... It get everywhere.
The archive manager that comes with mate (Engrampa) can create archives with following formats:
* Tar (.tar) archives, including those compressed with
gzip (.tar.gz, .tgz), bzip (.tar.bz, .tbz), bzip2 (.tar.bz2, .tbz2),
compress (.tar.Z, .taz), lzip (.tar.lz, .tlz), lzop (.tar.lzo, .tzo),
lzma (.tar.lzma) and xz (.tar.xz)
* Zip archives (.zip)
* Jar archives (.jar, .ear, .war)
* 7z archives (.7z)
* iso9660 CD images (.iso)
* Lha archives (.lzh)
* Single files compressed with gzip (.gz), bzip (.bz), bzip2 (.bz2),
compress (.Z), lzip (.lz), lzop (.lzo), lzma (.lzma) and xz (.xz)

Engrampa doesn't perform archive operations by itself, but relies on
standard tools for this. It can open a hell of a lot of formats as well.


dawlane(Posted 2013) [#20]
Currently adding support for PCLinuxOS 2013.04. And here's something: I didn't patch the BlitzMax install yet and the alsa driver works (at least it does in virtualbox) could this mean that the code patch that I will apply break it?

Edit: something more interesting. I'm getting a 'Assertion 's' failed at pulse/simple.c:255, function pa_simple_free() with pulse enabled. And I'm not even doing the 64bit yet.
I will see what it does on real hardware.

Edit: OK was missing the pulse driver (would have thought that would have been installed along with the development files) but still no sound.

Edit:Had a suspicion that to use pulse you had down load the full pulseaudio kit (mixer,etc) and then enable it in the hardware control center. Guess I was right as sound is now working after 5 minutes of messing around.

I may have to think about rewriting the patching file

EDIT: The 64bit version of PCLinuxOS will not work with BlitzMax as the distributors only supply a limited number of 32bit libraries ( and I can not find any other information on this issue ). This will also mean that any binary created with BlitzMax will not work unless you supply these yourself with instructions on how to install them.

EDIT: Looks like I may be able to add 64bit support but this means going to have to add some functions to allow download from the repository server and extract the files necessary to be added to the system.


Blitzplotter(Posted 2013) [#21]
Looks like I may be able to add 64bit support but this means going to have to add some functions to allow download from the repository server and extract the files necessary to be added to the system.

Good you found a work around! That'll keep BMax compiling into 64 bit linux land.


dawlane(Posted 2013) [#22]
Actually the work around was a lot easier than I thought it would be. I figured out how the repository was structured. It was then just a case of copying the sources.list with and duplicating the repositories, but with swapping x86_64 for update and the year repository from 2011 to 2010.

The down side here is that you have to explicitly pass the package name.
You can't just type libxpm-devel as the package manager gets confused and will either ask which package version you want or just download the 32bit version. So to get any 32bit binaries you have to add .32bit to the end and for 64bit you have to include 64 in the name somewhere e.g. lib64xpm-devel.

Arch Linux 64bit is a little more tricky ( and I'm not talking about getting it up and running). For some reason some of the 32bit libraries are in the Arch User Repository and not in the main multilib repository.

Edit: Well Arch Linux's pacman is a mess along with multilib support.


dawlane(Posted 2013) [#23]
OK updated to include PCLinuxOS and Arch Linux (fingers crossed)
bmax-install-0.5-3.zip


dawlane(Posted 2013) [#24]
OK having a look at Manjaro Linux this morning.... This is a distribution based of Arch Linux that's much simpler to install. My verdict is not good as this OS is still in a beta phase from what I can gather and isn't going to be added until you can update it without telling you that you need to update the same bloody packages all the time.


jkrankie(Posted 2013) [#25]
I'm using crunchbang linux at the minute, will this work do you think? It's debian based.

Cheers
Charlie


dawlane(Posted 2013) [#26]
Hi charlie
Just tested crunchbang out in virtualbox and I have to say that the distributor is very sloppy when it comes to distribution identification.
It's one of those distributions that I can't see the point of as to me it's just Debian with a window manager that's already set up with a just a script to update and install a few packages. You can do the same thing with the minimal Debian install and a bit of work.

Does it work? Yes to a point and providing that it's using Debian 7.1 as it's base, but without a full desktop environment such as GNOME or KDE then menus and desktop icons are out (ignore the error when it tries to create a desktop icon). At some point in the future I will have to look into what needs to be done to set such things up, but if I remember different window managers haven't got a standard and do things in there own way. You can add maxide using the obmenu tool or run it from the command line.

If you are going to try these scripts on real hardware; then for gods sake backup everything that's important before commencing. It's always best to try them out with a virtual machine first. But if a virtual machine is out; then backing up your files is a must. I will not be held responsible for ant data lost, time waste etc.

I should also point out that the full 32bit multi-lib packages are installed on any 64bit OS, not just those that are required to run Blitz Max. So make sure that if is it's a Linux on a stick set up that there is enough room. I was going to modify the apt sources.list directly (there another topic here about that), but if there are any third party repositories in there that don't support 32bit binaries it could break updating and installing.