Fix indentation.

This commit is contained in:
Antonin Décimo
2020-03-28 17:29:07 +01:00
parent 4e69a1f3f3
commit e734cc12f1
9 changed files with 92 additions and 104 deletions

View File

@@ -17,9 +17,9 @@ function Args:initialize()
self.pre = Args.pre self.pre = Args.pre
local parser = argparse() local parser = argparse()
:name "love-release" :name "love-release"
:description "Makes LÖVE games releases easier !" :description "Makes LÖVE games releases easier !"
:epilog "For more info, see https://github.com/MisterDA/love-release" :epilog "For more info, see https://github.com/MisterDA/love-release"
parser:argument("release", "Project release directory.") parser:argument("release", "Project release directory.")

View File

@@ -39,8 +39,8 @@ function pipe.pipe(project)
if not utils.love.isSupported(version) then if not utils.love.isSupported(version) then
local scriptLoveVersion = project.loveVersion local scriptLoveVersion = project.loveVersion
err("CONF: Your LÖVE conf version ("..v err("CONF: Your LÖVE conf version ("..v
.. ") is not supported by love-release ("..tostring(scriptLoveVersion) .. ") is not supported by love-release ("..tostring(scriptLoveVersion)
.. ").\n") .. ").\n")
if version > scriptLoveVersion then if version > scriptLoveVersion then
err(" You should update love-release.\n") err(" You should update love-release.\n")
elseif version < scriptLoveVersion then elseif version < scriptLoveVersion then
@@ -76,8 +76,6 @@ function pipe.pipe(project)
end end
setmetatable(pipe, { setmetatable(pipe, { __call = function(_, project) return pipe.pipe(project) end })
__call = function(_, project) return pipe.pipe(project) end,
})
return pipe return pipe

View File

@@ -84,8 +84,8 @@ function pipe.pipe(project)
if systemLoveVersion and not isSupported(systemLoveVersion) then if systemLoveVersion and not isSupported(systemLoveVersion) then
err("ENV: Your LÖVE installed version (" .. tostring(systemLoveVersion) .. err("ENV: Your LÖVE installed version (" .. tostring(systemLoveVersion) ..
") is not supported by love-release (" .. tostring(scriptLoveVersion) .. ") is not supported by love-release (" .. tostring(scriptLoveVersion) ..
").\n") ").\n")
if systemLoveVersion > scriptLoveVersion then if systemLoveVersion > scriptLoveVersion then
err(" You should update love-release.\n") err(" You should update love-release.\n")
elseif systemLoveVersion < scriptLoveVersion then elseif systemLoveVersion < scriptLoveVersion then
@@ -95,8 +95,8 @@ function pipe.pipe(project)
if webLoveVersion and not isSupported(webLoveVersion) then if webLoveVersion and not isSupported(webLoveVersion) then
err("ENV: The upstream LÖVE version (" .. tostring(webLoveVersion) .. err("ENV: The upstream LÖVE version (" .. tostring(webLoveVersion) ..
") is not supported by love-release (" .. tostring(scriptLoveVersion) .. ") is not supported by love-release (" .. tostring(scriptLoveVersion) ..
").\n") ").\n")
err(" You should update love-release.\n") err(" You should update love-release.\n")
end end
@@ -108,8 +108,6 @@ function pipe.pipe(project)
end end
setmetatable(pipe, { setmetatable(pipe, { __call = function(_, project) return pipe.pipe(project) end })
__call = function(_, project) return pipe.pipe(project) end,
})
return pipe return pipe

View File

@@ -142,8 +142,8 @@ end
-- it is within the project directory. -- it is within the project directory.
function Project:excludeFiles() function Project:excludeFiles()
local dir, rm_dir = self.releaseDirectory:gsub( local dir, rm_dir = self.releaseDirectory:gsub(
"^"..utils.lua.escape_string_regex(self.projectDirectory).."/", "^"..utils.lua.escape_string_regex(self.projectDirectory).."/",
"") "")
if rm_dir > 0 then if rm_dir > 0 then
dir = "^"..dir dir = "^"..dir
end end
@@ -184,21 +184,21 @@ end
-- @local -- @local
function Project:__tostring() function Project:__tostring()
return return
'{\n'.. '{\n'..
' title = '..escape(self.title)..',\n'.. ' title = '..escape(self.title)..',\n'..
' package = '..escape(self.package)..',\n'.. ' package = '..escape(self.package)..',\n'..
' loveVersion = \''..escape(self.loveVersion)..'\',\n'.. ' loveVersion = \''..escape(self.loveVersion)..'\',\n'..
' version = '..escape(self.version)..',\n'.. ' version = '..escape(self.version)..',\n'..
' author = '..escape(self.author)..',\n'.. ' author = '..escape(self.author)..',\n'..
' email = '..escape(self.email)..',\n'.. ' email = '..escape(self.email)..',\n'..
' description = '..escape(self.description)..',\n'.. ' description = '..escape(self.description)..',\n'..
' homepage = '..escape(self.homepage)..',\n'.. ' homepage = '..escape(self.homepage)..',\n'..
' identifier = '..escape(self.identifier)..',\n'.. ' identifier = '..escape(self.identifier)..',\n'..
' excludeFileList = { '..escape(table.concat(self.excludeFileList, "', '"))..'} ,\n'.. ' excludeFileList = { '..escape(table.concat(self.excludeFileList, "', '"))..'} ,\n'..
' compile = '..escape(self.compile)..',\n'.. ' compile = '..escape(self.compile)..',\n'..
' projectDirectory = '..escape(self.projectDirectory)..',\n'.. ' projectDirectory = '..escape(self.projectDirectory)..',\n'..
' releaseDirectory = '..escape(self.releaseDirectory)..',\n'.. ' releaseDirectory = '..escape(self.releaseDirectory)..',\n'..
'}' '}'
end end
--- Sets the title. --- Sets the title.

View File

@@ -80,34 +80,34 @@ function s.script(project)
-- /DEBIAN/control -- /DEBIAN/control
writeFile("/DEBIAN/control", writeFile("/DEBIAN/control",
"Package: "..project.package.."\n".. "Package: "..project.package.."\n"..
"Version: "..project.version.."\n".. "Version: "..project.version.."\n"..
"Architecture: all\n".. "Architecture: all\n"..
"Maintainer: "..project.author.." <"..project.email..">\n".. "Maintainer: "..project.author.." <"..project.email..">\n"..
"Installed-Size: ".. "Installed-Size: "..
math.floor(assert(lfs.attributes(loveFileRel, "size")) / 1024).."\n".. math.floor(assert(lfs.attributes(loveFileRel, "size")) / 1024).."\n"..
"Depends: love (>= "..tostring(project.loveVersion)..")\n".. "Depends: love (>= "..tostring(project.loveVersion)..")\n"..
"Priority: extra\n".. "Priority: extra\n"..
"Homepage: "..project.homepage.."\n".. "Homepage: "..project.homepage.."\n"..
"Description: "..project.description.."\n" "Description: "..project.description.."\n"
) )
-- /usr/share/applications/${PACKAGE}.desktop -- /usr/share/applications/${PACKAGE}.desktop
writeFile("/usr/share/applications/"..project.package..".desktop", writeFile("/usr/share/applications/"..project.package..".desktop",
"[Desktop Entry]\n".. "[Desktop Entry]\n"..
"Name="..project.title.."\n".. "Name="..project.title.."\n"..
"Comment="..project.description.."\n".. "Comment="..project.description.."\n"..
"Exec="..project.package.."\n".. "Exec="..project.package.."\n"..
"Type=Application\n".. "Type=Application\n"..
"Categories=Game;\n", "Categories=Game;\n",
true true
) )
-- /usr/bin/${PACKAGE} -- /usr/bin/${PACKAGE}
writeFile("/usr/bin/"..project.package, writeFile("/usr/bin/"..project.package,
"#!/bin/sh\n".. "#!/bin/sh\n"..
"love '"..loveFileDeb:gsub("'", "\\'").."'\n", "love '"..loveFileDeb:gsub("'", "\\'").."'\n",
true true
) )
-- FIXME: escape this path? -- FIXME: escape this path?
assert(fs.set_permissions(tempDir.."/usr/bin/"..project.package, assert(fs.set_permissions(tempDir.."/usr/bin/"..project.package,
@@ -125,7 +125,7 @@ function s.script(project)
-- create the package -- create the package
local deb = project.releaseDirectory.."/"..project.package.."-".. local deb = project.releaseDirectory.."/"..project.package.."-"..
project.version.."_all.deb" project.version.."_all.deb"
fs.delete(deb) fs.delete(deb)
assert(fs.execute("fakeroot dpkg-deb -b ", tempDir, deb), assert(fs.execute("fakeroot dpkg-deb -b ", tempDir, deb),
"DEBIAN: error while building the package.") "DEBIAN: error while building the package.")
@@ -134,8 +134,6 @@ function s.script(project)
end end
setmetatable(s, { setmetatable(s, { __call = function(_, project) return s.script(project) end })
__call = function(_, project) return s.script(project) end,
})
return s return s

View File

@@ -13,8 +13,6 @@ function s.script(project)
end end
setmetatable(s, { setmetatable(s, { __call = function(_, project) return s.script(project) end })
__call = function(_, project) return s.script(project) end,
})
return s return s

View File

@@ -62,12 +62,12 @@ function s.script(project)
local infoPlist = assert(infoPlistHandle:read(infoPlistSize)) local infoPlist = assert(infoPlistHandle:read(infoPlistSize))
infoPlistHandle:close() infoPlistHandle:close()
infoPlist = infoPlist infoPlist = infoPlist
:gsub("\n\t<key>UTExportedTypeDeclarations</key>.*</array>", :gsub("\n\t<key>UTExportedTypeDeclarations</key>.*</array>",
"") "")
:gsub("(CFBundleIdentifier.-<string>)(.-)(</string>)", :gsub("(CFBundleIdentifier.-<string>)(.-)(</string>)",
"%1"..project.identifier.."%3") "%1"..project.identifier.."%3")
:gsub("(CFBundleName.-<string>)(.-)(</string>)", :gsub("(CFBundleName.-<string>)(.-)(</string>)",
"%1"..project.title..".love%3") "%1"..project.title..".love%3")
ar:add("love.app/Contents/Resources/"..script.loveFile, ar:add("love.app/Contents/Resources/"..script.loveFile,
"file", script.loveFile) "file", script.loveFile)
@@ -91,8 +91,6 @@ function s.script(project)
end end
setmetatable(s, { setmetatable(s, { __call = function(_, project) return s.script(project) end })
__call = function(_, project) return s.script(project) end,
})
return s return s

View File

@@ -14,7 +14,7 @@ local s = {}
local function release(script, project, arch) local function release(script, project, arch)
local prefix, dir, bin local prefix, dir, bin
if project.loveVersion == ver'11.2' or if project.loveVersion == ver'11.2' or
project.loveVersion == ver'11.1' then project.loveVersion == ver'11.1' then
prefix = "love-"..tostring(project.loveVersion) prefix = "love-"..tostring(project.loveVersion)
dir = prefix..".0-win"..arch.."/" dir = prefix..".0-win"..arch.."/"
prefix = prefix.."-win" prefix = prefix.."-win"
@@ -73,8 +73,8 @@ local function release(script, project, arch)
stat = ar:stat(i) stat = ar:stat(i)
if stat then if stat then
ar:rename(i, stat.name:gsub( ar:rename(i, stat.name:gsub(
"^"..utils.lua.escape_string_regex(dir), "^"..utils.lua.escape_string_regex(dir),
utils.lua.escape_string_regex(project.title).."-win"..arch.."/")) utils.lua.escape_string_regex(project.title).."-win"..arch.."/"))
end end
end end
@@ -97,8 +97,6 @@ function s.script(project, arch)
end end
setmetatable(s, { setmetatable(s, { __call = function(_, project, arch) return s.script(project, arch) end })
__call = function(_, project, arch) return s.script(project, arch) end,
})
return s return s

View File

@@ -16,9 +16,9 @@ fs.init()
utils.cache = nil utils.cache = nil
do do
local cache = dir.dir_name(cfg.local_cache) .. "/love-release" local cache = dir.dir_name(cfg.local_cache) .. "/love-release"
assert(fs.make_dir(cache)) assert(fs.make_dir(cache))
utils.cache = cache utils.cache = cache
end end
@@ -27,42 +27,42 @@ end
utils.love = {} utils.love = {}
local ver = { local ver = {
major = nil, major = nil,
minor = nil, minor = nil,
patch = nil, patch = nil,
str = nil str = nil
} }
utils.love.ver = ver utils.love.ver = ver
function ver:new(str) function ver:new(str)
local major, minor, patch = str:match("^(%d+)%.?(%d*)%.?(%d*)$") local major, minor, patch = str:match("^(%d+)%.?(%d*)%.?(%d*)$")
assert(type(major) == 'string', assert(type(major) == 'string',
("Could not extract version number(s) from %q"):format(str)) ("Could not extract version number(s) from %q"):format(str))
local o = { major = tonumber(major), local o = { major = tonumber(major),
minor = tonumber(minor), minor = tonumber(minor),
patch = tonumber(patch), patch = tonumber(patch),
str = str } str = str }
setmetatable(o, self) setmetatable(o, self)
self.__index = self self.__index = self
return o return o
end end
function ver:__eq(other) function ver:__eq(other)
return self.major == other.major and self.minor == other.minor and return self.major == other.major and self.minor == other.minor and
self.patch == other.patch self.patch == other.patch
end end
function ver:__lt(other) function ver:__lt(other)
if self.major ~= other.major then return self.major < other.major end if self.major ~= other.major then return self.major < other.major end
if self.minor ~= other.minor then return self.minor < other.minor end if self.minor ~= other.minor then return self.minor < other.minor end
if self.patch ~= other.patch then return self.patch < other.patch end if self.patch ~= other.patch then return self.patch < other.patch end
return false return false
end end
function ver:__tostring() function ver:__tostring()
local buffer = { ("%d.%d"):format(self.major, self.minor) } local buffer = { ("%d.%d"):format(self.major, self.minor) }
if self.patch then table.insert(buffer, "." .. self.patch) end if self.patch then table.insert(buffer, "." .. self.patch) end
return table.concat(buffer) return table.concat(buffer)
end end
setmetatable(ver, { __call = ver.new }) setmetatable(ver, { __call = ver.new })
@@ -97,7 +97,7 @@ utils.love.minVersion = utils.love.versionTable[#utils.love.versionTable]
function utils.love.isSupported(version) function utils.love.isSupported(version)
assert(getmetatable(version) == ver) assert(getmetatable(version) == ver)
if version >= utils.love.minVersion if version >= utils.love.minVersion
and version <= utils.love.lastVersion then and version <= utils.love.lastVersion then
for _, v in ipairs(utils.love.versionTable) do for _, v in ipairs(utils.love.versionTable) do
if version == v then if version == v then
return true return true
@@ -130,9 +130,9 @@ end
function utils.lua.escape_string_regex(string) function utils.lua.escape_string_regex(string)
-- ^$()%.[]*+-? -- ^$()%.[]*+-?
return string:gsub('%%', '%%%%'):gsub('^%^', '%%^'):gsub('%$$', '%%$') return string:gsub('%%', '%%%%'):gsub('^%^', '%%^'):gsub('%$$', '%%$')
:gsub('%(', '%%('):gsub('%)', '%%)'):gsub('%.', '%%.') :gsub('%(', '%%('):gsub('%)', '%%)'):gsub('%.', '%%.')
:gsub('%[', '%%['):gsub('%]', '%%]'):gsub('%*', '%%*') :gsub('%[', '%%['):gsub('%]', '%%]'):gsub('%*', '%%*')
:gsub('%+', '%%+'):gsub('%-', '%%-'):gsub('%?', '%%?') :gsub('%+', '%%+'):gsub('%-', '%%-'):gsub('%?', '%%?')
end end