|
|
@ -5,7 +5,7 @@ const { updateURLLink } = require('./common'); |
|
|
|
|
|
|
|
const target = "UBUNTU_SERVER_RPI_IMAGE_URL" |
|
|
|
const url = "http://cdimage.ubuntu.com/ubuntu/releases/" |
|
|
|
const reg = ".*(?<release>[0-9]{2})\.04\.?(?<minor>[0-9]{1})?.*" |
|
|
|
const reg = ".*(?<release>[0-9][02468])\.04\.?(?<minor>[0-9]{1})?.*" |
|
|
|
|
|
|
|
// Read the input file, and parse the variable input
|
|
|
|
try { |
|
|
@ -26,12 +26,13 @@ JSDOM.fromURL(url, {}).then(dom => { |
|
|
|
var refs = document.getElementsByTagName("a"); |
|
|
|
var matches = Array.from(refs) |
|
|
|
.filter(ref => ref.textContent.match(reg)) |
|
|
|
.filter(ref => !ref.textContent.match(reg).groups.minor) // Ignore the minor number
|
|
|
|
.reduce((acc, ref) => { |
|
|
|
acc.push(ref.textContent.match(reg)) |
|
|
|
return acc |
|
|
|
}, []) |
|
|
|
.sort((a,b) => { |
|
|
|
return parseInt(b.groups.release) - parseInt(a.groups.release) || parseFloat(b.groups.minor) - parseFloat(a.groups.minor) |
|
|
|
return parseInt(b.groups.release) - parseInt(a.groups.release) |
|
|
|
}) |
|
|
|
var matchOn = matches[0].input |
|
|
|
|
|
|
@ -44,10 +45,10 @@ JSDOM.fromURL(url, {}).then(dom => { |
|
|
|
JSDOM.fromURL(`${url}${releaseVersion}/release/`, {}).then(dom => { |
|
|
|
var document = dom.window.document; |
|
|
|
var refs = document.getElementsByTagName("a"); |
|
|
|
const match = Array.from(refs).find(ref => ref.href.match(`.*ubuntu-${releaseVersion}-preinstalled-server-armhf.*\.img\.xz$`)) |
|
|
|
const match = Array.from(refs).find(ref => ref.href.match(`.*ubuntu-${releaseVersion}\.?[0-9]+-preinstalled-server-armhf.*\.img\.xz$`)) |
|
|
|
if (match) { |
|
|
|
console.log(`Ubuntu server image has a new release: ${match}`) |
|
|
|
updateURLLink(`${target}=${match}`, target) |
|
|
|
updateURLLink(`${target}=\"${match}\"`, target) |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|