appscript —
Very lightweight script to create
self-extractable archives
appscript |
[-Lt] [-c
[gzip|xz|zstd]]
[-o filename]
directory |
appscript is a very lightweight script
that compresses a directory using
tar(1), encodes the result with
base64(1), and then creates a
sh(1) script that decompresses that result into a temporary
location (optionally using
tmpfs(4)), and finally executes a script named
APPSCRIPT from the current working directory.
The resulting script handles signals generated by certain events
to clean up the temporary location created, including unmounting the mounted
tmpfs(4) filesystem if the script is configured to do so.
The idea is similar to how
makeself(1) works, but it is written entirely in POSIX shell,
leveraging
tmpfs(4), and is much lighter.
appscript has been implemented in fewer than 160
lines, and the resulting script has fewer than 60 lines. Unlike
makeself(1), which aims to implement more use cases and
emulate the behavior of some file archiving utilities that create
executables, appscript only aims to run a script
with all dependencies contained within it. In this context,
“dependencies” refers to the files the script wants to use.
You can combine appscript with
appjail(1) to run applications (possibly with
appjail-x11(1)) in an isolated and disposable manner. From
the user’s perspective, it’s like running an application with
a single click.
-L
- All symbolic links will be followed.
Normally, symbolic links are archived as such. With this option, the target
of the link will be archived instead.
-v
- Display version information about
appscript.
-t
- Configure the resulting script to use
tmpfs(4) when
vfs.usermount
is set to 1.
If the attempt to mount
tmpfs(4) fails, the resulting script will continue
regardless.
-c
[gzip|xz|zstd]
- Compression algorithm to be used.
xz is the
default.
-o
filename
- Name of the resulting script. By default,
/dev/stdout.
The execute bit is always set if this argument is a file.
- directory
- Directory to be compressed.
appscript assumes that the
APPSCRIPT script is already present and has the
execute bit set.
APPSCRIPT_PWD
- Since APPSCRIPT runs from the current user's working
directory, it does not know the location of the temporary directory. This
environment variable specifies that location.
APPSCRIPT_SCRIPT
- Absolute path to the AppScript that is currently running.