This commit is contained in:
Jacob Hrbek 2020-07-16 10:41:35 +02:00
parent 61fffcaec6
commit 608d8a9ffb
37 changed files with 1201 additions and 1 deletions

@ -3,3 +3,7 @@
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

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

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

@ -0,0 +1,3 @@
# Zeres-0 (Bash)
This directory contains logic for zeres-0 to process standardized bash/shell downstream

@ -0,0 +1,211 @@
#!/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 "$3" 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
;;
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 '$3' has been provided in $myName"
esac
unset funcname
exit 255
esac
}; alias die='die "$LINENO"'

@ -0,0 +1,38 @@
#!/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
exit 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
exit 0 ;;
result)
printf "$EBENCH_FORMAT_STRING_RESULT" "$2" || die invalid-format
unset funcname
exit 0 ;;
*) die 2 "Invalid argument '$2' has been parsed in $funcname"
esac
}; alias ebench='ebench "$LINENO"'

@ -0,0 +1,31 @@
#!/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
exit 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
exit 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,0 +1,30 @@
#!/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
exit 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
exit 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,0 +1,53 @@
#!/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"
exit 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" "$2" >> "$logPath" || die invalid-format
unset funcname
exit 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
exit 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,0 +1,29 @@
#!/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
exit 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
exit 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,0 +1,30 @@
#!/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"
case "$2" in
"debug")
if [ "$DEBUG" = 0 ] || [ -z "$DEBUG" ]; then
unset funcname
exit 0
elif [ "$DEBUG" = 1 ]; then
"$PRINTF" "$ELOG_FORMAT_STRING_DEBUG_LOG" "$2" >> "$logPath" || die invalid-format
unset funcname
exit 0
else
case "$LANG" in
# FIXME-TRANSLATE: Translate to more languages
en-*|*) die bug "processing variable DEBUG with value '$DEBUG' in $funcname"
esac
fi ;;
*) die bug "Invalid argument '$2' has been parsed to $funcname"
esac
}; alias einfo='einfo "$LINENO"'

@ -0,0 +1,29 @@
#!/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
exit 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
exit 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,0 +1,13 @@
#!/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"
}

@ -0,0 +1,13 @@
#!/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"
}

@ -0,0 +1,13 @@
#!/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"
}

@ -0,0 +1,13 @@
#!/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"
}

@ -0,0 +1,13 @@
#!/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"
}

@ -0,0 +1,13 @@
#!/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"
}

@ -0,0 +1,13 @@
#!/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"
}

@ -0,0 +1,14 @@
#!/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"
}

@ -0,0 +1,15 @@
#!/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"
}

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

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

@ -0,0 +1,12 @@
#!/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"

@ -0,0 +1,13 @@
#!/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"

@ -0,0 +1,313 @@
#!/bin/sh
# All rights reserved by Jacob Hrbek <kreyren@rixotstudio.cz> in 04/2020
# 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"
MAINTAINER_EMAIL="kreyren@rixotstudio.cz"
MAINTAINER_NICKNAME="kreyren"
MAINTAINER_NAME="Jacob"
MAINTAINER_SURNAME="Hrbek"
# FIXME: _=${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="${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
# FIXME: Implement logic
[ -z "$DIE_FORMAT_STRING_SUCCESS" ] && DIE_FORMAT_STRING_SUCCESS="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"
### 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="BENCHMARK: Starting benchmark for action %s\n"
[ -z "$EBENCH_FORMAT_STRING_RESULT" ] && EBENCH_FORMAT_STRING="BENCHMARK: Action %s took $SECONDS seconds\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
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
# 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

@ -0,0 +1,5 @@
# Zeres-0 (ion)
Stub implementation for zeres-0 to process ion-based downstream
FIXME: Implement (See zeres-0's bash for reference)

@ -0,0 +1,5 @@
# Zeres-0 (python)
Stub implementation for zeres-0 to process python-based downstream
FIXME: Implement (See zeres-0's bash for reference)

@ -0,0 +1,5 @@
# Zeres-0 (visualbasic)
Stub implementation for zeres-0 to process visualbasic-based downstream
FIXME: Implement (See zeres-0's bash for reference)

@ -0,0 +1,5 @@
# Zeres-0 (zsh)
Stub implementation for zeres-0 to process zsh-based downstream
FIXME: Implement (See zeres-0's bash for reference)

@ -0,0 +1,5 @@
# master-downstream
FIXME: Stub name
Work in progress implementation of downstream management for zernit

@ -0,0 +1,24 @@
# Packages
Directory dedicated to various packages that are expected to be processed by zernit
The packages are expected to be stored as `category/package`
invidual package version, slot, origin are expected to be stored as:
```
category/package-version:slot::origin
```
for the logic to be implemented as:
```
category/package-version:slot::origin OPTION: something -something
```
or
```
category/package-version:slot::origin \
OPTION: something -something
```

@ -0,0 +1 @@
Some introduction of the package here

@ -0,0 +1,19 @@
{
"package": {
"name": "Some Name",
"summary": "Some summary",
"description": "long description of what this package is",
"homepage": "https://some.url",
"thumbnail": {
"64x64": "path/to/somewhere",
"128x128": "https://url.to/thumbnail",
},
"license": "some license",
"options": {
"X": {
"description": "Enables support for X.org",
"conflicts": ""
}
}
}

@ -0,0 +1,74 @@
# Concept created by Jacob Hrbek <kreyren@rixotstudio.cz> under All rights reserved in 03.03.2020
# - Temporary set as proprietary until custom four freedom respecting license is finished
###! This is a concept for various non-upstream or not directly upstream modifications added to the package
---
# Comment
NAME: something
# FIXME: Implement built-in cap for lenght
SUMMARY: Short summary
Description: does something
# Used to display thumbnail in the GUI/TUI(?)
THUMBNAIL:
64x64: path/to/image -or- https://some.url
128x128: path/to/image -or- https://some.url
HOMEPAGE: www.somewhere.something
LICENSE: something
# FIXME: This is not a good implementation
DEPENDENCIES:
some/dependency:0::origin[>=1.0.0]
description: something
either-of-these
some/dependency:0::origin[=1.0.0]
some/other-dependency:0::origin[=1.0.0]
# FIXME: This is not a good implementation
OPTIONS:
# Compiler
exactly-one
gcc:
description: Compile using gcc
clang:
description: Compile using clang
# LibC
exactly-one
libc:
description: Compile with libc
musl:
description: Compile with musl
# For tested shell version used to process this file, used to capture changes made by upstream that might break our runtime
# FIXME: Cause a fatal error if the downstream wasn't tested on this version
# - FIXME: Allow this being skipped in configuration
# - FIXME: We should implement a method
SHELL_COMPAT:
1.1.0:
Tested-by: Some One <email>
---
# Trigger zernit backend to resolve metadata and dependencies
## - Without this zernit will just run this as a script with option to use it's backend on demand
zernit_init
# Used to source a library
# FIXME: We need some way to export specific parts of the library
## NOTICE: Paludis is using `require djvu scm-git autotools [ supported_autoconf=[ 2.5 ] supported_automake=[ 1.13 ] ]`
require someLibrary
phase_call src_fetch
phase_call src_configure
my_phase() {
i do something cool
}; my_phase
phase_call src_compile
phase_call src_merge
# FIXME: Add method to create something like 'snap' or 'appimage' that can then be just exported on any system to use the software from a sandboxed environment
maintainer_note \
"I just wanted to say something important after the package has been merged in the system" \
"There is a rare bug in version 1.1.1 which might break processing png files, reproduction of the issue provided in url/to/tracking are welcomed!" \
"Glad to waste your time!"

@ -0,0 +1,55 @@
#!/bin/false
# - Used only for sourcing
#@ Concept created by Jacob Hrbek <kreyren@rixotstudio.cz> under All rights reserved in 03.03.2020
#@ - Temporary set as proprietary until custom four freedom respecting license is finished
# shellcheck shell=sh # Written to be POSIX-compatible
# Function to return a json database of this package
zernit_json() {
cat <<-EOF > somewhere?
"package": {
"name": "$PN",
"description": "...",
"conflicts": {
"some/package:slot::origin[=version]" {
"reasoning:" "example reasoning"
}
# FIXME: What if this conflicts with an option?
"option": "A" {
reasoning: "some reasoning to why option A is not expected on this package"
}
}
}
EOF
}
# Trigger zernit backend to resolve metadata and dependencies
## - Without this zernit will just run this as a script with option to use it's backend on demand
zernit_init
# Used to source a library
# FIXME: We need some way to export specific parts of the library
## NOTICE: Paludis is using `require djvu scm-git autotools [ supported_autoconf=[ 2.5 ] supported_automake=[ 1.13 ] ]`
require someLibrary
phase_call src_metadata
phase_call src_fetch
phase_call src_configure
my_phase() {
i do something cool
}; my_phase
phase_call src_compile
phase_call src_merge
# FIXME: Add method to create something like 'snap' or 'appimage' that can then be just exported on any system to use the software from a sandboxed environment
maintainer_note \
"I just wanted to say something important after the package has been merged in the system" \
"There is a rare bug in version 1.1.1 which might break processing png files, reproduction of the issue provided in url/to/tracking are welcomed!" \
"Glad to waste your time!"

@ -0,0 +1,74 @@
# Concept created by Jacob Hrbek <kreyren@rixotstudio.cz> under All rights reserved in 03.03.2020
# - Temporary set as proprietary until custom four freedom respecting license is finished
---
# Comment
NAME: something
# FIXME: Implement built-in cap for lenght
SUMMARY: Short summary
Description: does something
# Used to display thumbnail in the GUI/TUI(?)
THUMBNAIL:
64x64: path/to/image -or- https://some.url
128x128: path/to/image -or- https://some.url
HOMEPAGE: www.somewhere.something
License: something
DEPENDENCIES:
some/dependency:0::origin[>=1.0.0]
descrip
# Trigger zernit backend to resolve metadata and dependencies
## - Without this zernit will just run this as a script with option to use it's backend on demandtion: Requi
zernit_init
red for something
either-of-these
some/dependency:0::origin[=1.0.0]
some/other-dependency:0::origin[=1.0.0]
OPTIONS:
# Compiler
exactly-one
gcc:
description: Compile using gcc
clang:
description: Compile using clang
# LibC
exactly-one
libc:
description: Compile with libc
musl:
description: Compile with musl
# For tested shell version used to process this file, used to capture changes made by upstream that might break our runtime
# FIXME: Cause a fatal error if the downstream wasn't tested on this version
# - FIXME: Allow this being skipped in configuration
# - FIXME: We should implement a method
SHELL_COMPAT:
1.1.0:
Tested-by: Some One <email>
---
# Trigger zernit backend to resolve metadata and dependencies
## - Without this zernit will just run this as a script with option to use it's backend on demand
zernit_init
# Used to source a library
# FIXME: We need some way to export specific parts of the library
## NOTICE: Paludis is using `require djvu scm-git autotools [ supported_autoconf=[ 2.5 ] supported_automake=[ 1.13 ] ]`
require someLibrary
phase_call src_fetch
phase_call src_configure
my_phase() {
i do something cool
}; my_phase
phase_call src_compile
phase_call src_merge
# FIXME: Add method to create something like 'snap' or 'appimage' that can then be just exported on any system to use the software from a sandboxed environment
maintainer_note \
"I just wanted to say something important after the package has been merged in the system" \
"There is a rare bug in version 1.1.1 which might break processing png files, reproduction of the issue provided in url/to/tracking are welcomed!" \
"Glad to waste your time!"