tectonic tribulations edition: host preparation
authorChris Koeritz <fred@gruntose.com>
Sun, 31 Oct 2021 23:15:56 +0000 (19:15 -0400)
committerChris Koeritz <fred@gruntose.com>
Sun, 31 Oct 2021 23:15:56 +0000 (19:15 -0400)
needed for a bit; just automates a lot of separate install instructions.
planning to support windows with apt-cyg and mac with brew, but those steps are kinda hosed still.
is_feisty_up lets a caller know if the system is initialized yet or not, which was needed in prep_feisty_host.
functions have a couple changes, esp. a better whichable that now returns an error code instead of just not echoing text.

readme.txt
scripts/core/functions.sh
scripts/core/is_feisty_up.sh [new file with mode: 0644]
scripts/core/prep_feisty_host.sh [new file with mode: 0644]

index e77c89ab0756864d5162c4fdf0ce75617550c993..4b52f9ba40223bbbcbd1841ded4e6f63b2ef5e7c 100644 (file)
@@ -15,6 +15,8 @@ If you have stored it elsewhere, then please adapt the commands accordingly.
 
 How to get the feisty meow codebase
 
+These steps assume that you have the "git" tool available.
+
 | On Microsoft Windows, install the Cygwin tools as documented here:
 | /opt/feistymeow.org/feisty_meow/documentation/cygwin_install_list.txt (local file) or
 | https://feistymeow.org/feisty_meow/documentation/cygwin_install_list.txt (web)
@@ -26,6 +28,11 @@ $ git clone git://feistymeow.org/feisty_meow
 
 How to load the feisty meow script environment
 
+Prepare your host by installing the packages needed to bootstrap feisty meow.
+If this fails, then you may need the manual installation steps at the end of
+this file.
+$ bash /opt/feistymeow.org/feisty_meow/scripts/core/prep_feisty_host.sh
+
 Set up the feisty_meow scripts; this is only needed once, when you first get
 the codebase.
 $ bash /opt/feistymeow.org/feisty_meow/scripts/core/reconfigure_feisty_meow.sh
@@ -52,26 +59,6 @@ https://feistymeow.org/feisty_meow/documentation/feisty_meow_command_reference.t
 
 ==============
 
-How to install the feisty meow script dependencies
-
-A couple of perl modules are required by some of the scripts (including the
-differ utility and the feisty meow customization system).  They can be
-installed with either apt or CPAN.
-
-Install using apt (on Ubuntu or Debian-based OS):
-$ sudo apt install libfile-which-perl libtext-diff-perl
-
-Install using yum (on Centos or similar distros):
-$ yum install perl-File-Which perl-Text-Diff
-
-or Install using perl's CPAN:
-$ sudo cpan install Text::Diff File::Which
-
-or on Cygwin (MS-Windows), install with apt-cyg:
-$ apt-cyg install perl-File-Which perl-Text-Diff
-
-==============
-
 How to update the feisty meow codebase to the latest online version
 
 This assumes that a somewhat current version of feisty meow is already
@@ -84,25 +71,6 @@ $ rpuffer $FEISTY_MEOW_APEX ; regenerate
 
 ==============
 
-How to install the build dependencies for feisty meow
-
-These dependencies are used for building the applications, tools and tests
-in the "nucleus", "octopi", "graphiq" and other C++ collections.
-
-| Ubuntu / Debian:
-| $ sudo apt install build-essential librtmp-dev libcurl4-gnutls-dev libssl-dev
-
-| Centos / Redhat / Fedora:
-| $ sudo yum install gcc gcc-c++ openssl-devel.x86_64 curl-devel
-
-The "kona" collection depends on Java version 8 or better.
-
-| Ubuntu:
-| Set up the java PPA archive as described here:
-| https://launchpad.net/~webupd8team/+archive/ubuntu/java
-
-==============
-
 How to build the feisty meow codebase
 
 Run the following command to build the feisty meow libraries and applications.
@@ -155,4 +123,43 @@ More information is available at the official site: https://feistymeow.org
 
 ==============
 
+Manual Installation Steps:
+
+How to install the feisty meow script dependencies...
+
+A couple of perl modules are required by some of the scripts (including the
+differ utility and the feisty meow customization system).  They can be
+installed with either apt or CPAN.
+
+Install using apt (on Ubuntu or Debian-based OS):
+$ sudo apt install libfile-which-perl libtext-diff-perl
+
+Install using yum (on Centos or similar distros):
+$ yum install perl-File-Which perl-Text-Diff
+
+or Install using perl's CPAN:
+$ sudo cpan install Text::Diff File::Which
+
+or on Cygwin (MS-Windows), install with apt-cyg:
+$ apt-cyg install perl-File-Which perl-Text-Diff
+
+How to install the build dependencies for feisty meow...
+
+These dependencies are used for building the applications, tools and tests
+in the "nucleus", "octopi", "graphiq" and other C++ collections.
+
+| Ubuntu / Debian:
+| $ sudo apt install build-essential librtmp-dev libcurl4-gnutls-dev libssl-dev
+
+| Centos / Redhat / Fedora:
+| $ sudo yum install gcc gcc-c++ openssl-devel.x86_64 curl-devel
+
+The "kona" collection depends on Java version 8 or better.
+
+| Ubuntu:
+| Set up the java PPA archive as described here:
+| https://launchpad.net/~webupd8team/+archive/ubuntu/java
+
+==============
+
 
index c1a14c0e83d594258a7f06e12eb6798ad17f8c1e..207a384f90ab134df4617f3603d612bc1e073801 100644 (file)
@@ -40,11 +40,19 @@ if [ -z "$skip_all" ]; then
   {
     to_find="$1"; shift
     local WHICHER="$(\which which 2>/dev/null)"
+#>&2 echo "got whicher as: $WHICHER"
     if [ $? -ne 0 ]; then
       # there is no which command here.  we produce nothing due to this.
       echo
+      return 2
     fi
-    echo $($WHICHER $to_find 2>/dev/null)
+    local sporkenz  # must be defined local here, before call, or we don't get exit value?!
+    sporkenz=$($WHICHER "$to_find" 2>/dev/null)
+#>&2 echo "broken with this line, but here is exit val: $?"
+    local err=$?
+#>&2 echo "got whicher as: $WHICHER"
+    echo $sporkenz
+    return $err
   }
 
   # makes a directory of the name specified and then tries to change the
diff --git a/scripts/core/is_feisty_up.sh b/scripts/core/is_feisty_up.sh
new file mode 100644 (file)
index 0000000..1f4b2d8
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# tells the caller if the feisty_meow scripts have been initialized
+# successfully or not, as far as we can tell.
+# any parameter passed will cause us to go into debugging mode.
+
+do_debug="$1"; shift
+
+if [ \
+    -z "$FEISTY_MEOW_APEX" -o \
+    -z "$CORE_VARIABLES_LOADED" -o \
+    -z "$FEISTY_MEOW_LOADING_DOCK" \
+  ]; then
+  if [ ! -z "$do_debug" ]; then
+    echo "Bailing out because a crucial Feisty Meow initialization variable is missing."
+  fi
+  exit 1
+fi
+
+# we got through the minimal gauntlet, so claim we're initialized.
+if [ ! -z "$do_debug" ]; then
+  echo "Looking good for every Feisty Meow initialization variable that we check."
+fi
+exit 0
+
+
diff --git a/scripts/core/prep_feisty_host.sh b/scripts/core/prep_feisty_host.sh
new file mode 100644 (file)
index 0000000..07b95ae
--- /dev/null
@@ -0,0 +1,152 @@
+#!/bin/bash
+
+# this is the feisty meow host preparation script.  it installs all the packages required to run and build feisty meow scripts and applications.
+# this script may still be a bit incomplete; we definitely use a lot of unix and linux tools in different scripts.
+
+# preconditions and dependencies--this script itself depends on:
+#   feisty meow
+#   bash
+#   anything else?
+
+####
+
+# something borrowed...
+function exit_on_error() {
+  if [ $? -ne 0 ]; then
+    echo -e "\n\nan important action failed and this script will stop:\n\n$*\n\n*** Exiting script..."
+    error_sound
+    exit 1
+  fi
+}
+
+####
+
+# load feisty meow environment here, but first test that we *can* load it.
+
+#hmmm: currently, this script needs the system to have already been configured?
+#  that's the implication of calling launch_feisty...
+#  can we find that same bootstrapping code that will reconfigure first?
+#more about this...
+#    hmmm: we need clean starty type approach!  must not expect feisty to already be configured for use!
+#    e.g.?? $ bash /opt/feistymeow.org/feisty_meow/scripts/core/reconfigure_feisty_meow.sh
+#    hmmm: above ALSO ESSENTIAL TO GET RIGHT!
+
+PHASE_MESSAGE="Checking integrity of Feisty Meow subsystem"
+if [ -z $FEISTY_MEOW_APEX ]; then
+  false; exit_on_error $PHASE_MESSAGE
+fi
+
+# simple brute force check.  can we go there?
+pushd $FEISTY_MEOW_APEX &> /dev/null
+exit_on_error locating feisty meow top-level folder
+popd &> /dev/null
+
+# now ask feisty if it's there; should work as long as our scripts are in place.
+bash $FEISTY_MEOW_APEX/scripts/core/is_feisty_up.sh
+exit_on_error $PHASE_MESSAGE
+
+# standard load-up.
+#hmmm: this will currently fail if reconfigure has never been called.
+source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
+
+####
+
+# first the crucial bits for scripts to work...
+
+PHASE_MESSAGE="installing perl file and diff modules"
+
+# ubuntu or debian or other apt-based OSes...
+if whichable apt; then
+  sudo apt install libfile-which-perl libtext-diff-perl
+  exit_on_error $PHASE_MESSAGE
+# rpm based with yum available...
+elif whichable yum; then  
+  sudo yum install perl-File-Which perl-Text-Diff
+  exit_on_error $PHASE_MESSAGE
+# macos based...
+elif [ ! -z "$IS_DARWIN" ]; then
+
+#hmmm: not quite right yet...
+  brew install blah blah? lots?
+  exit_on_error $PHASE_MESSAGE
+
+# windows-based with cygwin (or we'll fail out).
+elif [ "$OS" == "Windows_NT" ]; then
+#hmmm: install apt-cyg!
+# we need this to do the following step, so why not automate that?
+# can we at least check for the packages we absolutely need?
+
+#hmmm: can we bootstrap and still survive on the basic cygwin modules if already installed?
+#  then we could use our huge list to get the rest!
+
+#hmmm: is there any other way to get the missing ones, that we need for apt-cyg?
+
+  apt-cyg install perl-File-Which perl-Text-Diff
+  exit_on_error $PHASE_MESSAGE
+fi
+
+####
+
+# then the builder packages...
+
+PHASE_MESSAGE="installing code builder packages"
+
+# ubuntu or debian or other apt-based OSes...
+if whichable apt; then
+  sudo apt install build-essential librtmp-dev libcurl4-gnutls-dev libssl-dev
+  exit_on_error $PHASE_MESSAGE
+# rpm based with yum available...
+elif whichable yum; then  
+  sudo yum install gcc gcc-c++ openssl-devel.x86_64 curl-devel
+  exit_on_error $PHASE_MESSAGE
+# macos based...
+elif [ ! -z "$IS_DARWIN" ]; then
+
+#hmmm: not quite right yet...
+  brew install blork blork? lots?
+  exit_on_error $PHASE_MESSAGE
+
+# windows-based with cygwin (or we'll fail out).
+elif [ "$OS" == "Windows_NT" ]; then
+#hmmm: unknown list needed still...
+  apt-cyg install fugazi combustinatorinibasil scampnific
+  exit_on_error $PHASE_MESSAGE
+fi
+
+####
+
+# install other external packages and whatnot.
+
+#hmmm: anything else to get installed?
+  #hmmm: java?
+  #hmmm: python?
+  #hmmm: perl itself!?
+
+
+####
+
+# get ready to finish up.
+
+#...finishing steps...  if any.
+
+# all done now.
+exit 0
+
+####
+
+
+#############################
+#scav line
+#############################
+
+The "kona" collection depends on Java version 8 or better.
+| Ubuntu:
+| Set up the java PPA archive as described here:
+| https://launchpad.net/~webupd8team/+archive/ubuntu/java
+
+#not needed at the moment.
+#echo "bailing because script is immature.  farts!"
+#exit 1
+