-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild-will2e.lua
More file actions
96 lines (78 loc) · 2.31 KB
/
build-will2e.lua
File metadata and controls
96 lines (78 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
--[====================================[
L3BUILD CUSTOMISATION FOR WILL2e
--]====================================]
gittag = module.."-v"..version
today = os.date("%Y/%m/%d")
theyear = os.date("%Y")
pkgdate = pkgdate or today
if pkgdate ~= today then
print("Package date is not today:"..
"\nPkg date: "..pkgdate..
"\nToday: "..today)
end
local function prequire(m) -- from: https://stackoverflow.com/a/17878208
local ok, err = pcall(require, m)
if not ok then return nil, err end
return err
end
prequire("l3build-wspr.lua")
--[===========[--
TAGGING
--]===========]--
status_bool = false
function check_status()
if status_bool then
return true
end
local handle = io.popen('git status --porcelain --untracked-files=no')
local gitstatus = string.gsub(handle:read("*a"),'%s*$','')
handle:close()
if gitstatus=="" then
print("Checking git status: clean")
status_bool = true
return status_bool
else
print("ABORTING, git status is not clean:")
print(gitstatus)
status_bool = false
return status_bool
end
end
function tag_hook(tagname)
if check_status() then
print("Update git with commit & tag? [y/n]")
tag_check = io.read()
if tag_check == "y" then
os.execute('git commit -a -m "Step release tag ('..gittag..')"')
os.execute('git tag -a -m "" ' .. gittag)
end
end
end
function update_tag(file,content,tagname,tagdate)
if content==nil then
print("content should not be nil!")
end
if not(check_status()) then
return content
end
local content = content
-- copyright
local newpattern = "(C) "..copyrightyear.."-"..theyear
local findpattern = "%(C%)%s"..copyrightyear.."%-%d%d%d%d"
local foundpattern = content:match(findpattern)
if foundpattern and not(newpattern==foundpattern) then
print("File copyright: " .. foundpattern)
print("New copyright: " .. newpattern)
content = content:gsub(findpattern,newpattern)
end
-- versioning
local newtag = pkgdate .. " v" .. version
local findpattern = "%d%d%d%d/%d%d/%d%d%sv%d%.%d%a*"
local foundtag = content:match(findpattern)
if foundtag and not(newtag==foundtag) then
print("Old package date/version: " .. foundtag)
print("Replaced with: " .. newtag)
content = content:gsub(findpattern,newtag)
end
return content
end