VPATH = .:$(TOPLEVEL)/generic:$(TOPLEVEL)
SCRIPTS =
-GLOBALLUATOOLS = e2-create-project e2-fetch-project e2-install-e2 e2-root
-GLOBALSHTOOLS = e2-locate-project-root e2ssh
+GLOBALLUATOOLS = e2-create-project e2-fetch-project e2-install-e2
+GLOBALSHTOOLS = e2-locate-project-root e2ssh e2-su
GLOBALTOOLS = $(GLOBALLUATOOLS) $(GLOBALSHTOOLS)
-CLEAN_FILES = e2 e2-su e2.conf
+CLEAN_FILES = e2 e2.conf
LUA_LIBS = strict.lua plugin.lua e2lib.lua
LUA_LIBS += e2option.lua hash.lua tools.lua transport.lua cache.lua url.lua
LUA_LIBS += generic_git.lua luafile.lua err.lua lock.lua
.PHONY: all install uninstall clean
-all: e2 $(SCRIPTS) e2-su \
+all: e2 $(SCRIPTS) \
$(GLOBALSHTOOLS:=.sh) e2.conf sha1.so e2-su-2.2 \
luafile_ll.so e2util.so
for i in $(GLOBALSHTOOLS) ; do \
install -m 755 $$i.sh $(DESTDIR)$(BINDIR)/$$i ; \
done
- $(SUDO) install -m 4754 -o root -g $(E2_GROUP) e2-su $(DESTDIR)$(BINDIR)/
install -m 755 e2 $(DESTDIR)$(BINDIR)/
if [ ! -f "$(DESTDIR)$(SYSCONFDIR)/e2.conf" ] ; then \
install -m 644 e2.conf $(DESTDIR)$(SYSCONFDIR)/e2.conf ; \
rm -f $(DESTDIR)$(BINDIR)/e2-su-2.2
rm -f $(DESTDIR)$(LIBDIR)/luafile_ll.so
rm -f $(DESTDIR)$(LIBDIR)/e2util.so
- rm -f $(DESTDIR)$(TOOLDIR)/e2-root
- rm -f $(DESTDIR)$(BINDIR)/e2-su
rm -f $(DESTDIR)$(BINDIR)/e2
doc:
%.lua: %.lua.in
$(TOPLEVEL)/scripts/genscript.sh $< $@
-e2-su: e2-su.c
- $(CC) $(CFLAGS) $(CPPFLAGS) $< -o $@
-
%.sh: %.sh.in
$(TOPLEVEL)/scripts/genscript.sh $< $@
+++ /dev/null
---[[
- e2factory, the emlix embedded build system
-
- Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
- Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, emlix GmbH
- Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH
-
- For more information have a look at http://www.e2factory.org
-
- e2factory is a registered trademark by emlix GmbH.
-
- This file is part of e2factory, the emlix embedded build system.
-
- e2factory is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-]]
-
-env_tool = "@ENV_TOOL@"
-chroot_tool = "@CHROOT_TOOL@"
-tar_tool = "@TAR_TOOL@"
-chown_tool = "@CHOWN_TOOL@"
-rm_tool = "@RM_TOOL@"
-
-compat_2_1 = true -- be compatible with e2-2.1?
-
-function assert_chroot_environment(path)
- local fname = string.format("%s/emlix-chroot", path)
- local f = io.open(fname, "r")
- if not f then
- print("not a chroot environment")
- os.exit(99)
- end
- f:close()
- return true
-end
-
--- e2-root <command> ...
-if arg[1] == "chroot_2_2" then
- -- 2_2_chroot <path> <command>
- local path = arg[2]
- local command = arg[3]
- if (not path) or (not command) or #arg ~= 3 then
- print("wrong arguments")
- os.exit(99)
- end
- assert_chroot_environment(path)
- local cmd = string.format("%s -i %s '%s' %s", env_tool, chroot_tool, path,
- command)
- local rc = os.execute(cmd)
- os.exit(rc/256)
-elseif arg[1] == "extract_tar_2_2" then
- -- extract_tar_2_2 <path> <tartype> <file>
- local path = arg[2]
- local tartype = arg[3]
- local file = arg[4]
- if (not path) or (not tartype) or (not file) or #arg ~= 4 then
- print("wrong arguments")
- os.exit(99)
- end
- assert_chroot_environment(path)
- if tartype == "tar.gz" then
- tarflags = "-z"
- elseif tartype == "tar.bz2" then
- tarflags = "-j"
- elseif tartype == "tar" then
- tarflags = ""
- end
- local cmd = string.format("%s -i %s %s -C '%s' -xf '%s'",
- env_tool, tar_tool, tarflags, path, file)
- local rc = os.execute(cmd)
- os.exit(rc/256)
-elseif arg[1] == "set_permissions_2_2" then
- -- set_permissions_2_2 <path>
- local path = arg[2]
- if (not path) then
- print("wrong arguments")
- os.exit(99)
- end
- assert_chroot_environment(path)
- local cmd = string.format("%s -i %s root:root '%s'", env_tool, chown_tool,
- path)
- local rc = os.execute(cmd)
- os.exit(rc/256)
-elseif arg[1] == "remove_chroot_2_2" then
- -- remove_chroot_2_2 <path>
- local path = arg[2]
- if (not path) then
- print("wrong arguments")
- os.exit(99)
- end
- assert_chroot_environment(path)
- local cmd = string.format("%s -i %s -fr '%s'", env_tool, rm_tool, path)
- local rc = os.execute(cmd)
- os.exit(rc/256)
-end
-
--- e2-root <command> <tmpdir> <project> <result> <...>
-
-if not compat_2_1 then
- print("unknown command")
- os.exit(3)
-end
-
-if #arg < 4 then
- print("too few arguments")
- os.exit(3)
-end
-
-local call = {}
-call.username = os.getenv("USER")
-if not call.username then
- print("can't get USER environment variable")
- os.exit(3)
-end
-call.cmd = arg[1]
-call.tmpdir = arg[2] .. "/e2build"
-call.proj = arg[3]
-call.result = arg[4]
-call.chroot_path = call.tmpdir .. "/" .. call.username .. "/" ..
-call.proj .. "/" .. call.result .. "/chroot"
-
-local rc = 1
-if call.cmd == "setup-chroot" then
- rc = os.execute("mkdir -p " .. call.chroot_path ..
- " && touch \"" .. call.chroot_path .. "/emlix-chroot\"")
- os.exit(rc/256)
-
-elseif call.cmd == "extract-tar" then
- call.file = arg[5]
- local opts = "-xzf"
- if string.match(call.file, ".bz2$") then
- opts = "-xjf"
- elseif string.match(call.file, ".tar$") then
- opts = "-xf"
- end
- rc = os.execute("tar -C \"" .. call.chroot_path ..
- "\" " .. opts .. " \"" .. call.file .. "\"")
- os.exit(rc/256)
-
-elseif call.cmd == "prepare" then
- rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " ..
- "T=\"/tmp/e2\" " ..
- "r=\"" .. call.result .. "\" " ..
- "chroot " .. call.chroot_path .. " " ..
- "/bin/bash -e -x \"/tmp/e2/script/e2-runbuild-unpack-source\"")
- os.exit(rc/256)
-
-elseif call.cmd == "runbuild" then
- rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " ..
- "T=\"/tmp/e2\" " ..
- "r=\"" .. call.result .. "\" " ..
- "chroot " .. call.chroot_path .. " " ..
- "/bin/bash -e -x \"/tmp/e2/script/e2-runbuild-build\"")
- os.exit(rc/256)
-
-elseif call.cmd == "enter" then
- local cmd = arg[5]
- if cmd then
- command = string.format(" -c \"%s\"", cmd)
- else
- command = ""
- end
- rc = os.execute("PATH=/usr/sbin:/sbin:$PATH " ..
- "T=\"/tmp/e2\" " ..
- "r=\"" .. call.result .. "\" " ..
- "chroot " .. call.chroot_path .. " " ..
- "/bin/bash --rcfile \"/tmp/e2/script/e2-runbuildrc\"" ..
- command)
- os.exit(rc/256)
-
-elseif call.cmd == "rm-chroot" then
- rc = os.execute("rm -fr \"" .. call.chroot_path .. "\"")
- os.exit(rc/256)
-
-end
-
-print("unknown command")
-os.exit(3)
-
--- vim:sw=4:sts=4:et:
+++ /dev/null
-/*
- e2factory, the emlix embedded build system
-
- Copyright (C) 2007-2009 Gordon Hecker <gh@emlix.com>, emlix GmbH
- Copyright (C) 2007-2009 Oskar Schirmer <os@emlix.com>, emlix GmbH
- Copyright (C) 2007-2008 Felix Winkelmann, emlix GmbH
-
- For more information have a look at http://www.e2factory.org
-
- e2factory is a registered trademark by emlix GmbH.
-
- This file is part of e2factory, the emlix embedded build system.
-
- e2factory is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <limits.h>
-#include <grp.h>
-
-#ifndef TOOLDIR
-#error TOOLDIR not defined
-#endif
-#ifndef E2_ROOT_TOOL_NAME
-#define E2_ROOT_TOOL_NAME "e2-root"
-#endif
-#ifndef E2_ROOT_TOOL_PATH
-#define E2_ROOT_TOOL_PATH TOOLDIR "/" E2_ROOT_TOOL_NAME
-#endif
-
-char *tool_name = E2_ROOT_TOOL_NAME;
-char *tool_path = E2_ROOT_TOOL_PATH;
-
-int main(int argc, char *argv[])
-{
- int rc;
- int i;
- char *arg [ 1024 ];
-
- if(argc < 2) {
- fprintf(stderr, "this tool is not intended to be executed directly\n");
- exit(1);
- }
-
- int k = 0;
- arg[k++] = tool_name;
- for(i=1; argv[i]; i++) {
- if(argv[i][0] == '-')
- continue;
- arg[k++] = argv[i];
- //fprintf(stderr, "%s\n");
- }
- arg[k] = NULL;
-
- if(getenv("DEBUG")) {
- printf("%s\n", E2_ROOT_TOOL_PATH);
- for(i=0; arg[i]; i++) {
- printf("\"%s\"\n", arg[i]);
- }
- }
-
- rc = setuid(0);
- if(rc != 0) {
- perror("can't setuid(0)");
- exit(1);
- }
-
- rc = setgid(0);
- if(rc != 0) {
- perror("can't setgid(0)");
- exit(1);
- }
-
- rc = setgroups(0, NULL);
- if(rc != 0) {
- perror("can't setgroups()");
- exit(1);
- }
-
- rc = execvp(E2_ROOT_TOOL_PATH, arg);
- perror("can't exec");
- exit(3);
-}