public inbox for gentoo-devhelp@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-devhelp] Questions on a Warcraft I ebuild
@ 2025-01-04 21:26 Hoël Bézier
  2025-01-05 11:28 ` Andrew Udvare
  0 siblings, 1 reply; 3+ messages in thread
From: Hoël Bézier @ 2025-01-04 21:26 UTC (permalink / raw
  To: gentoo-devhelp

[-- Attachment #1: Type: text/plain, Size: 5151 bytes --]

Hi,

I have written an ebuild for Warcraft I. This game used to be sold on GOG.com, 
so the ebuild allows installation from the installer you could download there.

The full patch is attached. It includes the ebuild, the Manifest, the 
metadata.xml, the dosbox configuration file and a shell script meant to be 
installed in PATH.

I have a few questions about the decisions I took when writing these. Feel free 
to also point out anything that seems of interest to you.

> +SLOT="1"

At first I had named the package warcraft-1, but then when I added the version 
it gave me a weird filename (warcraft-1-1.2.28330.ebuild), so I figured I would 
call the package warcraft, and use SLOT to differentiate between ebuilds for 
warcraft I, II and III.

I’m pretty sure the SLOT system has not been thought for this, but it works 
quite well. Are there any reasons I should NOT do that?

> +DIR="/opt/${PN}-${SLOT}"

Since I’m installing prebuilt binaries, I put them all into /opt/${PN}-${SLOT}. 
Most similar packages install into /opt/${PN}, but if I did that, I wouldn’t be 
able to install files for the three different slots simultaneously.

> +src_unpack() {
> +	innoextract -Lms -d "${S}" "${DISTDIR}/${A}" || die
> +	unzip -c "${S}/app/webcache.zip" 4fae796ad7d4bd7357fa49e5013e6aa881b6fcfcd37a1de052adab337fd0b236.png > "${S}/icon.png" || die
> +}

unpack doesn’t support extracting Inno Setup installers, so it seems I’m left 
with using innoextract directly.

However the only icon included in the installer is in .ico format, which isn’t 
supported by make_desktop_entry from desktop.eclass, so I’m left with either 
converting it using ImageMagick or extracting the icon from the 
app/webcache.zip file which contains it in a usable format. I decided for the 
latter. My question is, should I try to have several sizes of that icon, which 
I can obtain either by converting the .ico file or by extracting all files from 
the zip?

> +	insinto "${DIR}"
> +	doins -r data drivers *.bin *.cue *.war icon.png

This results in the icon being installed in /opt. Should I instead install it 
using newicon in /usr/share/icons, especially if I install several sizes of it? 
It feels weird to me to have only the icon be installed in /usr and the rest of 
the package in /opt: I feel I should either install the package in system 
files, or stay nicely contained in /opt.

> +	newins "${FILESDIR}/warcraft1-dosbox.conf" dosbox.conf

Warcraft I is run with dosbox, which means I use a dosbox configuration file. I 
install it, like everything else, in /opt. Should I put it somewhere else, like 
/usr/share/warcraft-1/dosbox.conf, /etc/warcraft-1/dosbox.conf, 
/etc/dosbox/warcraft-1.conf? I have the same feeling regarding this file as I 
have regarding the icon.

Let’s switch to the shell script now.

> +if ! test -d "${HOME}/.local/share/${PN}"
> +then
> +	mkdir -p "${HOME}/.local/share/${PN}"
> +	cp /opt/${PN}/*.war "${HOME}/.local/share/${PN}"
> +fi
> +
> +mkdir -p "${HOME}/.cache/${PN}"
> +ln -sft "${HOME}/.cache/${PN}" /opt/${PN}/*
> +ln -sft "${HOME}/.cache/${PN}" ${HOME}/.local/share/${PN}/*
> +ln -sft "${HOME}/.cache/${PN}" ${HOME}/.config/${PN}/* 2>/dev/null || true
> +rm -f "${HOME}/.cache/${PN}/*" # Might be created by the previous commands
> 
> +dosbox -conf "${HOME}/.cache/${PN}/dosbox.conf" -exit "${HOME}/.cache/${PN}/war.exe"
> +
> +find "${HOME}/.cache/${PN}" -type f -execdir mv '{}' "${HOME}/.local/share/${PN}/" \;

So, Warcraft being a DOS game, it expects to be able to write files in its 
installation directory, whether it be editing existing files or creating new 
ones.

This is obviously not possible here, unless you play as root which is not 
recommended.

We can work around this by making copies of files the game wants to edit 
in the user’s homedir, then linking everything into a temporary directory in 
which the user has write permissions so that they can create new files, and 
running the game from this temporary directory instead of the system 
installation directory.

I additionally link the user’s ~/.config/warcraft-1 into that temporary 
directory, so that they may overwrite the dosbox.conf if so they wish. (They 
actually can overwrite any file they want, but most users won’t.)

After the game has run, any file in this temporary directory is a file which 
has been created by the game (since before that everything is a symlink), so we 
move that to a persistent directory.

Are there any better ways to solve this problem, or do you have examples of 
similar games solving this in a different fashion?


Regarding dependencies of the package, I have put dosbox because it is used in 
the shell script, but in order to have music, you also need a midi server 
running. Is there any way I can express that somewhere? The game, nor my shell 
script, can’t be responsible for setting this up and running it, so I don’t 
feel I should have one in RDEPEND, but nevertheless the user should be made 
aware they need one. How can I go about that?


If you don’t have much to say about this, do you think this is fit to be 
uploaded to GURU?

Thanks for reading,
Hoël

[-- Attachment #2: warcraft.patch --]
[-- Type: text/plain, Size: 6255 bytes --]

diff --git a/games-strategy/warcraft/Manifest b/games-strategy/warcraft/Manifest
new file mode 100644
index 0000000..f9b69e3
--- /dev/null
+++ b/games-strategy/warcraft/Manifest
@@ -0,0 +1,5 @@
+AUX warcraft-1 634 BLAKE2B f0084ac142757b712d02fcf59792db2232e1ebee1ae9967d7a5ef43e985251f1820f690f85bfa4bddca1efe0374e38d376aaa4d8f6af6c93ee9712ca3ada7e14 SHA512 6350687da904642a3a4f9d9325d3e5e799c0e08a0ba9718127f7ccd89fd8286ffd7c02bc15f6b49c8fc27305f69b9c1a9579441b3d2780a92fae0082b76d2998
+AUX warcraft1-dosbox.conf 1383 BLAKE2B 3ad2135fd5829e7c5cf52afacda23ab6d681b59ee6fdeb6c813eaaa60b4bd61e1185ae9423c3412e566b2357f7deb0c443258a3368f7af0341debea4463473a0 SHA512 714cb66baa42f1b26a0e4671cb63b1dfe9e84183c6007b9da042ca625a12f09f089e11850e787f48b6d7920fe44953beb07247f43d79383213af84b665a7bd9b
+DIST setup_warcraft_orcs__humans_1.2_(28330).exe 517514432 BLAKE2B 8b4f5257a5f745604b48d1079f9bec09c5fefe33a4fc1e49aaed60bfe5fbacd7d689fa9f677bc0baf518af3cc0492c5a3fcfb9ee5d7cb9273c29aa97d5077b78 SHA512 15aec94c95aba3269e7b85891432db71084e60e99375d5a9f4ca20607b36e109393b824bf51f71232c1186cf7015c29a527838bc94bdb0fe07cc7fe695b72ffa
+EBUILD warcraft-1.2.28330-r2.ebuild 1150 BLAKE2B be35ed3af9ba5314773f96ff732575fd8b443700113706d85f4ab029786cd6f326c8dcfba020b5350ae19f249246e6b3b9c72a536b9bb7ad5fe3879eb2b35bea SHA512 9dbb309ba6e1f758aacbedb82d7dbb66083b400d81bbcda53c56989a70b4aaf5606d621eaf3c2ec4c6b4fded6a620d7152265a97bc87d78863f20e812b985442
+MISC metadata.xml 251 BLAKE2B 19c151f5703da8ebf54919c481478b9d57a1eae77b2d74febf1cddb49172e6d4b738519579e872b0ae60741d15a729e90042a38b2c5a4cb79844fd3c833e784b SHA512 6465fbacaf70f1a1c5a0c8d825bd99c2eb81c67451193d8c2bfb6d2cbdd9d6821726695ed289200aab6aa736a3baccd42d1fd31bed709e6c2ae51c392c67056c
diff --git a/games-strategy/warcraft/files/warcraft-1 b/games-strategy/warcraft/files/warcraft-1
new file mode 100644
index 0000000..c4a65e5
--- /dev/null
+++ b/games-strategy/warcraft/files/warcraft-1
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -eu
+
+PN=warcraft-1
+
+if ! test -d "${HOME}/.local/share/${PN}"
+then
+	mkdir -p "${HOME}/.local/share/${PN}"
+	cp /opt/${PN}/*.war "${HOME}/.local/share/${PN}"
+fi
+
+mkdir -p "${HOME}/.cache/${PN}"
+ln -sft "${HOME}/.cache/${PN}" /opt/${PN}/*
+ln -sft "${HOME}/.cache/${PN}" ${HOME}/.local/share/${PN}/*
+ln -sft "${HOME}/.cache/${PN}" ${HOME}/.config/${PN}/* 2>/dev/null || true
+rm -f "${HOME}/.cache/${PN}/*" # Might be created by the previous commands
+
+dosbox -conf "${HOME}/.cache/${PN}/dosbox.conf" -exit "${HOME}/.cache/${PN}/war.exe"
+
+find "${HOME}/.cache/${PN}" -type f -execdir mv '{}' "${HOME}/.local/share/${PN}/" \;
diff --git a/games-strategy/warcraft/files/warcraft1-dosbox.conf b/games-strategy/warcraft/files/warcraft1-dosbox.conf
new file mode 100644
index 0000000..ea5ef7a
--- /dev/null
+++ b/games-strategy/warcraft/files/warcraft1-dosbox.conf
@@ -0,0 +1,91 @@
+[sdl]
+fullscreen       = true
+fulldouble       = false
+fullresolution   = desktop
+windowresolution = original
+output           = overlay
+autolock         = true
+sensitivity      = 100
+waitonerror      = true
+priority         = higher,normal
+mapperfile       = mapper-SVN.map
+usescancodes     = true
+
+[dosbox]
+language = 
+machine  = svga_s3
+captures = capture
+memsize  = 16
+
+[render]
+frameskip = 0
+aspect    = true
+scaler    = normal2x
+
+[cpu]
+core      = auto
+cputype   = auto
+cycles    = fixed 30000
+cycleup   = 1000
+cycledown = 1000
+
+[mixer]
+nosound   = false
+rate      = 44100
+blocksize = 1024
+prebuffer = 25
+
+[midi]
+mpu401     = intelligent
+mididevice = default
+midiconfig = 128:0
+
+[sblaster]
+sbtype  = sb16
+sbbase  = 220
+irq     = 7
+dma     = 1
+hdma    = 5
+sbmixer = true
+oplmode = auto
+oplemu  = default
+oplrate = 44100
+
+[gus]
+gus      = false
+gusrate  = 44100
+gusbase  = 240
+gusirq   = 5
+gusdma   = 3
+ultradir = C:\ULTRASND
+
+[speaker]
+pcspeaker = true
+pcrate    = 44100
+tandy     = auto
+tandyrate = 44100
+disney    = true
+
+[joystick]
+joysticktype  = auto
+timed         = true
+autofire      = false
+swap34        = false
+buttonwrap    = false
+circularinput = false
+deadzone      = 10
+
+[serial]
+serial1 = dummy
+serial2 = dummy
+serial3 = disabled
+serial4 = disabled
+
+[dos]
+xms            = true
+ems            = true
+umb            = true
+keyboardlayout = auto
+
+[ipx]
+ipx = false
diff --git a/games-strategy/warcraft/metadata.xml b/games-strategy/warcraft/metadata.xml
new file mode 100644
index 0000000..00298a3
--- /dev/null
+++ b/games-strategy/warcraft/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="person">
+		<email>hoelbezier@riseup.net</email>
+		<name>Hoël Bézier</name>
+	</maintainer>
+</pkgmetadata>
diff --git a/games-strategy/warcraft/warcraft-1.2.28330-r2.ebuild b/games-strategy/warcraft/warcraft-1.2.28330-r2.ebuild
new file mode 100644
index 0000000..5c4f0cf
--- /dev/null
+++ b/games-strategy/warcraft/warcraft-1.2.28330-r2.ebuild
@@ -0,0 +1,51 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit desktop xdg
+
+MY_PV="$(ver_cut 1-2)_($(ver_cut 3))"
+
+DESCRIPTION="Warcraft: Orcs & Humans"
+HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"
+SRC_URI="setup_warcraft_orcs__humans_${MY_PV}.exe"
+
+LICENSE="GOG-EULA"
+SLOT="1"
+KEYWORDS="~amd64"
+RESTRICT="bindist fetch splitdebug"
+
+BDEPEND="
+	app-arch/innoextract
+	app-arch/unzip
+"
+
+RDEPEND="
+	games-emulation/dosbox
+"
+
+DIR="/opt/${PN}-${SLOT}"
+QA_PREBUILT="${DIR#/}/*"
+
+pkg_nofetch() {
+	einfo "Please buy and download ${SRC_URI}"
+	einfo "and move it to your distfiles directory."
+}
+
+src_unpack() {
+	innoextract -Lms -d "${S}" "${DISTDIR}/${A}" || die
+	unzip -c "${S}/app/webcache.zip" 4fae796ad7d4bd7357fa49e5013e6aa881b6fcfcd37a1de052adab337fd0b236.png > "${S}/icon.png" || die
+}
+
+src_install() {
+	exeinto "${DIR}"
+	doexe *.exe
+
+	insinto "${DIR}"
+	doins -r data drivers *.bin *.cue *.war icon.png
+	newins "${FILESDIR}/warcraft1-dosbox.conf" dosbox.conf
+
+	dobin "${FILESDIR}/${PN}-${SLOT}"
+	make_desktop_entry "${PN}-${SLOT}" "Warcraft: Orcs & Humans" "${EPREFIX}/${DIR}/icon.png"
+}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [gentoo-devhelp] Questions on a Warcraft I ebuild
  2025-01-04 21:26 [gentoo-devhelp] Questions on a Warcraft I ebuild Hoël Bézier
@ 2025-01-05 11:28 ` Andrew Udvare
  2025-01-06 17:36   ` Hoël Bézier
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Udvare @ 2025-01-05 11:28 UTC (permalink / raw
  To: gentoo-devhelp


[-- Attachment #1.1: Type: text/plain, Size: 7415 bytes --]

On 04/01/2025 16:26, Hoël Bézier wrote:
> Hi,
> 
> I have written an ebuild for Warcraft I. This game used to be sold on 
> GOG.com, so the ebuild allows installation from the installer you could 
> download there.
> 
> The full patch is attached. It includes the ebuild, the Manifest, the 
> metadata.xml, the dosbox configuration file and a shell script meant to 
> be installed in PATH.

It's an interesting idea. I don't think it will gain wide acceptance but 
you could make an overlay of dosbox-gog stuff.
> 
> I have a few questions about the decisions I took when writing these. 
> Feel free to also point out anything that seems of interest to you.
> 
>> +SLOT="1"
> 
> At first I had named the package warcraft-1, but then when I added the 
> version it gave me a weird filename (warcraft-1-1.2.28330.ebuild), so I 
> figured I would call the package warcraft, and use SLOT to differentiate 
> between ebuilds for warcraft I, II and III.
> 
> I’m pretty sure the SLOT system has not been thought for this, but it 
> works quite well. Are there any reasons I should NOT do that?

I would not do that. Game suffixes are really not the same as different 
versions of the same software. There can be Warcraft 1 1.0, Warcraft 2 
1.0, etc. New game releases of a series are rarely considered an 
'upgrade' from the prior game. They are basically separate. The only 
case I know of historically is RollerCoaster Tycoon where RCT2 actually 
gets marked as version 2.0.

I would just use warcraft, warcraft2, etc as the package names.
> 
>> +DIR="/opt/${PN}-${SLOT}"
> 
> Since I’m installing prebuilt binaries, I put them all into /opt/${PN}- 
> ${SLOT}. Most similar packages install into /opt/${PN}, but if I did 
> that, I wouldn’t be able to install files for the three different slots 
> simultaneously.

You can also put this stuff in /usr/share/${PN} since it's just random 
non-source content, nor is it Linux-native binaries.
> 
>> +src_unpack() {
>> +    innoextract -Lms -d "${S}" "${DISTDIR}/${A}" || die
>> +    unzip -c "${S}/app/webcache.zip" 
>> 4fae796ad7d4bd7357fa49e5013e6aa881b6fcfcd37a1de052adab337fd0b236.png > 
>> "${S}/icon.png" || die
>> +}
> 
> unpack doesn’t support extracting Inno Setup installers, so it seems I’m 
> left with using innoextract directly.

This is fine.

> However the only icon included in the installer is in .ico format, which 
> isn’t supported by make_desktop_entry from desktop.eclass, so I’m left 
> with either converting it using ImageMagick or extracting the icon from 
> the app/webcache.zip file which contains it in a usable format. I 
> decided for the latter. My question is, should I try to have several 
> sizes of that icon, which I can obtain either by converting the .ico 
> file or by extracting all files from the zip?
> 
>> +    insinto "${DIR}"
>> +    doins -r data drivers *.bin *.cue *.war icon.png

I would not bother with making different sizes. If there is only one 
size and you don't specify the size to doicon then it goes in pixmaps.

> 
> This results in the icon being installed in /opt. Should I instead 
> install it using newicon in /usr/share/icons, especially if I install 
> several sizes of it? It feels weird to me to have only the icon be 
> installed in /usr and the rest of the package in /opt: I feel I should 
> either install the package in system files, or stay nicely contained 
> in /opt.

Does not matter if placement of files is mixed.

Definitely make use of newicon to install the icon properly as ${PN}. 
Then you can remove the full path argument from make_desktop_entry.

> 
>> +    newins "${FILESDIR}/warcraft1-dosbox.conf" dosbox.conf
> 
> Warcraft I is run with dosbox, which means I use a dosbox configuration 
> file. I install it, like everything else, in /opt. Should I put it 
> somewhere else, like /usr/share/warcraft-1/dosbox.conf, /etc/warcraft-1/ 
> dosbox.conf, /etc/dosbox/warcraft-1.conf? I have the same feeling 
> regarding this file as I have regarding the icon.

Put it in /usr/share.

> Let’s switch to the shell script now.
> 
>> +if ! test -d "${HOME}/.local/share/${PN}"
>> +then
>> +    mkdir -p "${HOME}/.local/share/${PN}"
>> +    cp /opt/${PN}/*.war "${HOME}/.local/share/${PN}"
>> +fi
>> +
>> +mkdir -p "${HOME}/.cache/${PN}"
>> +ln -sft "${HOME}/.cache/${PN}" /opt/${PN}/*
>> +ln -sft "${HOME}/.cache/${PN}" ${HOME}/.local/share/${PN}/*
>> +ln -sft "${HOME}/.cache/${PN}" ${HOME}/.config/${PN}/* 2>/dev/null || 
>> true
>> +rm -f "${HOME}/.cache/${PN}/*" # Might be created by the previous 
>> commands
>>
>> +dosbox -conf "${HOME}/.cache/${PN}/dosbox.conf" -exit 
>> "${HOME}/.cache/${PN}/war.exe"
>> +
>> +find "${HOME}/.cache/${PN}" -type f -execdir mv '{}' "${HOME}/.local/ 
>> share/${PN}/" \;
> 
> So, Warcraft being a DOS game, it expects to be able to write files in 
> its installation directory, whether it be editing existing files or 
> creating new ones.
> 
> This is obviously not possible here, unless you play as root which is 
> not recommended.
> 
> We can work around this by making copies of files the game wants to edit 
> in the user’s homedir, then linking everything into a temporary 
> directory in which the user has write permissions so that they can 
> create new files, and running the game from this temporary directory 
> instead of the system installation directory.
> 
> I additionally link the user’s ~/.config/warcraft-1 into that temporary 
> directory, so that they may overwrite the dosbox.conf if so they wish. 
> (They actually can overwrite any file they want, but most users won’t.)
> 
> After the game has run, any file in this temporary directory is a file 
> which has been created by the game (since before that everything is a 
> symlink), so we move that to a persistent directory.
> 
> Are there any better ways to solve this problem, or do you have examples 
> of similar games solving this in a different fashion?

This is probably the best course of action for this. Most games of the 
time are not designed with ACLs in mind. FAT12/32 had none. The game 
does not take up a lot of space so it is fine.
> 
> 
> Regarding dependencies of the package, I have put dosbox because it is 
> used in the shell script, but in order to have music, you also need a 
> midi server running. Is there any way I can express that somewhere? The 
> game, nor my shell script, can’t be responsible for setting this up and 
> running it, so I don’t feel I should have one in RDEPEND, but 
> nevertheless the user should be made aware they need one. How can I go 
> about that?

IUSE="midi" and RDPEEND="midi? ( midi-server-package1 || 
midi-server-package2 )" is a quick solution for this.

Which server would you put there?
> 
> 
> If you don’t have much to say about this, do you think this is fit to be 
> uploaded to GURU?

I wouldn't without more input. You should consider putting it into an 
overlay that focuses on Dosbox conversions.

Also there are other Dosbox packages like Dosbox-staging and Dosbox-X 
(my overlay). You should RDEPEND on either: RDEPEND="( 
games-emulation/dosbox || games-emulation/dosbox-staging )"

Also I don't think QA_PREBUILT is necessary for non-Linux binary data.

--
Andrew


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-devhelp] Questions on a Warcraft I ebuild
  2025-01-05 11:28 ` Andrew Udvare
@ 2025-01-06 17:36   ` Hoël Bézier
  0 siblings, 0 replies; 3+ messages in thread
From: Hoël Bézier @ 2025-01-06 17:36 UTC (permalink / raw
  To: gentoo-devhelp

[-- Attachment #1: Type: text/plain, Size: 8053 bytes --]

Hi Andrew,

Thanks a lot for the quick and thorough answer! I’ve mostly followed all your 
advices. I’ve attached the new diff if anyone’s interested.

Am So, Jan 05, 2025 am 06:28:58 -0500 schrieb Andrew Udvare:
>On 04/01/2025 16:26, Hoël Bézier wrote:
>> Hi,
>>
>> I have written an ebuild for Warcraft I. This game used to be sold on
>> GOG.com, so the ebuild allows installation from the installer you could
>> download there.
>>
>> The full patch is attached. It includes the ebuild, the Manifest, the
>> metadata.xml, the dosbox configuration file and a shell script meant to
>> be installed in PATH.
>
>It's an interesting idea. I don't think it will gain wide acceptance but
>you could make an overlay of dosbox-gog stuff.
>>
>> I have a few questions about the decisions I took when writing these.
>> Feel free to also point out anything that seems of interest to you.
>>
>>> +SLOT="1"
>>
>> At first I had named the package warcraft-1, but then when I added the
>> version it gave me a weird filename (warcraft-1-1.2.28330.ebuild), so I
>> figured I would call the package warcraft, and use SLOT to differentiate
>> between ebuilds for warcraft I, II and III.
>>
>> I’m pretty sure the SLOT system has not been thought for this, but it
>> works quite well. Are there any reasons I should NOT do that?
>
>I would not do that. Game suffixes are really not the same as different
>versions of the same software. There can be Warcraft 1 1.0, Warcraft 2
>1.0, etc. New game releases of a series are rarely considered an
>'upgrade' from the prior game. They are basically separate. The only
>case I know of historically is RollerCoaster Tycoon where RCT2 actually
>gets marked as version 2.0.
>
>I would just use warcraft, warcraft2, etc as the package names.

That’s a very good idea, I’ll do just that.
>>
>>> +DIR="/opt/${PN}-${SLOT}"
>>
>> Since I’m installing prebuilt binaries, I put them all into /opt/${PN}-
>> ${SLOT}. Most similar packages install into /opt/${PN}, but if I did
>> that, I wouldn’t be able to install files for the three different slots
>> simultaneously.
>
>You can also put this stuff in /usr/share/${PN} since it's just random
>non-source content, nor is it Linux-native binaries.

Uhm, right. I felt like pre-distributed stuff should be kept as-is and put into 
/opt, but I guess /usr/share/${PN} is fine too. Also, this answers my questions 
about the icon and the dosbox config.
>>
>>> +src_unpack() {
>>> +    innoextract -Lms -d "${S}" "${DISTDIR}/${A}" || die
>>> +    unzip -c "${S}/app/webcache.zip"
>>> 4fae796ad7d4bd7357fa49e5013e6aa881b6fcfcd37a1de052adab337fd0b236.png >
>>> "${S}/icon.png" || die
>>> +}
>>
>> unpack doesn’t support extracting Inno Setup installers, so it seems I’m
>> left with using innoextract directly.
>
>This is fine.
>
>> However the only icon included in the installer is in .ico format, which
>> isn’t supported by make_desktop_entry from desktop.eclass, so I’m left
>> with either converting it using ImageMagick or extracting the icon from
>> the app/webcache.zip file which contains it in a usable format. I
>> decided for the latter. My question is, should I try to have several
>> sizes of that icon, which I can obtain either by converting the .ico
>> file or by extracting all files from the zip?
>>
>>> +    insinto "${DIR}"
>>> +    doins -r data drivers *.bin *.cue *.war icon.png
>
>I would not bother with making different sizes. If there is only one
>size and you don't specify the size to doicon then it goes in pixmaps.
>
>>
>> This results in the icon being installed in /opt. Should I instead
>> install it using newicon in /usr/share/icons, especially if I install
>> several sizes of it? It feels weird to me to have only the icon be
>> installed in /usr and the rest of the package in /opt: I feel I should
>> either install the package in system files, or stay nicely contained
>> in /opt.
>
>Does not matter if placement of files is mixed.
>
>Definitely make use of newicon to install the icon properly as ${PN}.
>Then you can remove the full path argument from make_desktop_entry.

I did that too.
>
>>
>>> +    newins "${FILESDIR}/warcraft1-dosbox.conf" dosbox.conf
>>
>> Warcraft I is run with dosbox, which means I use a dosbox configuration
>> file. I install it, like everything else, in /opt. Should I put it
>> somewhere else, like /usr/share/warcraft-1/dosbox.conf, /etc/warcraft-1/
>> dosbox.conf, /etc/dosbox/warcraft-1.conf? I have the same feeling
>> regarding this file as I have regarding the icon.
>
>Put it in /usr/share.
>
>> Let’s switch to the shell script now.
>>
>>> +if ! test -d "${HOME}/.local/share/${PN}"
>>> +then
>>> +    mkdir -p "${HOME}/.local/share/${PN}"
>>> +    cp /opt/${PN}/*.war "${HOME}/.local/share/${PN}"
>>> +fi
>>> +
>>> +mkdir -p "${HOME}/.cache/${PN}"
>>> +ln -sft "${HOME}/.cache/${PN}" /opt/${PN}/*
>>> +ln -sft "${HOME}/.cache/${PN}" ${HOME}/.local/share/${PN}/*
>>> +ln -sft "${HOME}/.cache/${PN}" ${HOME}/.config/${PN}/* 2>/dev/null ||
>>> true
>>> +rm -f "${HOME}/.cache/${PN}/*" # Might be created by the previous
>>> commands
>>>
>>> +dosbox -conf "${HOME}/.cache/${PN}/dosbox.conf" -exit
>>> "${HOME}/.cache/${PN}/war.exe"
>>> +
>>> +find "${HOME}/.cache/${PN}" -type f -execdir mv '{}' "${HOME}/.local/
>>> share/${PN}/" \;
>>
>> So, Warcraft being a DOS game, it expects to be able to write files in
>> its installation directory, whether it be editing existing files or
>> creating new ones.
>>
>> This is obviously not possible here, unless you play as root which is
>> not recommended.
>>
>> We can work around this by making copies of files the game wants to edit
>> in the user’s homedir, then linking everything into a temporary
>> directory in which the user has write permissions so that they can
>> create new files, and running the game from this temporary directory
>> instead of the system installation directory.
>>
>> I additionally link the user’s ~/.config/warcraft-1 into that temporary
>> directory, so that they may overwrite the dosbox.conf if so they wish.
>> (They actually can overwrite any file they want, but most users won’t.)
>>
>> After the game has run, any file in this temporary directory is a file
>> which has been created by the game (since before that everything is a
>> symlink), so we move that to a persistent directory.
>>
>> Are there any better ways to solve this problem, or do you have examples
>> of similar games solving this in a different fashion?
>
>This is probably the best course of action for this. Most games of the
>time are not designed with ACLs in mind. FAT12/32 had none. The game
>does not take up a lot of space so it is fine.
>>
>>
>> Regarding dependencies of the package, I have put dosbox because it is
>> used in the shell script, but in order to have music, you also need a
>> midi server running. Is there any way I can express that somewhere? The
>> game, nor my shell script, can’t be responsible for setting this up and
>> running it, so I don’t feel I should have one in RDEPEND, but
>> nevertheless the user should be made aware they need one. How can I go
>> about that?
>
>IUSE="midi" and RDPEEND="midi? ( midi-server-package1 ||
>midi-server-package2 )" is a quick solution for this.
>
>Which server would you put there?

I know two: timidity++ and fluidsynth. I’m currently using timidity++ and it 
works like a charm.
>>
>>
>> If you don’t have much to say about this, do you think this is fit to be
>> uploaded to GURU?
>
>I wouldn't without more input. You should consider putting it into an
>overlay that focuses on Dosbox conversions.

Should I create one, or do you already know about one that could accept this 
ebuild?
>
>Also there are other Dosbox packages like Dosbox-staging and Dosbox-X
>(my overlay). You should RDEPEND on either: RDEPEND="(
>games-emulation/dosbox || games-emulation/dosbox-staging )"

Good catch, I’ve changed that.
>
>Also I don't think QA_PREBUILT is necessary for non-Linux binary data.

Right, I removed it.
>
>--
>Andrew
>


[-- Attachment #2: warcraft.patch --]
[-- Type: text/plain, Size: 6245 bytes --]

diff --git a/games-strategy/warcraft/Manifest b/games-strategy/warcraft/Manifest
new file mode 100644
index 0000000..f23b790
--- /dev/null
+++ b/games-strategy/warcraft/Manifest
@@ -0,0 +1,5 @@
+AUX dosbox.conf 1383 BLAKE2B 3ad2135fd5829e7c5cf52afacda23ab6d681b59ee6fdeb6c813eaaa60b4bd61e1185ae9423c3412e566b2357f7deb0c443258a3368f7af0341debea4463473a0 SHA512 714cb66baa42f1b26a0e4671cb63b1dfe9e84183c6007b9da042ca625a12f09f089e11850e787f48b6d7920fe44953beb07247f43d79383213af84b665a7bd9b
+AUX warcraft 644 BLAKE2B 519507c97e786546cfdd37a531c213592bbd43de9ced6690c45c456eb72f3a1a3b73f84c1a0bcf3a77b212c15f117c2605afb7d84fdbd6009fef6741036dda2a SHA512 58b6251b3bdd742937a8e7d56853bbd928559987b0512a3a82908418189e815361b9b517df83aff2bd059c00cb6f8e53a57e2f2f204f3c5ea8e4f8fa3bcbb896
+DIST setup_warcraft_orcs__humans_1.2_(28330).exe 517514432 BLAKE2B 8b4f5257a5f745604b48d1079f9bec09c5fefe33a4fc1e49aaed60bfe5fbacd7d689fa9f677bc0baf518af3cc0492c5a3fcfb9ee5d7cb9273c29aa97d5077b78 SHA512 15aec94c95aba3269e7b85891432db71084e60e99375d5a9f4ca20607b36e109393b824bf51f71232c1186cf7015c29a527838bc94bdb0fe07cc7fe695b72ffa
+EBUILD warcraft-1.2.28330-r4.ebuild 1179 BLAKE2B a807e8b9cd65c5284ebe0940dcef1c5d5e7e76ab55358facdbf9638a1db3a03906d97751e134f050ed8881b13fa4238ecffaeb49a6e1b14461927099c66af691 SHA512 be4971200d38042baf7264e584e9b322a6314cc7e14ce352fe96265f893fc54231d46470c8dd2ceb5ba542b328f9352341b211f7ff539c3ac0698198a1a5786d
+MISC metadata.xml 251 BLAKE2B 19c151f5703da8ebf54919c481478b9d57a1eae77b2d74febf1cddb49172e6d4b738519579e872b0ae60741d15a729e90042a38b2c5a4cb79844fd3c833e784b SHA512 6465fbacaf70f1a1c5a0c8d825bd99c2eb81c67451193d8c2bfb6d2cbdd9d6821726695ed289200aab6aa736a3baccd42d1fd31bed709e6c2ae51c392c67056c
diff --git a/games-strategy/warcraft/files/dosbox.conf b/games-strategy/warcraft/files/dosbox.conf
new file mode 100644
index 0000000..ea5ef7a
--- /dev/null
+++ b/games-strategy/warcraft/files/dosbox.conf
@@ -0,0 +1,91 @@
+[sdl]
+fullscreen       = true
+fulldouble       = false
+fullresolution   = desktop
+windowresolution = original
+output           = overlay
+autolock         = true
+sensitivity      = 100
+waitonerror      = true
+priority         = higher,normal
+mapperfile       = mapper-SVN.map
+usescancodes     = true
+
+[dosbox]
+language = 
+machine  = svga_s3
+captures = capture
+memsize  = 16
+
+[render]
+frameskip = 0
+aspect    = true
+scaler    = normal2x
+
+[cpu]
+core      = auto
+cputype   = auto
+cycles    = fixed 30000
+cycleup   = 1000
+cycledown = 1000
+
+[mixer]
+nosound   = false
+rate      = 44100
+blocksize = 1024
+prebuffer = 25
+
+[midi]
+mpu401     = intelligent
+mididevice = default
+midiconfig = 128:0
+
+[sblaster]
+sbtype  = sb16
+sbbase  = 220
+irq     = 7
+dma     = 1
+hdma    = 5
+sbmixer = true
+oplmode = auto
+oplemu  = default
+oplrate = 44100
+
+[gus]
+gus      = false
+gusrate  = 44100
+gusbase  = 240
+gusirq   = 5
+gusdma   = 3
+ultradir = C:\ULTRASND
+
+[speaker]
+pcspeaker = true
+pcrate    = 44100
+tandy     = auto
+tandyrate = 44100
+disney    = true
+
+[joystick]
+joysticktype  = auto
+timed         = true
+autofire      = false
+swap34        = false
+buttonwrap    = false
+circularinput = false
+deadzone      = 10
+
+[serial]
+serial1 = dummy
+serial2 = dummy
+serial3 = disabled
+serial4 = disabled
+
+[dos]
+xms            = true
+ems            = true
+umb            = true
+keyboardlayout = auto
+
+[ipx]
+ipx = false
diff --git a/games-strategy/warcraft/files/warcraft b/games-strategy/warcraft/files/warcraft
new file mode 100644
index 0000000..ba504d4
--- /dev/null
+++ b/games-strategy/warcraft/files/warcraft
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -eu
+
+PN=warcraft
+
+if ! test -d "${HOME}/.local/share/${PN}"
+then
+	mkdir -p "${HOME}/.local/share/${PN}"
+	cp /usr/share/${PN}/*.war "${HOME}/.local/share/${PN}"
+fi
+
+mkdir -p "${HOME}/.cache/${PN}"
+ln -sft "${HOME}/.cache/${PN}" /usr/share/${PN}/*
+ln -sft "${HOME}/.cache/${PN}" ${HOME}/.local/share/${PN}/*
+ln -sft "${HOME}/.cache/${PN}" ${HOME}/.config/${PN}/* 2>/dev/null || true
+rm -f "${HOME}/.cache/${PN}/*" # Might be created by the previous commands
+
+dosbox -conf "${HOME}/.cache/${PN}/dosbox.conf" -exit "${HOME}/.cache/${PN}/war.exe"
+
+find "${HOME}/.cache/${PN}" -type f -execdir mv '{}' "${HOME}/.local/share/${PN}/" \;
diff --git a/games-strategy/warcraft/metadata.xml b/games-strategy/warcraft/metadata.xml
new file mode 100644
index 0000000..00298a3
--- /dev/null
+++ b/games-strategy/warcraft/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="person">
+		<email>hoelbezier@riseup.net</email>
+		<name>Hoël Bézier</name>
+	</maintainer>
+</pkgmetadata>
diff --git a/games-strategy/warcraft/warcraft-1.2.28330-r4.ebuild b/games-strategy/warcraft/warcraft-1.2.28330-r4.ebuild
new file mode 100644
index 0000000..f8e2eb4
--- /dev/null
+++ b/games-strategy/warcraft/warcraft-1.2.28330-r4.ebuild
@@ -0,0 +1,50 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit desktop xdg
+
+MY_PV="$(ver_cut 1-2)_($(ver_cut 3))"
+
+DESCRIPTION="Warcraft: Orcs & Humans"
+HOMEPAGE="https://wiki.gentoo.org/wiki/No_homepage"
+SRC_URI="setup_warcraft_orcs__humans_${MY_PV}.exe"
+
+LICENSE="GOG-EULA"
+SLOT="0"
+KEYWORDS="~amd64"
+RESTRICT="bindist fetch splitdebug"
+
+IUSE="midi"
+
+BDEPEND="
+	app-arch/innoextract
+	app-arch/unzip
+"
+
+RDEPEND="
+	|| ( games-emulation/dosbox games-emulation/dosbox-staging )
+	midi? ( || ( media-sound/timidity++ media-sound/fluidsynth ) )
+"
+
+pkg_nofetch() {
+	einfo "Please buy and download ${SRC_URI}"
+	einfo "and move it to your distfiles directory."
+}
+
+src_unpack() {
+	innoextract -Lms -d "${S}" "${DISTDIR}/${A}" || die
+	unzip -c "${S}/app/webcache.zip" 4fae796ad7d4bd7357fa49e5013e6aa881b6fcfcd37a1de052adab337fd0b236.png > "${S}/icon.png" || die
+}
+
+src_install() {
+	exeinto "/usr/share/${PN}"
+	doexe *.exe
+	insinto "/usr/share/${PN}"
+	doins -r data drivers *.bin *.cue *.war "${FILESDIR}/dosbox.conf"
+	newicon icon.png "${PN}.png"
+
+	dobin "${FILESDIR}/${PN}"
+	make_desktop_entry "${PN}" "Warcraft: Orcs & Humans"
+}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-06 17:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-04 21:26 [gentoo-devhelp] Questions on a Warcraft I ebuild Hoël Bézier
2025-01-05 11:28 ` Andrew Udvare
2025-01-06 17:36   ` Hoël Bézier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox