main: support debian backports
This commit is contained in:
parent
b91baffed3
commit
e535e3a99c
52
main.js
52
main.js
|
@ -5,17 +5,23 @@ const hub = require("docker-hub-utils")
|
||||||
const path = require("path")
|
const path = require("path")
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
|
|
||||||
function getDistribution(distribution) {
|
function getImageTag(imageName, distribution) {
|
||||||
return distribution.replace("UNRELEASED", "unstable")
|
if (imageName == "debian") {
|
||||||
.replace("-security", "")
|
return distribution.replace("UNRELEASED", "unstable")
|
||||||
.replace("-backports", "")
|
.replace("-security", "")
|
||||||
|
} else {
|
||||||
|
return distribution.replace("UNRELEASED", "unstable")
|
||||||
|
.replace("-security", "")
|
||||||
|
.replace("-backports", "")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getOS(distribution) {
|
async function getImageName(distribution) {
|
||||||
for (const os of ["debian", "ubuntu"]) {
|
const tag = getImageTag("", distribution)
|
||||||
const tags = await hub.queryTags({ user: "library", name: os })
|
for (const image of ["debian", "ubuntu"]) {
|
||||||
if (tags.find(tag => tag.name == distribution)) {
|
const tags = await hub.queryTags({ user: "library", name: image })
|
||||||
return os
|
if (tags.find(t => t.name == tag)) {
|
||||||
|
return image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,25 +38,25 @@ async function main() {
|
||||||
|
|
||||||
const file = path.join(sourceDirectory, "debian/changelog")
|
const file = path.join(sourceDirectory, "debian/changelog")
|
||||||
const changelog = await firstline(file)
|
const changelog = await firstline(file)
|
||||||
const regex = /^(?<package>.+) \(((?<epoch>[0-9]+):)?(?<version>[^:-]+)(-(?<revision>[^:-]+))?\) (?<distribution>.+);/
|
const regex = /^(?<pkg>.+) \(((?<epoch>[0-9]+):)?(?<version>[^:-]+)(-(?<revision>[^:-]+))?\) (?<distribution>.+);/
|
||||||
const match = changelog.match(regex)
|
const match = changelog.match(regex)
|
||||||
const { package, epoch, version, revision, distribution } = match.groups
|
const { pkg, epoch, version, revision, distribution } = match.groups
|
||||||
const os = await getOS(getDistribution(distribution))
|
const imageName = await getImageName(distribution)
|
||||||
const container = package
|
const imageTag = await getImageTag(imageName, distribution)
|
||||||
const image = os + ":" + getDistribution(distribution)
|
const container = pkg
|
||||||
|
const image = imageName + ":" + imageTag
|
||||||
|
|
||||||
fs.mkdirSync(artifactsDirectory, { recursive: true })
|
fs.mkdirSync(artifactsDirectory, { recursive: true })
|
||||||
|
|
||||||
core.startGroup("Print details")
|
core.startGroup("Print details")
|
||||||
const details = {
|
const details = {
|
||||||
package: package,
|
pkg: pkg,
|
||||||
epoch: epoch,
|
epoch: epoch,
|
||||||
version: version,
|
version: version,
|
||||||
revision: revision,
|
revision: revision,
|
||||||
distribution: getDistribution(distribution),
|
distribution: distribution,
|
||||||
os: os,
|
|
||||||
container: container,
|
|
||||||
image: image,
|
image: image,
|
||||||
|
container: container,
|
||||||
workspaceDirectory: workspaceDirectory,
|
workspaceDirectory: workspaceDirectory,
|
||||||
sourceDirectory: sourceDirectory,
|
sourceDirectory: sourceDirectory,
|
||||||
buildDirectory: buildDirectory,
|
buildDirectory: buildDirectory,
|
||||||
|
@ -89,8 +95,8 @@ async function main() {
|
||||||
"tar",
|
"tar",
|
||||||
"--exclude-vcs",
|
"--exclude-vcs",
|
||||||
"--exclude", "./debian",
|
"--exclude", "./debian",
|
||||||
"--transform", `s/^\./${package}-${version}/S`,
|
"--transform", `s/^\./${pkg}-${version}/S`,
|
||||||
"-cvzf", `${buildDirectory}/${package}_${version}.orig.tar.gz`,
|
"-cvzf", `${buildDirectory}/${pkg}_${version}.orig.tar.gz`,
|
||||||
"-C", sourceDirectory,
|
"-C", sourceDirectory,
|
||||||
"./"
|
"./"
|
||||||
])
|
])
|
||||||
|
@ -109,7 +115,7 @@ async function main() {
|
||||||
await exec.exec("docker", [
|
await exec.exec("docker", [
|
||||||
"exec",
|
"exec",
|
||||||
container,
|
container,
|
||||||
"apt-get", "install", "-yq", "dpkg-dev", "debhelper"
|
"apt-get", "install", "-yq", "-t", imageTag, "dpkg-dev", "debhelper"
|
||||||
])
|
])
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
|
@ -117,7 +123,7 @@ async function main() {
|
||||||
await exec.exec("docker", [
|
await exec.exec("docker", [
|
||||||
"exec",
|
"exec",
|
||||||
container,
|
container,
|
||||||
"apt-get", "build-dep", "-yq", sourceDirectory
|
"apt-get", "build-dep", "-yq", "-t", imageTag, sourceDirectory
|
||||||
])
|
])
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
|
@ -136,7 +142,7 @@ async function main() {
|
||||||
"find",
|
"find",
|
||||||
buildDirectory,
|
buildDirectory,
|
||||||
"-maxdepth", "1",
|
"-maxdepth", "1",
|
||||||
"-name", `${package}*${version}*.*`,
|
"-name", `${pkg}*${version}*.*`,
|
||||||
"-type", "f",
|
"-type", "f",
|
||||||
"-print",
|
"-print",
|
||||||
"-exec", "mv", "{}", artifactsDirectory, ";"
|
"-exec", "mv", "{}", artifactsDirectory, ";"
|
||||||
|
|
Loading…
Reference in a new issue