diff options
-rw-r--r-- | Makefile | 74 | ||||
-rw-r--r-- | bin/.gitignore | 4 | ||||
-rw-r--r-- | bin/gitano-auth.in (renamed from bin/gitano-auth) | 4 | ||||
-rw-r--r-- | bin/gitano-post-receive-hook.in (renamed from bin/gitano-post-receive-hook) | 4 | ||||
-rw-r--r-- | bin/gitano-update-hook.in (renamed from bin/gitano-update-hook) | 4 | ||||
-rw-r--r-- | bin/gitano-update-ssh.in (renamed from bin/gitano-update-ssh) | 4 | ||||
-rw-r--r-- | utils/install-lua-bin | 44 |
7 files changed, 134 insertions, 4 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0328947 --- /dev/null +++ b/Makefile @@ -0,0 +1,74 @@ +all: local + +# Configuration (override on the commandline) + +LUA_VER := 5.1 +LUA := /usr/bin/lua$(LUA_VER) +INST_ROOT := /usr/local + +# Internal stuff +LUA_MOD_PATH := $(INST_ROOT)/share/lua/$(LUA_VER) +LUA_MOD_INST_PATH := $(DESTDIR)$(LUA_MOD_PATH) +BIN_PATH := $(INST_ROOT)/bin +BIN_INST_PATH := $(DESTDIR)$(BIN_PATH) + +BINS := gitano-auth gitano-post-receive-hook gitano-update-hook \ + gitano-update-ssh + +MODS := gitano \ + \ + gitano.util \ + gitano.actions gitano.config gitano.lace gitano.log \ + gitano.markdown gitano.repository gitano.supple \ + gitano.command gitano.admincommand gitano.usercommand \ + \ + gitano.git gitano.git.commit gitano.git.ll gitano.git.object \ + gitano.git.repository gitano.git.tag gitano.git.tree + +MOD_DIRS := gitano gitano/git +MOD_FILES := $(patsubst %,%.lua,$(subst .,/,$(MODS))) +SRC_MOD_FILES := $(patsubst %,lib/%,$(MOD_FILES)) + +LOCAL_BINS := $(patsubst %,bin/%,$(BINS)) +BIN_SRCS := $(patsubst %,bin/%.in,$(BINS)) + +GEN_BIN := utils/install-lua-bin +RUN_GEN_BIN := $(LUA) $(GEN_BIN) $(LUA) +define GEN_LOCAL_BIN + +$(RUN_GEN_BIN) $(shell pwd)/lib $1 $2 +chmod 755 $2 + +endef + +define GEN_INSTALL_BIN + +$(RUN_GEN_BIN) $(LUA_MOD_PATH) $1 $2 +chmod 755 $2 + +endef + +define GEN_INSTALL_MOD + +install -m 644 $1 $2 + +endef + +local: $(LOCAL_BINS) + +clean: + @echo "CLEAN: local binaries" + @$(RM) $(LOCAL_BINS) + +bin/%: bin/%.in $(GEN_BIN) + $(call GEN_LOCAL_BIN,$<,$@) + +install: install-bins install-mods + +install-bins: $(BIN_SRCS) $(GEN_BIN) + mkdir -p $(BIN_INST_PATH) + $(foreach BIN,$(BINS),$(call GEN_INSTALL_BIN,bin/$(BIN).in,$(BIN_INST_PATH)/$(BIN))) + +install-mods: $(SRC_MOD_FILES) + mkdir -p $(patsubst %,$(LUA_MOD_INST_PATH)/%,$(MOD_DIRS)) + $(foreach MOD,$(MOD_FILES),$(call GEN_INSTALL_MOD,lib/$(MOD),$(LUA_MOD_INST_PATH)/$(MOD))) diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..344c403 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,4 @@ +gitano-auth +gitano-post-receive-hook +gitano-update-hook +gitano-update-ssh diff --git a/bin/gitano-auth b/bin/gitano-auth.in index f5a95a5..a16c4df 100644 --- a/bin/gitano-auth +++ b/bin/gitano-auth.in @@ -1,4 +1,4 @@ -#!/usr/bin/env lua +-- @@SHEBANG -- -*- Lua -*- -- gitano-auth -- @@ -8,6 +8,8 @@ -- -- +-- @@GITANO_LUA_PATH + local gitano = require "gitano" local luxio = require "luxio" local sio = require "luxio.simple" diff --git a/bin/gitano-post-receive-hook b/bin/gitano-post-receive-hook.in index bd52155..9b5ae37 100644 --- a/bin/gitano-post-receive-hook +++ b/bin/gitano-post-receive-hook.in @@ -1,4 +1,4 @@ -#!/usr/bin/env lua +-- @@SHEBANG -- -*- Lua -*- -- gitano-post-receive-hook -- @@ -8,6 +8,8 @@ -- -- +-- @@GITANO_LUA_PATH + local gitano = require "gitano" local luxio = require "luxio" local sio = require "luxio.simple" diff --git a/bin/gitano-update-hook b/bin/gitano-update-hook.in index 431bd3c..51283b7 100644 --- a/bin/gitano-update-hook +++ b/bin/gitano-update-hook.in @@ -1,4 +1,4 @@ -#!/usr/bin/env lua +-- @@SHEBANG -- -*- Lua -*- -- gitano-update-hook -- @@ -8,6 +8,8 @@ -- -- +-- @@GITANO_LUA_PATH + local gitano = require "gitano" local luxio = require "luxio" local sio = require "luxio.simple" diff --git a/bin/gitano-update-ssh b/bin/gitano-update-ssh.in index ed96bab..aa3f957 100644 --- a/bin/gitano-update-ssh +++ b/bin/gitano-update-ssh.in @@ -1,4 +1,4 @@ -#!/usr/bin/env lua +-- @@SHEBANG -- -*- Lua -*- -- gitano-auth -- @@ -8,6 +8,8 @@ -- -- +-- @@GITANO_LUA_PATH + local gitano = require "gitano" local luxio = require "luxio" local sio = require "luxio.simple" diff --git a/utils/install-lua-bin b/utils/install-lua-bin new file mode 100644 index 0000000..1e5b105 --- /dev/null +++ b/utils/install-lua-bin @@ -0,0 +1,44 @@ +-- Run this explicitly through -*- Lua -*- + +local lua_bin, inst_mod_path, input_name, output_name = ... + +local input_fh = assert(io.open(input_name, "r")) +local output_fh = assert(io.open(output_name, "w")) + +local line = input_fh:read "*l" + +if not inst_mod_path:match("%?") then + inst_mod_path = inst_mod_path .. "/?.lua" + inst_mod_path = inst_mod_path:gsub("/+", "/") +end + +local mod_path_present = false +for path_elem in package.path:gmatch("([^;]+)") do + if path_elem == inst_mod_path then + mod_path_present = true + break + end +end + +while line do + local token = line:match("^%-%- @@(.+)$") + if token then + if token == "SHEBANG" then + output_fh:write(("#!%s\n"):format(lua_bin)) + elseif token == "GITANO_LUA_PATH" then + if not mod_path_present then + output_fh:write(("package.path = ('%%s;%%s'):" .. + "format(%q, package.path)" .. + "\n"):format(inst_mod_path)) + else + output_fh:write("-- Gitano modules installed into " .. + inst_mod_path .. "\n") + end + else + output_fh:write("-- Unknown token: " .. token .. "\n") + end + else + output_fh:write(line .. "\n") + end + line = input_fh:read "*l" +end |