From e028924d612d73a4c127d1ddc9b4db9e65da6783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 1 May 2015 12:16:55 +0200 Subject: [PATCH] Added -x option to cp.lua to allow not copying mounts, used in install.lua to avoid recursively copying target mount to itself. Fixed deobf build shipping parts of the Railcraft API... sometimes Gradle confuses me greatly. --- build.gradle | 1 + .../assets/opencomputers/loot/OpenOS/bin/cp.lua | 13 +++++++++++++ .../opencomputers/loot/OpenOS/bin/install.lua | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index bd6bd6065..5a30a7a7a 100644 --- a/build.gradle +++ b/build.gradle @@ -248,6 +248,7 @@ javadoc { task deobfJar(type: Jar) { from sourceSets.main.output exclude "cofh/**" + exclude "mods/**" configurations.embedded.each { dep -> from(project.zipTree(dep)) { exclude 'META-INF', 'META-INF/**' diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua index 5a15b1cf9..85920d0aa 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/cp.lua @@ -10,6 +10,7 @@ if #args < 2 then io.write(" -u: copy only when the SOURCE file differs from the destination\n") io.write(" file or when the destination file is missing.\n") io.write(" -v: verbose output.") + io.write(" -x: stay on original source file system.") return end @@ -58,6 +59,15 @@ local function areEqual(path1, path2) return result end +local function isMount(path) + path = fs.canonical(path) + for _, mountPath in fs.mounts() do + if path == fs.canonical(mountPath) then + return true + end + end +end + local function recurse(fromPath, toPath) status(fromPath, toPath) if fs.isDirectory(fromPath) then @@ -72,6 +82,9 @@ local function recurse(fromPath, toPath) -- my real cp always does this, even with -f, -n or -i. return nil, "cannot overwrite non-directory `" .. toPath .. "' with directory `" .. fromPath .. "'" end + if options.x and isMount(fromPath) then + return true + end fs.makeDirectory(toPath) for file in fs.list(fromPath) do local result, reason = recurse(fs.concat(fromPath, file), fs.concat(toPath, file)) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua index 0ded2c5b1..25367c286 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua @@ -59,7 +59,7 @@ local name = options.name or "OpenOS" io.write("Installing " .. name .." to device " .. (choice.getLabel() or choice.address) .. "\n") os.sleep(0.25) local cpPath = filesystem.concat(findMount(filesystem.get(os.getenv("_")).address), "bin/cp") -local cpOptions = "-vr" .. (options.u and "ui " or "") +local cpOptions = "-vrx" .. (options.u and "ui " or "") local cpSource = filesystem.concat(findMount(fromAddress), options.fromDir or "/", "*") local cpDest = findMount(choice.address) .. "/" local result, reason = os.execute(cpPath .. " " .. cpOptions .. " " .. cpSource .. " " .. cpDest)