<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=1696&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / How to create a self-extracting, self-executing tarball]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=1696</link>
		<description><![CDATA[The most recent posts in How to create a self-extracting, self-executing tarball.]]></description>
		<lastBuildDate>Sat, 04 Nov 2017 23:34:20 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6029#p6029</link>
			<description><![CDATA[<p>I had heard dash was faster, didn&#039;t know it could be <em>that</em> much faster. Good to know. I&#039;ll definitely try avoid bashisms from now on.</p><p>Enjoy the scripts, greenjeans! I&#039;m happy to mingle with you here--learn something new every day!</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 04 Nov 2017 23:34:20 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6029#p6029</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6017#p6017</link>
			<description><![CDATA[<div class="quotebox"><cite>GNUser wrote:</cite><blockquote><div><p>P.S. Another option would be to ditch the bashisms in the scripts and use a /bin/sh she-bang. Surely all GNU/Linux users would have <strong>some</strong> shell installed. This would be an easy upgrade.</p></div></blockquote></div><p>I&#039;ve been using dash for everything i&#039;m making, after login is done (bash) the system switches to dash anyway on Devuan and Debian, it&#039;s said to be 4-5 times faster than bash, just got to keep the bashism&#039;s outta the script. </p><p>I like your script even better now, and FYI i&#039;m stealing it too. <img src="https://dev1galaxy.org/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[dummy@example.com (greenjeans)]]></author>
			<pubDate>Sat, 04 Nov 2017 20:42:44 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6017#p6017</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=6000#p6000</link>
			<description><![CDATA[<p>I purged the bashisms and added some polish. Here are the scripts again, tested and working on multiple shells (bash, dash, busybox ash):</p><div class="codebox"><pre><code>#!/bin/sh

# This script should be called &quot;pack&quot;. It works as-is for any project.

project_folder=&quot;$(dirname &quot;$(realpath &quot;$0&quot;)&quot;)&quot;
project_name=&quot;$(basename &quot;$project_folder&quot;)&quot;

cd &quot;$project_folder&quot;
tar cvzf ../payload.tar.gz ./*
cd ..
cat &quot;$project_folder/unpack&quot; payload.tar.gz &gt;&quot;$project_name.run&quot; &amp;&amp; chmod a+x &quot;$project_name.run&quot;
mv &quot;$project_name.run&quot; $HOME/Desktop 2&gt;/dev/null
rm payload.tar.gz
printf &quot;$HOME/Desktop/$project_name.run created\n&quot;
exit 0</code></pre></div><div class="codebox"><pre><code>#!/bin/sh

# This script should be called &quot;unpack&quot;. Only the POST-UNPACK COMMAND needs to be customized.

ARCHIVE_STARTLINE=$(awk &#039;/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }&#039; &quot;$0&quot;) # gets line number below &quot;__ARCHIVE_BELOW__&quot;

if [ &quot;$1&quot; = &quot;unpack&quot; ]; then
	runfile_dir=&quot;$(dirname &quot;$(realpath &quot;$0&quot;)&quot;)&quot;
	project_name=&quot;$(basename &quot;$0&quot; .run)&quot;
	DEST_DIR=&quot;$runfile_dir/$project_name&quot;; [ -d &quot;$DEST_DIR&quot; ] &amp;&amp; rm -r &quot;$DEST_DIR&quot;; mkdir &quot;$DEST_DIR&quot;
	tail -n +$ARCHIVE_STARTLINE &quot;$0&quot; | tar xzv -C &quot;$DEST_DIR&quot;
else
	export TMPDIR=$(mktemp -d /tmp/selfextract.XXXXXX)
	trap &quot;rm -rf $TMPDIR&quot; EXIT HUP TERM INT
	tail -n +$ARCHIVE_STARTLINE &quot;$0&quot; | tar xzv -C &quot;$TMPDIR&quot; 1&gt;/dev/null &amp;&amp; cd &quot;$TMPDIR&quot;
	./foo &quot;$@&quot; # &lt;-- POST-UNPACK COMMAND
fi
exit 0

__ARCHIVE_BELOW__</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 04 Nov 2017 13:37:06 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=6000#p6000</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5995#p5995</link>
			<description><![CDATA[<div class="quotebox"><blockquote><div><p>Surely all GNU/Linux users would have some shell installed</p></div></blockquote></div><p>Yes, according to <a href="http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/bin.html" rel="nofollow">FSSTND</a>, you&#039;ll need to venture off the ranch for that one.</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Sat, 04 Nov 2017 02:27:53 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5995#p5995</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5993#p5993</link>
			<description><![CDATA[<p>P.S. Another option would be to ditch the bashisms in the scripts and use a /bin/sh she-bang. Surely all GNU/Linux users would have <strong>some</strong> shell installed. This would be an easy upgrade.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 04 Nov 2017 01:41:53 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5993#p5993</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5992#p5992</link>
			<description><![CDATA[<p>Nice thought. That hadn&#039;t occurred to me, nor could I imagine that some penguinistas might have a problem with bash. Wow, there are some real hard-core minimalists out there!</p><p>All of my projects contain binaries in the tarball anyway (with accompanying source code--hence the benefit of user being able to unpack and re-pack the .run file), so using a shell script header does not expand the audience. Therefore, I would only stand to gain by using a binary header instead.</p><p>I&#039;ll check out using C or newlisp as an alternative when I have a chance. I have a crush on C, but tend to gravitate towards bash and python because I&#039;m lazy. If you can&#039;t have the one you love, love the one you&#039;re with.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Sat, 04 Nov 2017 01:16:18 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5992#p5992</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5991#p5991</link>
			<description><![CDATA[<p>Good script.</p><p>One (small) remaining problem would be that it&#039;s still a script and not a binary; it relies on a pre-installed interpreter (bash), and is thus not fully self contained. Of course, that&#039;s not much of a problem except for those who take offence to installing bash, and those who wants a suid program.</p><p>But if you want that covered as well, you could write up that header function in C (probably with some minor variation to the separation logic), and then pack such a binary in front of a tar to make a <em>binary</em>, self-executable tar. The point being that you can concatenate anything to a binary executable without that destroying it.</p><p>(Or, rather than C, you could use <a href="http://www.newlisp.org" rel="nofollow">newlisp</a>, which in fact includes an embedding method similar to this.)</p><p>On the other hand, as a binary, it&#039;ll instead be sensitive to the architecture, and thus less universally distributable -- swings and carousels.</p>]]></description>
			<author><![CDATA[dummy@example.com (ralph.ronnquist)]]></author>
			<pubDate>Sat, 04 Nov 2017 00:22:31 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5991#p5991</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5961#p5961</link>
			<description><![CDATA[<p>Combining multiple files into a single file is trivial (tar) but is just one of three ingredients. The challenging and fun part was figuring out how to make the tarball <em>self-extracting</em> and <em>self-executing</em>. I thought I&#039;d share how I did it, since it was not trivial and could be useful to someone.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Thu, 02 Nov 2017 18:55:12 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5961#p5961</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5959#p5959</link>
			<description><![CDATA[<p>....or you could just use <strong>tar</strong>. <img src="https://dev1galaxy.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (FOSSuser)]]></author>
			<pubDate>Thu, 02 Nov 2017 18:30:22 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5959#p5959</guid>
		</item>
		<item>
			<title><![CDATA[How to create a self-extracting, self-executing tarball]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=5955#p5955</link>
			<description><![CDATA[<p>I enjoy putting together little apps for myself or my penguin friends, and have long looked for a simple way to bundle scripts, binaries, and icons. I realize this can be accomplished with a .deb or an AppImage, but I&#039;ve always longed for something much simpler.</p><p>Well, I finally figured something out. It just involves two scripts.</p><p>This one should be named &quot;pack&quot;:</p><div class="codebox"><pre><code>#!/bin/bash

# no need to change anything in this script (nothing in here is project-specific)

project_folder=&quot;$(dirname &quot;$(realpath &quot;$0&quot;)&quot;)&quot;
project_name=&quot;$(basename &quot;$project_folder&quot;)&quot;

tar cvzf ../payload.tar.gz ./*
cd ..
cat &quot;$project_folder/unpack&quot; payload.tar.gz &gt;&quot;$project_name.run&quot; &amp;&amp; chmod a+x &quot;$project_name.run&quot;
mv &quot;$project_name.run&quot; $HOME/Desktop 2&gt;/dev/null
rm payload.tar.gz
echo &quot;$HOME/Desktop/$project_name.run created&quot;
exit 0</code></pre></div><p>And this one should be named &quot;unpack&quot;:</p><div class="codebox"><pre><code>#!/bin/bash

# the only line in this script that you need to customize is the POST-UNPACK COMMAND

ARCHIVE_STARTLINE=`awk &#039;/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }&#039; &quot;$0&quot;` # gets line number below &quot;__ARCHIVE_BELOW__&quot;

if [[ &quot;$1&quot; = &quot;unpack&quot; || &quot;$1&quot; = &quot;extract&quot; ]]; then
	executable_name=&quot;$(basename &quot;$0&quot;)&quot;
	project_name=&quot;${executable_name%.*}&quot; # strip extension
	executable_folder=&quot;$(dirname &quot;$(realpath &quot;$0&quot;)&quot;)&quot;
	DEST_DIR=&quot;$executable_folder/$project_name&quot;; [ -d &quot;$DEST_DIR&quot; ] &amp;&amp; rm -r &quot;$DEST_DIR&quot;; mkdir &quot;$DEST_DIR&quot;
	tail -n+$ARCHIVE_STARTLINE &quot;$0&quot; | tar xzv -C &quot;$DEST_DIR&quot; &amp;&gt;/dev/null
	exit 0
else
	export TMPDIR=`mktemp -d /tmp/selfextract.XXXXXX`
	tail -n+$ARCHIVE_STARTLINE &quot;$0&quot; | tar xzv -C &quot;$TMPDIR&quot; &amp;&gt;/dev/null
	cd &quot;$TMPDIR&quot;
	./foo &quot;$@&quot; # &lt;-- POST-UNPACK COMMAND
	# cleanup:
	cd -
	rm -rf &quot;$TMPDIR&quot;
	exit 0
fi

__ARCHIVE_BELOW__</code></pre></div><p>Say you have a directory called some-project, which contains shell scripts, binaries, icons, and maybe other things your app needs. Simply put the pack and unpack scripts in the some-project directory. The only thing that needs to be customized is the POST-UNPACK COMMAND line in the unpack script.</p><p>Now executing pack will create &quot;some-project.run&quot; on your desktop, which you can use yourself or share with your friends. </p><p>Running some-project.run will unpack the some-project directory to /tmp and launch the post-unpack command. If your friend is computer-savvy and wants to inspect and/or change the contents of some-project.run, running some-project.run with &quot;unpack&quot; as an argument will give them the some-project directory so that they can change stuff and then re-pack:</p><div class="codebox"><pre><code>some-project.run unpack # this will create some-project directory
cd some-project
# change stuff in the some-project directory
./pack</code></pre></div><p>P.S. The central idea for all of this was <a href="https://www.linuxjournal.com/node/1005818" rel="nofollow">this amazing old post</a> from Jeff Parent. For an example project, check out my portable (no dependencies!) <a href="http://files.dantas.airpost.net/public/international-keyboard.run" rel="nofollow">international-keyboard.run</a>.</p>]]></description>
			<author><![CDATA[dummy@example.com (GNUser)]]></author>
			<pubDate>Thu, 02 Nov 2017 16:50:25 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=5955#p5955</guid>
		</item>
	</channel>
</rss>
