Merge pull request #2805 from avsej/xz-dist

Implement support for XZ dist tarball
This commit is contained in:
Andreas Rumpf 2015-05-26 12:55:04 +02:00
commit 16ebd8a3b5
2 changed files with 12 additions and 13 deletions

View file

@ -47,6 +47,7 @@ Possible Commands:
csource [options] builds the C sources for installation csource [options] builds the C sources for installation
pdf builds the PDF documentation pdf builds the PDF documentation
zip builds the installation ZIP package zip builds the installation ZIP package
xz builds the installation XZ package
nsis [options] builds the NSIS Setup installer (for Windows) nsis [options] builds the NSIS Setup installer (for Windows)
tests [options] run the testsuite tests [options] run the testsuite
update updates nim to the latest version from github update updates nim to the latest version from github
@ -106,10 +107,10 @@ proc zip(args: string) =
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" % exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim zip compiler/installer.ini" %
["tools/niminst/niminst".exe, VersionAsString]) ["tools/niminst/niminst".exe, VersionAsString])
proc targz(args: string) = proc xz(args: string) =
exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % exec("$3 cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" %
[VersionAsString, compileNimInst, findNim()]) [VersionAsString, compileNimInst, findNim()])
exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim targz compiler/installer.ini" % exec("$# --var:version=$# --var:mingw=none --main:compiler/nim.nim xz compiler/installer.ini" %
["tools" / "niminst" / "niminst".exe, VersionAsString]) ["tools" / "niminst" / "niminst".exe, VersionAsString])
proc buildTool(toolname, args: string) = proc buildTool(toolname, args: string) =
@ -367,7 +368,7 @@ of cmdArgument:
of "pdf": pdf() of "pdf": pdf()
of "csource", "csources": csource(op.cmdLineRest) of "csource", "csources": csource(op.cmdLineRest)
of "zip": zip(op.cmdLineRest) of "zip": zip(op.cmdLineRest)
of "targz": targz(op.cmdLineRest) of "xz": xz(op.cmdLineRest)
of "nsis": nsis(op.cmdLineRest) of "nsis": nsis(op.cmdLineRest)
of "install": install(op.cmdLineRest) of "install": install(op.cmdLineRest)
of "test", "tests": tests(op.cmdLineRest) of "test", "tests": tests(op.cmdLineRest)

View file

@ -35,7 +35,7 @@ type
actionNsis, # action: create NSIS installer actionNsis, # action: create NSIS installer
actionScripts # action: create install and deinstall scripts actionScripts # action: create install and deinstall scripts
actionZip, # action: create zip file actionZip, # action: create zip file
actionTargz, # action: create targz file actionXz, # action: create xz file
actionDeb # action: prepare deb package actionDeb # action: prepare deb package
FileCategory = enum FileCategory = enum
@ -172,7 +172,7 @@ proc parseCmdLine(c: var ConfigData) =
of "csource": incl(c.actions, actionCSource) of "csource": incl(c.actions, actionCSource)
of "scripts": incl(c.actions, actionScripts) of "scripts": incl(c.actions, actionScripts)
of "zip": incl(c.actions, actionZip) of "zip": incl(c.actions, actionZip)
of "targz": incl(c.actions, actionTargz) of "xz": incl(c.actions, actionXz)
of "inno": incl(c.actions, actionInno) of "inno": incl(c.actions, actionInno)
of "nsis": incl(c.actions, actionNsis) of "nsis": incl(c.actions, actionNsis)
of "deb": incl(c.actions, actionDeb) of "deb": incl(c.actions, actionDeb)
@ -560,9 +560,9 @@ when haveZipLib:
else: else:
quit("Cannot open for writing: " & n) quit("Cannot open for writing: " & n)
proc targzDist(c: var ConfigData) = proc xzDist(c: var ConfigData) =
let proj = toLower(c.name) & "-" & c.version let proj = toLower(c.name) & "-" & c.version
var n = "$#.tar.gz" % proj var n = "$#.tar.xz" % proj
let tmpDir = if c.outdir.len == 0: "build" else: c.outdir let tmpDir = if c.outdir.len == 0: "build" else: c.outdir
template processFile(z, dest, src) = template processFile(z, dest, src) =
@ -571,7 +571,7 @@ proc targzDist(c: var ConfigData) =
echo "Copying ", s, " to ", tmpDir / d echo "Copying ", s, " to ", tmpDir / d
let destdir = tmpdir / d.splitFile.dir let destdir = tmpdir / d.splitFile.dir
if not dirExists(destdir): createDir(destdir) if not dirExists(destdir): createDir(destdir)
copyFile(s, tmpDir / d) copyFileWithPermissions(s, tmpDir / d)
processFile(z, proj / buildBatFile32, "build" / buildBatFile32) processFile(z, proj / buildBatFile32, "build" / buildBatFile32)
processFile(z, proj / buildBatFile64, "build" / buildBatFile64) processFile(z, proj / buildBatFile64, "build" / buildBatFile64)
@ -593,9 +593,7 @@ proc targzDist(c: var ConfigData) =
let oldDir = getCurrentDir() let oldDir = getCurrentDir()
setCurrentDir(tmpDir) setCurrentDir(tmpDir)
try: try:
#if execShellCmd("7z a -ttar $1.tar $1" % proj) != 0 or if execShellCmd("XZ_OPT=-9 tar Jcf $1.tar.xz $1" % proj) != 0:
# execShellCmd("7z a -tgzip $1.tar.gz $1.tar" % proj) != 0 or
if execShellCmd("7z a -tzip $1.zip $1" % proj) != 0:
echo("External program failed") echo("External program failed")
finally: finally:
setCurrentDir(oldDir) setCurrentDir(oldDir)
@ -666,7 +664,7 @@ if actionZip in c.actions:
zipDist(c) zipDist(c)
else: else:
quit("libzip is not installed") quit("libzip is not installed")
if actionTargz in c.actions: if actionXz in c.actions:
targzDist(c) xzDist(c)
if actionDeb in c.actions: if actionDeb in c.actions:
debDist(c) debDist(c)