How to make system installation of my own software

Need help with C, C++, perl, python, etc?

How to make system installation of my own software

Postby larienna » 2018-02-06 12:15

I have just finished my cmake script for my game, and now I am trying to configure it for system wide installation. Normally on unix OS, files are spread across the system, but since my game was originally developed in DOS, it assume that everything is in the same folder. Also since it should also be built on windows, placing all files in the same folder is also the logical thing to do.

So far, I configured cmake to copy assets files into relative folders

Code: Select all
games/wizardry/datafile
games/wizardry/adventure

and it copie the files correctly in
Code: Select all
/usr/local/games/wizardry/datafile
/usr/local/games/wizardry/adventure


and the binary is copied to

Code: Select all
/usr/local/games/wizardry


----------------------------------------------------------------------------------

Now the problems is that I cannot execute the game from anywhere in the system.

1. I first tried to put wizardry into /usr/local/bin, but it ends up not finding the assets
2. Then I tried create a symbolic link. I could not make cmake create the link, but even if I create the link manually, I end up not being in the right working directory and it does not find the assets.
3. I tried making a script that opens a sub shell, change folder and execute the program. But I cannot do it with relative path. And since I don't know where the user will have the software installed, I cannot use absolute path.

Other solutions: I could add /usr/local/games/wizardry to the system PATH variable from the cmake script

But then even if I do succeed, local configuration files created in the root folder once the game starts will not be created unless the game is executed as sudo.

-------------------------------------------------------------------------------------------

So now I am wondering If I should change the path inside my program instead. I would need to branch with precompiler directive if the OS is linux, to change all the path used in the game.

User config will be in $HOME
Binary will be in ???/bin
while assets will be in ???/games/wizardry

Where ??? should be /usr/local, but that is variable from a system to another, because the user can change the installation path when running cmake. Which adds another complication of how to find where the user installed the files within my program. Unless the CMAKE script creates a path variable and pass it into the compilation process, so that I can use absolute path.

It's hard to find information on installation standard or the recommended practice to use when installing software.

So is there another solution to install the software, or should I simply recode my paths to be more unix friendly?
larienna
 
Posts: 41
Joined: 2014-09-27 20:54

Re: How to make system installation of my own software

Postby bw123 » 2018-02-06 18:58

Now the problems is that I cannot execute the game from anywhere in the system.


I think you should leave this up to the person installing it to make the appropriate links on their system to run the program.
User avatar
bw123
 
Posts: 3385
Joined: 2011-05-09 06:02
Location: TN_USA

Re: How to make system installation of my own software

Postby larienna » 2018-02-07 01:18

Well, the "make install" script should put the files at the right place so that the user can execute the program from anywhere. That is what "make install" script do. Sure, it could be possible to change the destination installation, but by default, that is the expected results.
larienna
 
Posts: 41
Joined: 2014-09-27 20:54

Re: How to make system installation of my own software

Postby dryden » 2018-02-07 21:40

Normally you would configure your program to have configurable locations for every category, so that it can be moved from system to system.

Of course you know that in Linux normally:

/etc/wizardry/ would contain configuration
/usr/lib/wizardry/ would contain the executable
/usr/share/wizardry/ would contain assets
/usr/bin/wizardry would be a symlink to /usr/lib/wizardry
/home/user/.wizardry/ or similar would store user files.

If you pack everything together, this becomes

/opt/wizardry/etc
/opt/wizardry/lib
/opt/wizardry/share
/opt/wizardry/bin
/home/user/.wizardry

And then you can put it in /usr/local/games/wizardry, or, more conveniently, /opt/wizardry.

All in all your program will have to be configurable with these locations through cmake. If you want to make it relative.

Then your program will have to discover its own location.

E.g. in bash this is $(cd $dirname $0 && pwd)
dryden
 
Posts: 80
Joined: 2015-02-04 08:54

Re: How to make system installation of my own software

Postby larienna » 2018-02-11 14:21

Thanks, that was what I was looking for since there is little documentation about it. Now it seems modifying the code will be necessary,

I thought the binairies were directly in the bin folder.
larienna
 
Posts: 41
Joined: 2014-09-27 20:54


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable