diff options
author | Sergey Avseyev <sergey.avseyev@gmail.com> | 2015-05-26 12:51:31 +0300 |
---|---|---|
committer | Sergey Avseyev <sergey.avseyev@gmail.com> | 2015-05-26 13:23:41 +0300 |
commit | ba2aa474a1e96acb06190236fbc2896d2e170494 (patch) | |
tree | bcaaed23837ba3a4036977890c0cdaa7ce058deb /tools | |
parent | 8ee98b36814fd83973d408d49c8b702a3308d014 (diff) | |
download | Nim-ba2aa474a1e96acb06190236fbc2896d2e170494.tar.gz |
Implement support for XZ dist tarball
Motivation ---------- Currenly tarballs for linux created manually. ZIP files are not suitable, because they do not preserve unix file permissions. Modification ------------ Implement 'koch xz' command to produce dist tarball in xz format. Also the same command implemented in niminst.nim. Result ------ Now it is easy to create source distribution for git stapshot and use it further in packaging scripts.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/niminst/niminst.nim | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tools/niminst/niminst.nim b/tools/niminst/niminst.nim index f0ae45484..aed4624f5 100644 --- a/tools/niminst/niminst.nim +++ b/tools/niminst/niminst.nim @@ -36,6 +36,7 @@ type actionScripts # action: create install and deinstall scripts actionZip, # action: create zip file actionTargz, # action: create targz file + actionXz, # action: create xz file actionDeb # action: prepare deb package FileCategory = enum @@ -173,6 +174,7 @@ proc parseCmdLine(c: var ConfigData) = of "scripts": incl(c.actions, actionScripts) 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 "nsis": incl(c.actions, actionNsis) of "deb": incl(c.actions, actionDeb) @@ -600,6 +602,44 @@ proc targzDist(c: var ConfigData) = finally: setCurrentDir(oldDir) +proc xzDist(c: var ConfigData) = + let proj = toLower(c.name) & "-" & c.version + var n = "$#.tar.xz" % proj + let tmpDir = if c.outdir.len == 0: "build" else: c.outdir + + template processFile(z, dest, src) = + let s = src + let d = dest + echo "Copying ", s, " to ", tmpDir / d + let destdir = tmpdir / d.splitFile.dir + if not dirExists(destdir): createDir(destdir) + copyFile(s, tmpDir / d) + + processFile(z, proj / buildBatFile32, "build" / buildBatFile32) + processFile(z, proj / buildBatFile64, "build" / buildBatFile64) + processFile(z, proj / buildShFile, "build" / buildShFile) + processFile(z, proj / makeFile, "build" / makeFile) + processFile(z, proj / installShFile, installShFile) + processFile(z, proj / deinstallShFile, deinstallShFile) + for f in walkFiles(c.libpath / "lib/*.h"): + processFile(z, proj / "c_code" / extractFilename(f), f) + for osA in 1..c.oses.len: + for cpuA in 1..c.cpus.len: + var dir = buildDir(osA, cpuA) + for k, f in walkDir("build" / dir): + if k == pcFile: processFile(z, proj / dir / extractFilename(f), f) + + for cat in items({fcConfig..fcOther, fcUnix}): + for f in items(c.cat[cat]): processFile(z, proj / f, f) + + let oldDir = getCurrentDir() + setCurrentDir(tmpDir) + try: + if execShellCmd("tar Jcf $1.tar.xz $1" % proj) != 0: + echo("External program failed") + finally: + setCurrentDir(oldDir) + # -- prepare build files for .deb creation proc debDist(c: var ConfigData) = @@ -668,5 +708,7 @@ if actionZip in c.actions: quit("libzip is not installed") if actionTargz in c.actions: targzDist(c) +if actionXz in c.actions: + xzDist(c) if actionDeb in c.actions: debDist(c) |