Chapter 5: Advanced
This chapter contains advanced topics and tidbits for developers and intermediate users of GoboLinux. These are not mandatory but probably useful to know in the long run.
This chapter contains advanced topics and tidbits for developers and intermediate users of GoboLinux. These are not mandatory but probably useful to know in the long run.
Many scripts accept command-line options. All options feature a short,
one-letter form, and a long form. Following the GNU conventions, short form
options are preceded by a single hyphen (as in -a, -b) and long form options
are preceded by two hyphend (as in --foo, --bar).
All command-line options have to be passed first, before other types of arguments (file names, package names, etc).
In other words:
works, but
does not.
Some command-line options accept arguments. These arguments must be passed as the word following the argument, both in short and long forms. For example, say that -s and –long are options that take a parameter. This is the correct way to use them:
These are not recognized:
Each option should be passed in a separate token, even when in short mode.
If -a, -b and -c are options for an immaginary FooScript, then
is correct, but
is not.
All scripts have a --help option (or, in short form, -h). When a program
that needs arguments is run without arguments, the help text will be
displayed. (Note: Actually, not all scripts conform to this yet, but this is
being worked on).
Many of the restrictions above are actually
implementation limitations. “Fixing” them is not a high-priority in the project,
but patches to lift this restrictions are welcome. See
/Programs/Scripts/Current/Functions/OptionParser if you’re curious.
Many scripts accept command-line options. All options feature a short,
one-letter form, and a long form. Following the GNU conventions, short form
options are preceded by a single hyphen (as in -a, -b) and long form options
are preceded by two hyphens (as in --foo, --bar).
All command-line options have to be passed first, before other types of arguments (file names, package names, etc). In other words,
works, but
does not.
Some command-line options accept arguments. These arguments must be passed as
the word following the argument, both in short and long forms. For example, say
that -s and --long are options that take a parameter. This is the correct
way to use them:
These are not recognized:
Each option should be passed in a separate token, even when in short mode. If
-a, -b and -c are options for an imaginary FooScript, then
is correct, but
is not.
All scripts have a --help option (or, in short form, -h). When a program
that needs arguments is run without arguments, the help text will be displayed.
(Note: Actually, not all scripts conform to this yet, but this is being worked
on).
This script is used everywhere inside many scripts. It exports shell variables
such as $goboExecutables, $goboUsers, $goboKernel, and so on, which
contains a string specifying where in the file system these entries are
(/System/Index/bin, /Users, /System/Kernel, and so on).
For example, in the Scripts package, within the bin/ subdirectory are files
such as ScriptFunctions or SuggestUpdates, among others. These source
GoboPath via:
This is normally within the Scripts package, at bin/GoboPath. The whole
GoboLinux hierarchy is kept as referential prefix in that file. The variable
$goboPrefix keeps track as to where GoboLinux is mounted at.
Let’s avoid hardcoding things, sourcing this file and using these variables makes the world a better place :-)
This section documents the coding style used in GoboLinux shell scripts.
It’s important to note that not all scripts follow these guidelines, because of historical baggage (some of the scripts are older than GoboLinux itself). Patches to correct the non-conformities are welcome.
A few rules of thumb:
do and then in the same line
with ;, instead put it on a line by itself, aligned with for, while or
if.if rather than idioms like && { }, but apply your common
sense.${x} syntax when merging variables inside strings.esac is ridiculous.Functional module. By now, Map() is defined in the Array
module.It’s hard to believe, but the only shell module containing GoboLinux-specific
stuff is the one aptly called GoboLinux. Keep that in mind when submitting
functions for inclusion in one of the modules.
The idea in the naming convention is to orthogonally describe scope and purpose
of each name. We define “local scope” as names that are specific to a given
script, and “library scope” as names defined in Scripts modules such as
GoboPath, ScriptFunctions or one of the imported
function modules.
These are the guidelines:
Example: local_function, Library_Function
Example: localvariable, LibraryVariable
Example: Library_Function, LibraryVariable
Example: local_function, localvariable
Example: PATH, LD_LIBRARY_PATH
Example: compileRecipeDirs, editKeymapLayout
Normally, you shouldn’t need to compile “manually”, i.e., without using the
Compile tool. However, it is possible to manually run
the same commands that Compile uses.
See also: How To’s → Manual Compile
Compiling programs in Linux is typically a three-part process: prepare the
sources with ./configure, compile them with make, and install the compiled
program with make install.
To this process, Gobo adds a source configuration step to target the GoboLinux
directory structure, and after the install phase, a step that symlinks the files
from the application directory under /Programs to /System/Index. It is this
last step that makes programs “visible” to the GoboLinux system.
These are the relevant commands:
PrepareProgram is a wrapper to the first step
described above. SandboxInstall is a wrapper to
the third step, ensuring safe execution of make install.
SymlinkProgram performs the final operations
that integrate the new program into the system.
The PrepareProgram script does two things. It
creates a directory hierarchy for the program under /Programs, and it attempts
to prepare the sources for compilation.
The syntax for the PrepareProgram is:.
Passing a program name and version number is mandatory. These names are the ones used in the directories under programs. For example,
(the --tree switch) creates the directories /Programs/Foo/Settings,
/Programs/Foo/1.0, /Programs/Foo/1.0/bin and so on.
The second task performed by PrepareProgram is
to prepare the sources. Since there isn’t a standardized format for distribution
of source-code tarballs in the free software world, there is no way to implement
completely automated preparation. Fortunately, the popularization of the GNU
AutoTools brings us much closer.
PrepareProgram, in this second step, will
detect availability of preparation tools and perform one of the following:
configure script generated by GNU autoconf,
PrepareProgram will run it, passing the
necessary options (mainly --prefix, --sysconfdir) as well as any
additional options requested by the user in the command line (as
<additional-options>).configure scripts, but due to the
popularity of GNU autoconf, design a command line interface similar to that
used by autoconf. PrepareProgram tries to
detect if a non-autoconf configure script accepts at least the --prefix
option, and uses it.In short, PrepareProgram can be considered a
wrapper to configure. Instead of running, for example,
you’ll run
Strictly speaking, if everything were configured correctly you could simply run
make and make install, and all files would be installed under the
appropriate subdirectory under Programs/.
To ensure this happens is to guarantee the modularity of the software installation.
To prevent any possibility of files being copied elsewhere in the directory tree
than the target under /Programs, GoboLinux conducts the install step in a
“sandbox” that is isolated from the rest of the filesystem.
SandboxInstall constructs a container for
make install. It uses a sandbox provided by the
FiboSandbox script, which configures custom
permissions for an allowed set of paths to a special user,
fibo. On systems with a UnionFS backend (such as
FunionFS, UnionFS-FUSE or OverlayFS), the sandbox is provided by the alternative
script UnionSandbox. Installation then runs
confined to a sandbox, with no permission to write anywhere but the few places
SandboxInstall allows it to, such as
/Programs/Foo/Current and /Programs/Foo/Settings. Therefore, no files can be
installed in “random places”. A typical call to
SandboxInstall looks like this:
If necessary, additional options can be passed. Refer to the SandboxInstall
reference page for details.
The final step in the compilation of a program is performed by the
SymlinkProgram. This is the script responsible
for creating the symbolic links under /System/Index.
The syntax for SymlinkProgram is:
The second argument is optional. If no version number is specified, the one
linked as Current will be used. A commonly used command-line parameter is -c
overwrite, which tells it to overwrite any existing symlinks in case of
conflicts (the default action is to preserve the existing links in order to not
affect previously existing applications). To integrate a program Foo into the
/System structure, overwriting any links, you would type:
SymlinkProgram features many command-line
switches, to cover more advanced needs. You can refer to the SymlinkProgram
reference page for details if necessary.
To simplify the users’ view of filesystem, GoboHide conceals legacy unix
directories such as /usr, /lib, /sbin, and /etc, which contain links to
files placed elsewhere under The GoboLinux Filesystem
Hierarchy.
GoboHide works by hooking directory read operations directly in the root of the
problem: since every readdir() call is translated and performed by the kernel,
we have added a list which is kept in kernel, checking every readdir()
operation. If the current inode being read is stored in this list, then it
simply doesn’t get copied onto the destination buffer, which should be returned
to the user.
The user’s interface to the GoboHide ioctl’s is through a userspace tool, called
gobohide, and has the following options:
In order to hide a directory, one would need to run gobohide with -h, passing
the target entry. A subsequent ls will not show the hidden entry, then:
This allows entries to be really hidden from the filesystem. But don’t worry, this can be only performed by the superuser, and he/she has power to ask the kernel for the entries being hidden. This ensures that nothing gets hidden without the superuser’s conscience:
And the best of it all: you can still access your files inside these hidden entries, and even bash would tell you that files exist in these directories:
GoboHide currently supports hiding entries on any mounted filesystem. Because it is implemented at the level of the Linux virtual filesystem, it is independent of specific filesystems.
The Linux kernel differs from standard packages. It has nothing to be linked against the legacy tree: no libraries, no binaries, no headers, no manuals or info pages. Moreover, there are many things on a regular system which are very tied to the kernel itself, such as the proc and sys filesystems, the device nodes and the boot loader files.
These characteristics led to the creation of a special directory for the kernel,
called /System/Kernel. This tree is organized in the following way:
/System/Kernel/Boot - Bootloader files, including the kernel image/System/Kernel/Devices - Device nodes, populated by Udev + Hotplug/System/Kernel/Modules - Kernel modules/System/Kernel/Objects - Sysfs, providing information gathered from Linux
2.6/System/Kernel/Status - The mounted proc filesystemThanks to Compile, installing a new kernel is pretty straightforward on
GoboLinux. The Linux recipe takes into account the existence of a file called
config.gz inside /System/Kernel/Status. This file contains the current
configuration for the running kernel, and is used thereby to feed the new kernel
options.
In short, running Compile Linux will fetch the latest available recipe
(which already contains GoboLinux optional patches). After doing that, the
kernel itself is automatically downloaded, patched and filled with the current
configuration, taken from config.gz.
The menuconfig entry then appears, and allows for the user to modify their
kernel options. Just selecting Exit and telling the script to save the changes
will finish the user’s interaction with the Linux kernel compilation. After
completed, a new entry will appear under
/System/Kernel/Modules/$KERNEL_RELEASE, and the new bzImage and System.map
files will get installed under /System/Kernel/Boot.
The old bzImage and System.map files aren’t overwritten, though. They’re just
symlinks to the current kernel image, and this guarantees that if something goes
wrong, a rollback can be done by simply modifying the kernel image at the GRUB’s
bootloader prompt, and later by reverting the symlink’s target to the previous
release.
To install a kernel which is newer than the available recipe, or one other than
vanilla, you may use NewVersion.
If you already have a kernel downloaded, or have a special source package, you
may place it in /Data/Compile/Archives.
NewVersion Linux <Version> https://kernel.org/pub/linux/kernel/v6.12/<your-archive-name>
to create a recipe. Using a fake URL is all right if you don’t intend to
distribute the recipe./Data/Compile/LocalRecipes/Linux/<Version> directory.Compile as usual.The Linux recipe comes with a few patches in order to improve the user’s experience with the system. The patchset includes, but is not restricted to, the following modifications:
mount commandGoboLinux has some design features to assist adapting software builds to the GoboLinux directory structure.
Symbolic links play a major role in a GoboLinux system, but some programs don’t behave as expected when they are used. This section lists the files that cannot be symlinks.
“That is the reason why /System/Settings is not /System/Index/Settings: it does not only contain links, by definition (or, better put, by necessity)” – Hisham Muhammad
/System/Settings/sudoersThe configuration file for sudo must be a regular file. If it is not, sudo
will complain and do nothing.
/System/Settings/passwd and friendsThe settings files used by the Shadow package are quite interesting. Theoretically, they can be symlinks, but there is a caveat: utilities like useradd don’t just modify these files; they remove and recreate them as regular files. Hence, in practice, they cannot be symbolic links.
The build system in GoboLinux uses sandboxing to ensure that all the filesystem writes during the software install phase are limited to an appropriate part of the filesystem. GoboLinux 016 ships with two different sandbox implementations.
UnionSandbox is a modern implementation which uses file system unions to achieve isolation. It is the default sandbox installer.
FiboSandbox is a fallback method used when a union-filesystem implementation
is not available in the running kernel. It sets up an isolated environment and
commands are run by a special user (named fibo) without root privileges.
During the installation phase of the software build process, most build systems
call the install program to copy files to their destination directories with
the proper ownership and attributes. install belongs to the CoreUtils
package.
Since user fibo lacks authority to change file ownership, the link at
/System/Index/bin/install points to a wrapper script in the Scripts package.
Under UnionSandbox, this wrapper script translates the superuser name if
necessary and calls real_install, a symlink to the CoreUtils install
utility, passing along the modified arguments.
Under FiboSandbox, the wrapper discards change-of-owner directives before
calling real_install.
GoboLinux has its own replacements for a few standard commands like su and
make. The reasons for making a replacement ranges from adding necessary
functionality (su) to making prettier output (make).
While having these “replaced programs” is not a problem in itself (in fact, most provide enhanced functionality which adds to the GoboLinux experience), it’s important to point out these differences here so that you can know what’s going on with these perhaps unexpected behaviors.
The replacements are provided by several different packages. All except
install are handled by making an alias in the shell initialization scripts.
This way, you can easily disable the alias and restore the original version of a
program, if you so wish. They can be often found in their own subdirectory
Resources/Wrappers inside the program directory.
ColorMake in the Scripts
package to produce colorful outputAliases enabling “enhanced replacements” such as Htop and Pinfo are set in the
Environment section of these packages. This way, if you want to stick to plain
top and/or info, all you need to do is to remove (or just not install) these
replacements.