]> gitweb.fluxo.info Git - templater.git/commitdiff
Dectect if templater is locally or system installed
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 28 Oct 2017 13:56:20 +0000 (11:56 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 28 Oct 2017 13:56:20 +0000 (11:56 -0200)
TODO.md
templater

diff --git a/TODO.md b/TODO.md
index 806cc5427d51ae3ee43e49882d799cf502affc5e..240d41450252e9a3785a6e37b3b60979831428de 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -25,6 +25,5 @@ TODO
   * Be verbose about the need to review and edit files, adding LICENSE headers into source files, etc
   * Try an alternative command-line format, like "module:option1=value,option2=value with spaces"
   * Git: optionally configure user.signingkey, commit.gpgsign, etc
-  * Dectect if it's locally or system installed (BASEDIR)
   * Print module descriptions along with usage
   * Split into module folders/files, support any programming language
index d3f5d436d9db3058e3765cb6439d438d35289c31..aa98fb9d150405c7de90c9bdf742326161b9277b 100755 (executable)
--- a/templater
+++ b/templater
@@ -5,7 +5,6 @@
 
 # Parameters
 PROGRAM="$0"
-DIRNAME="`dirname $0`"
 BASENAME="`basename $0`"
 PROJECT="$1"
 shift
@@ -13,6 +12,15 @@ MODULES="$*"
 BOOTSTRAP="https://git.fluxo.info/puppet-bootstrap"
 CWD="`pwd`"
 
+# Set shared files location
+if [ -e "`dirname $(readlink -f $0)`/share/$NAME" ]; then
+  # Development or local installation layout
+  SHARE="`dirname $(readlink -f $0)`/share/$NAME"
+else
+  # System installation layout
+  SHARE="`dirname $(readlink -f $0)`/../share/$NAME"
+fi
+
 # Initialize project
 function __templater_init {
   if [ ! -d "$PROJECT" ]; then
@@ -64,9 +72,9 @@ function __templater_copy_or_append {
   fi
 
   if [ ! -e "$file" ]; then
-    cp $DIRNAME/share/$implementation/$file .
-  elif ! grep -q -f $DIRNAME/share/$implmenentation/$file $file; then
-    cat $DIRNAME/share/$implementation/$file >> $file
+    cp $SHARE/$implementation/$file .
+  elif ! grep -q -f $SHARE/$implmenentation/$file $file; then
+    cat $SHARE/$implementation/$file >> $file
   fi
 }
 
@@ -218,28 +226,28 @@ function templater_ikiwiki {
     __templater_copy_or_append ikiwiki .gitignore
 
     #if [ ! -e "index.md" ]; then
-    #  cp $DIRNAME/share/ikiwiki/index.md .
+    #  cp $SHARE/ikiwiki/index.md .
     #fi
-    cp $DIRNAME/share/ikiwiki/index.md .
+    cp $SHARE/ikiwiki/index.md .
 
     if [ ! -e "ikiwiki.yaml" ]; then
-      cp $DIRNAME/share/ikiwiki/ikiwiki.yaml.
+      cp $SHARE/ikiwiki/ikiwiki.yaml.
     fi
 
     if [ ! -e "Makefile" ]; then
-      cp $DIRNAME/share/ikiwiki/Makefile .
+      cp $SHARE/ikiwiki/Makefile .
     #elif ! grep -q ^wiki: Makefile; then
-    #  grep -v '^#' $DIRNAME/share/ikiwiki/Makefile >> Makefile
+    #  grep -v '^#' $SHARE/ikiwiki/Makefile >> Makefile
     else
-      cp $DIRNAME/share/ikiwiki/Makefile Makefile.ikiwiki
+      cp $SHARE/ikiwiki/Makefile Makefile.ikiwiki
     fi
 
     if [ ! -d "templates" ]; then
-      cp -r $DIRNAME/share/ikiwiki/templates .
+      cp -r $SHARE/ikiwiki/templates .
     fi
 
     if [ ! -d "bootstrap" ]; then
-      cp -r $DIRNAME/share/ikiwiki/bootstrap .
+      cp -r $SHARE/ikiwiki/bootstrap .
     fi
 
     #if [ -d ".git" ]; then
@@ -259,18 +267,18 @@ function templater_sphinx {
     #__templater_checkout_develop
     __templater_copy_or_append sphinx .gitignore
 
-    cp $DIRNAME/share/sphinx/conf.py .
+    cp $SHARE/sphinx/conf.py .
 
     if [ ! -e "Makefile" ]; then
-      cp $DIRNAME/share/sphinx/Makefile .
+      cp $SHARE/sphinx/Makefile .
     #elif ! grep -q sphinx Makefile; then
-    #  grep -v '^#' $DIRNAME/share/sphinx/Makefile >> Makefile
+    #  grep -v '^#' $SHARE/sphinx/Makefile >> Makefile
     else
-      cp $DIRNAME/share/ikiwiki/Makefile Makefile.sphinx
+      cp $SHARE/ikiwiki/Makefile Makefile.sphinx
     fi
 
     if [ ! -d "_static" ]; then
-      cp -r $DIRNAME/share/sphinx/_static .
+      cp -r $SHARE/sphinx/_static .
     fi
 
     if [ ! -d "_themes" ]; then
@@ -290,18 +298,18 @@ function templater_pelican {
     #__templater_checkout_develop
     __templater_copy_or_append pelican .gitignore
 
-    cp $DIRNAME/share/sphinx/pelicanconf.py .
+    cp $SHARE/sphinx/pelicanconf.py .
 
     if [ ! -e "Makefile" ]; then
-      cp $DIRNAME/share/pelican/Makefile .
+      cp $SHARE/pelican/Makefile .
     #elif ! grep -q pelican Makefile; then
-    #  grep -v '^#' $DIRNAME/share/pelican/Makefile >> Makefile
+    #  grep -v '^#' $SHARE/pelican/Makefile >> Makefile
     else
-      cp $DIRNAME/share/ikiwiki/Makefile Makefile.pelican
+      cp $SHARE/ikiwiki/Makefile Makefile.pelican
     fi
 
     if [ ! -d "content" ]; then
-      cp -r $DIRNAME/share/pelican/content .
+      cp -r $SHARE/pelican/content .
     fi
   else
     __templater_echo "Pelican already set"
@@ -344,15 +352,15 @@ function templater_drupal7 {
     __templater_echo "Setting up Drupal 7..."
 
     #if [ ! -e "Makefile" ]; then
-    #  cp $DIRNAME/share/drupal7/Makefile .
+    #  cp $SHARE/drupal7/Makefile .
     ##elif ! grep -q ^drupal: Makefile; then
-    ##  grep -v '^#' $DIRNAME/share/drupal7/Makefile >> Makefile
+    ##  grep -v '^#' $SHARE/drupal7/Makefile >> Makefile
     #else
-    #  cp $DIRNAME/share/drupal7/Makefile Makefile.drupal7
+    #  cp $SHARE/drupal7/Makefile Makefile.drupal7
     #fi
 
     if [ ! -e "drupal.make.yml" ]; then
-      cp $DIRNAME/share/drupal7/drupal.make.yml .
+      cp $SHARE/drupal7/drupal.make.yml .
     fi
 
     mkdir -p files themes modules libraries
@@ -374,29 +382,29 @@ function templater_drupal8 {
     fi
 
     if [ ! -e "settings.dev.php" ]; then
-      cp $DIRNAME/share/drupal8/default.settings.php settings.dev.php
-      #cp $DIRNAME/share/drupal8/default.settings.php .
+      cp $SHARE/drupal8/default.settings.php settings.dev.php
+      #cp $SHARE/drupal8/default.settings.php .
     fi
 
     ln -sf settings.dev.php settings.php
 
     if [ ! -e "services.yml" ]; then
-      cp $DIRNAME/share/drupal8/default.services.yml services.dev.yml
-      #cp $DIRNAME/share/drupal8/default.services.yml .
+      cp $SHARE/drupal8/default.services.yml services.dev.yml
+      #cp $SHARE/drupal8/default.services.yml .
     fi
 
     ln -sf services.dev.yml services.yml
 
     if [ ! -e "Makefile" ]; then
-      cp $DIRNAME/share/drupal8/Makefile .
+      cp $SHARE/drupal8/Makefile .
     #elif ! grep -q ^drupal: Makefile; then
-    #  grep -v '^#' $DIRNAME/share/drupal8/Makefile >> Makefile
+    #  grep -v '^#' $SHARE/drupal8/Makefile >> Makefile
     else
-      cp $DIRNAME/share/drupal8/Makefile Makefile.drupal8
+      cp $SHARE/drupal8/Makefile Makefile.drupal8
     fi
 
     if [ ! -e "drupal.make.yml" ]; then
-      cp $DIRNAME/share/drupal8/drupal.make.yml .
+      cp $SHARE/drupal8/drupal.make.yml .
     fi
 
     mkdir -p files config themes modules libraries
@@ -410,7 +418,7 @@ function templater_drupal8 {
 function templater_gpl {
   if [ ! -e "LICENSE" ]; then
     __templater_echo "Setting up GPLv3 License..."
-    cp $DIRNAME/share/gpl/LICENSE .
+    cp $SHARE/gpl/LICENSE .
   else
     __templater_echo "LICENSE already set"
   fi
@@ -420,7 +428,7 @@ function templater_gpl {
 function templater_agpl {
   if [ ! -e "LICENSE" ]; then
     __templater_echo "Setting up Affero GPLv3 License..."
-    cp $DIRNAME/share/agpl/LICENSE .
+    cp $SHARE/agpl/LICENSE .
   else
     __templater_echo "LICENSE already set"
   fi
@@ -430,7 +438,7 @@ function templater_agpl {
 function templater_mit {
   if [ ! -e "LICENSE" ]; then
     __templater_echo "Setting up MIT License..."
-    cp $DIRNAME/share/mit/LICENSE .
+    cp $SHARE/mit/LICENSE .
   else
     __templater_echo "LICENSE already set"
   fi
@@ -440,7 +448,7 @@ function templater_mit {
 function templater_apache {
   if [ ! -e "LICENSE" ]; then
     __templater_echo "Setting up Apache License..."
-    cp $DIRNAME/share/apache/LICENSE .
+    cp $SHARE/apache/LICENSE .
   else
     __templater_echo "LICENSE already set"
   fi
@@ -450,7 +458,7 @@ function templater_apache {
 function templater_bsd {
   if [ ! -e "LICENSE" ]; then
     __templater_echo "Setting up BSD 3-clause (New BSD) License..."
-    cp $DIRNAME/share/bsd/LICENSE .
+    cp $SHARE/bsd/LICENSE .
   else
     __templater_echo "LICENSE already set"
   fi
@@ -460,7 +468,7 @@ function templater_bsd {
 function templater_mpl {
   if [ ! -e "LICENSE" ]; then
     __templater_echo "Setting up Mozilla Public License..."
-    cp $DIRNAME/share/mpl/LICENSE .
+    cp $SHARE/mpl/LICENSE .
   else
     __templater_echo "LICENSE already set"
   fi
@@ -470,7 +478,7 @@ function templater_mpl {
 function templater_wtfpl {
   if [ ! -e "LICENSE" ]; then
     __templater_echo "Setting up Do What the Fuck You Want Public License..."
-    cp $DIRNAME/share/wtfpl/LICENSE .
+    cp $SHARE/wtfpl/LICENSE .
   else
     __templater_echo "LICENSE already set"
   fi
@@ -480,7 +488,7 @@ function templater_wtfpl {
 function templater_conduct {
   if [ ! -e "CODE_OF_CONDUCT.md" ]; then
     __templater_echo "Setting up Code of Conduct..."
-    cp $DIRNAME/share/conduct/CODE_OF_CONDUCT.md .
+    cp $SHARE/conduct/CODE_OF_CONDUCT.md .
   else
     __templater_echo "Code of Conduct already set"
   fi