Compare commits

..

1 Commits

Author SHA1 Message Date
Kreyren
a1891a1dcc
Create sms.yml
Stub for implementation to sent SMS about critical issues to relevant people
2020-03-18 11:23:58 +01:00
159 changed files with 42 additions and 3178 deletions

@ -2,8 +2,4 @@
FIXME: Preamble needed
FIXME: Do not assign translate variables in fixme messages
### Translate the project
Search the code for `FIXME-TRANSLATE` and add logic for your language
FIXME: Do not assign translate variables in fixme messages

3
.github/FUNDING.yml vendored

@ -16,5 +16,4 @@ issuehunt: rixotstudio
otechie: rixotstudio
# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
# Referer link on github.com/kreyren
custom: https://my.fsf.org/join?referrer=3706032
custom: https://my.fsf.org/join

86
.github/README.md vendored

@ -1,86 +1,16 @@
**FIXME:** Markdownlint has to be optimized for this file<br>
**FIXME:** Source the header in different markdown file to make GitHub README different from GitLab.
**NOTICE:** This project in in "init phase" so everything will be remade into a new orphen branch once methods for quality assurance, documentation, automatization and code is decided to be used as a foundation for new commits
**FIXME:** Change the name based on name repository used.
fixme: Source the header in different markdown file to make GitHub README different from GitLab
<h1 align="center">
<a href=https://github.com/RXT0112/Zernit>Zernit</a> (RXT0112)
</h1>
<h4 align="center">Community maintained (FIXME: Unknown clarification) designed to work cross-platform and using multiple programming languages depending on which one provides the most efficiency per required runtime on target system</h4>
fixme: Change the name based on repository used.
<p align="center">
<img src="https://img.shields.io/badge/Maintained%3F-Yes-green?style=for-the-badge">
<img src="https://img.shields.io/github/license/RXT0112/Zernit?style=for-the-badge">
<img src="https://img.shields.io/github/issues/RXT0112/Zernit?color=violet&style=for-the-badge">
<img src="https://img.shields.io/github/stars/RXT0112/Zernit?style=for-the-badge">
<img src="https://img.shields.io/github/forks/RXT0112/Zernit?color=teal&style=for-the-badge">
</p>
# Zernit (RXT0112)
**NOTICE:** Code-related implementation merge requests are currently not accepted due to the lack of repository management for multi-language project which is currently being worked on, however merge request will be processed if submitted with a priority affected by this restriction.
System manager of WIP_NAME designed to work cross-platform and using multiple programming languages depending on which one provides the most efficiency per required runtime.
**FIXME:** Change the URL based on the website used<br>
fixme: Change the URL based on the website used<br>
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/RXT0112/RXT0112)
**FIXME:** Add a pretty button<br>
**FIXME:** codesandbox currently cannot be used for zernit<br>
**FIXME:** Add tracking for scodsandbox usage on zernit<br>
https://codesandbox.io/sgithub/RXT0112/RXT0112
fixme: Add prety button<br>
https://codesandbox.io/s/github/RXT0112/RXT0112
**FIXME:** Change the URL based on the website used<br>
**FIXME:** repl.it currently cannot be used for zernit<br>
**FIXME:** Add tracking for scodsandbox usage on zernit<br>
[![Run on Repl.it](https://repl.it/badge/github/RXT0112/Zernit)](https://repl.it/github/RXT0112/Zernit)
## When to make a new issue?
### Questions
All relavant questions are welcomed and will be answered as soon as possible depending on the lenght of the question and the understanding of the supporter.
### Bugs
Everything relevant that does not work as expected or can be improved. The more issues we are aware of the more work we can put in to resolve them.
### Feature requests
Propose anything we will listen and consider it as long as it's relevant.
### Legal requests
**NOTICE:** This is currently being implemented so there might be a delay in responses due to the lack of resources
This project has custom community maintained license which is designed to avoid common issues related to FSF/GNU/OSS-endorsed licenses while directing the workflow, see License below for more info.
Anything relevant to legal is welcomed in:
- Our bug tracker
- Mentioning `@RXT0112/legal-team` in your relevant GitHub tickets
- Sending an e-mail on [zernit-legal@rixotstudio.cz](mailto:zernit-legal@rixotstudio.cz)
## Mentoring program
**NOTICE:** This is currently work in progress and provided with limited resources
This project provides a free mentoring program for anyone who makes a new merge request with (TBD)
This mentoring support is provided by the community for the community to provide a free education to improve the community-wide code quality and to ensure that everyone who wants to code has the resources to start and learn.
If you need a help on projects outside of project RXT0112 then mension `@RXT0112/mentors` in your GitHub tickets.
Mentoring support is also provided on community server (TBD)
Project RXT0112 hopes to provide an environment for everyone to learn, freel free to mension our mentoring program in your repositories.
## Where to get support
1. For simple questions, guidance and mentoring use chat on https://webchat.freenode.net/#zernit-support
2. For complicated issues either:
- Mension `@RXT0112/support` in your issues or relevant merge requests on GitHub
- Make a new issue in relevant RXT0112 organization (anything relevant is welcomed!)
3. Sent an email on [zernit-support@rixotstudio.cz](mailto:zernit-support@rixotstudio.cz)
## License
This project is designed around a community maintained license that is used to direct a workflow while preserving end-user's freedoms to fix common FSF/GNU/OSS-endorsed license issues (FIXME: Reference the issues) that would allow blockchain implementation and for-profit business plan.
**NOTICE:** The for-profit business plan is currently being investigated to make it suitable for this project, might be turned in non-profit

10
.github/workflows/sms.yml vendored Normal file

@ -0,0 +1,10 @@
- name: 'Sending SMS Notification'
uses: twilio-labs/actions-sms@v1
with:
fromPhoneNumber: '+1(234)5678901'
toPhoneNumber: '+1(234)3334444'
message: 'Hello from Twilio'
env:
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }}
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }}

@ -11,7 +11,7 @@ jobs:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'FIXME: Stale issue message (https://github.com/RXT0112/Zernit/edit/master/.github/workflows/stale.yml)'
stale-pr-message: 'FIXME: Stale pull request message (https://github.com/RXT0112/Zernit/edit/master/.github/workflows/stale.yml)'
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'

@ -1,8 +1,7 @@
privileged: true
image:
file: gitpod/debian.Dockerfile
# FIXME: Change gitpod user on GITPOD_GIT_USER_NAME env value
tasks:
# Does not accept Quotation without '|' ?
@ -31,4 +30,4 @@ vscode:
- matklad.rust-analyzer@0.1.20200217:zozmBmOg1N91pRISIsYXBg==
- exiasr.hadolint@0.3.0:/FkAW3eTb+z9O7VZAyAa0w==
- DavidAnson.vscode-markdownlint@0.34.0:l4DL7iPpo7DdhfUHIUtcuQ==
- yzhang.markdown-all-in-one@2.7.0:5+DmuGcePw8L9PtfgOAAHg==
- yzhang.markdown-all-in-one@2.7.0:5+DmuGcePw8L9PtfgOAAHg==

@ -13,7 +13,7 @@ edition = "2018"
# FIXME: Replace with latest once development is in gold
clap = "2.33.0"
# Used for repository management as alternative to 'make'
cargo-make = "0.30.0"
cargo-make = "0.28.0"
# Used for reading toml files
toml = "0.5.6"
# Custom logging solution

@ -1,3 +1,3 @@
All rights reserved by Jacob Hrbek <kreyren@rixotstudio.cz> in 12/07/2018 unless explicitedly specified otherwise.
This project's license is located in the LICENSE directory, please refer there for more informations.
This repository is designed to be used with a licences specified in src/licences that are custom made for this project and projects alike to define a new standard.
License is transleted through crowdsourcing where file with name EN-LICENSE is the original license.

3
LICENSE/README.md Normal file

@ -0,0 +1,3 @@
This directory contains license used for the whole repository unless defined otherwise in the license itself.
Everyone has the right to propose new changes for review with reasoning to why they should be adapted.

@ -1,7 +1,5 @@
The licensing has been discussed in FSF which is due to the activity and info provided getting out of hand for me to process all the informations and resolve duplicate questions thus this file has been created hopefully being usable for the project in the future.
TODO(Krey): Each license should have four freedom compilance statement.
# What is this?
Summary: This is project codenamed as RXT0112 with assigned name Zernit currently hosted on https://github.com/RXT0112/Zernit which is expected to be system/package-manager that is expected to supports any downstream on any kernel with custom dowsntream method.

@ -8,11 +8,6 @@ all:
@ printf '%s\n' "Unknown option '$1' parsed in target all"
@ exit 2
## UNLEASH RUNTIME ##
unleash-elisp:
@ src/RXT0112-1/downstream-classes/zeres-0/elisp/UNLEASH.el
## BUILD ##
# All build targets are expected in 'build/build-LANG' where 'LANG' is the unique identifier of the language used
# FIXME: Replace 'exit 1' with helpful messages
@ -122,7 +117,7 @@ check-vlang:
# FIXME: Run all benches if this is executed
bench: bench-rustlang
# FIXME: Run vendor and
# FIXME: Run vendor and
bench-rustlang:
@ cargo bench
@ -134,4 +129,4 @@ clean: clean-vendor clean-benches
clean-vendor:
@ # FIXME: Output helpful message if directory doesn't exists
@ [ -d vendor ] && { rm -rf vendor || exit 1 ;} || exit 0
@ [ -d vendor ] && { rm -rf vendor || exit 1 ;} || exit 0

1
QA/README.md Normal file

@ -0,0 +1 @@
Backend for Quality Assurance

@ -1,12 +0,0 @@
SUCCESS: test!
SUCCESS: test!
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil
SUCCESS: nil

@ -1,7 +1,11 @@
FROM debian:latest
# FIXME: Outputs `gitpod@ws-ce281d58-997b-44b8-9107-3f2da7feede3:/workspace/gitpod-tests1$` in terminal
# FIXME: Add hadolint executable
# FIXME: We can use /bin/sh instead of /bin/bash to get minor optimization
# To avoid bricked workspaces (https://github.com/gitpod-io/gitpod/issues/1171)
ENV DEBIAN_FRONTEND=noninteractive
ARG DEBIAN_FRONTEND=noninteractive
USER root
@ -18,7 +22,7 @@ RUN useradd \
# Install dependencies
RUN apt-get update \
&& apt-get install -y rustc sudo cargo pkg-config \
&& apt-get install -y rustc cargo pkg-config \
&& : "Install hadolint if not available in downstream" \
&& if ! apt-cache search hadolint | grep -qP "^hadolint -.*"; then { if ! command -v wget >/dev/null; then apt-get install -y wget; fi ;} && wget https://github.com/hadolint/hadolint/releases/download/v1.17.5/hadolint-Linux-x86_64 -O /usr/bin/hadolint && { [ ! -x /usr/bin/hadolint ] && chmod +x /usr/bin/hadolint ;}; elif apt-cache search hadolint | grep -qP "^hadolint -.*"; then apt-get install -y hadolint; fi \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh \

@ -1,15 +1 @@
FROM scratch
# Blocked by https://github.com/gitpod-io/gitpod/issues/39
COPY gitpod/scripts/root-access.sh /usr/bin/root-access
RUN true "7a8fhs1g" \
&& chmod +x /usr/bin/root-access \
&& /usr/bin/root-access \
&& rm /usr/bin/root-access
# Blocked by https://github.com/gitpod-io/gitpod/issues/1265
COPY gitpod/scripts/vm-support.sh /usr/bin/vm-support
RUN true "dg798sda7h" \
&& chmod +x /usr/bin/vm-support \
&& /usr/bin/vm-support \
&& rm /usr/bin/vm-support
FROM scratch

@ -1,19 +1,5 @@
FROM gitpod/workspace-full-vnc:latest
# Blocked by https://github.com/gitpod-io/gitpod/issues/39
COPY gitpod/scripts/root-access.sh /usr/bin/root-access
RUN true "7a8fhs1g" \
&& chmod +x /usr/bin/root-access \
&& /usr/bin/root-access \
&& rm /usr/bin/root-access
# Blocked by https://github.com/gitpod-io/gitpod/issues/1265
COPY gitpod/scripts/vm-support.sh /usr/bin/vm-support
RUN true "dg798sda7h" \
&& chmod +x /usr/bin/vm-support \
&& /usr/bin/vm-support \
&& rm /usr/bin/vm-support
# FIXME: Add hadolint executable
# To avoid bricked workspaces (https://github.com/gitpod-io/gitpod/issues/1171)

@ -1,43 +0,0 @@
#!/bin/sh
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> under GPLv3 <https://www.gnu.org/licenses/gpl-3.0.en.html> in 19/05/2020 16:28
###! Terminate gitpod if the blocking root access bug has not been resolved yet
# FIXME: Quick-script
set -e
# FIXME: Rushed
die() {
printf 'FATAL: %s\n' "$2"
exit "$1"
}
# FIXME: Sanitize
if ! command -v curl 1>/dev/null; then
apt-get update
apt-get install curl -y
elif command -v curl 1>/dev/null; then
true
else
die 255 "processing curl"
fi
bugStatus="$(curl https://api.github.com/repos/gitpod-io/gitpod/issues/39 2>/dev/null | grep -o state.* || true)"
case "$bugStatus" in
"state\": \"open\",")
printf '\033[31m\033[1mBLOCKED:\033[0m %s\n' "Gitpod does not provide a root access which is mandatory for this repository, see it's tracking in https://github.com/gitpod-io/gitpod/issues/39"
if [ "$GITPOD_IGNORE_BLOCKERS" != 1 ]; then
exit 1
else
true
fi
;;
"state\": \"closed\",")
true
;;
*)
printf '\033[31m\033[1mBUG:\033[0m %s\n' "GitHub API returned an unknown state '$bugStatus' of bug https://github.com/gitpod-io/gitpod/issues/39"
exit 1
esac

@ -1,43 +0,0 @@
#!/bin/sh
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> under GPLv3 <https://www.gnu.org/licenses/gpl-3.0.en.html> in 19/05/2020 16:28
###! Terminate gitpod if the blocking root access bug has not been resolved yet
# FIXME: Quick-script
set -e
# FIXME: Rushed
die() {
printf 'FATAL: %s\n' "$2"
exit "$1"
}
# FIXME: Sanitize
if ! command -v curl 1>/dev/null; then
apt-get update
apt-get install curl -y
elif command -v curl 1>/dev/null; then
true
else
die 255 "processing curl"
fi
bugStatus="$(curl https://api.github.com/repos/gitpod-io/gitpod/issues/1265 2>/dev/null | grep -o state.* || true)"
case "$bugStatus" in
"state\": \"open\",")
die 1 "Gitpod does not provide a VM support which blocks cross-platform development, see tracking on https://github.com/gitpod-io/gitpod/issues/1265"
if [ "$GITPOD_IGNORE_BLOCKERS" != 1 ]; then
exit 1
else
true
fi
;;
"state\": \"closed\",")
true
;;
*)
printf '\033[31m\033[1mBUG:\033[0m %s\n' "GitHub API returned an unknown state '$bugStatus' of bug https://github.com/gitpod-io/gitpod/issues/1265"
exit 1
esac

@ -1,6 +1,6 @@
# Meta Compiler
Experiment for compilation based on the results of benchmarks made on the target system assuming this project being multi-planguag
Experiment for compilation based on the results of benchmarks made on the target system
## ABSTRACT

@ -1,191 +0,0 @@
#!/usr/bin/zernit sh
# Created by Jacob Hrbek <kreyren@rixotstudio,cz> under all rights reserved in 11/08/2020 01:02:33 CEST
# shellcheck shell=sh # Written to be POSIX compatible
###! Script designed to generate the white paper for this project in supported language
###! The whitepaper should be done to be understandable by the general public so avoid over-complication where possible.
[ -n "$whitepaperPath" ] || whitepaperPath="README.md"
# FIXME: Implement logic to deduce this
UPSTREAM_NAME="Zernit"
sectionNumber=0
# Exit on anything unexpected to capture code quality issues
set -x
# Wipe the current whipaper
"$PRINTF" '%s\n' "" > "$whitepaperPath"
# Title
case "$LANG" in
*)
"$CAT" <<-EOF >> "$whitepaperPath"
<h1 align="center">
<a href=$UPSTREAM_REPOSITORY>$PROJECT_NAME</a>
</h1>
EOF
esac
# Preamble
case "$LANG" in
en-*|*)
"$CAT" <<-EOF >> "$whitepaperPath"
$PROJECT_NAME is a system-manager designed to make devices capable of running our written logic painless and efficient while maintaining highest possible code quality standard and platform compatibility.
This whitepaper is not legally bindable and is provided to be used as a reference for the software development and comunity management.
If you find a conflicting part in the source code, then file a new tracking in $UPSTREAM_REPOSITORY and we will process it with relevant priority to ensure that these conditions are met as soon as possible or brainstorm it for this whitepaper to be updated.
Contributions to this whitepaper and suggestions are appreciated to influece the relevant software development.
EOF
esac
# Terminology
case "$LANG" in
en-*|*)
"$CAT" <<-EOF >> "$whitepaperPath"
## $(( sectionNumber + 1 )). Terminology
Software Users (SU) -- Parties that are using this software or are in other way affiliated with it or it's development
EOF
esac
# Ethicality
case "$LANG" in
en-*|*)
"$CAT" <<-EOF >> "$whitepaperPath"
## $(( sectionNumber + 1 )). Project ethiques
FIXME-DOCS
EOF
esac
# Privacy
# FIXME: Add logic for the sub number
case "$LANG" in
en-*|*)
"$CAT" <<-EOF >> "$whitepaperPath"
### $sectionNumber.1 Privacy
This project is designed to provide the absolute anonimity without compromise for it's SU unless relevant juristiction forces it to require informations of relevant parties in the area where said juristiction has the rightful authority to enforce these information processing that would otherwise make the usage of this software illegal in that area.
Data of SU should never be processed without an explicit permission that has to be opted-in and NEVER set by default at the cost of software malfunction (that should be sanitized to avoid fatal failure) where SU should never be prevented from using this software just because they don't want to provide their personal information.
Functions that explicitely require personal information should fail safely if said information is not provided or use a default value allowing the SU to blend into a crowd of anonymous users.
From experience with Enoch-based distributions alike Gentoo Linux as explained on hyperlink https://wiki.gentoo.org/wiki/User:MGorny/GCO_real_name_requirement it's required to provide an indentification to be allowed to submit changes to the source code.
This should never be limited on this project where possible and SU should have the option to submit their contribution under project's name (with their nickname if desired) if they don't want to or can't affort sharing this kind of information assuming that the contribution doesn't break the legal cleanroom and does not have a copyright which would make it impossible to be used in judistical areas that honors copyright law.
EOF
esac
# Freedom
# FIXME: Add logic for the sub number
case "$LANG" in
en-*|*)
"$CAT" <<-EOF >> "$whitepaperPath"
### $sectionNumber.1 Freedom of relevant parties
This project is designed to give it's SU the full freedom of doing whatever they want with the software and most importantly with it's source code as long as it doesn't have a negative impact on the business plan with some flexibility from the Software Authorities.
This solution is not ideal, but it's the best that we currently have, proposals for a better solution are appreciated.
The license should contain 'Four Freedom Compilance' that should be maintained over time to ensure that the license complies with four essential freedoms of Free Software defined by Free Software Foundation as explained in https://en.wikipedia.org/wiki/The_Free_Software_Definition#The_Four_Essential_Freedoms_of_Free_Software
It's important to mension that this project can be abused for an illegal activity as a result of provided freedom above that the project has legal obligation to enforce per local juristiction of the user assuming that the user chosed to provide it's locality where these laws applies. Thus users that chosed to not provide their location should be warned about this risk as they can be legally prosecuted by the relevant juristiction for which zernit is not responsible.
EOF
esac
# Software Design
case "$LANG" in
en-*|*)
"$CAT" <<-EOF >> "$whitepaperPath"
## $(( sectionNumber + 1 )). Software Design
The software is designed to work everywhere possible to be deployed painlessly to manage the target device as efficiently as possible.
EOF
esac
## Cross-platform
case "$LANG" in
en-*|*)
"$CAT" <<-EOF >> "$whitepaperPath"
## $(( sectionNumber + 1 )).1 Cross-platform support
FIXME: Decide
EOF
esac
# FIXME: The backend is currently undetermined
## Downstream
"$CAT" <<-EOF >> "$whitepaperPath"
Zernit is designed to make it efficient for it's SU to implement their own package downstream and make it available for everyone if desired.
Zernit creators are providing their own downstream with work in progress name \`zeres-0\` that is designed to provide system to process source code while giving the SU all available options to efficiently alter the build result
This downstream management is designed to provide tools that may be useful for package processing, but none of them are mandatory meaning that if desired you can run a blank file and zernit won't stop you.
To ensure the expected runtime this is expected to be enforced through provided standard per downstream repository.
## List of downstream items
Zeres-0 devices it's downstream into a \`downstream items\` each of which is designed to process diferent product.
### Packages
Used to process various source code into a package that can be imported on the target system/sandbox.
This downstream item is designed to either process the source code of the software into a package that then can be imported on the system or using pre-built binary with static options made to work on majority of devices.
In terms of database this requires following entries:
- Package Name
- Package Category
- Package Version
- Package Slot
And optionally:
- Homepage
- Upstream repository URL
- Upstream name
- Upstream organization
- License
- And anything relevant which the SU can cherrypick per system
Each package is processed through phases that are designed to each process specific part of the package where the developers have the option to specify which phases will be used to process the package meaning than none of these are mandatory at the cost of software malfunction:
- Fetch
Fetch the source code in the specified destination for processing
- Checksum check
Designed to check the checksum of fetched files that can be (if desired):
1. Checked agains virustotal database
2. Checked agains provided checksum by downstream to ensure that expected file is fetched for processing
- Cache
Designed to cache the source code tarball for processing
SU has options to:
1. Cache the tarball so if the tarball is needed zernit can get this file locally
2. Provide this file as standalone mirror that can be added to the downstream
3. Provide this file through torrent for peer-2-peer distribution
4. Provide this file through custom torrent-inspired distribution system focused on privacy and security
- Configure
Designed to configure the source code for proccessing in the \`compile\` phase
- Compile
Designed to provide backend required to process the package for compilation
- Sandbox
Designed to place the runtime in a jail that prevents the software from accessing the live userland.
- Containerize
Designed to place the content of \`IMAGE\` directory into a redistributable container that runs on the target system without the need for dependencies
To ensure compatibility this has to have a logic to determine wether it's being run on a supported system.
This can be also used for release of pre-compiled targets
- Merge
Merge the content of \`IMAGE\` directory into a live system
### Audio
Designed for distribution of audio tracks
In terms of database this requires following entries:
- Artist name
- Song name
And optionally:
- License
EOF

@ -1,7 +0,0 @@
# The unnamed package manager
FIXME: We need a name (https://github.com/RXT0112/Zernit/issues/156)
Directory for the system manager source code
FIXME: Name required

@ -1 +0,0 @@
FIXME: WIP directory designed for Continuous Delivery of the source code

@ -1,7 +0,0 @@
FIXME: WIP directory designed for quality assurance (also known as Continuous Integration)
FIXME: The logic should be managed by a custom management system (Should be implemented through https://github.com/RXT0113 so that it can be maintained cross-project)
FIXME: Support for TravisCI
FIXME: Support for GitHubCI
FIXME: Support for CircleCI
FIXME: Support for SourceHutCI

@ -1,8 +0,0 @@
# Downstream distribution
To ensure the quality provided on downstream for various distributions this repository prohibits distribution maintainers from making their own 3rd party logic for a package managers thus this directory has been created to monitor the downstream while providing an upstream support.
Distribution maintainers that do not satisfy the required standard are not allowed to keep source code for Zernit in their repositories.
FIXME-LEGAL(Krey): Update Legal
FIXME-QA(Krey): Provide a CI that tests the downstream on relevant distributions
FIXME-QA(Krey): Provide a CD that distributes the downstream instructions the way that the maintainer prefers (expected to be automated once the change has been made, approved and passed QA)

@ -1,3 +0,0 @@
# downstream-classes
This directory is used to define logic for various downstreaming methods used in zernit

@ -1,3 +0,0 @@
# zeres-0
Initial class designed for the downstream in posix shell

@ -1,5 +0,0 @@
# Zeres-0 (Bash)
This directory contains logic for zeres-0 to process standardized bash/shell downstream
The `UNLEASH` file is the first thing invoked by zernit

@ -1,336 +0,0 @@
#!/bin/sh
# All rights reserved by Jacob Hrbek <kreyren@rixotstudio.cz> in 04/2020 (Prepared for four freedom respecting license)
# Peer-reviewed by: <YOUR_NAME> <YOUR_EMAIL> in <DATE+TIME+TIMEZONE>
# shellcheck shell=sh
###! Base bashrc for zernit's bash backend
###! Requires:
# FIXME: Implement logic for this
###! - Command 'uname' to identify the kernel
# FIXME: Implement logic for this
###! - Command 'lsb_release' or file /etc/os-release to identify distribution and release on linux
###! Exit codes:
###! - FIXME-DOCS(Krey): Defined in die()
###! Platforms:
###! - [ ] Linux
###! - [ ] Debian
###! - [ ] Ubuntu
###! - [ ] Fedora
###! - [ ] NixOS
###! - [ ] Archlinux
###! - [ ] Alpine
###! - [ ] FreeBSD
###! - [ ] Darwin
###! - MacOS
###! - [ ] Redox
###! - [ ] ReactOS
###! - [ ] Windows
###! - [ ] Windows xp
###! - [ ] Windows 7
###! - [ ] Windows 8
###! - [ ] Windows 8.1
###! - [ ] Windows 10
###! - [ ] Windows/Cygwin
###! - [ ] Windows 10
###! Code Quality:
###! - Replace all external commands alike 'uname' with variable to be replaced in command overrides
###! - Everything has to be sanitized
###! - Has to be tested in docker and vagrant
###! - echo() is non-standard on XNU/Darwin -> Use printf
###! - Apply styles to allow translate of the output
###! Resources:
###! - https://pkgs.org | To search Linux distros for files and package informations
# Maintainer info
UPSTREAM="https://github.com/RXT0112/Zernit"
UPSTREAM_NAME="RiXotStudio"
UPSTREAM_EMAIL="rxt0112@rixotstudio.cz"
MAINTAINER_EMAIL="kreyren@rixotstudio.cz"
MAINTAINER_NICKNAME="kreyren"
MAINTAINER_NAME="Jacob"
MAINTAINER_SURNAME="Hrbek"
# FIXME-SUGGESTION: _=${var:="some text"} is less verbose and less error prone than [ -z "$var" ] && var="some text"
# Command overrides
## These may be required on some systems
[ -z "$PRINTF" ] && PRINTF="printf"
[ -z "$WGET" ] && WGET="wget"
[ -z "$CURL" ] && CURL="curl"
[ -z "$ARIA2C" ] && ARIA2C="aria2c"
[ -z "$CHMOD" ] && CHMOD="chmod"
[ -z "$UNAME" ] && UNAME="uname"
[ -z "$TR" ] && TR="tr"
[ -z "$SED" ] && SED="sed"
[ -z "$GREP" ] && GREP="grep"
# Customization of the output
## efixme
[ -z "$EFIXME_FORMAT_STRING" ] && EFIXME_FORMAT_STRING="FIXME: %s\n"
[ -z "$EFIXME_FORMAT_STRING_LOG" ] && EFIXME_FORMAT_STRING_LOG="${logPrefix}FIXME: %s\n"
[ -z "$EFIXME_FORMAT_STRING_DEBUG" ] && EFIXME_FORMAT_STRING_DEBUG="FIXME($myName:$LINENO): %s\n"
[ -z "$EFIXME_FORMAT_STRING_DEBUG_LOG" ] && EFIXME_FORMAT_STRING_DEBUG_LOG="${logPrefix}FIXME($myName:$LINENO): %s\n"
## eerror
[ -z "$EERROR_FORMAT_STRING" ] && EERROR_FORMAT_STRING="ERROR: %s\n"
[ -z "$EERROR_FORMAT_STRING_LOG" ] && EERROR_FORMAT_STRING_LOG="${logPrefix}ERROR: %s\n"
[ -z "$EERROR_FORMAT_STRING_DEBUG" ] && EERROR_FORMAT_STRING_DEBUG="ERROR($myName:$0): %s\n"
[ -z "$EERROR_FORMAT_STRING_DEBUG_LOG" ] && EERROR_FORMAT_STRING_DEBUG_LOG="${logPrefix}ERROR($myName:$0): %s\n"
## edebug
[ -z "$EERROR_FORMAT_STRING" ] && EERROR_FORMAT_STRING="ERROR: %s\n"
[ -z "$EERROR_FORMAT_STRING_LOG" ] && EERROR_FORMAT_STRING_LOG="${logPrefix}ERROR: %s\n"
[ -z "$EERROR_FORMAT_STRING_DEBUG" ] && EERROR_FORMAT_STRING_DEBUG="ERROR($myName:$0): %s\n"
[ -z "$EERROR_FORMAT_STRING_DEBUG_LOG" ] && EERROR_FORMAT_STRING_DEBUG_LOG="${logPrefix}ERROR($myName:$0): %s\n"
## einfo
[ -z "$EINFO_FORMAT_STRING" ] && EINFO_FORMAT_STRING="INFO: %s\n"
[ -z "$EINFO_FORMAT_STRING_LOG" ] && EINFO_FORMAT_STRING_LOG="${logPrefix}INFO: %s\n"
[ -z "$EINFO_FORMAT_STRING_DEBUG" ] && EINFO_FORMAT_STRING_DEBUG="INFO($myName:$0): %s\n"
[ -z "$EINFO_FORMAT_STRING_DEBUG_LOG" ] && EINFO_FORMAT_STRING_DEBUG_LOG="${logPrefix}INFO($myName:$0): %s\n"
## die
### Generic
[ -z "$DIE_FORMAT_STRING" ] && DIE_FORMAT_STRING="FATAL: %s in script '$myName' located at '$0'\\n"
[ -z "$DIE_FORMAT_STRING_LOG" ] && DIE_FORMAT_STRING_LOG="${logPath}FATAL: %s in script '$myName' located at '$0'\\n"
[ -z "$DIE_FORMAT_STRING_DEBUG" ] && DIE_FORMAT_STRING_DEBUG="FATAL($myName:$1): %s\n"
[ -z "$DIE_FORMAT_STRING_DEBUG_LOG" ] && DIE_FORMAT_STRING_DEBUG_LOG="${logPrefix}FATAL($myName:$1): %s\\n"
### Success trap
[ -z "$DIE_FORMAT_STRING_SUCCESS" ] && DIE_FORMAT_STRING_SUCCESS="SUCCESS: Script '$myName' located at '$0' finished successfully\\n"
[ -z "$DIE_FORMAT_STRING_LOG" ] && DIE_FORMAT_STRING_LOG="${logPath}$DIE_FORMAT_STRING_SUCCESS"
[ -z "$DIE_FORMAT_STRING_DEBUG" ] && DIE_FORMAT_STRING_DEBUG="SUCCESS($myName:$1): Script '$myName' located at '$0' finished successfully\\n"
[ -z "$DIE_FORMAT_STRING_DEBUG_LOG" ] && DIE_FORMAT_STRING_DEBUG_LOG="${logPrefix}$DIE_FORMAT_STRING_DEBUG_LOG"
### Syntax error (syntaxerr) trap
[ -z "$DIE_FORMAT_STRING_SYNTAXERR" ] && DIE_FORMAT_STRING_SYNTAXERR="SyntaxErr: Invalid argument(s) '$0' '$1' '$2' '$3' '$4' has been provided to $myName\\n"
[ -z "$DIE_FORMAT_STRING_SYNTAXERR_LOG" ] && DIE_FORMAT_STRING_LOG="${logPath}$DIE_FORMAT_STRING_SUCCESS"
[ -z "$DIE_FORMAT_STRING_SYNTAXERR_DEBUG" ] && DIE_FORMAT_STRING_DEBUG="SyntaxErr($myName:$1): Invalid argument(s) '$0' '$1' '$2' '$3' '$4' has been provided to $myName\\n"
[ -z "$DIE_FORMAT_STRING_SYNTAXERR_DEBUG_LOG" ] && DIE_FORMAT_STRING_DEBUG_LOG="${logPrefix}$DIE_FORMAT_STRING_DEBUG_LOG"
### Fixme trap
[ -z "$DIE_FORMAT_STRING_FIXME" ] && DIE_FORMAT_STRING_FIXME="FATAL: %s in script '$myName' located at '$0', fixme?\n"
[ -z "$DIE_FORMAT_STRING_FIXME_LOG" ] && DIE_FORMAT_STRING_FIXME_LOG="${logPrefix}FATAL: %s, fixme?\n"
[ -z "$DIE_FORMAT_STRING_FIXME_DEBUG" ] && DIE_FORMAT_STRING_FIXME_DEBUG="FATAL($myName:$1): %s, fixme?\n"
[ -z "$DIE_FORMAT_STRING_FIXME_DEBUG_LOG" ] && DIE_FORMAT_STRING_FIXME_DEBUG_LOG="${logPrefix}FATAL($myName:$1): %s, fixme?\\n"
### Bug Trap
[ -z "$DIE_FORMAT_STRING_BUG" ] && DIE_FORMAT_STRING_BUG="BUG: Unexpected happend while processing %s in script '$myName' located at '$0'\\n\\nIf you think that this is a bug, the report it to $UPSTREAM to @$MAINTAINER_NICKNAME with output from $logPath for relevant runtime"
[ -z "$DIE_FORMAT_STRING_BUG_LOG" ] && DIE_FORMAT_STRING_BUG_LOG="${logPrefix}$DIE_FORMAT_STRING_BUG"
[ -z "$DIE_FORMAT_STRING_BUG_DEBUG" ] && DIE_FORMAT_STRING_BUG_DEBUG="BUG:($myName:$1): ${DIE_FORMAT_STRING_BUG%%BUG:}"
[ -z "$DIE_FORMAT_STRING_BUG_DEBUG_LOG" ] && DIE_FORMAT_STRING_BUG_DEBUG_LOG="${logPrefix}$DIE_FORMAT_STRING_BUG_DEBUG"
### Fixme trap
[ -z "$DIE_FORMAT_STRING_FIXME" ] && DIE_FORMAT_STRING_FIXME="FATAL: %s in script '$myName' located at '$0', fixme?\n"
[ -z "$DIE_FORMAT_STRING_FIXME_LOG" ] && DIE_FORMAT_STRING_FIXME_LOG="${logPrefix}FATAL: %s, fixme?\n"
[ -z "$DIE_FORMAT_STRING_FIXME_DEBUG" ] && DIE_FORMAT_STRING_FIXME_DEBUG="FATAL($myName:$1): %s, fixme?\n"
[ -z "$DIE_FORMAT_STRING_FIXME_DEBUG_LOG" ] && DIE_FORMAT_STRING_FIXME_DEBUG_LOG="${logPrefix}FATAL($myName:$1): %s, fixme?\\n"
### Unexpected trap
[ -z "$DIE_FORMAT_STRING_UNEXPECTED" ] && DIE_FORMAT_STRING_UNEXPECTED="FATAL: Unexpected happend while %s in $myName located at $0\\n"
[ -z "$DIE_FORMAT_STRING_UNEXPECTED_LOG" ] && DIE_FORMAT_STRING_UNEXPECTED_LOG="${logPrefix}FATAL: Unexpected happend while %s\\n"
[ -z "$DIE_FORMAT_STRING_UNEXPECTED_DEBUG" ] && DIE_FORMAT_STRING_UNEXPECTED_DEBUG="FATAL($myName:$1): Unexpected happend while %s in $myName located at $0\\n"
[ -z "$DIE_FORMAT_STRING_UNEXPECTED_DEBUG_LOG" ] && DIE_FORMAT_STRING_UNEXPECTED_DEBUG="${logPrefix}FATAL($myName:$1): Unexpected happend while %s\\n"
# elog
[ -z "$ELOG_FORMAT_STRING_DEBUG_LOG" ] && ELOG_FORMAT_STRING_DEBUG_LOG="${logPrefix}LOG: %s\\n"
# ebench
[ -z "$EBENCH_FORMAT_STRING_START" ] && EBENCH_FORMAT_STRING_START="BENCHMARK: Starting benchmark for action %s\n"
[ -z "$EBENCH_FORMAT_STRING_RESULT" ] && EBENCH_FORMAT_STRING_RESULT="BENCHMARK: Action %s took $SECONDS seconds\n"
# invoke_privileged
[ -z "$INVOKE_PRIVILEGED_FORMAT_STRING_QUESTION" ] && INVOKE_PRIVILEGED_FORMAT_STRING_QUESTION="### PRIVILEGED ACCESS REQUEST ###\n\n\s\n"
# Exit on anything unexpected
set -e
# NOTICE(Krey): By default busybox outputs a full path in '$0' this is used to strip it
myName="${0##*/}"
# Used to prefix logs with timestemps, uses ISO 8601 by default
logPrefix="[ $(date -u +"%Y-%m-%dT%H:%M:%SZ") ] "
# Path to which we will save logs
# NOTICE(Krey): To avoid storing file '$HOME/.some-name.sh.log' we are stripping the '.sh' here
# FIXME-QA: Make sure the the directory path is present or this fails
# FIXME-COMPAT: Make sure this works on Windows and Darwin
logPath="${XDG_DATA_HOME:-$HOME/.local/share}/${myName%%.sh}.log"
# inicialize the script in logs
# FIXME: Allow end-users to customize this
"$PRINTF" '%s\n' "Started $myName on $("$UNAME" -s) at $(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> "$logPath"
# DNM: Specify the path to die()
. path/to/die
# DNM: Specify the path
. path/to/einfo
. path/to/ewarn
. path/to/efixme
efixme() { funcname=efixme
if [ "$IGNORE_FIXME" = 1 ]; then
edebug fixme "Fixme message for '$2' disabled"
elif [ "$IGNORE_FIXME" = 0 ] || [ -z "$IGNORE_FIXME" ]; then
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EFIXME_FORMAT_STRING" "$2"
"$PRINTF" "$EFIXME_FORMAT_STRING" "$2" >> "$logPath"
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EFIXME_FORMAT_STRING_DEBUG" "$2"
"$PRINTF" "$EFIXME_FORMAT_STRING_DEBUG_LOG" "$2" >> "$logPath"
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 255 "processing DEBUG variable with value '$DEBUG' in $funcname"
esac
fi
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 255 "processing variable IGNORE_FIXME with value '$IGNORE_FIXME' in $0"
esac
fi
}; alias efixme='efixme "$LINENO"'
# Resolve root
rootCheck() { funcname=rootCheck
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) edebug "Resolving root on user with ID '$(id -u)"
esac
if [ "$(id -u)" = 0 ]; then
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) edebug "Script has been executed as user with ID 0, assuming root"
esac
# NOTICE(Krey): We are prefixing root commands with '$SUDO', this is done to make sure that we are not using sudo here
unset SUDO
funcname="$myName"
return 0
# NOTICE(Krey): The ID 33333 is used by gitpod
elif [ "$(id -u)" = 1000 ] || [ "$(id -u)" = 33333 ]; then
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) ewarn "Script $myName is not expected to run as non-root, trying to elevate root.."
esac
if command -v sudo 1>/dev/null; then
case "$LANG" in
en-*|*) einfo "Found 'sudo' that can be used for root elevation"
esac
SUDO=sudo
funcname="$myName"
return 0
elif command -v su 1>/dev/null; then
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) einfo "Found 'su' that can be used for a root elevation"
esac
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) ewarn "This will require the end-user to parse a root password multiple times assuming that root has a password set"
esac
SUDO=su
funcname="$myName"
return 0
elif ! command -v sudo 1>/dev/null && ! command -v su 1>/dev/null; then
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 3 "Script $myName depends on root permission to install packages where commands 'sudo' nor 'su' are available for root elevation"
esac
funcname="$myName"
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 225 "processing root on non-root"
esac
fi
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 3 "Unknown user ID '$(id -u)' has been parsed in script $myName"
esac
fi
}
# Identify system
# FIXME: /etc/issue could also be used to identify the system
# FIXME: /etc/debian_version can also be used
# FIXME: /etc/devuan_version can also be used
if command -v "$UNAME" 1>/dev/null; then
unameKernel="$("$UNAME" -s)"
edebug "Identified the kernel as '$unameKernel"
case "$unameKernel" in
Linux)
KERNEL="$unameKernel"
# Assume Linux Distro and release
# NOTICE(Krey): We are expecting this to return a lowercase value
if command -v "$LSB_RELEASE" 1>/dev/null; then
assumedDistro="$("$LSB_RELEASE" -si | "$TR" :[upper]: :[lower]:)"
assumedRelease="$("$LSB_RELEASE" -cs | "$TR" :[upper]: :[lower]:)"
elif ! command -v "$LSB_RELEASE" 1>/dev/null && [ -f /etc/os-release ]; then
assumedDistro="$("$GREP" -o "^ID\=.*" /etc/os-release | "$SED" s/ID=//gm)"
assumedRelease="$("$GREP" -o"^VERSION_CODENAME\=.*" /etc/os-release | "$SED" s/VERSION_CODENAME=//gm)"
elif ! command -v "$LSB_RELEASE" 1>/dev/null && [ ! -f /etc/os-release ]; then
die 1 "Unable to identify linux distribution using command 'lsb_release' nor file '/etc/os-release'"
else
die 255 "attempting to assume linux distro and release"
fi
edebug "Identified distribution as '$assumedDistro'"
edebug "Identified distribution release as '$assumedRelease'"
# Verify Linux Distro
efixme "Add sanitization logic for other linux distributions"
case "$assumedDistro" in
ubuntu | debian | fedora | nixos | opensuse | gentoo | exherbo)
DISTRO="$assumedDistro"
;;
*) die fixme "Unexpected Linux distribution '$assumedDistro' has been detected."
esac
# Verify Linux Distro Release
efixme "Sanitize verification of linux distro release"
assumedRelease="$RELEASE"
;;
FreeBSD | Redox | Darwin | Windows)
KERNEL="$unameKernel"
;;
*) die 255 "Unexpected kernel '$unameKernel'"
esac
elif ! command -v "$UNAME" 1>/dev/null; then
die 1 "Standard command '$UNAME' is not available on this system, unable to identify kernel"
else
die 255 "Identifying system"
fi
# Define hostname
# NOTICE: Variable 'HOSTNAME' is not defined on POSIX sh
if command -v hostname 1>/dev/null; then
HOSTNAME="$(hostname)"
elif [ -s /etc/hostname ]; then
HOSTNAME="$(cat /etc/hostname)"
elif ! command -v hostname 1>/dev/null && [ ! -s /etc/hostname ]; then
die false "Unable to determine the hostname from command 'hostname' (which doesn't exists) and from file /etc/hostname (that doesn't exists or is blank)"
else
die unexpected "processing hostname"
fi
# Argument management
while [ "$#" -gt 0 ]; do case "$1" in
install-deps)
packageManagement
;;
test-docker-debian)
efixme "Implement logic to make sure that docker is available"
die fixme "Implement tests for debian on docker"
$SUDO docker run debian sh -c "true \
&& apt-get update -q \
&& apt-get install -qy lsb-release \
&& sh $0"
;;
--help|help)
efixme "HELP_MESSAGE"
;;
*)
die 2 "FIXME_MESSAGE"
;;
esac; done

@ -1,3 +0,0 @@
# Identifiers
Functions used to identify various elements on the system i.e kernel

@ -1,22 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 18/08/2020 08:13:35 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Make sure this works
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Identifier script used to identify a hostname on the target system and store it in 'HOSTNAME' environment variable
# Define hostname
# POSIX: Variable 'HOSTNAME' is not defined on POSIX sh
if command -v hostname 1>/dev/null; then
HOSTNAME="$(hostname)"
elif [ -s /etc/hostname ]; then
HOSTNAME="$("$CAT" /etc/hostname)"
elif ! command -v hostname 1>/dev/null && [ ! -s /etc/hostname ]; then
die false "Unable to determine the hostname from command 'hostname' (which doesn't exists) and from file /etc/hostname (that doesn't exists or is blank)"
else
die unexpected "processing hostname"
fi

@ -1,64 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 18/08/2020 08:13:35 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Make sure this works
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Identifier script used to identify:
###! - Kernel - Stored in environment variable 'KERNEL' lowercase i.e 'linux'
###! - Release - Stores
# Identify system
# FIXME: /etc/issue could also be used to identify the system
# FIXME: /etc/debian_version can also be used
# FIXME: /etc/devuan_version can also be used
if "$COMMAND" -v "$UNAME" 1>/dev/null; then
unameKernel="$("$UNAME" -s)"
edebug "Identified the kernel as '$unameKernel"
case "$unameKernel" in
Linux)
KERNEL="$(printf '%s\n' "$unameKernel" | "$TR" [[:upper:]] [[:lower:]])"
# Assume Linux Distro and release
# NOTICE(Krey): We are expecting this to return a lowercase value
if "$COMMAND" -v "$LSB_RELEASE" 1>/dev/null; then
assumedDistro="$("$LSB_RELEASE" -si | "$TR" [[:upper:]] [[:lower:]])"
assumedRelease="$("$LSB_RELEASE" -cs | "$TR" [[:upper:]] [[:lower:]])"
elif ! "$COMMAND" -v "$LSB_RELEASE" 1>/dev/null && [ -f /etc/os-release ]; then
assumedDistro="$("$GREP" -o "^ID\=.*" /etc/os-release | "$SED" s/ID=//gm | "$TR" [[:upper:]] [[:lower:]])"
assumedRelease="$("$GREP" -o "^VERSION_CODENAME\=.*" /etc/os-release | "$SED" s/VERSION_CODENAME=//gm | "$TR" [[:upper:]] [[:lower:]])"
elif ! "$COMMAND" -v "$LSB_RELEASE" 1>/dev/null && [ ! -f /etc/os-release ]; then
die 1 "Unable to identify linux distribution using command 'lsb_release' nor file '/etc/os-release'"
else
die 255 "attempting to assume linux distro and release"
fi
edebug "Identified distribution as '$assumedDistro'"
edebug "Identified distribution release as '$assumedRelease'"
# Verify Linux Distro
efixme "Add sanitization logic for other linux distributions"
case "$assumedDistro" in
ubuntu | debian | fedora | nixos | opensuse | gentoo | exherbo | devuan)
DISTRO="$assumedDistro"
;;
*) die fixme "Unexpected Linux distribution '$assumedDistro' has been detected."
esac
# Verify Linux Distro Release
efixme "Sanitize verification of linux distro release"
RELEASE="$assumedRelease"
;;
FreeBSD | Redox | Darwin | Windows)
KERNEL="$unameKernel"
;;
*) die 255 "Unexpected kernel '$unameKernel'"
esac
elif ! "$COMMAND" -v "$UNAME" 1>/dev/null; then
die 1 "Standard command '$UNAME' is not available on this system, unable to identify kernel"
else
die 255 "Identifying system"
fi

@ -1,228 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Make sure this works
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Assertion wrapper that outputs message and exits with specified exit code
# NOTICE-DOCS(Krey): Make sure that the text is easy to follow from the exit code
###! Exit codes:
###! - 0/1 --- General true depending on kernel used
###! - 1/0 --- General false depending on kernel used
###! - 2 ----- syntax error
###! - 3 ----- permission issue
###! - 28 ---- Security trap
###! - 36 ---- Fixme trap
###! - 111 --- Invalid format string (used to capture printf failure)
###! - 126 --- not executable(?)
###! - 223 --- Unexpected trap captured for bug
###! - 255 --- Unexpected trap
# NOTICE(Krey): Aliases are required for posix-compatible line output (https://gist.github.com/Kreyren/4fc76d929efbea1bc874760e7f78c810)
# NOTICE(Krey): End-users are allowed to customize the format string so we have to capture printf failures using `|| { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}` instead of `die invalid-format`
# FIXME-DUP_CODE: Fix duplicate code for easier maintainance
die() { funcname="die"
case "$2" in
###! Generic true
###! - Used to exit the shell successfully
###! Compatibility: Returns Error code 0 on Unix and Error Code 1 on Windows
"true")
# In case no message is provided
if [ -z "$3" ]; then
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*)
"$PRINTF" "$DIE_FORMAT_STRING_TRUE" "Exitted successfully"
"$PRINTF" "$DIE_FORMAT_STRING_TRUE" "Exitted successfully" >> "$logPath"
esac
elif [ "$DEBUG" = 1 ]; then
case "$LANG" in
en-*|*)
# FIXME-TRANSLATE: Translate in your language
"$PRINTF" "$DIE_FORMAT_STRING_TRUE_DEBUG" "Exitted successfully"
"$PRINTF" "$DIE_FORMAT_STRING_TRUE_DEBUG" "Exitted successfully" >> "$logPath"
esac
else
# NOTICE(Krey): Do not use die() in die for unexpected
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
# Message on second argument is provided
elif [ -n "$3" ]; then
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_TRUE" "$3"
"$PRINTF" "$DIE_FORMAT_STRING_TRUE" "$3" >> "$logPath"
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_TRUE_DEBUG" "$3"
"$PRINTF" "$DIE_FORMAT_STRING_TRUE_DEBUG" "$3" >> "$logPath"
else
# NOTICE(Krey): Do not use die() in die for unexpected
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
fi
# Assertion
case "$KERNEL" in
linux)
unset funcname
exit 0 ;;
windows)
unset funcname
exit 1 ;;
*)
"$PRINTF" 'BUG: %s\n' "Invalid kernel has been provided in $myName for arguments '$*': $KERNEL"
unset funcname
exit 255
esac
;;
###! Generic failure
###! - Used to exit the shell with fatal error
###! Compatibility: Returns Error code 1 on Unix and Error Code 0 on Windows
"false")
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_FALSE" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_FALSE_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_FALSE_DEBUG" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_FALSE_DEBUG_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
# Assertion
case "$KERNEL" in
linux)
unset funcname
exit 1 ;;
windows)
unset funcname
exit 0 ;;
*)
"$PRINTF" 'BUG: %s\n' "Invalid kernel has been provided in $myName: $KERNEL"
unset funcname
exit 223
esac
;;
2|syntaxerr)
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_SYNTAXERR" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_SYNTAXERR_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_SYNTAXERR_DEBUG" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_SYNTAXERR_DEBUG_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 28 # In case 'fixme' argument is provided
;;
28|"security")
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_SECURITY" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_SECURITY_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_SECURITY_DEBUG" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_SECURITY_DEBUG_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 28 # In case 'fixme' argument is provided
;;
38|"fixme") # For features that needs to be implemented and prefents runtime from continuing
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_FIXME" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_FIXME_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_FIXME_DEBUG" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_FIXME_DEBUG_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 38 # In case 'fixme' argument is provided
;;
111|"invalid-format")
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT_DEBUG" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT_DEBUG_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) "$PRINTF" "$DIE_FORMAT_STRING" "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 223 # In case 'bug' is used
;;
223|"bug") # Unexpected trap
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_BUG" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_BUG_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_BUG_DEBUG" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_BUG_DEBUG_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) "$PRINTF" "$DIE_FORMAT_STRING" "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 223 # In case 'bug' is used
;;
255|"unexpected") # Unexpected trap
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_UNEXPECTED" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_UNEXPECTED_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_UNEXPECTED_DEBUG" "$3" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_UNEXPECTED_DEBUG_LOG" "$3" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) "$PRINTF" "$DIE_FORMAT_STRING" "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 255 # In case 'unexpected' is used
;;
*)
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) "$PRINTF" 'BUG: %s\n' "Invalid argument '$2' has been provided in $funcname"
esac
unset funcname
exit 255
esac
}; alias die='die "${LINENO:-0}"'

@ -1,38 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to time specific actions
# FIXME: Allow timing of specific tasks
# Allow skipping benchmark
ebench() { funcname="ebench"
case "$SKIP_BENCHMARK" in
1)
unset funcname
return 0 ;;
0|"") edebug 3 "Benchmark was not skipped" ;;
*) die 23 "Variable SKIP_BENCHMARK has unexpected value '$SKIP_BENCHMARK', expecting only '1' or blank"
esac
case "$2" in
start)
printf "$EBENCH_FORMAT_STRING_START" "$2" || die invalid-format
# POSIX: We might be able to use /proc/uptime on Unix
efixme "Variable 'SECONDS' is not POSIX compatible, implement logic"
SECONDS=0
unset funcname
return 0 ;;
result)
printf "$EBENCH_FORMAT_STRING_RESULT" "$2" || die invalid-format
unset funcname
return 0 ;;
*) die 2 "Invalid argument '$2' has been parsed in $funcname"
esac
}; alias ebench='ebench "${LINENO:-0}"'

@ -1,31 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to output a debug message depending on value in DEBUG variable
# NOTICE(Krey): Aliases are required for posix-compatible line output (https://gist.github.com/Kreyren/4fc76d929efbea1bc874760e7f78c810)
edebug() { funcname="edebug"
efixme "Implement debug channels in $funcname"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EDEBUG_FORMAT_STRING" "$2" || die invalid-format
"$PRINTF" "$EDEBUG_FORMAT_STRING_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EDEBUG_FORMAT_STRING_DEBUG" "$2" || die invalid-format
"$PRINTF" "$EDEBUG_FORMAT_STRING_DEBUG_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 255 "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}; alias die='die "${LINENO:-0}"'

@ -1,30 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to output an error message about non-fatal issues to inform the end-user
# NOTICE(Krey): Aliases are required for posix-compatible line output (https://gist.github.com/Kreyren/4fc76d929efbea1bc874760e7f78c810)
eerror() { funcname="eerror"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EERROR_FORMAT_STRING" "$2" || die invalid-format
"$PRINTF" "$EERROR_FORMAT_STRING_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EERROR_FORMAT_STRING_DEBUG" "$2" || die invalid-format
"$PRINTF" "$EERROR_FORMAT_STRING_DEBUG_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}; alias eerror='eerror "${LINENO:-0}"'

@ -1,53 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to output annoying fixme messages for features that needs to be implemented for the expected runtime, but that doesn't prevent the abstract
###! For example Hotfixes that need proper implementation:
###!
###! # Not up to standard
###! efixme "Sanitize rm"
###! rm something
###!
###! # Better implementation
###! [ -e something ] && rm something
###! Can be disabled by storing value '1' in variable IGNORE_FIXME
# FIXME-QA(Krey): Merge in edebug once debugging channels are implemented?
# - (Krey) Probably better to implement a debug channel that efixme is reading from
# NOTICE(Krey): Aliases are required for posix-compatible line output (https://gist.github.com/Kreyren/4fc76d929efbea1bc874760e7f78c810)
efixme() { funcname="efixme"
if [ "$IGNORE_FIXME" = 1 ]; then
# FIXME: Implement 'fixme' debug channel
edebug fixme "Fixme message for '$2' disabled"
return 0
elif [ "$IGNORE_FIXME" = 0 ] || [ -z "$IGNORE_FIXME" ]; then
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EFIXME_FORMAT_STRING" "$2" || die invalid-format
"$PRINTF" "$EFIXME_FORMAT_STRING_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EFIXME_FORMAT_STRING_DEBUG" "$2" || die invalid-format
"$PRINTF" "$EFIXME_FORMAT_STRING_DEBUG_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 255 "processing DEBUG variable with value '$DEBUG' in $funcname"
esac
fi
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 255 "processing variable IGNORE_FIXME with value '$IGNORE_FIXME' in $0"
esac
fi
}; alias efixme='efixme "${LINENO:-0}"'

@ -1,29 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to inform the end-user about what is happening during the runtime
einfo() { funcname="einfo"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EINFO_FORMAT_STRING" "$1" || die invalid-format
"$PRINTF" "$EINFO_FORMAT_STRING_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EINFO_FORMAT_STRING_DEBUG" "$1" || die invalid-format
"$PRINTF" "$EINFO_FORMAT_STRING_DEBUG_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}; alias einfo='einfo "${LINENO:-0}"'

@ -1,26 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to store output in log
elog() { funcname="elog"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$ELOG_FORMAT_STRING_DEBUG_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}; alias einfo='einfo "${LINENO:-0}"'

@ -1,29 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to warn the end-user about something important
ewarn() { funcname="ewarn"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EWARN_FORMAT_STRING" "$2" || die invalid-format
"$PRINTF" "$EWARN_FORMAT_STRING_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EWARN_FORMAT_STRING_DEBUG" "$2" || die invalid-format
"$PRINTF" "$EWARN_FORMAT_STRING_DEBUG_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}; alias ewarn='ewarn "${LINENO:-0}"'

@ -1,228 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Make sure this works
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Assertion wrapper that outputs message and exits with specified exit code
# NOTICE-DOCS(Krey): Make sure that the text is easy to follow from the exit code
###! Exit codes:
###! - 0/1 --- General true depending on kernel used
###! - 1/0 --- General false depending on kernel used
###! - 2 ----- syntax error
###! - 3 ----- permission issue
###! - 28 ---- Security trap
###! - 36 ---- Fixme trap
###! - 111 --- Invalid format string (used to capture printf failure)
###! - 126 --- not executable(?)
###! - 223 --- Unexpected trap captured for bug
###! - 255 --- Unexpected trap
# NOTICE(Krey): Aliases are required for posix-compatible line output (https://gist.github.com/Kreyren/4fc76d929efbea1bc874760e7f78c810)
# NOTICE(Krey): End-users are allowed to customize the format string so we have to capture printf failures using `|| { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$2' with message '$3'"; exit 111 ;}` instead of `die invalid-format`
# FIXME-DUP_CODE: Fix duplicate code for easier maintainance
die() { funcname="die"
case "$1" in
###! Generic true
###! - Used to exit the shell successfully
###! Compatibility: Returns Error code 0 on Unix and Error Code 1 on Windows
"true")
# In case no message is provided
if [ -z "$2" ]; then
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*)
"$PRINTF" "$DIE_FORMAT_STRING_TRUE" "Exitted successfully"
"$PRINTF" "$DIE_FORMAT_STRING_TRUE" "Exitted successfully" >> "$logPath"
esac
elif [ "$DEBUG" = 1 ]; then
case "$LANG" in
en-*|*)
# FIXME-TRANSLATE: Translate in your language
"$PRINTF" "$DIE_FORMAT_STRING_TRUE_DEBUG" "Exitted successfully"
"$PRINTF" "$DIE_FORMAT_STRING_TRUE_DEBUG" "Exitted successfully" >> "$logPath"
esac
else
# NOTICE(Krey): Do not use die() in die for unexpected
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
# Message on second argument is provided
elif [ -n "$2" ]; then
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_TRUE" "$2"
"$PRINTF" "$DIE_FORMAT_STRING_TRUE" "$2" >> "$logPath"
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_TRUE_DEBUG" "$2"
"$PRINTF" "$DIE_FORMAT_STRING_TRUE_DEBUG" "$2" >> "$logPath"
else
# NOTICE(Krey): Do not use die() in die for unexpected
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
fi
# Assertion
case "$KERNEL" in
linux)
unset funcname
exit 0 ;;
windows)
unset funcname
exit 1 ;;
*)
"$PRINTF" 'BUG: %s\n' "Invalid kernel has been provided in $myName for arguments '$*': $KERNEL"
unset funcname
exit 255
esac
;;
###! Generic failure
###! - Used to exit the shell with fatal error
###! Compatibility: Returns Error code 1 on Unix and Error Code 0 on Windows
"false")
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_FALSE" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_FALSE_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_FALSE_DEBUG" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_FALSE_DEBUG_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
# Assertion
case "$KERNEL" in
linux)
unset funcname
exit 1 ;;
windows)
unset funcname
exit 0 ;;
*)
"$PRINTF" 'BUG: %s\n' "Invalid kernel has been provided in $myName: $KERNEL"
unset funcname
exit 223
esac
;;
2|syntaxerr)
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_SYNTAXERR" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_SYNTAXERR_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_SYNTAXERR_DEBUG" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_SYNTAXERR_DEBUG_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 28 # In case 'fixme' argument is provided
;;
28|"security")
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_SECURITY" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_SECURITY_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_SECURITY_DEBUG" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_SECURITY_DEBUG_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 28 # In case 'fixme' argument is provided
;;
38|"fixme") # For features that needs to be implemented and prefents runtime from continuing
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_FIXME" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_FIXME_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_FIXME_DEBUG" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_FIXME_DEBUG_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate in your language
en-*|*) "$PRINTF" 'BUG: %s\n' "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 38 # In case 'fixme' argument is provided
;;
111|"invalid-format")
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT_DEBUG" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT_DEBUG_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) "$PRINTF" "$DIE_FORMAT_STRING" "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 223 # In case 'bug' is used
;;
223|"bug") # Unexpected trap
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_BUG" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_BUG_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_BUG_DEBUG" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_BUG_DEBUG_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) "$PRINTF" "$DIE_FORMAT_STRING" "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 223 # In case 'bug' is used
;;
255|"unexpected") # Unexpected trap
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$DIE_FORMAT_STRING_UNEXPECTED" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_UNEXPECTED_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$DIE_FORMAT_STRING_UNEXPECTED_DEBUG" "$2" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
"$PRINTF" "$DIE_FORMAT_STRING_UNEXPECTED_DEBUG_LOG" "$2" >> "$logPath" || { "$PRINTF" "$DIE_FORMAT_STRING_INVALID_FORMAT" "Invalid format string was parsed in $funcname calling argument '$1' with message '$2'"; exit 111 ;}
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) "$PRINTF" "$DIE_FORMAT_STRING" "Unexpected happend while processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
unset funcname
exit 255 # In case 'unexpected' is used
;;
*)
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) "$PRINTF" 'BUG: %s\n' "Invalid argument '$1' has been provided in $funcname"
esac
unset funcname
exit 255
esac
}

@ -1,38 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to time specific actions
# FIXME: Allow timing of specific tasks
# Allow skipping benchmark
ebench() { funcname="ebench"
case "$SKIP_BENCHMARK" in
1)
unset funcname
return 0 ;;
0|"") edebug 3 "Benchmark was not skipped" ;;
*) die 23 "Variable SKIP_BENCHMARK has unexpected value '$SKIP_BENCHMARK', expecting only '1' or blank"
esac
case "$1" in
start)
printf "$EBENCH_FORMAT_STRING_START" "$1" || die invalid-format
# POSIX: We might be able to use /proc/uptime on Unix
efixme "Variable 'SECONDS' is not POSIX compatible, implement logic"
SECONDS=0
unset funcname
return 0 ;;
result)
printf "$EBENCH_FORMAT_STRING_RESULT" "$1" || die invalid-format
unset funcname
return 0 ;;
*) die 2 "Invalid argument '$1' has been parsed in $funcname"
esac
}

@ -1,36 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to output a debug message depending on value in DEBUG variable
efixme "Implement debug channels in $funcname"
# NOTICE(Krey): Aliases are required for posix-compatible line output (https://gist.github.com/Kreyren/4fc76d929efbea1bc874760e7f78c810)
edebug() { funcname="edebug"
case "$1" in
*)
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EDEBUG_FORMAT_STRING" "$2" || die invalid-format
"$PRINTF" "$EDEBUG_FORMAT_STRING_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EDEBUG_FORMAT_STRING_DEBUG" "$2" || die invalid-format
"$PRINTF" "$EDEBUG_FORMAT_STRING_DEBUG_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 255 "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
;;
esac
}

@ -1,30 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to output an error message about non-fatal issues to inform the end-user
# NOTICE(Krey): Aliases are required for posix-compatible line output (https://gist.github.com/Kreyren/4fc76d929efbea1bc874760e7f78c810)
eerror() { funcname="eerror"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EERROR_FORMAT_STRING" "$1" || die invalid-format
"$PRINTF" "$EERROR_FORMAT_STRING_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EERROR_FORMAT_STRING_DEBUG" "$1" || die invalid-format
"$PRINTF" "$EERROR_FORMAT_STRING_DEBUG_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}

@ -1,53 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to output annoying fixme messages for features that needs to be implemented for the expected runtime, but that doesn't prevent the abstract
###! For example Hotfixes that need proper implementation:
###!
###! # Not up to standard
###! efixme "Sanitize rm"
###! rm something
###!
###! # Better implementation
###! [ -e something ] && rm something
###! Can be disabled by storing value '1' in variable IGNORE_FIXME
# FIXME-QA(Krey): Merge in edebug once debugging channels are implemented?
# - (Krey) Probably better to implement a debug channel that efixme is reading from
# NOTICE(Krey): Aliases are required for posix-compatible line output (https://gist.github.com/Kreyren/4fc76d929efbea1bc874760e7f78c810)
efixme() { funcname="efixme"
if [ "$IGNORE_FIXME" = 1 ]; then
# FIXME: Implement 'fixme' debug channel
edebug fixme "Fixme message for '$1' disabled"
return 0
elif [ "$IGNORE_FIXME" = 0 ] || [ -z "$IGNORE_FIXME" ]; then
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EFIXME_FORMAT_STRING" "$1" || die invalid-format
"$PRINTF" "$EFIXME_FORMAT_STRING_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EFIXME_FORMAT_STRING_DEBUG" "$1" || die invalid-format
"$PRINTF" "$EFIXME_FORMAT_STRING_DEBUG_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 255 "processing DEBUG variable with value '$DEBUG' in $funcname"
esac
fi
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die 255 "processing variable IGNORE_FIXME with value '$IGNORE_FIXME' in $0"
esac
fi
}

@ -1,29 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to inform the end-user about what is happening during the runtime
einfo() { funcname="einfo"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EINFO_FORMAT_STRING" "$1" || die invalid-format
"$PRINTF" "$EINFO_FORMAT_STRING_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EINFO_FORMAT_STRING_DEBUG" "$1" || die invalid-format
"$PRINTF" "$EINFO_FORMAT_STRING_DEBUG_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}

@ -1,26 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to store output in log
elog() { funcname="elog"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$ELOG_FORMAT_STRING_DEBUG_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}

@ -1,29 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to warn the end-user about something important
ewarn() { funcname="ewarn"
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
"$PRINTF" "$EWARN_FORMAT_STRING" "$1" || die invalid-format
"$PRINTF" "$EWARN_FORMAT_STRING_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$EWARN_FORMAT_STRING_DEBUG" "$1" || die invalid-format
"$PRINTF" "$EWARN_FORMAT_STRING_DEBUG_LOG" "$1" >> "$logPath" || die invalid-format
unset funcname
return 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi
}

@ -1,13 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase to fetch source code to be processed
src_fetch() { funcname="src_fetch"
die fixme "Implement $funcname"
}

@ -1,13 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase to configure the source code for compilation
src_configure() { funcname="src_configure"
die fixme "Implement $funcname"
}

@ -1,13 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase to compile the source code
src_compile() { funcname="src_compile"
die fixme "Implement $funcname"
}

@ -1,13 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase to compile the source code
src_compile() { funcname="src_compile"
die fixme "Implement $funcname"
}

@ -1,13 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase to compile the source code
src_compile() { funcname="src_compile"
die fixme "Implement $funcname"
}

@ -1,13 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase to perform benchmarks on source code
src_compile() { funcname="src_compile"
die fixme "Implement $funcname"
}

@ -1,13 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase to install the compiled source code in sandboxed environment for testing
src_compile() { funcname="src_compile"
die fixme "Implement $funcname"
}

@ -1,14 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase process content of sandboxed directory into a container package i.e appimage
###! - This is expected to be processed on demand
src_compile() { funcname="src_compile"
die fixme "Implement $funcname"
}

@ -1,15 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# shellcheck source=src/RXT0112-1/downstream-classes/zeres-0/bash/zernit.bashrc
###! Phase to merge processed source code from sandboxed directory in live system
# FIXME: Duplicates are a concern
src_merge() { funcname="src_merge"
die fixme "Implement $funcname"
}

@ -1,3 +0,0 @@
# Processing phases
This directory is used to define processing phases on zernit's runtime

@ -1,3 +0,0 @@
# Utilities
Directory for various utilities used in downstream

@ -1,12 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to check if relevant option is set
die fixme "Implement 'option' command"

@ -1,13 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Function to source shell library to expected environment
###! NOTE: On bash this would be `source path/to/file` which is not posix-compatible and we need it to source only expected files from expected paths
die fixme "Implement 'require' command"

@ -1,5 +0,0 @@
# Wrappers
Directory dedicated to various wrapper functions
Wrapper meaning that they wrap another function to handle it's functionality

@ -1,58 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Sanitized wrapper to check if command is executable in it's environment
###! Example usage:
###!
###! if cmd_check bash; then
###! printf '%s\n' "Command 'bash' is executable! ^o^"
###! elif ! cmd_check bash; then
###! printf '%s\n' "Command 'bash' is not executable! :("
###! else
###! die bug "Function 'cmd_check' returned unexpected exit code"
###! fi
###!
# Check executability of a program
cmd_check() { funcname="cmd_check"
# FIXME-STUB: This is a stub implementation
if command; then
true
elif ! command; then
die fixme "Command 'command' is not executable on this system when runtime requested function '$funcname', we are unable to continue"
else
die unexpected "Unexpected happend while checking command 'command' in $funcname"
fi
if command -v "$1" 1>/dev/null; then
edebug cmd_check "Command '$1' has been confirmed to be executable on this system"
case "$KERNEL" in
"linux")
unset funcname
return 0 ;;
"windows")
unset funcname
return 1 ;;
*) die fixme "Kernel '$KERNEL' is not implemented in function '$funcname'"
esac
elif ! command -v "$1" 1>/dev/null; then
edebug cmd_check "Command '$1' is not executable on this system"
case "$KERNEL" in
"linux")
unset funcname
return 1 ;;
"windows")
unset funcname
return 0 ;;
*) die fixme "Kernel '$KERNEL' is not implemented in function '$funcname'"
esac
else
die unexpected "Command 'command' returned an unexpected result in function '$funcname'"
fi
}

@ -1,43 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=somewhere
###! Sanitized wrapper to create a directory
emkdir() { funcname="emkdir"
edebug "$funcname" "Instructed to create directory at path '$1'"
case "$KERNEL" in
"linux")
if [ -d "$1" ]; then
edebug "$funcname" "Directory '$1' already exists, no need to create it"
unset funcname
return 0
elif [ ! -d "$1" ]; then
einfo "Creating a new directory in '$1' as requested"
# Create the directory
if cmd_check "$MKDIR"; then
mkdir "$1" || die 1 "Function '$funcname' called from '$myName' is unable to create a new directory in '$1'"
unset funcname
return 0
elif ! cmd_check "$MKDIR"; then
die false "Unable to create a new directory, because neither neither of supported command(s) are available on this system: mkdir"
else
die bug "checking for command used to create directories in $funcname"
fi
else
die bug "checking wether '$1' is a directory"
fi
;;
*) die fixme "Function '$funcname' is not implemented for kernel '$KERNEL'"
esac
die security "Function '$funcname' escaped sanitization"
}

@ -1,161 +0,0 @@
#!/bin/false
# - Used only for sourcing
# Created by Jacob Hrbek <kreyren@rixotstudio.cz> as All Rights Reserved in 08.07.2020 03:32:02 CET
# Peer-reviewed by <NAME> <EMAIL> in <DATE> <TIME> <TIMEZONE>
# shellcheck shell=sh # Written to be posix-compatible
# DNM: Specify somewhere
# shellcheck source=src/downstream-classes/zeres-0/bash/UNLEASH.sh
###! Sanitized wrapper to create a directory
# Root elevation on-demand
# SYNOPSIS: rootme [reason for privileged access] [command]
# FIXME-QA: Needs better implementation
invoke_privileged() { funcname="invoke_privileged"
if [ "$privileged" = "false" ]; then
efixme "Implement $funcname to execute '$2' as privileged user, invoking 'sudo' as a workaround"
sudo "$@"
# DNM: HOTFIX!
return 0
edebug "Script '$myName' has been executed from an unprivileged user, deducing possible elevation"
# Ask for permission to execute the command
"$PRINTF" "$INVOKE_PRIVILEGED_FORMAT_STRING_QUESTION" "$1"
while true; do
"$PRINTF" '%s\n' "Requesting permission to invoke '$2' as privileged user (y/n)"
read -r privilege_granted
case "$privilege_granted" in
"Y"|"y"|"YES"|"yes")
edebug "User granted permission to invoke '$2' as privileged user"
unset privilege_granted
break
;;
"N"|"n"|"NO"|"no")
die 3 "Unable to execute '$2' as privileged user"
;;
*) "$PRINTF" '%s\n' "Input '$privilege_granted' is not recognized, try again.."
esac
done
# Check what we can use for executing command as privileged user
unset privilege_commands
# FIXME-QA: Fix duplicate code
## Check for sudo
if command -v "$SUDO" 1>/dev/null; then
privilege_commands="$privilege_commands sudo"
elif ! command -v "$SUDO" 1>/dev/null; then
edebug "Command '$SUDO' is not executable in $funcname, unable to use it"
else
die bug "checking wether command sudo is executable in $funcname"
fi
## Check for su
if command -v "$SU" 1>/dev/null; then
privilege_commands="$privilege_commands su"
elif ! command -v "$SU" 1>/dev/null; then
edebug "Command '$SU' is not executable in $funcname, unable to use it"
else
die bug "checking wether command su is executable in $funcname"
fi
case "$("$PRINTF" '%s\n' "$privilege_commands" | tr ' ' '\n' | wc -l)" in
0) die 3 "Neither of supported commands used to invoke command as privileged user '$privilege_commands' are available on this system, unable to invoke '$2'" ;;
1)
cmd_count="$("$PRINTF" '%s\n' "$privilege_commands" | sed "s/ //gm")"
case "$cmd_count" in
"sudo")
while true; do
printf '%s\n' "Requesting permission to use '${SUDO:-sudo}' for invokation of '$2' (y/n)"
read -r allowed_to_use_sudo
case "$allowed_to_use_sudo" in
"Y"|"y"|"YES"|"yes")
sudo "$2" | die 3 "Unable to execute '$2' with privileged permission"
break
;;
"N"|"n"|"NO"|"no")
die 3 "Unable to execute '$2' with privileged permission using sudo, because we were not allowed to proceed"
;;
*)
"$PRINTF" '%s\n' "Input '$allowed_to_use_sudo' is not recognized, retrying.."
unset allowed_to_use_sudo
esac
done
;;
"su")
while true; do
printf '%s\n' "Requesting permission to use '${SUDO:-sudo}' for invokation of '$2' (y/n)"
read -r allowed_to_use_sudo
case "$allowed_to_use_sudo" in
"Y"|"y"|"YES"|"yes")
su root -c "$2" | die 3 "Unable to execute '$2' with privileged permission"
break
;;
"N"|"n"|"NO"|"no")
die 3 "Unable to execute '$2' with privileged permission using sudo, because we were not allowed to proceed"
;;
*)
"$PRINTF" '%s\n' "Input '$allowed_to_use_sudo' is not recognized, retrying.."
unset allowed_to_use_sudo
esac
done
;;
esac ;;
2)
# NOTICE: This is adapted to allow more commands in the future
while true; do
printf '%s\n\n' \
"We found following commands that we can use to execute the command as privileged user:"
# FIXME: seq might not be available on the system
# - yes | head -n 3| nl | cut -f1 | while read i; do echo $i; done
# - awk 'BEGIN{for(i=0;i<10;i++)print i}
for num in $(seq 1 "$cmd_count" | tr '\n' ' '); do
for cmd in $privilege_commands; do
printf "%s\n" "$num. $cmd"
done
printf '%s\n' ""
printf '%s\n' "Which command do you want to use?"
done
read -r privilege_choice
case "$privilege_choice" in
[1-2])
die fixme "Choose the appropriate choice, invoke this script as privileged user as a workaround"
break
;;
*)
printf '%s\n' "Invalid choice '$privilege_choice', retrying.."
unset privilege_choice
esac
done
# DNM: Implement proper logic
efixme "Implement better logic here, invoking 'sudo' for testing.."
sudo "$2" || die 3 "unable to use privileged permission" ;;
*)
# FIXME-QA: Implement better output
die bug "Unexpected value has been returned for variable 'privilege_commands'"
esac
elif [ "$privileged" = "true" ]; then
edebug "Executing '$1' as privileged user"
unset funcname
return 0
fi
}

@ -1,8 +0,0 @@
# Emacs-lisp downstream class
Downstream class used by zernit the over-engineered package manager to process it's downstream items using elisp runner.
### FAQ
Q: Why
A: Because we can dammit! Also krey's emacs needs a package manager..

@ -1,25 +0,0 @@
#!/bin/sh
":"; exec emacs --script "$0" "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
;; Created by Jacob Hrbek identified with an e-mail <kreyren@rixotstudio.cz> and GPG signature <0x765AED304211C28410D5C478FCBA0482B0AB9F10> under all rights reserved in 26/08/2020 11:11:38 CEST
;; WARNING: NOT IMPLEMENTED!
;(message "NOT IMPLEMENTED!")
;(kill-emacs 36)
(require 'cl-lib)
;; Source wrappers
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/wrappers/zn-defun.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/wrappers/zn-defvar.el")
;; Source variables
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/variables/emacs-debug.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/variables/emacs-log-file.el")
;; Source functions
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/die.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/ewarn.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/einfo.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/efixme.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/edebug.el")
(load "/home/kreyren/Repositories/Zernit/src/RXT0112-1/downstream-classes/zeres-0/elisp/output/eerror.el")

@ -1 +0,0 @@
Directory for various functions used for logging and output

@ -1,242 +0,0 @@
#!/bin/sh
":"; exec emacs --script "$0" "$@" # -*- mode: emacs-lisp; lexical-binding: t; -*-
;; Created by Jacob Hrbek identified with an electronic mail <kreyren@rixotstudio.cz> and GPG signature <0x765AED304211C28410D5C478FCBA0482B0AB9F10> under all rights reserved in 26/08/2020 11:11:38 CEST
;; Formatting string declaration
;;; Success
(defvar die-format-string-success "SUCCESS: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using success trap")
(defvar die-format-string-success-log "SUCCESS: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using success trap")
(defvar die-format-string-success-debug "SUCCESS: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using success trap")
(defvar die-format-string-success-debug-log "SUCCESS: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using success trap")
;;; Failure
(defvar die-format-string-failure "FATAL: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using failure trap")
(defvar die-format-string-failure-log "FATAL: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using failure trap")
(defvar die-format-string-failure-debug "FATAL: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using failure trap")
(defvar die-format-string-failure-debug-log "FATAL: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using failure trap")
;;; Security
(defvar die-format-string-security "SECURITY: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using security trap")
(defvar die-format-string-security-log "SECURITY: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using security trap")
(defvar die-format-string-security-debug "SECURITY: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using security trap")
(defvar die-format-string-security-debug-log "SECURITY: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using security trap")
;;; Fixme
(defvar die-format-string-fixme "FIXME: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using fixme trap")
(defvar die-format-string-fixme-log "FIXME: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using fixme trap")
(defvar die-format-string-fixme-debug "FIXME: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using fixme trap")
(defvar die-format-string-fixme-debug-log "FIXME: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using fixme trap")
;;; Bug
(defvar die-format-string-bug "BUG: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using bug trap")
(defvar die-format-string-bug-log "BUG: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using bug trap")
(defvar die-format-string-bug-debug "BUG: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using bug trap")
(defvar die-format-string-bug-debug-log "BUG: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using bug trap")
;;; Unexpected
(defvar die-format-string-unexpected "UNEXPECTED: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for regular output using unexpected trap")
(defvar die-format-string-unexpected-log "UNEXPECTED: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for log entry using unexpected trap")
(defvar die-format-string-buunexpectedg-debug "UNEXPECTED: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging output using unexpected trap")
(defvar die-format-string-unexpected-debug-log "UNEXPECTED: %s\n" "Non-standard variable storing formatting string for non-standard function `die' to be used for debugging log entry using unexpected trap")
;; FIXME-TEST: Make sure that function 'die' works after changes
(zn-defun die (exitcode &optional message)
"Reimplementation of a non-standard function provided by the Zernit project (https://github.com/RXT0112/Zernit/blob/master/src/RXT0112-1/downstream-classes/zeres-0/bash/output/die.sh) into an emacs lisp that allow assertion of elisp runner with specified exit code and message with logging and debugging.
Due to the cross-platform compatibility the function is using strings for the exit codes instead of numerical values.
- true - Returns 0 on linux and 1 on windows to exit successfully
- false - Returns 1 on linux and 0 on windows for general failure
- security - Returns 28, used to fail safely in case security threat is detected
- fixme - Returns 36, used for unimplemented features
- bug - Returns 250, used to capture bugs in the wild
- unexpected - Returns 255, used for unexpected behavior
Messages are optional, if no message is provided the function will use a hardcoded message which should be avoided when the message might me inaccurate to the failure point to avoid user confusion.
Formatting strings of the messages are variables designed to be customized on demand using variables:
- '<function-name>-format-string-<exitcode>' for regular messages
- '<function-name>-format-string-<exitcode>-debug' for regular messages with debugging enabled
- '<function-name>-format-string-<exitcode>-log' for logging output in path defined in non-standard variable `emacs-log-file'
- '<function-name>-format-string-<exitcode>-log' for logging output in path defined in non-standard variable `emacs-log-file' with debugging enabled
Requires following variables:
- `emacs-log-file' - Non-standard variable used to output logging in a path of file
- `emacs-debug' - Non-standard variable used to set debugging level"
(pcase exitcode
("true" ;; Generic success
(cond
;; Process the message by lenght and debug state
((> (length message) 0)
(cond
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-success message))
(append-to-file (format die-format-string-success-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
((string-equal emacs-debug function-name)
(princ (format die-format-string-success-debug message))
(append-to-file (format die-format-string-success-debug-log message) nil emacs-log-file ) )
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
)
)
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-success "Logically determined that processed finished successfully"))
(append-to-file (format die-format-string-success-log "Logically determined that processed finished successfully") nil emacs-log-file) )
(t
(princ (format die-format-string-bug (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)))
(append-to-file (format die-format-string-bug-log (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)) nil emacs-log-file )
(kill-emacs 250) )
)
(cl-case system-type
((gnu gnu/linux gnu/kfreebsd darwin cygwin aix berkeley-unix hpux irix usg-unix-v)
(kill-emacs 0) )
((windows-nt ms-dos)
(kill-emacs 1) )
(otherwise
(princ (format die-format-string-unexpected (format "Platform '%1$s' is not implemented in function '%2$s' to handle assertion for argument '%3$s'" system-type function-name exitcode)))
(append-to-file (format die-format-string-unexpected (format "Platform '%1$s' is not implemented in function '%2$s' to handle assertion for argument '%3$s'" system-type function-name exitcode)) nil emacs-log-file ) )
(kill-emacs 250)
)
)
("false" ;; Generic failure
(cond
;; Process the message by lenght and debug state
((> (length message) 0)
(cond
((> (length message) 0)
(princ (format die-format-string-failure message))
(append-to-file (format die-format-string-failure-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
((string-equal emacs-debug function-name)
(princ (format die-format-string-failure-debug message))
(append-to-file (format die-format-string-failure-debug-log message) nil emacs-log-file ) )
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-failure message "Logically determined that process failed"))
(append-to-file (format die-format-string-failure-log message "Logically determined that processed failed") nil emacs-log-file) )
(t
(princ (format die-format-string-bug (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)))
(append-to-file (format die-format-string-bug-log (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)) nil emacs-log-file )
(kill-emacs 250) )
)
(cl-case system-type
((gnu gnu/linux gnu/kfreebsd darwin cygwin aix berkeley-unix hpux irix usg-unix-v)
(kill-emacs 1) )
((windows-nt ms-dos)
(kill-emacs 0) )
(otherwise
(princ (format die-format-string-unexpected (format "Platform '%1$s' is not implemented in function '%2$s' to handle assertion for argument '%3$s'" system-type function-name exitcode)))
(append-to-file (format die-format-string-unexpected (format "Platform '%1$s' is not implemented in function '%2$s' to handle assertion for argument '%3$s'" system-type function-name exitcode)) nil emacs-log-file ) )
(kill-emacs 250)
)
)
("security" ;; Security trap
(cond
;; Process the message by lenght and debug state
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (length message) 0)
(princ (format die-format-string-security message))
(append-to-file (format die-format-string-security-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
((string-equal emacs-debug function-name)
(princ (format die-format-string-security-debug message))
(append-to-file (format die-format-string-security-debug-log message) nil emacs-log-file ) )
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-security message "Runtime tripped security trap, exitting for safety"))
(append-to-file (format die-format-string-security-log message "Runtime tripped security trap, exitting for safety") nil emacs-log-file) )
(t
(princ (format die-format-string-bug (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)))
(append-to-file (format die-format-string-bug-log (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)) nil emacs-log-file )
(kill-emacs 250) )
)
(kill-emacs 28)
)
("fixme" ;; Fixme trap
(cond
;; Process the message by lenght and debug state
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (length message) 0)
(princ (format die-format-string-fixme message))
(append-to-file (format die-format-string-fixme-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
((string-equal emacs-debug function-name)
(princ (format die-format-string-fixme-debug message))
(append-to-file (format die-format-string-fixme-debug-log message) nil emacs-log-file ) )
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-fixme message "Runtime tripped fixme trap with no message provided, this is likely a bug where developer forgot to provide a message"))
(append-to-file (format die-format-string-fixme-log message "Runtime tripped fixme trap with no message provided, this is likely a bug where developer forgot to provide a message") nil emacs-log-file) )
(t
(princ (format die-format-string-bug (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)))
(append-to-file (format die-format-string-bug-log (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)) nil emacs-log-file )
(kill-emacs 250) )
)
(kill-emacs 36)
)
("bug" ;; Bug trap
(cond
;; Process the message by lenght and debug state
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (length message) 0)
(princ (format die-format-string-bug message))
(append-to-file (format die-format-string-bug-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
((string-equal emacs-debug function-name)
(princ (format die-format-string-bug-debug message))
(append-to-file (format die-format-string-bug-debug-log message) nil emacs-log-file ) )
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-bug message "Runtime tripped bug trap with no message provided, this is likely a bug where developer forgot to provide a message"))
(append-to-file (format die-format-string-bug-log message "Runtime tripped bug trap with no message provided, this is likely a bug where developer forgot to provide a message") nil emacs-log-file) )
(t
(princ (format die-format-string-bug (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)))
(append-to-file (format die-format-string-bug-log (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)) nil emacs-log-file )
(kill-emacs 250) )
)
(kill-emacs 250)
)
("unexpected" ;; Unexpected trap
(cond
;; Process the message by lenght and debug state
((> (length message) 0)
(cond
;; FIXME: This does not trigger if message is unbound or ""
((> (length message) 0)
(princ (format die-format-string-unexpected message))
(append-to-file (format die-format-string-unexpected-log message) nil emacs-log-file) )
;; FIXME: Implement logic that triggers only when emacs-debug contains 'function-name
((string-equal emacs-debug function-name)
(princ (format die-format-string-unexpected-debug message))
(append-to-file (format die-format-string-unexpected-debug-log message) nil emacs-log-file ) )
(t
(princ (format die-format-string-bug "Function '%1$s' with argument '%2$s' triggered unexpected case while processing variable 'emacs-debug' containing value '%3$s'" function-name exitcode emacs-debug)) )
) )
((or (= (length message) 0) (boundp 'message))
(princ (format die-format-string-unexpected message "Runtime tripped unexpected trap with no message provided, this is likely a bug where developer forgot to provide a message"))
(append-to-file (format die-format-string-unexpected-log message "Runtime tripped unexpected trap with no message provided, this is likely a bug where developer forgot to provide a message") nil emacs-log-file) )
(t
(princ (format die-format-string-bug (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)))
(append-to-file (format die-format-string-bug-log (format "Function '%1$s' tripped unexpected trap while processing message '%2$s' with argument '%3$s'" function-name message exitcode)) nil emacs-log-file )
(kill-emacs 250) )
)
(kill-emacs 255)
)
("" ;; No argument provided
(princ (format die-format-string-bug (format "No argument was provided in function '%1$s' which is not implemented to handle this scenario" function-name)))
(kill-emacs 250) )
(_ ;; unimplemented argument provided
(princ (format die-format-string-bug (format "Argument '%1$s' is not implemented in function '%2$s'" exitcode function-name)))
(kill-emacs 250) )
)
)

Some files were not shown because too many files have changed in this diff Show More