[Lunar-commits] <lunar> Merge pull request #5 from cavalier38/sanitize-config
Auke Kok
sofar+github at foo-projects.org
Mon Jul 9 23:25:26 CEST 2012
commit eb2a7da6018871a412d7a55702f8b6f58772d90d
Author: Auke Kok <sofar+github at foo-projects.org>
Date: Mon, 09 Jul 2012 14:25:26 -0700
URL: https://github.com/lunar-linux/lunar/commit/eb2a7da6018871a412d7a55702f8b6f58772d90d
Merge pull request #5 from cavalier38/sanitize-config
Sanitize config
---
Makefile +1/-0
etc/config +1/-15
misc/bootstrap +36/-0
prog/lget +1/-0
prog/lin +1/-0
prog/lrm +1/-0
prog/lsh +2/-1
prog/lunar +1/-0
prog/lvu +1/-0
9 files changed, 0 insertions (+), 0 deletions (-)
--- a/Makefile
+++ b/Makefile
@@ -56,6 +56,7 @@ install: .PHONY
install -m0755 $$F $(DESTDIR)/var/lib/lunar/compilers/ ; \
done
install -d $(DESTDIR)/var/lib/lunar
+ install -m0755 misc/bootstrap $(DESTDIR)/var/lib/lunar/
install -m0644 misc/excluded $(DESTDIR)/var/lib/lunar/
install -m0644 misc/protected $(DESTDIR)/var/lib/lunar/
install -m0644 misc/solo $(DESTDIR)/var/lib/lunar/
--- a/etc/config
+++ b/etc/config
@@ -16,6 +16,7 @@ export DIALOGRC=/etc/lunar/dialogrc
DEFAULT_PREFIX=/usr
+ BOOTSTRAP=/var/lib/lunar/bootstrap
EXCLUDED=/var/lib/lunar/excluded
MOONBASE=/var/lib/lunar/moonbase
PROTECTED=/var/lib/lunar/protected
@@ -116,18 +117,3 @@ export DIALOGRC=/etc/lunar/dialogrc
ENTER_IFS=$'\n'
STANDARD_IFS=$' \t\n'
-for FUNCTION in $FUNCTIONS/*.lunar ; do
- . $FUNCTION
-done
-
-if [ -s "$LOCAL_CONFIG" ] ; then
- . $LOCAL_CONFIG
-fi
-
-sound $SOUND
-color $COLOR
-
-for LUNAR_PLUGIN in $PLUGIN_DIR/*.plugin; do
- . $LUNAR_PLUGIN
-done
-
--- /dev/null
+++ b/misc/bootstrap
@@ -0,0 +1,36 @@
+#!/bin/bash
+############################################################
+# #
+# bootstrap - Lunar initialization code #
+# #
+############################################################
+# #
+# Copyright 2012 by Peter de Ridder under GPLv2 #
+# #
+############################################################
+
+# check if /etc/lunar/config is loaded
+if [ -z "$BOOTSTRAP" ] ; then
+ . /etc/lunar/config
+fi
+
+for FUNCTION in $FUNCTIONS/*.lunar ; do
+ . $FUNCTION
+done
+
+if [ -s "$LOCAL_CONFIG" ] ; then
+ . $LOCAL_CONFIG
+fi
+
+# validate and correct config variables from $LOCAL_CONFIG
+for DIR_VAR in CONFIG_CACHE DEPENDS_CONFIG BUILD_DIRECTORY DOCUMENT_DIRECTORY DEFAULT_PREFIX MOONBASE FUNCTIONS MENUS PLUGIN_DIR SOUND_DIRECTORY INSTALL_LOGS COMPILE_LOGS MD5SUM_LOGS INSTALL_CACHE SOURCE_CACHE TMPDIR ; do
+ # dir configuration values shouldn't end with a /
+ eval $DIR_VAR=\${$DIR_VAR/%\\/}
+done
+
+sound $SOUND
+color $COLOR
+
+for LUNAR_PLUGIN in $PLUGIN_DIR/*.plugin; do
+ . $LUNAR_PLUGIN
+done
--- a/prog/lget
+++ b/prog/lget
@@ -84,6 +84,7 @@ main() {
. /etc/lunar/config
+. $BOOTSTRAP
GETOPT_ARGS=$(getopt -q -n lget -o "adf:hu:vw:" -l "all,debug,from:,help,url:,verbose,want:" -- "$@")
--- a/prog/lin
+++ b/prog/lin
@@ -236,6 +236,7 @@ main() {
. /etc/lunar/config
+. $BOOTSTRAP
GETOPT_ARGS=$(getopt -q -n lin -o "cdf:hprRsvV:w:" -l "compile,debug,deps,from:,help,opts:,probe,reconfigure,resurrect,silent,verbose,Version:,want:" -- "$@")
--- a/prog/lrm
+++ b/prog/lrm
@@ -306,6 +306,7 @@ downgrade() {
. /etc/lunar/config
+. $BOOTSTRAP
GETOPT_ARGS=$(getopt -q -n lrm -o "dD:hknuvp" -l "debug,downgrade:,help,keepconfig,nosustain,upgrade,verbose,purge" -- "$@")
--- a/prog/lsh
+++ b/prog/lsh
@@ -5,6 +5,7 @@
#
. /etc/lunar/config
+. $BOOTSTRAP
set_priority
@@ -14,6 +15,6 @@ else
export PS1="\[\033[0;31m\][lunar] \u@\h \w \\$ \[\033[0m\]"
message "\n ${PROBLEM_COLOR}Warning:${DEFAULT_COLOR}${MESSAGE_COLOR}" \
"lsh is potentially hazardous to your system.${DEFAULT_COLOR}\n"
- bash --rcfile /etc/lunar/config
+ bash --rcfile $BOOTSTRAP
fi
--- a/prog/lunar
+++ b/prog/lunar
@@ -794,6 +794,7 @@ main() {
}
. /etc/lunar/config
+. $BOOTSTRAP
GETOPT_ARGS=$(getopt -q -n lunar -o "dhv" -l "debug,help,verbose" -- "$@")
--- a/prog/lvu
+++ b/prog/lvu
@@ -1668,6 +1668,7 @@ main() {
. /etc/lunar/config
+. $BOOTSTRAP
GETOPT_ARGS=$(getopt -q -n lvu -o "dhv" -l "debug,help,verbose" -- "$@")
More information about the Lunar-commits
mailing list