[latex3-commits] [git/LaTeX3-latex3-l3build] master: New ctanreadme variable (6051af4)

Joseph Wright joseph.wright at morningstar2.co.uk
Sun Sep 23 19:48:21 CEST 2018


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/6051af4aaf58ba06c68f0d047fbf2c542a1df274

>---------------------------------------------------------------

commit 6051af4aaf58ba06c68f0d047fbf2c542a1df274
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Sun Sep 23 18:48:21 2018 +0100

    New ctanreadme variable


>---------------------------------------------------------------

6051af4aaf58ba06c68f0d047fbf2c542a1df274
 CHANGELOG.md          |    1 +
 l3build-ctan.lua      |   12 ++++++++++++
 l3build-install.lua   |   11 +++++++++++
 l3build-variables.lua |    1 +
 l3build.dtx           |    6 ++++++
 5 files changed, 31 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b275c2b..ac7509d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ this project uses date-based 'snapshot' version identifiers.
 - Entries in `scriptfiles` are excluded from `installfiles`
 - Use a per-config directory for running tests
 - Enable use of local `texmf.cnf` file in tests and documentation
+- New `ctanreadme` variable
 
 ## [2018-09-21]
 
diff --git a/l3build-ctan.lua b/l3build-ctan.lua
index f1e0757..19f0961 100644
--- a/l3build-ctan.lua
+++ b/l3build-ctan.lua
@@ -25,6 +25,9 @@ for those people who are interested.
 local pairs = pairs
 local print = print
 
+local lower = string.lower
+local match = string.match
+
 -- Copy files to the main CTAN release directory
 function copyctan()
   mkdir(ctandir .. "/" .. ctanpkg)
@@ -129,6 +132,15 @@ function ctan()
         cp(i, j, tdsdir .. "/doc/" .. tdsroot .. "/" .. bundle)
       end
     end
+    -- Rename README if necessary
+    if ctanreadme ~= "" and not match(lower(ctanreadme),"^readme%.%w+") then
+      for dir in pairs({"ctandir .. "/" .. ctanpkg",
+        "tdsdir .. "/doc/" .. tdsroot .. "/" .. bundle"}) do
+        if fileexists(dir .. "/" .. ctanreadme) then
+          ren(dir,ctanreadme,"README." .. match(ctanreadme,"%.(%w+)$"))
+        end
+      end
+    end
     dirzip(tdsdir, ctanpkg .. ".tds")
     if packtdszip then
       cp(ctanpkg .. ".tds.zip", tdsdir, ctandir)
diff --git a/l3build-install.lua b/l3build-install.lua
index f4d51e5..12c5991 100644
--- a/l3build-install.lua
+++ b/l3build-install.lua
@@ -29,6 +29,7 @@ local set_program = kpse.set_program_name
 local var_value   = kpse.var_value
 
 local gsub  = string.gsub
+local lower = string.lower
 local match = string.match
 
 local insert = table.insert
@@ -185,6 +186,16 @@ function install_files(target,full,dry_run)
           {bibfiles,demofiles,docfiles,pdffiles,textfiles,typesetlist})
     if errorlevel ~= 0 then return errorlevel end
 
+    -- Rename README if necessary
+    if not dry_run then
+      if ctanreadme ~= "" and not match(lower(ctanreadme),"^readme%.%w+") then
+        local installdir = target .. "/doc/" .. moduledir
+        if fileexists(installdir .. "/" .. ctanreadme) then
+          ren(installdir,ctanreadme,"README." .. match(ctanreadme,"%.(%w+)$"))
+        end
+      end
+    end
+
     -- Any script man files need special handling
     local manfiles = { }
     for _,glob in pairs(scriptmanfiles) do
diff --git a/l3build-variables.lua b/l3build-variables.lua
index f24b11a..b3b9997 100644
--- a/l3build-variables.lua
+++ b/l3build-variables.lua
@@ -159,6 +159,7 @@ end
 -- Other required settings
 asciiengines = asciiengines or {"pdftex"}
 checkruns    = checkruns    or 1
+ctanreadme   = ctanreadme   or "README.md"
 ctanzip      = ctanzip      or ctanpkg .. "-ctan"
 epoch        = epoch        or 1463734800
 if flatten == nil then
diff --git a/l3build.dtx b/l3build.dtx
index ed36c79..e3136d7 100644
--- a/l3build.dtx
+++ b/l3build.dtx
@@ -152,6 +152,7 @@
 \luavarseparator
 \luavarset{asciiengines}{\{"pdftex"\}}{Engines which should log as sure ASCII}
 \luavarset{checkruns}   {1}           {Number of runs to complete for a test before comparing the log}
+\luavarset{ctanreadme}{"README.md"}   {Name of the file to send to CTAN as \texttt{README.\meta{ext}}}
 \luavarset{ctanzip}{ctanpkg ... "-ctan"}{Name of the zip file created for upload to CTAN}
 \luavarset{epoch}       {1463734800}  {Epoch (Unix date) to set for test runs}
 \luavarset{flatten}     {true}        {Switch to flatten any source structure when sending to CTAN}
@@ -437,6 +438,11 @@
 % The |source| tree is constructed from all files matched by \var{typesetfiles} and \var{sourcefiles}.
 % The |tex| tree from all files matched by \var{installfiles}.
 %
+% The special case \var{ctanreadme} is used to allow renaming of a local
+% |foo.xyz| file to |README.xyz|. The local |foo.xyz| should be listed in
+% \var{textfiles}, and will be renamed as part of constructing the CTAN
+% structure. The file extension will be unchanged by this process.
+%
 % Files that should always be excluded from the archive are matched against the \var{excludefiles} variable; by default this is \luavar{excludefiles}, which match Emacs' autosave files.
 %
 % Binary files should be specified with the \var{binaryfiles} variable (default \luavar{binaryfiles}); these are added to the zip archive without normalising line endings (text files are automatically converted to Unix-style line endings).





More information about the latex3-commits mailing list