Windows and GNU/Linux hybrid installers

Windows and GNU/Linux hybrid installers

Postby Lachu » 16 Jan 2019, 21:36

One or half of year ago I developed small scipt, which can be ran both on Windows and GNU/Linux systems. It's hybrid cmd and bash script. Today and yesterday I make it a lot of better and decided to share my solution.

The reason is simple. People don't know which systems they use and browser detection can not working. Since a lot of games contains data independent of the operating system and maybe independent on the hardware, you/we can create single installer file (shell script), which will detect platform, unpack game data, unpack correct executable, (on Unix) makes file executable and ran unpacked executable, giving file path with data as argument.

Another use case is Java. User could download multiplatform installer. And another use-case is also related to stuff like Java. I created my tool with be bridge of platform in mind, so someone writes program in Java and pack it into special executable file. This executable (script) will extract program written in Java, detect platform, check Java is installed. If Java isn't installed, it will download it for current platform and install. If Java is installed, it only runs extracted program.

But this is forums about game developing.
What about write multiplatform game installer, like mono installer, but it will works both on Windows and GNU/Linux platforms (MacOS in future)?

Below I attached example program. Tomorrow I will produce screencast and share build tool, which I used to build attached script.
{l Code}: {l Select All Code}
#!/bin/bash
@echo off
echo Ignore above notice. It is hack to run this script both on Windows and GNU/Linux systems.
::() { echo a > /dev/null; }; @echo() { echo a > /dev/null; }; goto() { echo a > /dev/null; }; rem() { echo a > /dev/null; }
goto dos_aliases
shopt -s expand_aliases
alias set='export'
if  false ; then
:unquote
set %1=%~2
goto :EOF
:dos_aliases
set fcmd="if \"%1\"==\"param\" goto param"
set scmd="start /B %~dp0\%~n0.bat param"
call :unquote fcmd %fcmd%
call :unquote scmd %scmd%
%fcmd%
%scmd%
sleep 1
exit 0
:param
:: ;fi
set content=IFRoaXMgaXMgdGV4dAo=
goto windows_variables
::; if false ; then
:windows_variables
set wr="cmd.exe /c"
set wd=""
set wscu="dHlwZSAlMSAK"
call :unquote wscu %wscu%
set wscn="super.bat"
call :unquote wscn %wscn%
set wcfe=".bat"
call :unquote wcfe %wcfe%
call :unquote wr %wr%
::; fi
set lr="source"
set ld=""
set lscu="IyEvYmluL2Jhc2gKY2F0ICQxCg=="
set lscn=""
::a () { echo a > /dev/null; }
goto a
alias ':a'='::a'
file=`mktemp -t flatpak-XXXXXX | tr -d '\n'`
echo -n $content | base64 -d > $file
rem we have two files to unpack here
if [ "$lscu" != "" ]; then
  file2=`mktemp -t flatpak-XXXXXX | tr -d '\n'`
  echo -n $lscu | base64 -d > $file2
  $lr $file2 $file
else
  chmod +x $file
  $lr $file
fi
if  false ; then
:a
del %UserProfile%\content
del %UserProfile%\content2
del %UserProfile%\scontent
del %UserProfile%\scontent2
echo -----BEGIN CERTIFICATE----- > %UserProfile%\content
echo %content% >> %UserProfile%\content
echo -----END CERTIFICATE----- >> %UserProfile%\content
certutil -decode %UserProfile%\content %UserProfile%\content2
move %UserProfile%\content2 content2%wcfe%
set fcmd="if \"%wscu%\"==\"\" goto win_one_executable"
call :unquote fcmd %fcmd%
%fcmd%
rem we have two files to unpack here
echo -----BEGIN CERTIFICATE----- > %UserProfile%\scontent
echo %wscu% >> %UserProfile%\scontent
echo -----END CERTIFICATE----- >> %UserProfile%\scontent
certutil -decode %UserProfile%\scontent %UserProfile%\scontent2
move %UserProfile%\scontent2 %wscn%
%wr% %wscn% %UserProfile%\content2%wcfe%
goto next1
:win_one_executable
%wr% %UserProfile%\content2%wcfe%
:next1
:: ; fi
Lachu
 
Posts: 22
Joined: 06 Oct 2017, 15:54

Re: Windows and GNU/Linux hybrid installers

Postby Lachu » 17 Jan 2019, 18:48

As I said, today I publish source code of wrapper builder. You can use build.sh bash script to build script working on windows 10 and Linux in this way:
{l Code}: {l Select All Code}
./build.sh output_file_name,bat platform_independent_file_archive windows_runner_command linux_runner_command should_be_empty_string should_be_empty_string windows_dependent_program_to_run linux_dependent_program_to_run windows_file_extension_for_platform_independent_file_archive windows_name_for_windows_program

For example:
{l Code}: {l Select All Code}
#invocation
./build.sh ./output.bat ./text 'cmd.exe /c' 'source' '' '' ./windows.bat ./linux.sh '.bat' 'super.bat'
#text
 This is text
#windows.bat
type %1
#linux,sh
#!/bin/bash
cat $1


There's still some easy to fix errors. One of them is on Windows, you must run the program in cmd.exe on your user home directory - C:\Users\Lachu for example. I don't have time to post screencast about how it works until Monday.

And now. I will start a new project. It will uses this project as a base. I will create universal game installer (Windows and GNU/Linux). Who will help?
Lachu
 
Posts: 22
Joined: 06 Oct 2017, 15:54

Re: Windows and GNU/Linux hybrid installers

Postby Lyberta » 18 Jan 2019, 14:12

Deleted.
Last edited by Lyberta on 01 Oct 2021, 04:52, edited 1 time in total.
Lyberta
 
Posts: 765
Joined: 19 Jun 2013, 10:45

Re: Windows and GNU/Linux hybrid installers

Postby Lachu » 18 Jan 2019, 14:31

Lyberta {l Wrote}:On GNU/Linux I prefer to use the packages that OS package manager uses (DEB, RPM, etc).

Thar's better way to distribute Open Source software, but what would do dev studio of commercial and closed-source software?
Lachu
 
Posts: 22
Joined: 06 Oct 2017, 15:54

Re: Windows and GNU/Linux hybrid installers

Postby dulsi » 18 Jan 2019, 17:18

Lachu {l Wrote}:
Lyberta {l Wrote}:On GNU/Linux I prefer to use the packages that OS package manager uses (DEB, RPM, etc).

Thar's better way to distribute Open Source software, but what would do dev studio of commercial and closed-source software?

Well as a forum for free software games, that is generally what we are distributing. Ignoring that while it is impressive that your script can work on Windows and Linux, it isn't the best installer experience. The first thing they going to see is an error message plus the below message or just the message:

Ignore above notice. It is hack to run this script both on Windows and GNU/Linux systems.

If I see that in an installer, I'm going to question the quality of the installer. Also as you mentioned this need to be run with the cmd program under Windows. If a non technical person is going to do that, it needs to have a bat or cmd extension. If it has one of those extensions, a Linux user is probably going to ignore it because we know that is for Windows.

I package Bt Builder for Windows and Fedora. It's mostly automated. I don't see the need for a combined installer for Windows and Linux.
dulsi
 
Posts: 570
Joined: 18 Feb 2016, 15:24

Re: Windows and GNU/Linux hybrid installers

Postby Jastiv » 30 Jan 2019, 07:12

Lachu {l Wrote}:

Lyberta {l Wrote}:
On GNU/Linux I prefer to use the packages that OS package manager uses (DEB, RPM, etc).


Thar's better way to distribute Open Source software, but what would do dev studio of commercial and closed-source software?


I'll tell you a couple problems with the package mangler (sorry, I mean manager) First of all, sometimes it still doesn't work right. (why, I don't know, it just doesn't. I'm not some kind of all knowing Linux Guru)
Secondly, the ones in in the package manager are almost always out of date, and you can get a cooler better more complete experience just by cloning the repository, compiling and running, and as a bonus, if it doesn't work, you have a chance of actually helping the developer by reporting bugs, rather than wasting time discovering a bug that was fixed two versions ago.

In spite of issues with the packages, I still don't want to compile my whole system from source. I just don't want to wait around that long, so I put up with them, but not for software (like games) where I really care about having the latest version.
User avatar
Jastiv
 
Posts: 285
Joined: 14 Mar 2011, 02:18
Location: Unitied States of America - East Coast

Re: Windows and GNU/Linux hybrid installers

Postby Lyberta » 31 Jan 2019, 06:25

Deleted.
Lyberta
 
Posts: 765
Joined: 19 Jun 2013, 10:45

Who is online

Users browsing this forum: Vikiznl and 1 guest