Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] How to package DOS programs with dosbox?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Sat Oct 20, 2018 11:59 pm    Post subject: [SOLVED] How to package DOS programs with dosbox? Reply with quote

DOS programs can be run with dosbox. However, many DOS programs do not save config in a separate config directory. They save config in the same directory as executables are in.

I thought about creating a dosbox launcher that separates program data from program through overlayfs. But, mounting and unmounting overlayfs can be fragile.

How would you approach packaging DOS programs?


Last edited by crocket on Sun Oct 21, 2018 10:37 am; edited 2 times in total
Back to top
View user's profile Send private message
fpemud
Guru
Guru


Joined: 15 Feb 2012
Posts: 349

PostPosted: Sun Oct 21, 2018 1:05 am    Post subject: Reply with quote

dosbox game ebuild example:
https://github.com/fpemud/fpemud-overlay/tree/master/games-simulation/f22-lightning2
https://github.com/fpemud/fpemud-overlay/tree/master/games-action/ciscoheat
https://github.com/fpemud/fpemud-overlay/blob/master/games-action/spacewar

example for how to store config files in /home for windows programs:
https://github.com/fpemud/fpemud-overlay/tree/master/games-simulation/need-for-speed9
Back to top
View user's profile Send private message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Sun Oct 21, 2018 2:33 am    Post subject: Reply with quote

fpemud wrote:
dosbox game ebuild example:
https://github.com/fpemud/fpemud-overlay/tree/master/games-simulation/f22-lightning2
https://github.com/fpemud/fpemud-overlay/tree/master/games-action/ciscoheat
https://github.com/fpemud/fpemud-overlay/blob/master/games-action/spacewar

example for how to store config files in /home for windows programs:
https://github.com/fpemud/fpemud-overlay/tree/master/games-simulation/need-for-speed9


I do not understand how they work. I don't have access to files that SRC_URI refers to. Reverse-engineering your ebuild is difficult.

Can you explain how you made it work? Can you explain in english?
Back to top
View user's profile Send private message
fpemud
Guru
Guru


Joined: 15 Feb 2012
Posts: 349

PostPosted: Sun Oct 21, 2018 5:41 am    Post subject: Reply with quote

The game is installed in a directory in /opt, and the game is started by a dedicated shell script.

Run the game for the first time:
1. Create a directory ~/.cache/XXX, symlink all the files in /opt/XXX into this directory.
2. Create a directory ~/.config/XXX for game config files and data files.
3. Start the game and wait for it to complete.
4. Generally, the game should create config files and data files in ~/.cache/XXX. Copy these files into ~/.config/XXX

Run the game normally:
1. Copy files in ~/.config/XXX to /.cache/XXX
2. Start the game and wait for it to complete.
3. Copy config files and data files in ~/.cache/XXX. into ~/.config/XXX

Data in windows registry can be treated in a similar way: import ~/.config/XXX into wine registry before game starts and do a reverse operation after game stops.

This solution can be applied to arbitrary dosbox/wine programs.


Quote:
I don't have access to files that SRC_URI refers to.

Git repo updated. Scripts and auxiliary config files have been moved from private ftp to ebuild directory.


By the way, what DOS program you are about to run on gentoo?
Back to top
View user's profile Send private message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Sun Oct 21, 2018 7:33 am    Post subject: Reply with quote

fpemud wrote:
The game is installed in a directory in /opt, and the game is started by a dedicated shell script.

Run the game for the first time:
1. Create a directory ~/.cache/XXX, symlink all the files in /opt/XXX into this directory.
2. Create a directory ~/.config/XXX for game config files and data files.
3. Start the game and wait for it to complete.
4. Generally, the game should create config files and data files in ~/.cache/XXX. Copy these files into ~/.config/XXX

Run the game normally:
1. Copy files in ~/.config/XXX to /.cache/XXX
2. Start the game and wait for it to complete.
3. Copy config files and data files in ~/.cache/XXX. into ~/.config/XXX

Data in windows registry can be treated in a similar way: import ~/.config/XXX into wine registry before game starts and do a reverse operation after game stops.

This solution can be applied to arbitrary dosbox/wine programs.


Quote:
I don't have access to files that SRC_URI refers to.

Git repo updated. Scripts and auxiliary config files have been moved from private ftp to ebuild directory.


By the way, what DOS program you are about to run on gentoo?


I think I can make it simpler by mounting an overlayfs file system, but overlayfs requires root permission, and it doesn't work on ZFS.
A normal user union mount is going to be really sweet.

I want to run DOS typing tutors through a dosbox launcher that helps package DOS programs for linux distrubitions. Those tutors save configurations and program data in the same directories as executables are in or in the subdirectories of these directories.

I'm thinking about utilizing https://packages.gentoo.org/packages/sys-fs/unionfs-fuse
Back to top
View user's profile Send private message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Sun Oct 21, 2018 9:43 am    Post subject: Reply with quote

I just succeeded in separating program data from program by using unionfs-fuse.

This is better than copying symlinks and regular files back and forth.

The procedure is

1. unionfs -o cow program_data_dir=RW:program_dir=RO merged_directory
2. dosbox -exit -other_options merged_directory/program.exe
3. fusermount -u merged_directory.

You can execute those commands as a normal user. This doesn't require root permission. With this, I can package DOS programs for gentoo.
Back to top
View user's profile Send private message
fpemud
Guru
Guru


Joined: 15 Feb 2012
Posts: 349

PostPosted: Sun Oct 21, 2018 11:14 am    Post subject: Reply with quote

Great work!

What I know is there's no unified way for all the dos/win32 program.
There are many programs that have ad-hoc behavior.

Your way is really a better solution, at least it can eliminate the usage of ~/.cache directory.
I think I can use it to simplify some of my ebuilds.
Back to top
View user's profile Send private message
crocket
Guru
Guru


Joined: 29 Apr 2017
Posts: 558

PostPosted: Mon Oct 22, 2018 12:24 am    Post subject: Reply with quote

fpemud wrote:
Great work!

What I know is there's no unified way for all the dos/win32 program.
There are many programs that have ad-hoc behavior.

Your way is really a better solution, at least it can eliminate the usage of ~/.cache directory.
I think I can use it to simplify some of my ebuilds.


You might want to combine fuse-zip with unionfs-fuse

Code:
#!/bin/sh

# Arguments
zipfile=/usr/share/DOSprogram/program.zip
dosboxconf=/usr/share/DOSprogram/dosbox.conf
progname=DOSprogram
exe=program.exe

# Variables
lower=/tmp/dosbox-launcher/$progname/lower
merged=/tmp/dosbox-launcher/$progname/merged
upper=~/.dosbox-launcher/$progname

fuse-zip -r $zipfile $lower
unionfs -o cow,hide_meta_files $upper=RW:$lower=RO $merged
dosbox -exit -userconf -conf $dosboxconf -conf ~/.config/dosbox-launcher/dosbox-$progname.conf $merged/$exe
fusermount -u $merged
fusermount -u $lower
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum