mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-07 09:04:05 +00:00
Allow and default to relative paths for binaries executed
This commit is contained in:
parent
9b2b3ad6e6
commit
564d54be76
@ -86,20 +86,26 @@ add_custom_target( manpage
|
|||||||
DEPENDS doc/manpage/lsyncd.1.txt
|
DEPENDS doc/manpage/lsyncd.1.txt
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# create_symlink( ${CMAKE_SOURCE_DIR}/tests tests)
|
||||||
|
ADD_CUSTOM_TARGET(add_tests ALL
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SOURCE_DIR}/tests tests)
|
||||||
|
|
||||||
add_custom_target( tests
|
add_custom_target( tests
|
||||||
COMMAND echo "Running the tests"
|
COMMAND echo "Running the tests"
|
||||||
COMMAND echo "Note you are expected to:"
|
COMMAND echo "Note you are expected to:"
|
||||||
COMMAND echo " * have lua-posix installed"
|
COMMAND echo " * have lua-posix installed"
|
||||||
COMMAND echo " * have a passwordless ssh access to localhost"
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/setup.lua
|
||||||
COMMAND ${LUA_EXECUTABLE} tests/schedule.lua
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/schedule.lua
|
||||||
COMMAND ${LUA_EXECUTABLE} tests/l4rsyncdata.lua
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/l4rsyncdata.lua
|
||||||
COMMAND ${LUA_EXECUTABLE} tests/filter-rsync.lua
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/filter-rsync.lua
|
||||||
COMMAND ${LUA_EXECUTABLE} tests/exclude-rsync.lua
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/exclude-rsync.lua
|
||||||
COMMAND ${LUA_EXECUTABLE} tests/exclude-rsyncssh.lua
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/exclude-rsyncssh.lua
|
||||||
COMMAND ${LUA_EXECUTABLE} tests/churn-rsync.lua
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/churn-rsync.lua
|
||||||
COMMAND ${LUA_EXECUTABLE} tests/churn-rsyncssh.lua
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/churn-rsyncssh.lua
|
||||||
COMMAND ${LUA_EXECUTABLE} tests/churn-direct.lua
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/churn-direct.lua
|
||||||
|
COMMAND ${LUA_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tests/teardown.lua
|
||||||
COMMAND echo "Finished all successfull!"
|
COMMAND echo "Finished all successfull!"
|
||||||
|
DEPENDS add_tests
|
||||||
)
|
)
|
||||||
|
|
||||||
# compiling and linking it all together
|
# compiling and linking it all together
|
||||||
|
@ -682,7 +682,7 @@ rsync.exitcodes = default.rsyncExitCodes
|
|||||||
rsync.rsync =
|
rsync.rsync =
|
||||||
{
|
{
|
||||||
-- The rsync binary to be called.
|
-- The rsync binary to be called.
|
||||||
binary = '/usr/bin/rsync',
|
binary = 'rsync',
|
||||||
links = true,
|
links = true,
|
||||||
times = true,
|
times = true,
|
||||||
protect_args = true
|
protect_args = true
|
||||||
|
@ -608,7 +608,7 @@ rsyncssh.ssh = {
|
|||||||
--
|
--
|
||||||
-- the binary called
|
-- the binary called
|
||||||
--
|
--
|
||||||
binary = '/usr/bin/ssh',
|
binary = 'ssh',
|
||||||
|
|
||||||
--
|
--
|
||||||
-- if set adds this key to ssh
|
-- if set adds this key to ssh
|
||||||
|
28
flake.nix
28
flake.nix
@ -13,39 +13,43 @@
|
|||||||
gcc
|
gcc
|
||||||
cmake
|
cmake
|
||||||
glib
|
glib
|
||||||
|
rsync
|
||||||
|
openssh
|
||||||
];
|
];
|
||||||
version = builtins.elemAt
|
version = builtins.elemAt
|
||||||
(builtins.match ''.*set\(.LSYNCD_VERSION ([0-9\.]*).*''
|
(builtins.match ''.*set\(.LSYNCD_VERSION ([0-9\.]*).*''
|
||||||
(builtins.substring 0 500
|
(builtins.substring 0 500
|
||||||
(builtins.readFile ./CMakeLists.txt))) 0;
|
(builtins.readFile ./CMakeLists.txt))) 0;
|
||||||
# buildTypes = {
|
buildTypes = {
|
||||||
# lua5_2 = pkgs.lua5_2;
|
lua5_1 = [pkgs.lua5_1 pkgs.lua51Packages.luaposix pkgs.lua51Packages.penlight];
|
||||||
# lua5_3 = pkgs.lua5_3;
|
lua5_2 = [pkgs.lua5_2 pkgs.lua52Packages.luaposix pkgs.lua52Packages.penlight];
|
||||||
# };
|
lua5_3 = [pkgs.lua5_3 pkgs.lua53Packages.luaposix pkgs.lua53Packages.penlight];
|
||||||
|
lua5_4 = [pkgs.lua5_4 pkgs.lua54Packages.luaposix pkgs.lua54Packages.penlight];
|
||||||
|
};
|
||||||
in
|
in
|
||||||
let
|
let
|
||||||
mkLsync = luaPackage: pkgs.stdenv.mkDerivation ({
|
mkLsync = luaPackages: pkgs.stdenv.mkDerivation ({
|
||||||
inherit version;
|
inherit version;
|
||||||
name = "lsyncd";
|
name = "lsyncd";
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
# nativeBuildInputs = [ pkgs.qt5.wrapQtAppsHook ];
|
# nativeBuildInputs = [ pkgs.qt5.wrapQtAppsHook ];
|
||||||
buildInputs = defaultDeps ++ [luaPackage];
|
buildInputs = defaultDeps ++ luaPackages;
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = {
|
packages = {
|
||||||
lsyncd = mkLsync pkgs.lua5_3;
|
lsyncd = mkLsync buildTypes.lua5_3;
|
||||||
lsyncd_lua5_1 = mkLsync pkgs.lua5_1;
|
lsyncd_lua5_1 = mkLsync buildTypes.lua5_1;
|
||||||
lsyncd_lua5_2 = mkLsync pkgs.lua5_2;
|
lsyncd_lua5_2 = mkLsync buildTypes.lua5_2;
|
||||||
lsyncd_lua5_3 = mkLsync pkgs.lua5_3;
|
lsyncd_lua5_3 = mkLsync buildTypes.lua5_3;
|
||||||
lsyncd_lua5_4 = mkLsync pkgs.lua5_4;
|
lsyncd_lua5_4 = mkLsync buildTypes.lua5_4;
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultPackage = self.packages.${system}.lsyncd;
|
defaultPackage = self.packages.${system}.lsyncd;
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
buildInputs = defaultDeps;
|
buildInputs = defaultDeps ++ buildTypes.lua5_3;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
2
lsyncd.c
2
lsyncd.c
@ -1278,7 +1278,7 @@ l_exec( lua_State *L )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
execv( binary, ( char ** ) argv );
|
execvp( binary, ( char ** ) argv );
|
||||||
|
|
||||||
// in a sane world execv does not return!
|
// in a sane world execv does not return!
|
||||||
printlogf(
|
printlogf(
|
||||||
|
9
tests/setup.lua
Normal file
9
tests/setup.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
-- a heavy duty test.
|
||||||
|
-- makes thousends of random changes to the source tree
|
||||||
|
|
||||||
|
require( 'posix' )
|
||||||
|
|
||||||
|
dofile( 'tests/testlib.lua' )
|
||||||
|
cwriteln( ' Start Testsuite ' )
|
||||||
|
|
||||||
|
startSshd()
|
8
tests/teardown.lua
Normal file
8
tests/teardown.lua
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
-- a heavy duty test.
|
||||||
|
-- makes thousends of random changes to the source tree
|
||||||
|
|
||||||
|
require( 'posix' )
|
||||||
|
|
||||||
|
dofile( 'tests/testlib.lua' )
|
||||||
|
|
||||||
|
stopSshd()
|
@ -1,5 +1,8 @@
|
|||||||
-- common testing environment
|
-- common testing environment
|
||||||
posix = require( 'posix' )
|
posix = require( 'posix' )
|
||||||
|
string = require( 'string' )
|
||||||
|
path = require( 'pl.path' )
|
||||||
|
stringx = require( 'pl.stringx' )
|
||||||
|
|
||||||
-- escape codes to colorize output on terminal
|
-- escape codes to colorize output on terminal
|
||||||
local c1='\027[47;34m'
|
local c1='\027[47;34m'
|
||||||
@ -90,13 +93,70 @@ function writefile
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function script_path()
|
||||||
|
-- local str = debug.getinfo(2, "S").source:sub(2)
|
||||||
|
-- return str:match("(.*/)")
|
||||||
|
return path.dirname(path.abspath(debug.getinfo(1).short_src))
|
||||||
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Starts test ssh server
|
||||||
|
--
|
||||||
|
function startSshd()
|
||||||
|
-- local f = io.open(script_path() .. "ssh/sshd.pid", 'r')
|
||||||
|
|
||||||
|
-- if f
|
||||||
|
-- then
|
||||||
|
-- return false
|
||||||
|
-- end
|
||||||
|
|
||||||
|
cwriteln(arg[0])
|
||||||
|
cwriteln(script_path() .. "ssh/sshd_config")
|
||||||
|
|
||||||
|
local sshdPath = script_path() .. "/ssh/"
|
||||||
|
local f = io.open( sshdPath .. "sshd_config", 'w')
|
||||||
|
f:write([[
|
||||||
|
Port 2468
|
||||||
|
HostKey ]] .. sshdPath .. [[ssh_host_rsa_key
|
||||||
|
HostKey ]] .. sshdPath .. [[ssh_host_dsa_key
|
||||||
|
AuthorizedKeysFile ]] .. sshdPath .. [[authorized_keys
|
||||||
|
ChallengeResponseAuthentication no
|
||||||
|
UsePAM no
|
||||||
|
#Subsystem sftp /usr/lib/ssh/sftp-server
|
||||||
|
PidFile ]] .. sshdPath .. [[sshd.pid
|
||||||
|
]])
|
||||||
|
f:close( )
|
||||||
|
local which = io.popen("which sshd")
|
||||||
|
local path = which:read("a")
|
||||||
|
local exePath = string.sub(path, 0, #path - 1 )
|
||||||
|
-- local sshPath = which:read("a*")
|
||||||
|
|
||||||
|
local pid = spawn(exePath, "-f", sshdPath .. "sshd_config")
|
||||||
|
cwriteln( 'spawned sshd server: ' .. pid)
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Stop test ssh server
|
||||||
|
--
|
||||||
|
function stopSshd()
|
||||||
|
local f = io.open(script_path() .. "/ssh/sshd.pid", 'r')
|
||||||
|
|
||||||
|
if not f
|
||||||
|
then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
pid = stringx.strip(f:read("*a"))
|
||||||
|
posix.kill(tonumber(pid))
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Spawns a subprocess.
|
-- Spawns a subprocess.
|
||||||
--
|
--
|
||||||
-- Returns the processes pid.
|
-- Returns the processes pid.
|
||||||
--
|
--
|
||||||
function spawn
|
function spawn(...)
|
||||||
(...)
|
|
||||||
args = { ... }
|
args = { ... }
|
||||||
|
|
||||||
cwriteln( 'spawning: ', table.concat( args, ' ' ) )
|
cwriteln( 'spawning: ', table.concat( args, ' ' ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user