From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

Upgrade cli, lua and httpserver-api modules to use OpenSSL 1.1 and Lua 5.3

As the issue #1022 explains, building the default OSv image that
implicitly adds cli module that in turn implicitly pulls httpserver-api
and cli modules, requires some bizarre workarounds on modern Linux distribution. This is caused by the fact that the lua module is based on Lua 5.2 and older version of LuaSec (OpenSSL library for Lua) which requires old version of OpenSSL 1.0.

This patch updates following modules:
1) cli:
- makes necessary changes to work with Lua 5.3
- drops explicit dependency on the modules ncurses and libedit in lieu of
  new terminfo and the script manifest_from_host.sh that pulls all necessary
  dependencies from host
- creates common cli executable that can be used on both host and OSv side

2) httpserver-api
- drops explicit dependency on the module libyaml in lieu of using
  manifest_from_host.sh that pulls all necessary dependencies from host

3) lua
- revamps this module completely by upgrading to Lua 5.3
- removes custom-made makefiles to build Lua from the source
- extensively employs manifest_from_host.sh to pull Lua libraries
  from host (see changes to setup.py) and minimize building from source
- updates Lua modules (like LuaSec) to the newest versions

4) openssl
- instead of using hardcoded usr.manifest that pulls openssl 1.0 libraries from external, new Makefile employs manifest_from_host.sh to find relevant main OpenSSL 1.1 library
 and its required dependencies from host

Finally it adds new terminfo module and changes setup.py to uninstall
compat-openssl10-devel if present and install openssl-devel and lua 5.3 packages.

This patch has been tested with following Linux distribution using Docker:
- Ubuntu 18.10 (OpenSSL 1.0 -> OpenSSL 1.1 upgrade)
- Ubuntu 19.04
- Fedora 27 (OpenSSL 1.0 -> OpenSSL 1.1 upgrade)
- Ubuntu 29

Fixes #1022

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
Message-Id: <20190813033250.1933-1-jwkozac...@gmail.com>

---
diff --git a/modules/cli/.gitignore b/modules/cli/.gitignore
--- a/modules/cli/.gitignore
+++ b/modules/cli/.gitignore
@@ -1,2 +1,2 @@
 cli
-cli.so
+usr.manifest
diff --git a/modules/cli/Makefile b/modules/cli/Makefile
--- a/modules/cli/Makefile
+++ b/modules/cli/Makefile
@@ -1,34 +1,27 @@
+LUA_LIB = $(shell pkg-config --libs lua53 2>/dev/null || pkg-config --libs lua || echo 'ERROR: Could not find lua, please run ./scripts/setup.py') +LUA_INCLUDES = $(shell pkg-config --cflags lua53 2>/dev/null || pkg-config --cflags lua || echo 'ERROR: Could not find lua, please run ./scripts/setup.py')
+
 CC=gcc
 CFLAGS=-O2 -g -Wall -std=gnu99
-INCLUDES=-I../lua/src \
-       -I$(lastword $(wildcard ../ncurses/build/*/include)) \
-       -I$(lastword $(wildcard ../libedit/build/*/src))
-LFLAGS=-L../lua/src \
-       -L$(lastword $(wildcard ../ncurses/build/*/lib)) \
-       -L$(lastword $(wildcard ../libedit/build/*/src/.libs))
-LIBS=-ledit -ltinfo -llua
+LIBS=-ledit -ltinfo $(LUA_LIB)
 SRCS=cli.c
-MAIN=cli.so
+MAIN=cli
+
+INCLUDES = $(LUA_INCLUDES)

-# For compiling executable running locally
-LOC_INCLUDES=-I../lua/src
-LOC_LFLAGS=-L../lua/src
-LOC_LDFLAGS=-Wl,-rpath,$(abspath ../lua/src)
-LOC_MAIN=cli
+SRC = $(shell readlink -f ../..)

 module: $(MAIN)
+       $(SRC)/scripts/manifest_from_host.sh $(MAIN) > usr.manifest

 $(MAIN): $(SRCS)
- $(CC) -DOSV_CLI $(CFLAGS) $(INCLUDES) -fPIC -shared -o $@ $(SRCS) $(LFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) $(INCLUDES) $^ -fPIC -pie -o $@ $(LIBS)

-$(LOC_MAIN): $(SRCS)
- $(CC) $(CFLAGS) $(LOC_INCLUDES) $^ -o $@ $(LOC_LDFLAGS) $(LOC_LFLAGS) $(LIBS)
+rpm: $(MAIN)
+       make -C rpmbuild

 clean:
-       rm -f $(MAIN) $(LOC_MAIN)
+       rm -f $(MAIN)
        make -f rpmbuild/Makefile clean

-rpm: $(LOC_MAIN)
-       make -C rpmbuild
-
 .PHONY: module clean rpm
diff --git a/modules/cli/cli.c b/modules/cli/cli.c
--- a/modules/cli/cli.c
+++ b/modules/cli/cli.c
@@ -5,6 +5,7 @@
 #include <signal.h>
 #include <getopt.h>
 #include <signal.h>
+#include <gnu/libc-version.h>

 #include <lua.h>
 #include <lauxlib.h>
@@ -16,17 +17,15 @@
 #include <sys/poll.h>
 #include <termios.h>

-#ifdef OSV_CLI
-#define CLI_LUA "/cli/cli.lua"
-#define CLI_LUA_PATH "/usr/share/lua/5.2/?.lua;/cli/lib/?.lua;/cli/lua/share/?.lua"
-#define CLI_LUA_CPATH "/usr/lib/lua/5.2/?.so;/cli/lua/lib/?.so"
-#define CLI_COMMANDS_PATH "/cli/commands"
-#else
-#define CLI_LUA "cli.lua"
-#define CLI_LUA_PATH "lib/?.lua;../lua/out/share/lua/5.2/?.lua;./lib/share/lua/5.2/?.lua"
-#define CLI_LUA_CPATH "../lua/out/lib/lua/5.2/?.so;./lib/lib/lua/5.2/?.so"
-#define CLI_COMMANDS_PATH "./commands"
-#endif
+#define OSV_CLI_LUA "/cli-app/cli.lua"
+#define OSV_CLI_LUA_PATH "/usr/share/lua/5.3/?.lua;/usr/share/lua/5.3/?/init.lua;/cli-app/lib/?.lua;/cli-app/lua/share/?.lua"
+#define OSV_CLI_LUA_CPATH "/usr/lib/lua/5.3/?.so;/cli-app/lua/lib/?.so"
+#define OSV_CLI_COMMANDS_PATH "/cli-app/commands"
+
+#define HOST_CLI_LUA "cli.lua"
+#define HOST_CLI_LUA_PATH "lib/?.lua;./lib/share/lua/5.3/?.lua;../lua/install/lua_modules/share/lua/5.3/?.lua;../lua/install/lua_modules/share/lua/5.3/?/init.lua" +#define HOST_CLI_LUA_CPATH "./lib/lib/lua/5.3/?.so;../lua/install/lua_modules/lib/lua/5.3/?.so"
+#define HOST_CLI_COMMANDS_PATH "./commands"

 #define PROMPT_MAXLEN 128
 static char sprompt[PROMPT_MAXLEN];
@@ -66,22 +65,26 @@ static struct {
 /* Misc */
 void print_usage();

+static int is_osv() {
+  return strcmp("OSv", gnu_get_libc_release()) == 0;
+}
+
 int main (int argc, char* argv[]) {
-#ifdef OSV_CLI
-  putenv("TERM=vt100-qemu");
+  if (is_osv()) {
+    putenv("TERM=vt100-qemu");

-  cli_console_size_dirty();
-#else
-  struct winsize sz;
-  ioctl(0, TIOCGWINSZ, &sz);
+    cli_console_size_dirty();
+  } else {
+    struct winsize sz;
+    ioctl(0, TIOCGWINSZ, &sz);

-  if (sz.ws_col > 0 && sz.ws_row > 0) {
-    con_width = sz.ws_col;
-    con_height = sz.ws_row;
+    if (sz.ws_col > 0 && sz.ws_row > 0) {
+      con_width = sz.ws_col;
+      con_height = sz.ws_row;

-    signal(SIGWINCH, cli_sigwinch_handler);
+      signal(SIGWINCH, cli_sigwinch_handler);
+    }
   }
-#endif

   int i;

@@ -137,6 +140,9 @@ int main (int argc, char* argv[]) {

   /* Lua state */
   L = cli_luaL_newstate();
+  if (L == NULL) {
+    exit(2);
+  }

   if (test_command != NULL) {
     if (L == NULL) {
@@ -292,10 +298,15 @@ lua_State *cli_luaL_newstate() {
   lua_State *L = luaL_newstate();
   luaL_openlibs(L);

-  cli_lua_settable(L, "package", "path", CLI_LUA_PATH);
-  cli_lua_settable(L, "package", "cpath", CLI_LUA_CPATH);
+  if (is_osv()) {
+    cli_lua_settable(L, "package", "path", OSV_CLI_LUA_PATH);
+    cli_lua_settable(L, "package", "cpath", OSV_CLI_LUA_CPATH);
+  } else {
+    cli_lua_settable(L, "package", "path", HOST_CLI_LUA_PATH);
+    cli_lua_settable(L, "package", "cpath", HOST_CLI_LUA_CPATH);
+  }

-  int error = luaL_loadfile(L, CLI_LUA) || lua_pcall(L, 0, 0, 0);
+ int error = luaL_loadfile(L, is_osv() ? OSV_CLI_LUA : HOST_CLI_LUA) || lua_pcall(L, 0, 0, 0);
   if (error) {
     fprintf(stderr, "Failed to load shell: %s\n", lua_tostring(L, -1));
     lua_pop(L, 1);
@@ -304,7 +315,7 @@ lua_State *cli_luaL_newstate() {
     return NULL;
   }

-  cli_lua_settable(L, "context", "commands_path", CLI_COMMANDS_PATH);
+ cli_lua_settable(L, "context", "commands_path", is_osv() ? OSV_CLI_COMMANDS_PATH : HOST_CLI_COMMANDS_PATH);
   for (int i=0; i<CTXC; i++) {
     if (ctxv[i]) {
       cli_lua_settable(L, "context", ctx[i].name, ctxv[i]);
@@ -443,6 +454,6 @@ void print_usage(char* program) {
 "-T, --test=[COMMAND]  run tests for a specifiec command\n"
 "-h, --help            print this help and exit\n\n"
 "For more help on the CLI, see "
-"https://github.com/cloudius-systems/osv/wiki/Command-line-interface\n";,
+"https://github.com/cloudius-systems/osv/wiki/Command-Line-Interface-(CLI)\n",
   program);
 }
diff --git a/modules/cli/lib/osv_api.lua b/modules/cli/lib/osv_api.lua
--- a/modules/cli/lib/osv_api.lua
+++ b/modules/cli/lib/osv_api.lua
@@ -91,12 +91,12 @@ local function create_ssl_socket()

   local params = {
     mode = "client",
-    protocol = "tlsv1",
+    protocol = "any",
     key = context.ssl_key,
     certificate = context.ssl_cert,
     cafile = context.ssl_cacert,
     verify = context.ssl_verify,
-    options = "all"
+    options = {"all", "no_sslv3"}
   }

   local st = getmetatable(conn.sock).__index.settimeout
diff --git a/modules/cli/module.py b/modules/cli/module.py
--- a/modules/cli/module.py
+++ b/modules/cli/module.py
@@ -3,16 +3,14 @@
 from osv.modules import api

 require('lua')
-require('ncurses')
-require('libedit')
+require('terminfo')
 require_running('httpserver')

 usr_files = FileMap()
-usr_files.add('${OSV_BASE}/modules/cli').to('/cli') \
-       .include('cli.so') \
+usr_files.add('${OSV_BASE}/modules/cli').to('/cli-app') \
        .include('cli.lua') \
        .include('lib/**') \
        .include('commands/**')

-full = api.run('/cli/cli.so')
+full = api.run('/cli')
 default = full
diff --git a/modules/cli/rpmbuild/Makefile b/modules/cli/rpmbuild/Makefile
--- a/modules/cli/rpmbuild/Makefile
+++ b/modules/cli/rpmbuild/Makefile
@@ -5,7 +5,7 @@ VERSION=1.0

 MAIN=rpm
 CLI_DIR=osv-cli-$(VERSION)/usr/lib64/osv-cli
-LOC_MAIN=cli
+LUA_LIB_PATH = $(shell ldconfig -p | grep -Po "/.*liblua*.5\.3.so" | head -1)

 module: clean all

@@ -30,9 +30,9 @@ copy-files:
        cp $(CLI_ROOT)/cli.lua $(CLI_DIR)
        cp $(CLI_ROOT)/lib/*.lua $(CLI_DIR)/lib
        cp -r $(CLI_ROOT)/commands $(CLI_DIR)
-       cp -r $(LUA_DIR)/out/share $(CLI_DIR)/lib
-       cp -r $(LUA_DIR)/out/lib $(CLI_DIR)/lib
-       cp $(LUA_DIR)/src/liblua.so $(CLI_DIR)/lib
+       cp -r $(LUA_DIR)/install/lua_modules/share $(CLI_DIR)/lib
+       cp -r $(LUA_DIR)/install/lua_modules/lib $(CLI_DIR)/lib
+       cp $(LUA_LIB_PATH) $(CLI_DIR)/lib

 clean:
        rm -rf BUILD
diff --git a/modules/httpserver-api/Makefile b/modules/httpserver-api/Makefile
--- a/modules/httpserver-api/Makefile
+++ b/modules/httpserver-api/Makefile
@@ -46,6 +46,7 @@ module: all

all: lib$(TARGET).so api_api api_app api_env api_file api_fs api_hardware api_network api_os api_trace $(call quiet, cat _usr_*.manifest | sort | uniq > usr.manifest, CREATE_MANIFEST) + $(call very-quiet, $(SRC)/scripts/manifest_from_host.sh lib$(TARGET).so
usr.manifest)

 add_api_to_manifest = \
echo "/usr/mgmt/plugins/libhttpserver-$(1).so: `pwd`/libhttpserver-$(1).so" > _usr_$(1).manifest diff --git a/modules/httpserver-api/module.py b/modules/httpserver-api/module.py
--- a/modules/httpserver-api/module.py
+++ b/modules/httpserver-api/module.py
@@ -13,7 +13,6 @@

 api.require('openssl')
 api.require('libtools')
-api.require('libyaml')

# only require next 3 modules if java (jre) is included in the list of modules
 api.require_if_other_module_present('josvsym','java')
diff --git a/modules/lua/.gitignore b/modules/lua/.gitignore
--- a/modules/lua/.gitignore
+++ b/modules/lua/.gitignore
@@ -1,5 +1,3 @@
-build
-download
-out
-src/*
-!src/Makefile
+install
+upstream
+usr.manifest
diff --git a/modules/lua/Makefile b/modules/lua/Makefile
--- a/modules/lua/Makefile
+++ b/modules/lua/Makefile
@@ -1,138 +1,65 @@
-# Some directories
-OUT=out
-BUILD=build
-DOWNLOAD=download
-
-# Official version
-LUA_V=5.2
-
-# Archive details
-LUA_VERSION=5.2.3
-LUA_FOLDER=lua-$(LUA_VERSION)
-LUA_DOWNLOAD=http://www.lua.org/ftp/$(LUA_FOLDER).tar.gz
-LUA_ARCHIVE=download/$(LUA_FOLDER).tar.gz
-
-# Lua sources for dependencies
-LUA_SRCS=lapi.c lapi.h lauxlib.c lauxlib.h lbaselib.c lbitlib.c lcode.c \
- lcode.h lcorolib.c lctype.c lctype.h ldblib.c ldebug.c ldebug.h ldo.c ldo.h \
-  ldump.c lfunc.c lfunc.h lgc.c lgc.h linit.c liolib.c llex.c llex.h \
- llimits.h lmathlib.c lmem.c lmem.h loadlib.c lobject.c lobject.h lopcodes.c \
-  lopcodes.h loslib.c lparser.c lparser.h lstate.c lstate.h lstring.c \
- lstring.h lstrlib.c ltable.c ltable.h ltablib.c ltm.c ltm.h lua.c luac.c \
-  luaconf.h lua.h lualib.h lundump.c lundump.h lvm.c lvm.h lzio.c lzio.h
-
-SRCS=$(addprefix src/, $(LUA_SRCS))
-
-# Out sub-directories
-BDIR=$(OUT)/bin
-LDIR=$(OUT)/lib/lua/$(LUA_V)
-CDIR=$(OUT)/share/lua/$(LUA_V)
-
-# Lua itself
-MAIN=src/liblua.so
-
-# Local executable used for LuaRocks
-LUA_BIN=$(BDIR)/lua
-LUA_ROCKS_BIN=$(BDIR)/luarocks
+SRC = $(shell readlink -f ../..)
+LUA_ROCKS=upstream/luarocks-3.1.1-linux-x86_64/luarocks
+MODULES_DIR=install/lua_modules
+LDIR=install/lua_modules/lib/lua/5.3
+CDIR=install/lua_modules/share/lua/5.3

 # List of Lua modules, each module has its own target
 LUA_MODULES=LuaSocket LuaJSON Lua_stdlib LuaFileSystem LuaPath LuaSec

-module: $(MAIN) $(LUA_MODULES)
-
-$(MAIN): $(SRCS)
-       cd src && $(MAKE)
-
-$(LUA_BIN): $(MAIN) | $(BDIR)
-       cp src/lua $(LUA_BIN)
-
-$(LUA_ARCHIVE): | $(DOWNLOAD)
-       cd $(DOWNLOAD) && \
-        curl --remote-name --remote-time $(LUA_DOWNLOAD)
-
-$(SRCS): $(LUA_ARCHIVE)
-       tar -Oxzf $< $(LUA_FOLDER)/$@ > $@
-
-$(DOWNLOAD) $(BUILD) $(LDIR) $(CDIR) $(BDIR):
-       @mkdir -p $@
-
-# == LuaRocks ==
-LuaRocks_V=2.1.2
-LuaRocks_F=luarocks-$(LuaRocks_V)
-LuaRocks_A=$(LuaRocks_F).tar.gz
-LuaRocks_D=http://luarocks.org/releases/$(LuaRocks_A)
-
-$(LUA_ROCKS_BIN): $(LUA_BIN) $(BUILD)/$(LuaRocks_F)/src/luarocks
-       cd $(BUILD)/$(LuaRocks_F) && \
-               make install
-
-$(BUILD)/$(LuaRocks_F)/src/luarocks: $(BUILD)/$(LuaRocks_F)/Makefile
-       cd $(BUILD)/$(LuaRocks_F) && \
-               make build
-
-$(BUILD)/$(LuaRocks_F)/Makefile: $(BUILD)/$(LuaRocks_F)/configure
-       $(eval PREFIX=$(shell pwd))
-       cd $(BUILD)/$(LuaRocks_F) && \
-               ./configure --prefix=$(PREFIX)/$(OUT) --force-config \
-               --with-lua-include=$(PREFIX)/src --lua-version=$(LUA_V) \
-               --with-lua=$(PREFIX)/$(OUT)
-       touch $@
+LUA_LIBRARY := $(shell ldconfig -p | grep -Po "liblua*.5\.3.so.0" | head -1)
+ifndef LUA_LIBRARY
+       LUA_LIBRARY := $(shell ldconfig -p | grep -Po "liblua*.5\.3.so" | head 
-1)
+endif

-$(BUILD)/$(LuaRocks_F)/configure: $(DOWNLOAD)/$(LuaRocks_A) | $(BUILD)
-       tar --directory $(BUILD) -xzf $<
-       touch $@
+module: $(LUA_MODULES)
+       mkdir -p $(MODULES_DIR)
+       $(SRC)/scripts/manifest_from_host.sh -l $(LUA_LIBRARY) > usr.manifest

-$(DOWNLOAD)/$(LuaRocks_A): | $(DOWNLOAD)
-       curl --remote-time --location $(LuaRocks_D) > $@
+$(LUA_ROCKS):
+       mkdir -p upstream
+ cd upstream && wget -c https://luarocks.github.io/luarocks/releases/luarocks-3.1.1-linux-x86_64.zip
+       cd upstream && unzip luarocks-3.1.1-linux-x86_64.zip

 # == LuaSocket ==
 LuaSocket: $(LDIR)/socket/core.so

-$(LDIR)/socket/core.so: $(LUA_ROCKS_BIN)
-       out/bin/luarocks install luasocket 3.0-rc1
+$(LDIR)/socket/core.so: $(LUA_ROCKS)
+       $(LUA_ROCKS) install --no-doc --tree $(MODULES_DIR) luasocket 3.0rc1-2

 # == LuaJSON ==
 LuaJSON: $(CDIR)/json.lua

-$(CDIR)/json.lua: $(LUA_ROCKS_BIN)
-       out/bin/luarocks install luajson 1.3.3
+$(CDIR)/json.lua: $(LUA_ROCKS)
+       $(LUA_ROCKS) install --no-doc --tree $(MODULES_DIR) luajson 1.3.4-1

 # == Lua_stdlib ==
 Lua_stdlib: $(CDIR)/std.lua

-$(CDIR)/std.lua: $(LUA_ROCKS_BIN)
-       out/bin/luarocks install stdlib 40
+$(CDIR)/std.lua: $(LUA_ROCKS)
+       $(LUA_ROCKS) install --no-doc --tree $(MODULES_DIR) stdlib 41.2.2-1

 # == LuaFileSystem ==
 LuaFileSystem: $(LDIR)/lfs.so

-$(LDIR)/lfs.so: $(LUA_ROCKS_BIN)
-       out/bin/luarocks install LuaFileSystem 1.6.2
+$(LDIR)/lfs.so: $(LUA_ROCKS)
+       $(LUA_ROCKS) install --no-doc --tree $(MODULES_DIR) LuaFileSystem 
1.7.0-2

 # == LuaPath ==
 LuaPath: $(CDIR)/path.lua

-$(CDIR)/path.lua: $(LUA_ROCKS_BIN)
-       out/bin/luarocks install lua-path 0.2.1
+$(CDIR)/path.lua: $(LUA_ROCKS)
+       $(LUA_ROCKS) install --no-doc --tree $(MODULES_DIR) lua-path 0.3.1-1

 # == LuaSec ==
 LuaSec: $(CDIR)/ssl.lua

-$(CDIR)/ssl.lua: $(LUA_ROCKS_BIN)
-       ./check-openssl-version
-
-# Workaround because LuaRocks ignores /lib64
-ifneq ("$(wildcard /usr/lib64/libssl.so*)", "")
-       out/bin/luarocks install LuaSec 0.5 OPENSSL_LIBDIR=/usr/lib64
-else
-       out/bin/luarocks install LuaSec 0.5
-endif
+$(CDIR)/ssl.lua: $(LUA_ROCKS)
+       $(LUA_ROCKS) install --no-doc --tree $(MODULES_DIR) LuaSec 0.8-1

-##
 clean:
-       rm -f $(SRCS)
-       rm -rf $(DOWNLOAD) $(BUILD) $(OUT)
-       cd src && $(MAKE) clean
+       rm -rf install
+       rm -rf upstream

 .PHONY: module clean $(LUA_MODULES)
 .NOTPARALLEL: $(LUA_MODULES)
diff --git a/modules/lua/check-openssl-version b/modules/lua/check-openssl-version
--- a/modules/lua/check-openssl-version
+++ b/modules/lua/check-openssl-version
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-# This is here to help cope with the transition period that the distro
-# use for openssl-1.0 to openssl-1.1
-if [ -f /usr/include/openssl/opensslv.h ]; then
-    has_new_openssl=$(grep "OpenSSL 1.1" /usr/include/openssl/opensslv.h)
-fi
-if [ "$has_new_openssl"x != "x" ]; then
-    echo "OpenSSL 1.1 header detected."
-    echo "On Fedora >= 26 please use the compat headers by doing:"
-    echo ""
-    echo "    dnf install --allowerasing compat-openssl10-devel -y"
-    echo ""
-    exit 1
-fi
-exit 0
diff --git a/modules/lua/module.py b/modules/lua/module.py
--- a/modules/lua/module.py
+++ b/modules/lua/module.py
@@ -1,10 +1,6 @@
 from osv.modules.filemap import FileMap

 usr_files = FileMap()
-usr_files.add('${OSV_BASE}/modules/lua/src/liblua.so').to('/usr/lib/liblua.so')
-
-usr_files.add('${OSV_BASE}/modules/lua/out').to('/usr') \
-       .exclude('bin/*') \
-       .exclude('etc/*') \
+usr_files.add('${OSV_BASE}/modules/lua/install/lua_modules/').to('/usr') \
        .exclude('lib/luarocks/**') \
        .exclude('share/lua/*/luarocks/**')
diff --git a/modules/lua/src/Makefile b/modules/lua/src/Makefile
--- a/modules/lua/src/Makefile
+++ b/modules/lua/src/Makefile
@@ -1,119 +0,0 @@
-# == MODIFIED VERSION OF ORIGINAL LUA MAKEFILE ==
-
-CC= gcc
-CFLAGS=-O2 -Wall -fPIC -DLUA_COMPAT_ALL -DLUA_USE_DLOPEN -DLUA_USE_STRTODHEX \
- -DLUA_USE_AFORMAT -DLUA_USE_LONGLONG -DLUA_USE_POSIX
-LDFLAGS=
-LIBS= -lm -ldl
-
-AR= ar rcu
-RANLIB= ranlib
-RM= rm -f
-
-LUA_A= liblua.a
-CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
-       lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o \
-       ltm.o lundump.o lvm.o lzio.o
-LIB_O= lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
-       lmathlib.o loslib.o lstrlib.o ltablib.o loadlib.o linit.o
-BASE_O= $(CORE_O) $(LIB_O)
-
-LUA_T= lua
-LUA_O= lua.o
-
-LUA_SO= liblua.so
-
-ALL_O= $(BASE_O) $(LUA_O)
-ALL_T= $(LUA_SO) $(LUA_A) $(LUA_T)
-
-all:   $(ALL_T)
-
-o:     $(ALL_O)
-
-$(LUA_A): $(BASE_O)
-       $(AR) $@ $(BASE_O)
-       $(RANLIB) $@
-
-$(LUA_T): $(LUA_O) $(LUA_A)
-       $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
-
-$(LUA_SO): $(ALL_O)
-       $(CC) $(CFLAGS) -shared -o $@ $(LDFLAGS) $? $(LIBS)
-
-clean:
-       $(RM) $(ALL_T) $(ALL_O)
-
-depend:
-       @$(CC) $(CFLAGS) -MM l*.c
-
-echo:
-       @echo "CC= $(CC)"
-       @echo "CFLAGS= $(CFLAGS)"
-       @echo "LDFLAGS= $(SYSLDFLAGS)"
-       @echo "LIBS= $(LIBS)"
-       @echo "RM= $(RM)"
-
-# list targets that do not create files (but not all makes understand .PHONY)
-.PHONY: all o clean depend echo
-
-# DO NOT DELETE
-
-lapi.o: lapi.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h ltm.h \
- lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lstring.h ltable.h lundump.h \
- lvm.h
-lauxlib.o: lauxlib.c lua.h luaconf.h lauxlib.h
-lbaselib.o: lbaselib.c lua.h luaconf.h lauxlib.h lualib.h
-lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h
-lcode.o: lcode.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
- lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lgc.h \
- lstring.h ltable.h lvm.h
-lcorolib.o: lcorolib.c lua.h luaconf.h lauxlib.h lualib.h
-lctype.o: lctype.c lctype.h lua.h luaconf.h llimits.h
-ldblib.o: ldblib.c lua.h luaconf.h lauxlib.h lualib.h
-ldebug.o: ldebug.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \
- ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h ldebug.h ldo.h \
- lfunc.h lstring.h lgc.h ltable.h lvm.h
-ldo.o: ldo.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h ltm.h \
- lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lopcodes.h lparser.h \
- lstring.h ltable.h lundump.h lvm.h
-ldump.o: ldump.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h \
- lzio.h lmem.h lundump.h
-lfunc.o: lfunc.c lua.h luaconf.h lfunc.h lobject.h llimits.h lgc.h \
- lstate.h ltm.h lzio.h lmem.h
-lgc.o: lgc.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
- lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h
-linit.o: linit.c lua.h luaconf.h lualib.h lauxlib.h
-liolib.o: liolib.c lua.h luaconf.h lauxlib.h lualib.h
-llex.o: llex.c lua.h luaconf.h lctype.h llimits.h ldo.h lobject.h \
- lstate.h ltm.h lzio.h lmem.h llex.h lparser.h lstring.h lgc.h ltable.h
-lmathlib.o: lmathlib.c lua.h luaconf.h lauxlib.h lualib.h
-lmem.o: lmem.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
- ltm.h lzio.h lmem.h ldo.h lgc.h
-loadlib.o: loadlib.c lua.h luaconf.h lauxlib.h lualib.h
-lobject.o: lobject.c lua.h luaconf.h lctype.h llimits.h ldebug.h lstate.h \
- lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h lvm.h
-lopcodes.o: lopcodes.c lopcodes.h llimits.h lua.h luaconf.h
-loslib.o: loslib.c lua.h luaconf.h lauxlib.h lualib.h
-lparser.o: lparser.c lua.h luaconf.h lcode.h llex.h lobject.h llimits.h \
- lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h ldo.h lfunc.h \
- lstring.h lgc.h ltable.h
-lstate.o: lstate.c lua.h luaconf.h lapi.h llimits.h lstate.h lobject.h \
- ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h llex.h lstring.h \
- ltable.h
-lstring.o: lstring.c lua.h luaconf.h lmem.h llimits.h lobject.h lstate.h \
- ltm.h lzio.h lstring.h lgc.h
-lstrlib.o: lstrlib.c lua.h luaconf.h lauxlib.h lualib.h
-ltable.o: ltable.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h \
- ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h
-ltablib.o: ltablib.c lua.h luaconf.h lauxlib.h lualib.h
-ltm.o: ltm.c lua.h luaconf.h lobject.h llimits.h lstate.h ltm.h lzio.h \
- lmem.h lstring.h lgc.h ltable.h
-lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h
-luac.o: luac.c lua.h luaconf.h lauxlib.h lobject.h llimits.h lstate.h \
- ltm.h lzio.h lmem.h lundump.h ldebug.h lopcodes.h
-lundump.o: lundump.c lua.h luaconf.h ldebug.h lstate.h lobject.h \
- llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h lundump.h
-lvm.o: lvm.c lua.h luaconf.h ldebug.h lstate.h lobject.h llimits.h ltm.h \
- lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h ltable.h lvm.h
-lzio.o: lzio.c lua.h luaconf.h llimits.h lmem.h lstate.h lobject.h ltm.h \
- lzio.h
diff --git a/modules/openssl/.gitignore b/modules/openssl/.gitignore
--- a/modules/openssl/.gitignore
+++ b/modules/openssl/.gitignore
@@ -0,0 +1 @@
+usr.manifest
diff --git a/modules/openssl/Makefile b/modules/openssl/Makefile
--- a/modules/openssl/Makefile
+++ b/modules/openssl/Makefile
@@ -0,0 +1,22 @@
+#
+# Copyright (C) 2019 Waldemar Kozaczuk, Ltd.
+#
+# This work is open source software, licensed under the terms of the
+# BSD license as described in the LICENSE file in the top-level directory.
+#
+SRC = $(shell readlink -f ../..)
+
+module:
+       $(SRC)/scripts/manifest_from_host.sh -l libssl.so.1.1 > usr.manifest
+       # From krb5-libs
+ $(SRC)/scripts/manifest_from_host.sh -l libgssapi_krb5.so.2 >> usr.manifest
+       # From libselinux
+       $(SRC)/scripts/manifest_from_host.sh -l libselinux.so.1 >> usr.manifest
+       # From xz-libs
+       $(SRC)/scripts/manifest_from_host.sh -l liblzma.so.5 >> usr.manifest
+
+.PHONY: module
+
+clean:
+       rm -rf usr.manifest
+.PHONY: clean
diff --git a/modules/openssl/usr.manifest b/modules/openssl/usr.manifest
--- a/modules/openssl/usr.manifest
+++ b/modules/openssl/usr.manifest
@@ -1,37 +0,0 @@
-#
-# Copyright (C) 2014 Cloudius Systems, Ltd.
-#
-# This work is open source software, licensed under the terms of the
-# BSD license as described in the LICENSE file in the top-level directory.
-#
-
-# From openssl-libs
-/usr/lib/openssl/**: %(miscbase)s/usr/lib64/openssl/**
-#/usr/lib/&/libssl.so.1.0.1k: %(miscbase)s/usr/lib64/&
-/usr/lib/&/libssl.so.10: %(miscbase)s/usr/lib64/&
-#/usr/lib/&/libcrypto.so.1.0.1k: %(miscbase)s/usr/lib64/&
-/usr/lib/&/libcrypto.so.10: %(miscbase)s/usr/lib64/&
-
-# From libcom_err
-/usr/lib/&/libcom_err.so.2: %(miscbase)s/usr/lib64/&
-#/usr/lib/&/libcom_err.so.2.1: %(miscbase)s/usr/lib64/&
-
-# From krb5-libs
-/&/etc/krb5.conf: %(miscbase)s/&
-/usr/lib/&/libgssapi_krb5.so.2: %(miscbase)s/usr/lib64/&
-/usr/lib/&/libk5crypto.so.3: %(miscbase)s/usr/lib64/&
-/usr/lib/&/libkrb5.so.3: %(miscbase)s/usr/lib64/&
-#/usr/lib/&/libkrb5.so.3.3: %(miscbase)s/usr/lib64/&
-/usr/lib/&/libkrb5support.so.0: %(miscbase)s/usr/lib64/&
-
-# From libselinux
-/usr/lib/&/libselinux.so.1: %(miscbase)s/usr/lib64/&
-
-# From keyutils-libs
-/usr/lib/&/libkeyutils.so.1: %(miscbase)s/usr/lib64/&
-
-# From pcre
-/usr/lib/&/libpcre.so.1: %(miscbase)s/usr/lib64/&
-
-# From xz-libs
-/usr/lib/&/liblzma.so.5: %(miscbase)s/usr/lib64/&
diff --git a/modules/terminfo/.gitignore b/modules/terminfo/.gitignore
--- a/modules/terminfo/.gitignore
+++ b/modules/terminfo/.gitignore
@@ -0,0 +1 @@
+out
diff --git a/modules/terminfo/Makefile b/modules/terminfo/Makefile
--- a/modules/terminfo/Makefile
+++ b/modules/terminfo/Makefile
@@ -0,0 +1,16 @@
+OUT=out
+TI_VT100=$(OUT)/terminfo/v/vt100-qemu
+
+module: $(TI_VT100)
+
+$(TI_VT100): $(MAIN)
+       @mkdir -p $(OUT)/terminfo
+ infocmp vt100 | sed 's/cud1=\(^J\|\\n\),/cud1=\\E[B,/; s/ind=\(^J\| \\n\),/ind=\\E[S,/; s/vt100/vt100-qemu/' \
+               > $(OUT)/terminfo.tmp
+       tic -o $(OUT)/terminfo $(OUT)/terminfo.tmp
+       rm -f $(OUT)/terminfo.tmp
+
+clean:
+       rm -rf $(OUT)
+
+.PHONY: module clean
diff --git a/modules/terminfo/module.py b/modules/terminfo/module.py
--- a/modules/terminfo/module.py
+++ b/modules/terminfo/module.py
@@ -0,0 +1,4 @@
+from osv.modules.filemap import FileMap
+
+usr_files = FileMap()
+usr_files.add('${OSV_BASE}/modules/terminfo/out/terminfo').to('/usr/share/terminfo')
diff --git a/scripts/setup.py b/scripts/setup.py
--- a/scripts/setup.py
+++ b/scripts/setup.py
@@ -22,6 +22,7 @@

 class Fedora(object):
     name = 'Fedora'
+ pre_install = '(yum list installed compat-openssl10-devel 2>/dev/null && yum -y remove compat-openssl10-devel) || echo "package compat-openssl10-devel not found -> no need to remove it"'
     install = 'yum -y install --allowerasing'
     packages = [
                 'ant',
@@ -63,35 +64,35 @@ class Fedora(object):
     ec2_post_install = standard_ec2_post_install

     class Fedora_25(object):
- packages = ['java-1.8.0-openjdk', 'python2-requests', 'openssl-devel'] + packages = ['java-1.8.0-openjdk', 'python2-requests', 'openssl-devel', 'lua-5.3.*', 'lua-devel-5.3.*']
         ec2_packages = []
         test_packages = []
         ec2_post_install = None
         version = '25'

     class Fedora_26(object):
- packages = ['java-1.8.0-openjdk', 'python2-requests', 'compat-openssl10-devel'] + packages = ['java-1.8.0-openjdk', 'python2-requests', 'openssl-devel', 'lua-5.3.*', 'lua-devel-5.3.*']
         ec2_packages = []
         test_packages = []
         ec2_post_install = None
         version = '26'

     class Fedora_27(object):
- packages = ['java-1.8.0-openjdk', 'python2-requests', 'compat-openssl10-devel'] + packages = ['java-1.8.0-openjdk', 'python2-requests', 'openssl-devel', 'lua-5.3.*', 'lua-devel-5.3.*']
         ec2_packages = []
         test_packages = []
         ec2_post_install = None
         version = '27'

     class Fedora_28(object):
- packages = ['java-1.8.0-openjdk', 'python2-requests', 'compat-openssl10-devel'] + packages = ['java-1.8.0-openjdk', 'python2-requests', 'openssl-devel', 'lua-5.3.*', 'lua-devel-5.3.*']
         ec2_packages = []
         test_packages = []
         ec2_post_install = None
         version = '28'

     class Fedora_29(object):
- packages = ['java-1.8.0-openjdk', 'python2-requests', 'compat-openssl10-devel'] + packages = ['java-1.8.0-openjdk', 'python2-requests', 'openssl-devel', 'lua-5.3.*', 'lua-devel-5.3.*']
         ec2_packages = []
         test_packages = []
         ec2_post_install = None
@@ -221,6 +222,8 @@ class Ubuntu(object):
                 'tcpdump',
                 'unzip',
                 'wget',
+                'lua5.3',
+                'liblua5.3',
                 'pax-utils',
                 ]

@@ -312,6 +315,8 @@ class LinuxMint_19(object):
     if name.startswith(distro.name):
         for dver in distro.versions:
if dver.version == version or version.startswith(dver.version+'.'):
+                if hasattr(distro, 'pre_install'):
+                    subprocess.check_call(distro.pre_install, shell=True)
                 pkg = distro.packages + dver.packages
                 if cmdargs.ec2:
                     pkg += distro.ec2_packages + dver.ec2_packages

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/000000000000d0d3440590243ec7%40google.com.

Reply via email to