Skip to content
Browse files

Added help module, updated package module.

  • Loading branch information...
1 parent d3c93c2 commit e0f9b29be8eda439fa03bf0cb7478de515f16bcc @wayneeseguin wayneeseguin committed
View
53 modules/bash/help/functions
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+
+show_help()
+{
+ while [[ $# -gt 0 ]] ; do
+ token="$1" ; shift
+
+ case "$token" in
+ desc*|description)
+ description
+ ;;
+ actions)
+ actions
+ ;;
+ help|usage|*)
+ usage
+ ;;
+ esac
+ done
+}
+
+description() { help_description="$*" ; }
+
+actions(){ help_actions="$*" ; }
+
+notes() { help_notes="$*" ; }
+
+dependencies() { help_dependencies="$*" ; }
+
+resources() { help_resources="$*" ; }
+
+usage()
+{
+ log "\nUsage\n\n bdsm ${extension} <action> <<arguments>>\n"
+
+ [[ -n "${help_description}" ]] && \
+ log "\nDescription\n BDSM ${help_description}"
+
+ log "\nActions\n"
+ [[ -n "${help_actions}" ]] && \
+ log "${help_actions}\n"
+ log " help - Display this help text."
+
+ [[ -n "${help_notes}" ]] && \
+ log "\nNotes\n${help_notes}"
+
+ [[ -n "${help_dependencies}" ]] && \
+ log "\nDependencies\n${help_dependencies}"
+
+ [[ -n "${help_resources}" ]] && \
+ log "\nResources\n${help_resources}"
+}
+
View
2 modules/bash/help/initialize
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+
View
97 modules/bash/package/functions
@@ -1,5 +1,83 @@
#!/usr/bin/env bash
+# Example Usage:
+#
+# define_package \
+# name "bash"
+# version "4.2"
+# url "ftp.gnu.org/gnu/bash/"
+#
+define_package()
+{
+ while [[ $# -gt 0 ]] ; do
+ key="$1" ; shift
+ if [[ -n "${1:-}" ]] ; then
+ value="$1" ; shift
+ else
+ fail "${extension} : ${action} : define_package() : Missing value for key '${key}'"
+ fi
+
+ case "$key" in
+ name)
+ package_name="${value}"
+ ;;
+ version)
+ package_version="${value}"
+ ;;
+ url)
+ package_url="${value}"
+ ;;
+ md5_url)
+ package_md5_url="${value}"
+ ;;
+ bin_path)
+ bin_path="${value}"
+ ;;
+ prefix_path)
+ prefix_path="${value}"
+ ;;
+ source_path)
+ source_path="${value}"
+ ;;
+ archive_format)
+ archive_format="${value}"
+ ;;
+ # TODO: Simplify into
+ #(+([[[:alnum:]]|])_path|name|version|url|md5_url)
+ # eval "${key}=${value}"
+ # ;;
+ *)
+ fail "Unknown key for define_package() : '${key}' (value: ${value})"
+ ;;
+ esac
+ done
+}
+
+# TODO: much more error checking and conditional branching.
+build_package()
+{
+ ensure_nonempty \
+ "package_name" \
+ "package_version" \
+ "archive_format"
+
+ ensure_paths_exist "${source_path}"
+
+ enter "${source_path}"
+
+ fetch_package
+
+ extract_package
+
+ enter "${package}-${package_version}"
+
+ configure_package
+
+ make_package
+
+ install_package
+}
+
fetch_package_md5()
{
true ${md5_url:=${1}.md5}
@@ -51,22 +129,3 @@ install_package()
make install
}
-build_package()
-{
- ensure_paths_exist "${source_path}"
-
- enter "${source_path}"
-
- fetch_package
-
- extract_package
-
- enter "${package}-${package_version}"
-
- configure_package
-
- make_package
-
- install_package
-}
-
View
9 modules/bash/package/initialize
@@ -2,7 +2,12 @@
# Ensure that default values are set.
true \
- "${source_path:=/usr/local/src}" \
+ "${package_name:=$package}" \
+ "${prefix_path:="/usr/local"}"
+
+true \
+ "${bin_path:="${prefix_path}/bin"}" \
+ "${source_path:="${prefix_path}/src"}" \
"${archive_format:=tar.gz}" \
- "${package_file:="${package}-${package_version}.${archive_format}"}"
+ "${package_file:="${package_name}-${package_version}.${archive_format}"}"
View
3 modules/bash/rvm/initialize
@@ -6,9 +6,10 @@
source_files "/etc/rvmrc" "$HOME/.rvmrc"
# Attempt to load RVM
-source_files first $(
+source_files $(first $(
nonempty_files \
"$rvm_path/.rvm/scripts/rvm" \
"$HOME/.rvm/scripts/rvm" \
"/usr/local/scripts/rvm"
+ )
)

0 comments on commit e0f9b29

Please sign in to comment.
Something went wrong with that request. Please try again.