commit:e08a49eb8946cad54f34d0299303b28392831c26
author:Chip Black
committer:Chip Black
date:Sat Mar 29 04:18:34 2014 -0500
parents:48eec2e56ddb2e1d87866ee3dad6645ab6deaed7
Add install routine (of sorts)
diff --git a/Makefile b/Makefile
line changes: +42/-1
index 94a17d8..1346294
--- 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
line changes: +39/-0
index 0000000..1be7645
--- /dev/null
+++ b/scripts/write-environment-configs.pl
@@ -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;