Add install routine (of sorts)
authorChip Black <bytex64@bytex64.net>
Sat, 29 Mar 2014 09:18:34 +0000 (04:18 -0500)
committerChip Black <bytex64@bytex64.net>
Sat, 29 Mar 2014 09:18:34 +0000 (04:18 -0500)
Makefile
scripts/write-environment-configs.pl [new file with mode: 0644]

index 94a17d8..1346294 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ clean:
        @-make -C builddeps/scrypt-1.1.6/lib/crypto clean
        @-make -C lib/perl/Blerg-Database clean
 
-.phony: perl-lib
+.PHONY: perl-lib
 perl-lib:
        cd lib/perl/Blerg-Database && perl Makefile.PL
        make -C lib/perl/Blerg-Database
@@ -70,3 +70,44 @@ builddeps/scrypt-1.1.6/config.h:
 builddeps/scrypt.a: builddeps/scrypt-1.1.6/config.h
        make -C builddeps/scrypt-1.1.6/lib/crypto CFLAGS="$(CFLAGS)"
        cp builddeps/scrypt-1.1.6/lib/crypto/scrypt.a builddeps/
+
+.PHONY: install
+install:
+       @echo "Please use 'make install-environment' to install BlĂ«rg to an environment"
+
+.PHONY: install-environment
+install-environment: all
+       @if [ -z "$(ENV_DIR)" ]; then \
+               echo "Specify the install directory in the ENV_DIR variable"; \
+               exit 1; \
+       fi
+       install --mode 755 -d \
+               $(ENV_DIR)/bin \
+               $(ENV_DIR)/lib/cgi-bin \
+               $(ENV_DIR)/etc \
+               $(ENV_DIR)/data/data \
+               $(ENV_DIR)/data/hash_tags \
+               $(ENV_DIR)/data/ref_tags \
+               $(ENV_DIR)/www/build \
+               $(ENV_DIR)/www/css \
+               $(ENV_DIR)/www/doc \
+               $(ENV_DIR)/www/images
+       install --mode 755 blerg.cgi rss.cgi $(ENV_DIR)/lib/cgi-bin/
+       install --mode 755 blergtool blerglatest $(ENV_DIR)/bin/
+       install --mode 644 www/favicon.gif www/favicon.ico www/index.html \
+               www/welcome.html \
+               $(ENV_DIR)/www/
+       install --mode 644 www/build/enyo-blerg.js www/build/enyo-blerg.css \
+               $(ENV_DIR)/www/build/
+       install --mode 644 www/css/blerg.css www/css/doc.css \
+               $(ENV_DIR)/www/css/
+       install --mode 644 www/doc/changelog.html www/doc/index.html \
+               www/doc/post_help.html www/doc/privacy_data.html \
+               $(ENV_DIR)/www/doc/
+       install --mode 644 www/images/blerglogo.png www/images/corner.svg \
+               www/images/play.png www/images/rss.png \
+               $(ENV_DIR)/www/images/
+       www/jssrc/lib/onyx/deploy.sh $(ENV_DIR)/www/jssrc/lib/onyx
+       cd lib/perl/Blerg-Database && perl Makefile.PL INSTALL_BASE="$(ENV_DIR)"
+       make -C lib/perl/Blerg-Database install
+       perl scripts/write-environment-configs.pl $(ENV_DIR)
diff --git a/scripts/write-environment-configs.pl b/scripts/write-environment-configs.pl
new file mode 100644 (file)
index 0000000..1be7645
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+use Cwd qw/abs_path/;
+use strict;
+
+my $ENV_DIR = shift;
+if (!defined $ENV_DIR) {
+    die "Please specify an environment directory to write configs into\n";
+}
+$ENV_DIR = abs_path($ENV_DIR);
+
+# Shell
+open C, '>', "$ENV_DIR/etc/env.sh";
+print C <<EOD;
+if [ -z "\$PATH" ]; then
+    PATH="$ENV_DIR/bin"
+else
+    PATH="\$PATH:$ENV_DIR/bin"
+fi
+export PATH
+
+if [ -z "\$PERL5LIB" ]; then
+    PERL5LIB="$ENV_DIR/lib/perl5"
+else
+    PERL5LIB="\$PERL5LIB:$ENV_DIR/lib/perl5"
+fi
+export PERL5LIB
+
+BLERG_PATH="$ENV_DIR/data"
+export BLERG_PATH
+EOD
+close C;
+
+# nginx FastCGI params
+open C, '>', "$ENV_DIR/etc/nginx-fastcgi-vars.conf";
+print C <<EOD;
+fastcgi_param BLERG_PATH "$ENV_DIR/data";
+fastcgi_param PERL5LIB "$ENV_DIR/lib/perl5";
+EOD
+close C;