Browse Source

Merge pull request #374 from oleorhagen/linkbot-ubuntu-lts

Linkbot now only handles Ubuntu LTS images
2.6.x
oleorhagen 3 years ago
committed by GitHub
parent
commit
ef0c5fe5dc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      scripts/linkbot/monitor-ub-server.js
  2. 2
      scripts/test/run-tests.sh

9
scripts/linkbot/monitor-ub-server.js

@ -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)
}
})
});

2
scripts/test/run-tests.sh

@ -29,7 +29,7 @@ RASPBIAN_IMAGE_URL="http://downloads.raspberrypi.org/raspbian_lite/images/raspbi
UBUNTU_IMAGE_URL="https://downloads.mender.io/mender-convert/images/Ubuntu-Bionic-x86-64.img.gz"
## Auto-update
UBUNTU_SERVER_RPI_IMAGE_URL="http://cdimage.ubuntu.com/ubuntu/releases/20.04.2/release/ubuntu-20.04.2-preinstalled-server-armhf+raspi.img.xz"
UBUNTU_SERVER_RPI_IMAGE_URL="http://cdimage.ubuntu.com/ubuntu/releases/20.04/release/ubuntu-20.04.2-preinstalled-server-armhf+raspi.img.xz"
# Keep common function declarations in separate utils script
UTILS_PATH=${0/$(basename $0)/test-utils.sh}

Loading…
Cancel
Save