aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-05-18 12:23:02 +0300
committerCem Keylan <cem@ckyln.com>2020-05-18 12:23:02 +0300
commita1acebc4ca699da837c1f063983e9aa046ed75af (patch)
tree092ef5b98bcd475d000a96ed1cb7a8116d0f1b0d
parente4a2415c13b9fa34a9c7b80d19120bfb1caa3319 (diff)
downloadmkrootfs-a1acebc4ca699da837c1f063983e9aa046ed75af.tar.gz
remove library after sourcing it
-rwxr-xr-xmkrootfs.sh23
1 files changed, 14 insertions, 9 deletions
diff --git a/mkrootfs.sh b/mkrootfs.sh
index 134b46a..ad06a41 100755
--- a/mkrootfs.sh
+++ b/mkrootfs.sh
@@ -4,21 +4,26 @@
# Bootstrapper for Carbs Linux
# See LICENSE file for copyright and license details
-# Source kiss as a library
-kissloc=$(command -v kiss)
-kissln=$(wc -l < "$kissloc")
-sed "${kissln}d" "$kissloc" > .kisslib
-. ./.kisslib
-
+{
+ # Source kiss as a library so that we can use pkg_order
+ #
+ # Get the line number so we can remove the last line
+ # that is calling the main function.
+ kissloc=$(command -v kiss)
+ kissln=$(wc -l < "$kissloc")
+
+ # Save the file on a temporary .kisslib file where we
+ # will be reading the library functions.
+ sed "${kissln}d" "$kissloc" > .kisslib
+ . ./.kisslib
+ rm -f .kisslib
+}
# Functions
msg() { printf '\033[1;35m-> \033[m%s\n' "$@" ;}
die() { printf '\033[1;31m!> ERROR: \033[m%s\n' "$@" >&2; exit 1 ;}
-# Exit if the user is not root
-[ "$(id -u)" -eq 0 ] || die "Please run as root"
-
# Let's get current working directory
BASEDIR="$PWD"