Compare commits
4 Commits
d080d1058f
...
95ba56491d
Author | SHA1 | Date | |
---|---|---|---|
95ba56491d | |||
6ae97994c3 | |||
8e374cae37 | |||
0a2f9c3995 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -97,5 +97,7 @@ public
|
|||||||
# DynamoDB Local files
|
# DynamoDB Local files
|
||||||
.dynamodb/
|
.dynamodb/
|
||||||
|
|
||||||
|
distribution/*.mts
|
||||||
|
distribution/*.mjs
|
||||||
jobs/*
|
jobs/*
|
||||||
!jobs/example.json5
|
!jobs/example.json5
|
@@ -1,75 +0,0 @@
|
|||||||
const spawn = require('child_process').spawn;
|
|
||||||
const clc = require('cli-color');
|
|
||||||
|
|
||||||
const TimeOut = 600000;
|
|
||||||
const ExtraSpace = new RegExp('\\s+', 'g');
|
|
||||||
|
|
||||||
class Checkupdates {
|
|
||||||
upgradable = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* runs comparepkg -u
|
|
||||||
* @param {number} timeout max execution time
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
FetchUpgradable(timeout = TimeOut) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.upgradable = [];
|
|
||||||
let process = spawn('artix-checkupdates', ['-u']);
|
|
||||||
let to = setTimeout(async () => {
|
|
||||||
process.kill() && await cleanUpLockfiles();
|
|
||||||
reject('Timed out');
|
|
||||||
}, timeout);
|
|
||||||
let outputstr = '';
|
|
||||||
let errorOutput = '';
|
|
||||||
process.stdout.on('data', data => {
|
|
||||||
outputstr += data.toString();
|
|
||||||
});
|
|
||||||
process.stderr.on('data', err => {
|
|
||||||
const errstr = err.toString();
|
|
||||||
errorOutput += `${errstr}, `;
|
|
||||||
console.error(errstr);
|
|
||||||
})
|
|
||||||
process.on('exit', async (code) => {
|
|
||||||
clearTimeout(to);
|
|
||||||
if (code !== 0 || errorOutput.length !== 0) {
|
|
||||||
errorOutput.includes('unable to lock database') && cleanUpLockfiles();
|
|
||||||
reject((code && `exited with ${code}`) || errorOutput);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.upgradable = this.parseCheckUpdatesOutput(outputstr);
|
|
||||||
this.upgradable.forEach(pkg => console.log(clc.blue(pkg)));
|
|
||||||
resolve(code);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* parse output of checkupdates
|
|
||||||
* @param {*} output output of artix-checkupdates
|
|
||||||
* @returns an array of package names from the checkupdates output
|
|
||||||
*/
|
|
||||||
parseCheckUpdatesOutput(output) {
|
|
||||||
let packages = [];
|
|
||||||
let lines = output.split('\n');
|
|
||||||
lines.forEach(l => {
|
|
||||||
let p = l.trim().replace(ExtraSpace, ' ');
|
|
||||||
if (p.length > 0 && p.indexOf('Package basename') < 0) {
|
|
||||||
packages.push(p.split(' ', 2)[0]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return packages;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether a package has an upgrade or rebuild pending
|
|
||||||
* @param {string} pkg the package name
|
|
||||||
* @returns {boolean} if it's upgradable
|
|
||||||
*/
|
|
||||||
IsUpgradable(pkg) {
|
|
||||||
return this.upgradable.includes(pkg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Checkupdates;
|
|
5
bin/artix-metro.mjs
Executable file
5
bin/artix-metro.mjs
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import { artixMetro } from '../distribution/index.mjs';
|
||||||
|
|
||||||
|
artixMetro();
|
85
gitea.js
85
gitea.js
@@ -1,85 +0,0 @@
|
|||||||
const p = require('phin');
|
|
||||||
|
|
||||||
// how is there no decent library for this shit?
|
|
||||||
class Gitea {
|
|
||||||
constructor(options = {}) {
|
|
||||||
this._protocol = options._protocol || 'https';
|
|
||||||
this._domain = options.domain || 'gitea.artixlinux.org';
|
|
||||||
this._apiPrefix = options.apiPrefix || '/api/v1';
|
|
||||||
this._token = options.token || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
getHomepage() {
|
|
||||||
return `${this._protocol}://${this._domain}/`;
|
|
||||||
}
|
|
||||||
|
|
||||||
getUrlPrefix() {
|
|
||||||
return `${this._protocol}://${this._domain}${this._apiPrefix}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
getRepo(...args) {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
|
||||||
let headers = {};
|
|
||||||
if (this._token) {
|
|
||||||
headers.Authorization = `token ${this._token}`
|
|
||||||
}
|
|
||||||
let resp = await p({
|
|
||||||
url: `${this.getUrlPrefix()}/repos/${args.join('/')}`,
|
|
||||||
headers,
|
|
||||||
method: 'GET',
|
|
||||||
parse: 'json',
|
|
||||||
});
|
|
||||||
resolve(resp.body);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getCommits(...args) {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
|
||||||
let headers = {};
|
|
||||||
if (this._token) {
|
|
||||||
headers.Authorization = `token ${this._token}`
|
|
||||||
}
|
|
||||||
let resp = await p({
|
|
||||||
url: `${this.getUrlPrefix()}/repos/${args.join('/')}/commits?limit=10`,
|
|
||||||
headers,
|
|
||||||
method: 'GET',
|
|
||||||
parse: 'json',
|
|
||||||
});
|
|
||||||
resolve(resp.body);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getStatus(...args) {
|
|
||||||
return new Promise(async (resolve, reject) => {
|
|
||||||
try {
|
|
||||||
let commits = await this.getCommits(...args);
|
|
||||||
let headers = {};
|
|
||||||
if (this._token) {
|
|
||||||
headers.Authorization = `token ${this._token}`
|
|
||||||
}
|
|
||||||
let resp = await p({
|
|
||||||
url: `${this.getUrlPrefix()}/repos/${args.join('/')}/commits/${commits[0].sha}/status`,
|
|
||||||
headers,
|
|
||||||
method: 'GET',
|
|
||||||
parse: 'json',
|
|
||||||
});
|
|
||||||
resolve(resp.body);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Gitea;
|
|
295
index.js
295
index.js
@@ -1,295 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const fsp = fs.promises;
|
|
||||||
const readline = require('readline');
|
|
||||||
const Writable = require('stream').Writable;
|
|
||||||
const path = require('path');
|
|
||||||
const spawn = require('child_process').spawn;
|
|
||||||
const clc = require('cli-color');
|
|
||||||
const JSON5 = require('json5');
|
|
||||||
const checkupdates = require('./Checkupdates');
|
|
||||||
const giteaapi = require('./gitea');
|
|
||||||
|
|
||||||
const PACKAGE_ORG = 'packages';
|
|
||||||
const SIGNATUREEXPIRY = 30000;//in ms
|
|
||||||
|
|
||||||
let JOB = process.env.JOB;
|
|
||||||
let START = null;
|
|
||||||
let LASTSIGNTIME = new Date(0);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sleep equivalent as a promise
|
|
||||||
* @param {number} ms Number of ms
|
|
||||||
* @returns Promise<void>
|
|
||||||
*/
|
|
||||||
const snooze = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wait for a new build to succeed
|
|
||||||
* @param {giteaapi} tea
|
|
||||||
* @param {string} pkg
|
|
||||||
* @param {string} lastHash
|
|
||||||
*/
|
|
||||||
async function waitForBuild(tea, pkg, lastHash) {
|
|
||||||
while (true) {
|
|
||||||
let status;
|
|
||||||
try {
|
|
||||||
status = await tea.getStatus(PACKAGE_ORG, pkg);
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
status = null;
|
|
||||||
await snooze(30000);
|
|
||||||
}
|
|
||||||
if (status) {
|
|
||||||
if (status.sha !== lastHash) {
|
|
||||||
if (status.state === 'success') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (status.state === 'failure') {
|
|
||||||
throw `Build ${status.sha} failed. ${tea.getHomepage()}${PACKAGE_ORG}/${pkg}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await snooze(5000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run a command (as a promise).
|
|
||||||
* @param {string} command
|
|
||||||
* @param {string[]} args
|
|
||||||
* @returns Promise<number>
|
|
||||||
*/
|
|
||||||
function runCommand(command, args = []) {
|
|
||||||
return new Promise((res, reject) => {
|
|
||||||
let proc = spawn(command, args, { stdio: ['ignore', process.stdout, process.stderr] });
|
|
||||||
proc.on('exit', code => {
|
|
||||||
if (code === 0) {
|
|
||||||
res();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
reject(code);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prompts the user to input their GPG password via stdin
|
|
||||||
* @returns a promise that resolves the password
|
|
||||||
*/
|
|
||||||
function getGpgPass() {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
let mutableStdout = new Writable({
|
|
||||||
write: function (chunk, encoding, callback) {
|
|
||||||
if (!this.muted) {
|
|
||||||
process.stdout.write(chunk, encoding);
|
|
||||||
}
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let rl = readline.createInterface({
|
|
||||||
input: process.stdin,
|
|
||||||
output: mutableStdout,
|
|
||||||
terminal: true
|
|
||||||
});
|
|
||||||
mutableStdout.muted = false;
|
|
||||||
rl.question(clc.yellow('Enter your GPG password: '), (password) => {
|
|
||||||
rl.close();
|
|
||||||
console.log();
|
|
||||||
resolve(password);
|
|
||||||
});
|
|
||||||
mutableStdout.muted = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Input gpg passphrase so pushing commits won't require it
|
|
||||||
* @param {*} config the json config
|
|
||||||
*/
|
|
||||||
async function refreshGpg(config) {
|
|
||||||
let currentTime = new Date();
|
|
||||||
if (currentTime.getTime() - LASTSIGNTIME.getTime() > SIGNATUREEXPIRY) {
|
|
||||||
console.log(clc.cyan('Refreshing signature...'));
|
|
||||||
await runCommand('touch', ['signfile']);
|
|
||||||
await runCommand('gpg', ['-a', '--passphrase', escapeCommandParam(config.gpgpass), '--batch', '--pinentry-mode', 'loopback', '--detach-sign', 'signfile']);
|
|
||||||
await fsp.rm('signfile.asc');
|
|
||||||
LASTSIGNTIME = currentTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formats text to be sent as a parameter to some command
|
|
||||||
* @param {string} param
|
|
||||||
*/
|
|
||||||
function escapeCommandParam(param) {
|
|
||||||
return param.replace(/\\/g, "\\\\");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* increment pkgrel
|
|
||||||
* @param {string} directory location of all package git repos
|
|
||||||
* @param {*} package package to increment
|
|
||||||
* @returns Promise<void>
|
|
||||||
*/
|
|
||||||
function increment(directory, package) {
|
|
||||||
return new Promise(async (res, reject) => {
|
|
||||||
const pkgbuild = path.join(directory, package, 'PKGBUILD');
|
|
||||||
let lines = [];
|
|
||||||
|
|
||||||
const rl = readline.createInterface({
|
|
||||||
input: fs.createReadStream(pkgbuild),
|
|
||||||
output: process.stdout,
|
|
||||||
terminal: false
|
|
||||||
});
|
|
||||||
|
|
||||||
rl.on('line', async line => {
|
|
||||||
if (line.startsWith('pkgrel')) {
|
|
||||||
let pkgrel = line.split('=')[1].trim();
|
|
||||||
// let's not deal with floats in javascript
|
|
||||||
let num = pkgrel.split('.');
|
|
||||||
if (num.length == 1) {
|
|
||||||
num.push(1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
num[1] = parseInt(num[1]) + 1;
|
|
||||||
}
|
|
||||||
lines.push(`pkgrel=${num.join('.')}`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
lines.push(line);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
rl.on('close', async () => {
|
|
||||||
await fsp.writeFile(pkgbuild, lines.join('\n') + '\n');
|
|
||||||
res();
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function isNewPackage(directory, package) {
|
|
||||||
if (!directory) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const pkgbuild = path.join(directory, package, 'PKGBUILD');
|
|
||||||
const stat = await fsp.stat(pkgbuild);
|
|
||||||
return !stat.size;
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
console.log('PKGBUILD doesn\'t exist. Assuming package is new.');
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process.argv.forEach((arg, i) => {
|
|
||||||
let iPlus = i + 1;
|
|
||||||
let args = process.argv;
|
|
||||||
if (arg === '--job' && iPlus < args.length) {
|
|
||||||
JOB = args[iPlus];
|
|
||||||
}
|
|
||||||
else if (arg === '--start' && iPlus < args.length) {
|
|
||||||
START = args[iPlus];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (JOB) {
|
|
||||||
(async function () {
|
|
||||||
let compare = null;
|
|
||||||
let job = JSON5.parse(await fsp.readFile(JOB));
|
|
||||||
job.source = job.source || 'trunk';
|
|
||||||
job.gpgpass = process.env.GPGPASS || (await getGpgPass()) || '';
|
|
||||||
let verifyJenkins = job.source === 'trunk';
|
|
||||||
let inc = job.increment;
|
|
||||||
let repo = job.repo;
|
|
||||||
let directory = job.directory || job.superrepo;
|
|
||||||
if (!repo) {
|
|
||||||
console.error(clc.redBright('Must provide `repo` destination in config!'));
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
if (inc && !directory) {
|
|
||||||
console.error(clc.redBright('Must provide `directory` path in config if increment is enabled!'));
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('artix-packy-pusher\nCory Sanin\n');
|
|
||||||
|
|
||||||
const gitea = new giteaapi(job.gitea);
|
|
||||||
if (job.source === 'trunk') {
|
|
||||||
console.log(clc.yellowBright('Running artix-checkupdates'));
|
|
||||||
compare = new checkupdates();
|
|
||||||
await compare.FetchUpgradable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// order is IMPORTANT. Must be BLOCKING.
|
|
||||||
for (let i = 0; i < (job.packages || []).length; i++) {
|
|
||||||
let lastHash = '';
|
|
||||||
let p = job.packages[i];
|
|
||||||
if (START === p) {
|
|
||||||
START = null;
|
|
||||||
}
|
|
||||||
if (START === null) {
|
|
||||||
if (compare === null || compare.IsUpgradable(p) || await isNewPackage(directory, p)) {
|
|
||||||
console.log((new Date()).toLocaleTimeString() + clc.magentaBright(` Package ${i}/${job.packages.length}`));
|
|
||||||
while (verifyJenkins) {
|
|
||||||
try {
|
|
||||||
lastHash = (await gitea.getStatus(PACKAGE_ORG, p)).sha
|
|
||||||
console.log(`current sha: ${lastHash}`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
console.log(clc.red(`Failed to get status of ${p}. Retrying...`));
|
|
||||||
await snooze(30000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(clc.yellowBright(`Pushing ${p} ...`));
|
|
||||||
if (job.source == 'trunk') {
|
|
||||||
if (inc) {
|
|
||||||
await increment(directory, p);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await runCommand('artixpkg', ['repo', 'import', p]);
|
|
||||||
}
|
|
||||||
await refreshGpg(job);
|
|
||||||
await runCommand('artixpkg', ['repo', 'add', '-p', repo, p]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
await refreshGpg(job);
|
|
||||||
await runCommand('artixpkg', ['repo', 'move', '-p', job.source, repo, p]);
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
console.log(clc.cyan(`Moving ${p} failed. Maybe nothing to move. Continuing.`));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(clc.blueBright(`${p} upgrade pushed`));
|
|
||||||
if (verifyJenkins) {
|
|
||||||
try {
|
|
||||||
await waitForBuild(gitea, p, lastHash);
|
|
||||||
console.log(clc.greenBright(`${p} built successfully.`));
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
console.error(clc.redBright(`Failed on ${p}:`));
|
|
||||||
console.error(ex);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(clc.magenta(`${p} isn't marked as upgradable. Skipping.`));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log(clc.greenBright('SUCCESS: All packages built'));
|
|
||||||
try {
|
|
||||||
await fsp.rm('signfile');
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
console.error(clc.red('failed to remove temp signfile'));
|
|
||||||
}
|
|
||||||
process.exit(0);
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.error(clc.redBright('A job file must be provided.\n--job {path/to/job.json(5)}'));
|
|
||||||
}
|
|
@@ -1,15 +1,8 @@
|
|||||||
{
|
{
|
||||||
// The Gitea API is used to tell when a package builds successfully.
|
// set source to move packages, or leave it undefined to upgrade packages
|
||||||
"gitea": {
|
"source": null,
|
||||||
"token": "youReGiteAtoKeNhERe",
|
|
||||||
"domain": "gitea.artixlinux.org"
|
|
||||||
},
|
|
||||||
// use "trunk" to import and build. Or supply a repo name to move from that repo.
|
|
||||||
"source": "trunk",
|
|
||||||
// The destination repo
|
// The destination repo
|
||||||
"repo": "world-gremlins",
|
"repo": "world-gremlins",
|
||||||
// The location for all the package repositories on your system
|
|
||||||
"directory": "/home/cory/Documents/pkg/artixlinux",
|
|
||||||
// (experimental) if set to true (and source is "trunk"),
|
// (experimental) if set to true (and source is "trunk"),
|
||||||
// package won't import from upstream and will instead do a .1 pkgrel bump on all packages.
|
// package won't import from upstream and will instead do a .1 pkgrel bump on all packages.
|
||||||
// Useful if packages were mistakenly built out of order.
|
// Useful if packages were mistakenly built out of order.
|
||||||
|
@@ -2,4 +2,4 @@
|
|||||||
APPRISE_API="http://localhost:8000"
|
APPRISE_API="http://localhost:8000"
|
||||||
APPRISE_DESTINATION="tgram://TOKEN/CHAT_ID"
|
APPRISE_DESTINATION="tgram://TOKEN/CHAT_ID"
|
||||||
|
|
||||||
curl -d "{\"title\":\"artix-packy-pusher\", \"body\":\"Job done.\", \"urls\":\"${APPRISE_DESTINATION}\"}" -H "Content-Type: application/json" "${APPRISE_API}/notify/"
|
curl -d "{\"title\":\"artix-metro\", \"body\":\"Job done.\", \"urls\":\"${APPRISE_DESTINATION}\"}" -H "Content-Type: application/json" "${APPRISE_API}/notify/"
|
180
package-lock.json
generated
180
package-lock.json
generated
@@ -1,28 +1,65 @@
|
|||||||
{
|
{
|
||||||
"name": "packagepusher",
|
"name": "artix-metro",
|
||||||
"version": "2.1.2",
|
"version": "3.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "packagepusher",
|
"name": "artix-metro",
|
||||||
"version": "2.1.2",
|
"version": "3.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"artix-checkupdates": "1.0.1",
|
||||||
"cli-color": "2.0.4",
|
"cli-color": "2.0.4",
|
||||||
"json5": "2.2.3",
|
"json5": "2.2.3",
|
||||||
"phin": "3.7.1"
|
"ky": "1.7.4"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"artix-metro": "bin/artix-metro.mjs"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@sindresorhus/tsconfig": "7.0.0",
|
||||||
|
"@types/cli-color": "2.0.6",
|
||||||
|
"@types/node": "22.10.7",
|
||||||
|
"typescript": "5.7.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/centra": {
|
"node_modules/@sindresorhus/tsconfig": {
|
||||||
"version": "2.7.0",
|
"version": "7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/centra/-/centra-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@sindresorhus/tsconfig/-/tsconfig-7.0.0.tgz",
|
||||||
"integrity": "sha512-PbFMgMSrmgx6uxCdm57RUos9Tc3fclMvhLSATYN39XsDV29B89zZ3KA89jmY0vwSGazyU+uerqwa6t+KaodPcg==",
|
"integrity": "sha512-i5K04hLAP44Af16zmDjG07E1NHuDgCM07SJAT4gY0LZSRrWYzwt4qkLem6TIbIVh0k51RkN2bF+lP+lM5eC9fw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/cli-color": {
|
||||||
|
"version": "2.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cli-color/-/cli-color-2.0.6.tgz",
|
||||||
|
"integrity": "sha512-uLK0/0dOYdkX8hNsezpYh1gc8eerbhf9bOKZ3e24sP67703mw9S14/yW6mSTatiaKO9v+mU/a1EVy4rOXXeZTA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@types/node": {
|
||||||
|
"version": "22.10.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.7.tgz",
|
||||||
|
"integrity": "sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==",
|
||||||
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.6"
|
"undici-types": "~6.20.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/artix-checkupdates": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/artix-checkupdates/-/artix-checkupdates-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-C0AxI3SfoUUekYg3ft/y4+tRjIe8uuDLvBQRSmkfNsRuBLNlEHaxhY/93JB6G4AGXp5RFLZYDnbgjakgbTLhkw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/cli-color": {
|
"node_modules/cli-color": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.4.tgz",
|
||||||
@@ -133,26 +170,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/type/-/type-2.6.0.tgz",
|
||||||
"integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ=="
|
"integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ=="
|
||||||
},
|
},
|
||||||
"node_modules/follow-redirects": {
|
|
||||||
"version": "1.15.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
|
||||||
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "individual",
|
|
||||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=4.0"
|
|
||||||
},
|
|
||||||
"peerDependenciesMeta": {
|
|
||||||
"debug": {
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/is-promise": {
|
"node_modules/is-promise": {
|
||||||
"version": "2.2.2",
|
"version": "2.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
||||||
@@ -169,6 +186,18 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ky": {
|
||||||
|
"version": "1.7.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/ky/-/ky-1.7.4.tgz",
|
||||||
|
"integrity": "sha512-zYEr/gh7uLW2l4su11bmQ2M9xLgQLjyvx58UyNM/6nuqyWFHPX5ktMjvpev3F8QWdjSsHUpnWew4PBCswBNuMQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sindresorhus/ky?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/lru-queue": {
|
"node_modules/lru-queue": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
||||||
@@ -197,18 +226,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
||||||
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
||||||
},
|
},
|
||||||
"node_modules/phin": {
|
|
||||||
"version": "3.7.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/phin/-/phin-3.7.1.tgz",
|
|
||||||
"integrity": "sha512-GEazpTWwTZaEQ9RhL7Nyz0WwqilbqgLahDM3D0hxWwmVDI52nXEybHqiN6/elwpkJBhcuj+WbBu+QfT0uhPGfQ==",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"centra": "^2.7.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/timers-ext": {
|
"node_modules/timers-ext": {
|
||||||
"version": "0.1.7",
|
"version": "0.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
||||||
@@ -222,17 +239,56 @@
|
|||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
||||||
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
||||||
|
},
|
||||||
|
"node_modules/typescript": {
|
||||||
|
"version": "5.7.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
|
||||||
|
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"tsc": "bin/tsc",
|
||||||
|
"tsserver": "bin/tsserver"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.17"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/undici-types": {
|
||||||
|
"version": "6.20.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||||
|
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"centra": {
|
"@sindresorhus/tsconfig": {
|
||||||
"version": "2.7.0",
|
"version": "7.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/centra/-/centra-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@sindresorhus/tsconfig/-/tsconfig-7.0.0.tgz",
|
||||||
"integrity": "sha512-PbFMgMSrmgx6uxCdm57RUos9Tc3fclMvhLSATYN39XsDV29B89zZ3KA89jmY0vwSGazyU+uerqwa6t+KaodPcg==",
|
"integrity": "sha512-i5K04hLAP44Af16zmDjG07E1NHuDgCM07SJAT4gY0LZSRrWYzwt4qkLem6TIbIVh0k51RkN2bF+lP+lM5eC9fw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@types/cli-color": {
|
||||||
|
"version": "2.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/cli-color/-/cli-color-2.0.6.tgz",
|
||||||
|
"integrity": "sha512-uLK0/0dOYdkX8hNsezpYh1gc8eerbhf9bOKZ3e24sP67703mw9S14/yW6mSTatiaKO9v+mU/a1EVy4rOXXeZTA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@types/node": {
|
||||||
|
"version": "22.10.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.7.tgz",
|
||||||
|
"integrity": "sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"follow-redirects": "^1.15.6"
|
"undici-types": "~6.20.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"artix-checkupdates": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/artix-checkupdates/-/artix-checkupdates-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-C0AxI3SfoUUekYg3ft/y4+tRjIe8uuDLvBQRSmkfNsRuBLNlEHaxhY/93JB6G4AGXp5RFLZYDnbgjakgbTLhkw=="
|
||||||
|
},
|
||||||
"cli-color": {
|
"cli-color": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.4.tgz",
|
||||||
@@ -337,11 +393,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"follow-redirects": {
|
|
||||||
"version": "1.15.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
|
||||||
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA=="
|
|
||||||
},
|
|
||||||
"is-promise": {
|
"is-promise": {
|
||||||
"version": "2.2.2",
|
"version": "2.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
||||||
@@ -352,6 +403,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="
|
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="
|
||||||
},
|
},
|
||||||
|
"ky": {
|
||||||
|
"version": "1.7.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/ky/-/ky-1.7.4.tgz",
|
||||||
|
"integrity": "sha512-zYEr/gh7uLW2l4su11bmQ2M9xLgQLjyvx58UyNM/6nuqyWFHPX5ktMjvpev3F8QWdjSsHUpnWew4PBCswBNuMQ=="
|
||||||
|
},
|
||||||
"lru-queue": {
|
"lru-queue": {
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
||||||
@@ -380,14 +436,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
||||||
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
||||||
},
|
},
|
||||||
"phin": {
|
|
||||||
"version": "3.7.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/phin/-/phin-3.7.1.tgz",
|
|
||||||
"integrity": "sha512-GEazpTWwTZaEQ9RhL7Nyz0WwqilbqgLahDM3D0hxWwmVDI52nXEybHqiN6/elwpkJBhcuj+WbBu+QfT0uhPGfQ==",
|
|
||||||
"requires": {
|
|
||||||
"centra": "^2.7.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"timers-ext": {
|
"timers-ext": {
|
||||||
"version": "0.1.7",
|
"version": "0.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
||||||
@@ -401,6 +449,18 @@
|
|||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
||||||
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
||||||
|
},
|
||||||
|
"typescript": {
|
||||||
|
"version": "5.7.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
|
||||||
|
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"undici-types": {
|
||||||
|
"version": "6.20.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||||
|
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
||||||
|
"dev": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
43
package.json
43
package.json
@@ -1,13 +1,44 @@
|
|||||||
{
|
{
|
||||||
"name": "packagepusher",
|
"name": "artix-metro",
|
||||||
"version": "2.1.2",
|
"version": "3.0.0",
|
||||||
"description": "Automate pushing packages to Artix",
|
"description": "Automate pushing packages to Artix",
|
||||||
"main": "index.js",
|
"keywords": [
|
||||||
"author": "Cory Sanin",
|
"artix",
|
||||||
|
"artixlinux"
|
||||||
|
],
|
||||||
|
"type": "module",
|
||||||
|
"main": "distribution/index.mjs",
|
||||||
|
"bin": {
|
||||||
|
"artix-metro": "./bin/artix-metro.mjs"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"distribution",
|
||||||
|
"bin"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Cory Sanin",
|
||||||
|
"email": "corysanin@artixlinux.org",
|
||||||
|
"url": "https://sanin.dev"
|
||||||
|
},
|
||||||
|
"homepage": "https://gitea.artixlinux.org/corysanin/artix-metro",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/CorySanin/artix-metro/issues"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://gitea.artixlinux.org/corysanin/artix-metro.git"
|
||||||
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"artix-checkupdates": "1.0.1",
|
||||||
"cli-color": "2.0.4",
|
"cli-color": "2.0.4",
|
||||||
"json5": "2.2.3",
|
"ky": "1.7.4",
|
||||||
"phin": "3.7.1"
|
"json5": "2.2.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "5.7.3",
|
||||||
|
"@sindresorhus/tsconfig": "7.0.0",
|
||||||
|
"@types/cli-color": "2.0.6",
|
||||||
|
"@types/node": "22.10.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
33
readme.md
33
readme.md
@@ -1,27 +1,42 @@
|
|||||||
# artix-packy-pusher
|
# artix-metro
|
||||||
|
|
||||||
Given a list of packages, build one at a time. Exits if a build fails.
|
Artix package pushing automation tool that waits for builds to pass before continuing in the queue.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* `artix-checkupdates` is used to skip packages without pending operations
|
||||||
|
* Package upgrades wait for successful builds before moving on to the next one
|
||||||
|
* Build failures stop execution
|
||||||
|
* Perfect for scripting large, recurring rebuilds
|
||||||
|
* Increment mode for fixing packages built completely out-of-order
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
`artix-checkupdates` is required. I highly recommend configuring it to use the developer artix mirror.
|
`artix-checkupdates` is required. I highly recommend configuring it to use the developer artix mirror.
|
||||||
It uses `artix-checkupdates` to retrieve a list of packages that actually do have updates pending. packy-pusher will skip packages that don't need to be updated.
|
|
||||||
|
|
||||||
Install node dependencies with `npm install`
|
|
||||||
|
1) Install node dependencies with `npm install`
|
||||||
|
2) Process the typescript source with `npm exec tsc`
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
Please see [example.json5](jobs/example.json5). Program can parse json5 or plain json.
|
In addition to the robust CLI, jobs can be defined in a JSON5 or plain JSON file. For recurring tasks, either a job file or a bash script with the CLI calls is recommended. See [example.json5](jobs/example.json5) for an example job file.
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
In order to sign commits, packy-pusher needs your GPG password. It can be provided via the `GPGPASS` environment variable.
|
|
||||||
|
In order to sign commits, artix-metro needs your GPG password. It can be provided via the `GPGPASS` environment variable.
|
||||||
Otherwise the program will prompt you for it on startup.
|
Otherwise the program will prompt you for it on startup.
|
||||||
|
|
||||||
Run a job:
|
Run a job:
|
||||||
```
|
```
|
||||||
node index.js --job jobs/example.json5
|
node bin/artix-metro.mjs --job jobs/example.json5
|
||||||
```
|
```
|
||||||
Run a job, skipping to a particular package:
|
Run a job, skipping to a particular package:
|
||||||
```
|
```
|
||||||
node index.js --job jobs/example.json5 --start kmail
|
node bin/artix-metro.mjs --job jobs/example.json5 --start kmail
|
||||||
```
|
```
|
||||||
|
Run an ad hoc job via the CLI:
|
||||||
|
```
|
||||||
|
node bin/artix-metro.mjs add stable libjpeg-turbo lib32-libjpeg-turbo
|
||||||
|
```
|
||||||
|
Notice that as long as the same shorthand works for all packages (e.g. stable, gremlins, goblins), repos can vary from package to package.
|
||||||
|
68
src/artoolsconf.mts
Normal file
68
src/artoolsconf.mts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import * as fsp from 'node:fs/promises';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import type { PathLike } from 'node:fs';
|
||||||
|
|
||||||
|
interface ArtoolsConf {
|
||||||
|
workspace: string;
|
||||||
|
giteaToken: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DefaultConf: ArtoolsConf = {
|
||||||
|
workspace: path.join(os.homedir(), 'artools-workspace'),
|
||||||
|
giteaToken: null
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseProperty(line: string): string {
|
||||||
|
return (line.split('=')[1] || '').trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeQuotes(str: string) {
|
||||||
|
if (
|
||||||
|
(
|
||||||
|
str.charAt(0) === '\'' ||
|
||||||
|
str.charAt(0) === '"'
|
||||||
|
) && str.charAt(0) === str.charAt(str.length - 1)) {
|
||||||
|
return str.substring(1, str.length - 1);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ArtoolsConfReader {
|
||||||
|
|
||||||
|
async readConf(): Promise<ArtoolsConf> {
|
||||||
|
const primaryLocation = path.join(os.homedir(), '.config', 'artools', 'artools-pkg.conf');
|
||||||
|
const systemConf = path.join('/', 'etc', 'artools', 'artools-pkg.conf');
|
||||||
|
try {
|
||||||
|
return await this.readConfFile(primaryLocation);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error(`artools config at "${primaryLocation}" could not be read. ${ex}\nUsing system config "${systemConf}" instead.`);
|
||||||
|
return await this.readConfFile(systemConf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async readConfFile(file: PathLike): Promise<ArtoolsConf> {
|
||||||
|
const lines = (await fsp.readFile(file)).toString().split('\n');
|
||||||
|
let workspace: string | null = null;
|
||||||
|
let giteaToken: string | null = null;
|
||||||
|
lines.forEach(l => {
|
||||||
|
switch (true) {
|
||||||
|
case l.startsWith('WORKSPACE_DIR='):
|
||||||
|
workspace = removeQuotes(parseProperty(l));
|
||||||
|
break;
|
||||||
|
case l.startsWith('GIT_TOKEN='):
|
||||||
|
giteaToken = removeQuotes(parseProperty(l));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
workspace: process.env['WORKSPACE'] || workspace || DefaultConf.workspace,
|
||||||
|
giteaToken: process.env['GIT_TOKEN'] || giteaToken || null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ArtoolsConfReader;
|
||||||
|
export { ArtoolsConfReader, DefaultConf };
|
||||||
|
export type { ArtoolsConf }
|
126
src/gitea.mts
Normal file
126
src/gitea.mts
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
import ky from 'ky';
|
||||||
|
import { snooze } from './snooze.mjs';
|
||||||
|
|
||||||
|
type CiStatus = "pending" | "success" | "error" | "failure";
|
||||||
|
|
||||||
|
interface GiteaConfig {
|
||||||
|
protocol?: string;
|
||||||
|
domain?: string;
|
||||||
|
apiPrefix?: string;
|
||||||
|
token?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Commit {
|
||||||
|
sha: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Status {
|
||||||
|
sha: string;
|
||||||
|
state: CiStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
class Gitea {
|
||||||
|
private _protocol: string;
|
||||||
|
private _domain: string;
|
||||||
|
private _apiPrefix: string;
|
||||||
|
private _token: string;
|
||||||
|
|
||||||
|
constructor(options: GiteaConfig = {}) {
|
||||||
|
this._protocol = options.protocol || 'https';
|
||||||
|
this._domain = options.domain || 'gitea.artixlinux.org';
|
||||||
|
this._apiPrefix = options.apiPrefix || '/api/v1';
|
||||||
|
this._token = options.token || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
setToken(token: string | null | undefined) {
|
||||||
|
if (token) {
|
||||||
|
this._token = token;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getHomepage() {
|
||||||
|
return `${this._protocol}://${this._domain}/`;
|
||||||
|
}
|
||||||
|
|
||||||
|
getUrlPrefix() {
|
||||||
|
return `${this._protocol}://${this._domain}${this._apiPrefix}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async getRepo(...args: string[]) {
|
||||||
|
try {
|
||||||
|
let headers: HeadersInit = {};
|
||||||
|
if (this._token) {
|
||||||
|
headers['Authorization'] = `token ${this._token}`
|
||||||
|
}
|
||||||
|
const resp = await ky.get(`${this.getUrlPrefix()}/repos/${args.join('/')}`, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
return await resp.json();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getCommits(...args: string[]): Promise<Commit[]> {
|
||||||
|
try {
|
||||||
|
let headers: HeadersInit = {};
|
||||||
|
if (this._token) {
|
||||||
|
headers['Authorization'] = `token ${this._token}`
|
||||||
|
}
|
||||||
|
const resp = await ky.get(`${this.getUrlPrefix()}/repos/${args.join('/')}/commits?limit=10`, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
return await resp.json();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getStatus(...args: string[]): Promise<Status> {
|
||||||
|
try {
|
||||||
|
let commits = await this.getCommits(...args);
|
||||||
|
let headers: HeadersInit = {};
|
||||||
|
if (this._token) {
|
||||||
|
headers['Authorization'] = `token ${this._token}`
|
||||||
|
}
|
||||||
|
const resp = await ky.get(`${this.getUrlPrefix()}/repos/${args.join('/')}/commits/${commits[0]?.sha}/status`, {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
return await resp.json();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async waitForBuild(lastHash: string, ...args: string[]): Promise<void> {
|
||||||
|
while (true) {
|
||||||
|
let status: Status | null;
|
||||||
|
try {
|
||||||
|
status = await this.getStatus(...args);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
status = null;
|
||||||
|
}
|
||||||
|
if (!status) {
|
||||||
|
await snooze(30000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (status.sha !== lastHash) {
|
||||||
|
if (status.state === 'success') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (status.state === 'failure') {
|
||||||
|
throw new Error(`Build ${status.sha} failed.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await snooze(5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Gitea;
|
||||||
|
export { Gitea };
|
||||||
|
export type { GiteaConfig, Commit, Status, CiStatus };
|
159
src/index.mts
Normal file
159
src/index.mts
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
import * as fsp from 'node:fs/promises';
|
||||||
|
import * as readline from 'node:readline/promises';
|
||||||
|
import clc from 'cli-color';
|
||||||
|
import JSON5 from 'json5';
|
||||||
|
import { Writable } from 'stream';
|
||||||
|
import { Pusher } from './pusher.mjs';
|
||||||
|
import type { Job, ArtixpkgRepo } from './pusher.mts';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompts the user to input their GPG password via stdin
|
||||||
|
* @returns a promise that resolves the password
|
||||||
|
*/
|
||||||
|
async function getGpgPass() {
|
||||||
|
let muted = false;
|
||||||
|
let mutableStdout = new Writable({
|
||||||
|
write: function (chunk, encoding, callback) {
|
||||||
|
if (!muted) {
|
||||||
|
process.stdout.write(chunk, encoding);
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let rl = readline.createInterface({
|
||||||
|
input: process.stdin,
|
||||||
|
output: mutableStdout,
|
||||||
|
terminal: true
|
||||||
|
});
|
||||||
|
const passwordPromise = rl.question(clc.yellow('Enter your GPG password: '));
|
||||||
|
muted = true;
|
||||||
|
const password = await passwordPromise;
|
||||||
|
rl.close();
|
||||||
|
console.log();
|
||||||
|
muted = false;
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function artixMetro() {
|
||||||
|
let job: Partial<Job> = {
|
||||||
|
increment: false,
|
||||||
|
packages: []
|
||||||
|
};
|
||||||
|
|
||||||
|
await (async function () {
|
||||||
|
let mode: 'add' | 'move' | null = null;
|
||||||
|
let startPkg: string | null = null;
|
||||||
|
let jobfile: string | null = null;
|
||||||
|
let skipOne = false;
|
||||||
|
let helpFlag: boolean = false;
|
||||||
|
|
||||||
|
process.argv.forEach((arg, i) => {
|
||||||
|
if (skipOne) {
|
||||||
|
skipOne = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const iPlus = i + 1;
|
||||||
|
const args = process.argv;
|
||||||
|
switch (true) {
|
||||||
|
case (arg === '--job' || arg === '-j') && iPlus < args.length:
|
||||||
|
if (jobfile) {
|
||||||
|
console.error(`multiple jobfiles provided. aborting.`);
|
||||||
|
process.exit(2);
|
||||||
|
}
|
||||||
|
jobfile = args[iPlus] as string;
|
||||||
|
skipOne = true;
|
||||||
|
break;
|
||||||
|
case arg === '--start' && iPlus < args.length:
|
||||||
|
startPkg = args[iPlus] as string;
|
||||||
|
skipOne = true;
|
||||||
|
break;
|
||||||
|
case arg === '--token' && iPlus < args.length:
|
||||||
|
job.giteaToken = args[iPlus] as string;
|
||||||
|
skipOne = true;
|
||||||
|
break;
|
||||||
|
case arg === '--workspace' && iPlus < args.length:
|
||||||
|
job.workspace = args[iPlus] as string;
|
||||||
|
skipOne = true;
|
||||||
|
break;
|
||||||
|
case arg === '--increment':
|
||||||
|
job.increment = true;
|
||||||
|
break;
|
||||||
|
case arg === '-p':
|
||||||
|
console.warn('-p option is implied.');
|
||||||
|
break;
|
||||||
|
case arg === '-h' || arg === '--help':
|
||||||
|
helpFlag = true;
|
||||||
|
break;
|
||||||
|
case arg.startsWith('-'):
|
||||||
|
console.error(`unrecognized option '${arg}'`);
|
||||||
|
process.exit(1);
|
||||||
|
case !mode && (arg === 'add' || arg === 'move'):
|
||||||
|
mode = arg;
|
||||||
|
break;
|
||||||
|
case mode === 'move' && !(job as Job).source:
|
||||||
|
job.source = arg as ArtixpkgRepo;
|
||||||
|
break;
|
||||||
|
case mode && !job.repo:
|
||||||
|
job.repo = arg as ArtixpkgRepo;
|
||||||
|
break;
|
||||||
|
case !!job.repo:
|
||||||
|
job.packages?.push(arg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (helpFlag || (!jobfile && !job.repo)) {
|
||||||
|
console.log([
|
||||||
|
`\nUsage: artix-metro [OPTIONS] [commands]...`,
|
||||||
|
'works similarly to "artixpkg repo"... but with a few tricks!',
|
||||||
|
'All package operations check if the package appears in the appropriate artix-checkupdate output.',
|
||||||
|
'Build operations don\'t proceed until the previous build succeeds. Halts on failed build.\n',
|
||||||
|
'Options',
|
||||||
|
'-j, --job <jobfile>\tread instructions from a job file. Overrides all other options except --start',
|
||||||
|
'--start <package>\tskips all packages before the provided package',
|
||||||
|
'--token <token>\t\tdefines the Gitea token to use for making calls to the Gitea API',
|
||||||
|
'--workspace <path>\tdefines the artools workspace',
|
||||||
|
'--increment\t\tenable increment mode',
|
||||||
|
'-h, --help\t\tshows this help message\n',
|
||||||
|
'Commands',
|
||||||
|
'add <destination> <pkgbase>...\t\t\tupgrade and push all packages to the specified destination',
|
||||||
|
'move <source> <destination> <pkgbase>...\tmove all packages from the source repo to the destination repo\n',
|
||||||
|
].join('\n'));
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jobfile) {
|
||||||
|
try {
|
||||||
|
job = JSON5.parse((await fsp.readFile(jobfile)).toString());
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error('A jobfile was provided but could not be read:');
|
||||||
|
console.error(ex);
|
||||||
|
process.exit(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startPkg && job.packages) {
|
||||||
|
const startPos = job.packages.indexOf(startPkg);
|
||||||
|
job.packages.splice(0, startPos < 0 ? job.packages.length : startPos)
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
let pusher = new Pusher({
|
||||||
|
gpgpass: process.env['GPGPASS'] || (await getGpgPass()) || ''
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('artix-metro\nCory Sanin\n');
|
||||||
|
|
||||||
|
try {
|
||||||
|
await pusher.runJob(job as Job);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error(clc.red('job threw exception:'));
|
||||||
|
console.error(ex);
|
||||||
|
process.exit(5)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default artixMetro;
|
||||||
|
export { artixMetro };
|
228
src/pusher.mts
Normal file
228
src/pusher.mts
Normal file
@@ -0,0 +1,228 @@
|
|||||||
|
import * as fs from 'node:fs';
|
||||||
|
import * as fsp from 'node:fs/promises';
|
||||||
|
import * as readline from 'node:readline/promises';
|
||||||
|
import clc from 'cli-color';
|
||||||
|
import path from 'node:path';
|
||||||
|
import os from 'node:os';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import { Checkupdates } from 'artix-checkupdates';
|
||||||
|
import { Gitea } from './gitea.mjs'
|
||||||
|
import { ArtoolsConfReader, DefaultConf } from './artoolsconf.mjs';
|
||||||
|
import { snooze } from './snooze.mjs';
|
||||||
|
import type { ArtixRepo } from 'artix-checkupdates';
|
||||||
|
import type { ArtoolsConf } from './artoolsconf.mts';
|
||||||
|
|
||||||
|
interface PusherConfig {
|
||||||
|
gpgpass?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArtixpkgRepo = ArtixRepo | 'stable' | 'gremlins' | 'goblins';
|
||||||
|
|
||||||
|
interface Job extends Partial<ArtoolsConf> {
|
||||||
|
source?: ArtixpkgRepo;
|
||||||
|
repo: ArtixpkgRepo;
|
||||||
|
increment: boolean;
|
||||||
|
packages: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const PACKAGE_ORG = 'packages';
|
||||||
|
const SIGNATUREEXPIRY = 30000;//in ms
|
||||||
|
const SIGNFILE = path.join(os.tmpdir(), 'signfile');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a command (as a promise).
|
||||||
|
* @param command command to run
|
||||||
|
* @param args args to pass
|
||||||
|
* @returns true if success
|
||||||
|
*/
|
||||||
|
function runCommand(command: string, args: string[] = []): Promise<boolean> {
|
||||||
|
return new Promise((res, _) => {
|
||||||
|
let proc = spawn(command, args, { stdio: ['ignore', process.stdout, process.stderr] });
|
||||||
|
proc.on('exit', code => res(code === 0));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats text to be sent as a parameter to some command
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
function escapeCommandParam(param: string) {
|
||||||
|
return param.replace(/\\/g, "\\\\");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Pusher {
|
||||||
|
private _gitea: Gitea | null;
|
||||||
|
private _lastSign: number = 0;
|
||||||
|
private _config: PusherConfig;
|
||||||
|
private _artools: ArtoolsConf;
|
||||||
|
private _constructed: Promise<void>;
|
||||||
|
|
||||||
|
constructor(config: PusherConfig = {}) {
|
||||||
|
this._gitea = null;
|
||||||
|
this._artools = DefaultConf
|
||||||
|
this._config = config;
|
||||||
|
this._constructed = (async () => {
|
||||||
|
try {
|
||||||
|
this._artools = await (new ArtoolsConfReader()).readConf();
|
||||||
|
this._gitea = new Gitea({
|
||||||
|
token: this._artools.giteaToken || ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
this._artools = DefaultConf
|
||||||
|
console.error(ex);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
async refreshGpg() {
|
||||||
|
let currentTime = (new Date()).getTime();
|
||||||
|
if (this._config.gpgpass && currentTime - this._lastSign > SIGNATUREEXPIRY) {
|
||||||
|
console.log(clc.cyan('Refreshing signature...'));
|
||||||
|
await runCommand('touch', [SIGNFILE]);
|
||||||
|
await runCommand('gpg', ['-a', '--passphrase', escapeCommandParam(this._config.gpgpass), '--batch', '--pinentry-mode', 'loopback', '--detach-sign', SIGNFILE]);
|
||||||
|
await fsp.rm(`${SIGNFILE}.asc`);
|
||||||
|
this._lastSign = currentTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
increment(pkg: string): Promise<void> {
|
||||||
|
return new Promise(async (res, _) => {
|
||||||
|
const pkgbuild = path.join(this._artools.workspace, 'artixlinux', pkg, 'PKGBUILD');
|
||||||
|
let lines: string[] = [];
|
||||||
|
|
||||||
|
const rl = readline.createInterface({
|
||||||
|
input: fs.createReadStream(pkgbuild),
|
||||||
|
output: process.stdout,
|
||||||
|
terminal: false
|
||||||
|
});
|
||||||
|
|
||||||
|
rl.on('line', async line => {
|
||||||
|
if (line.trim().startsWith('pkgrel')) {
|
||||||
|
const pkgrelLine = line.split('=');
|
||||||
|
if (pkgrelLine.length <= 1) {
|
||||||
|
throw new Error(`Failed to parse pkgrel line: \n${line}`);
|
||||||
|
}
|
||||||
|
const pkgrel = (pkgrelLine[1] as string).trim();
|
||||||
|
// let's not deal with floats in javascript
|
||||||
|
let num = pkgrel.split('.');
|
||||||
|
if (num.length > 1) {
|
||||||
|
num[1] = `${parseInt(num[1] as string) + 1}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
num.push('1');
|
||||||
|
}
|
||||||
|
lines.push(`pkgrel=${num.join('.')}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lines.push(line);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
rl.on('close', async () => {
|
||||||
|
await fsp.writeFile(pkgbuild, lines.join('\n') + '\n');
|
||||||
|
res();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async isNewPackage(pkg: string) {
|
||||||
|
const pkgbuild = path.join(this._artools.workspace, 'artixlinux', pkg, 'PKGBUILD');
|
||||||
|
try {
|
||||||
|
const stat = await fsp.stat(pkgbuild);
|
||||||
|
return !stat.size;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
console.log('PKGBUILD doesn\'t exist. Assuming package is new.');
|
||||||
|
console.info(`checked ${pkgbuild}`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async runJob(job: Job) {
|
||||||
|
await this._constructed;
|
||||||
|
const checkupdates = new Checkupdates();
|
||||||
|
const gitea = this._gitea as Gitea;
|
||||||
|
|
||||||
|
this._artools.workspace = job.workspace || this._artools.workspace;
|
||||||
|
gitea.setToken(job.giteaToken);
|
||||||
|
|
||||||
|
if (!job.repo) {
|
||||||
|
throw new Error('Must provide `repo` destination in config!');
|
||||||
|
}
|
||||||
|
if (job.increment && !this._artools?.workspace) {
|
||||||
|
throw new Error('Must provide `directory` path in config if increment is enabled!');
|
||||||
|
}
|
||||||
|
if (job.increment && job.source) {
|
||||||
|
throw new Error('increment can\'t be set to true for a move operation. Set increment to false or remove the source repo.');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(clc.yellowBright('Running artix-checkupdates'));
|
||||||
|
const actionable = job.increment ? job.packages : (await (!!job.source ? checkupdates.fetchMovable() : checkupdates.fetchUpgradable())).map(res => res.basename);
|
||||||
|
|
||||||
|
// order is IMPORTANT. Must be BLOCKING.
|
||||||
|
for (let i = 0; i < (job.packages || []).length; i++) {
|
||||||
|
const p: string = job.packages[i] as string;
|
||||||
|
let lastHash: string = '';
|
||||||
|
if (!job.increment && !actionable.includes(p) && ! await this.isNewPackage(p)) {
|
||||||
|
console.log(clc.magenta(`${p} isn't marked as upgradable. Skipping.`));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
console.log((new Date()).toLocaleTimeString() + clc.magentaBright(` Package ${i}/${job.packages.length}`));
|
||||||
|
while (!job.source) {
|
||||||
|
try {
|
||||||
|
lastHash = (await gitea.getStatus(PACKAGE_ORG, p)).sha
|
||||||
|
console.log(`current sha: ${lastHash}`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
console.log(clc.red(`Failed to get status of ${p}. Retrying...`));
|
||||||
|
await snooze(30000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(clc.yellowBright(`Pushing ${p} ...`));
|
||||||
|
if (job.source) {
|
||||||
|
try {
|
||||||
|
await this.refreshGpg();
|
||||||
|
await runCommand('artixpkg', ['repo', 'move', '-p', job.source, job.repo, p]);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
console.log(clc.cyan(`Moving ${p} failed.`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (job.increment) {
|
||||||
|
await this.increment(p);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await runCommand('artixpkg', ['repo', 'import', p]);
|
||||||
|
}
|
||||||
|
await this.refreshGpg();
|
||||||
|
await runCommand('artixpkg', ['repo', 'add', '-p', job.repo, p]);
|
||||||
|
}
|
||||||
|
console.log(clc.blueBright(`${p} commit pushed`));
|
||||||
|
if (!job.source) {
|
||||||
|
try {
|
||||||
|
await gitea.waitForBuild(lastHash, PACKAGE_ORG, p)
|
||||||
|
console.log(clc.greenBright(`${p} built successfully.`));
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
console.error(clc.redBright(`Failed on ${p} : ${gitea.getHomepage()}${PACKAGE_ORG}/${p}`));
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(clc.greenBright('SUCCESS: All packages built'));
|
||||||
|
try {
|
||||||
|
await fsp.rm(SIGNFILE);
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
console.error(clc.red('failed to remove temp signfile'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Pusher;
|
||||||
|
export { Pusher };
|
||||||
|
export type { PusherConfig, Job, ArtixpkgRepo };
|
11
src/snooze.mts
Normal file
11
src/snooze.mts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Sleep equivalent as a promise
|
||||||
|
* @param ms Number of ms
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
function snooze(ms: number): Promise<void> {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
export default snooze;
|
||||||
|
export { snooze };
|
12
tsconfig.dist.json
Normal file
12
tsconfig.dist.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"sourceMap": true,
|
||||||
|
"inlineSources": true,
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./distribution"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src"
|
||||||
|
]
|
||||||
|
}
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "@sindresorhus/tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"exactOptionalPropertyTypes": true
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src"
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user