From 6655537c6658e39b1d44c228a2315a62f6f9fc69 Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Thu, 1 Oct 2015 00:17:13 +0200 Subject: [PATCH 1/2] koch: Add geninstall generating just ./install.sh In opposite to `install` which generates ./install.sh and then calls it. --- koch.nim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/koch.nim b/koch.nim index 8992271bfd..3d1a22b9cc 100644 --- a/koch.nim +++ b/koch.nim @@ -41,6 +41,7 @@ Options: Possible Commands: boot [options] bootstraps with given command line options install [bindir] installs to given directory; Unix only! + geninstall generate ./install.sh; Unix only! clean cleans Nim project; removes generated files web [options] generates the website and the full documentation website [options] generates only the website @@ -127,9 +128,12 @@ proc nsis(args: string) = exec(("tools" / "niminst" / "niminst --var:version=$# --var:mingw=mingw$#" & " nsis compiler/installer.ini") % [VersionAsString, $(sizeof(pointer)*8)]) +proc geninstall(args="") = + exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini $#" % + [findNim(), compileNimInst, VersionAsString, args]) + proc install(args: string) = - exec("$# cc -r $# --var:version=$# --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % - [findNim(), compileNimInst, VersionAsString]) + geninstall() exec("sh ./install.sh $#" % args) proc web(args: string) = @@ -373,6 +377,7 @@ of cmdArgument: of "zip": zip(op.cmdLineRest) of "xz": xz(op.cmdLineRest) of "nsis": nsis(op.cmdLineRest) + of "geninstall": geninstall(op.cmdLineRest) of "install": install(op.cmdLineRest) of "test", "tests": tests(op.cmdLineRest) of "update": From 6cc98539354607306e213ac90b2dac7cb3e86f73 Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Thu, 1 Oct 2015 00:18:32 +0200 Subject: [PATCH 2/2] bootstrap: Generate final install.sh during build This solves problem where bootstrap was simply copying ./install.sh.template into ./install.sh. Then first call of ./install.sh was calling ./koch install that was running extra compilation and overwriting ./install.sh with new content. This was overcomplicated, and also caused first `sudo ./install.sh DIR` to run compilation under root account, leaving root owned files in working directory. Now bootstrap calls `./koch geninstall` that just generates ./install.sh without calling it. This ./install.sh is FINAL one, and running it does not generate any files aside passed DIR. This makes whole process simpler. --- bootstrap.sh | 7 +++++-- install.sh.template | 9 --------- 2 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 install.sh.template diff --git a/bootstrap.sh b/bootstrap.sh index ade74a9aa4..7f19c24406 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -12,8 +12,11 @@ cd ".." ./bin/nim c koch ./koch boot -d:release +./koch geninstall -cp -f install.sh.template install.sh -chmod +x install.sh +set +x + +echo +echo 'Install Nim using "./install.sh " or "sudo ./install.sh ".' exit 0 diff --git a/install.sh.template b/install.sh.template deleted file mode 100644 index 1292abdab5..0000000000 --- a/install.sh.template +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e -set -x - -if [ "$1" != "" ]; then - exec ./koch install "$1" -else - exec ./koch install -fi