mirror of
https://github.com/yuzu-emu/citra-qt-installer.git
synced 2024-11-22 06:25:36 +01:00
Reworked logic to detect if there are any releases to publish.
This commit is contained in:
parent
ed45e8f6b8
commit
9c98fa2144
@ -7,7 +7,7 @@ const zip_bin = require('7zip-bin').path7za;
|
|||||||
|
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
logger.exitOnError = false;
|
logger.exitOnError = false;
|
||||||
logger.add(logger.transports.File, { filename: './qt-installer-repository.log' });
|
logger.add(logger.transports.File, { filename: '/var/log/citra-qt-installer/citra-qt-installer-repository.log' });
|
||||||
|
|
||||||
const distDir = "./dist";
|
const distDir = "./dist";
|
||||||
|
|
||||||
@ -46,9 +46,6 @@ function getTopResultFor(jsonData, platform) {
|
|||||||
return {"notFound": true};
|
return {"notFound": true};
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.removeSync(distDir);
|
|
||||||
mkdirIfNotExists(distDir);
|
|
||||||
|
|
||||||
// The Qt Installer Framework is a pain to build or download.
|
// The Qt Installer Framework is a pain to build or download.
|
||||||
// Because all we need are a few 7-zipped + xml files, we might as well generate them for ourselves.
|
// Because all we need are a few 7-zipped + xml files, we might as well generate them for ourselves.
|
||||||
let targets = [
|
let targets = [
|
||||||
@ -79,6 +76,8 @@ let targets = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
async function execute() {
|
async function execute() {
|
||||||
|
mkdirIfNotExists(distDir);
|
||||||
|
|
||||||
// Get Git information
|
// Get Git information
|
||||||
logger.debug("Getting release info...");
|
logger.debug("Getting release info...");
|
||||||
for (result_key in targets) {
|
for (result_key in targets) {
|
||||||
@ -87,10 +86,15 @@ async function execute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Building metadata...");
|
logger.debug("Building metadata...");
|
||||||
|
|
||||||
|
// If updates available is still false at the end of the foreach loop
|
||||||
|
// then that means no releases have been made -- nothing to do.
|
||||||
|
var updatesAvailable = false;
|
||||||
|
|
||||||
// Updates.xml
|
// Updates.xml
|
||||||
let updates = [
|
let updates = [
|
||||||
{"ApplicationName": "{AnyApplication}"},
|
{"ApplicationName": "{AnyApplication}"},
|
||||||
{"ApplicationVersion": "1.0.0"}, // Separate from nightly/be versions
|
{"ApplicationVersion": "1.0.0"}, // Separate from nightly / canary versions
|
||||||
{"Checksum": false} // As they are pulled straight from Github
|
{"Checksum": false} // As they are pulled straight from Github
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -105,17 +109,21 @@ async function execute() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Building release information for ${name}.`);
|
|
||||||
const scriptName = platform + "-" + target_source.ScriptName;
|
const scriptName = platform + "-" + target_source.ScriptName;
|
||||||
|
|
||||||
// Build 7zip file
|
|
||||||
const version = release_data.release_id;
|
const version = release_data.release_id;
|
||||||
|
const targetMetadataPath = `${distDir}/${name}/${version}meta.7z`;
|
||||||
|
|
||||||
|
if (fs.existsSync(targetMetadataPath)) {
|
||||||
|
logger.debug(`Metadata information already exists for ${name} ${version}, skipping.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(`Building release information for ${name} ${version}.`);
|
||||||
|
updatesAvailable = true;
|
||||||
|
|
||||||
// Build directory structure
|
// Build directory structure
|
||||||
mkdirIfNotExists(`${distDir}/${name}`);
|
mkdirIfNotExists(`${distDir}/${name}`);
|
||||||
|
|
||||||
logger.debug(`Copying files for ${name}`);
|
|
||||||
|
|
||||||
// Copy license
|
// Copy license
|
||||||
fs.copySync("license.txt", `${distDir}/${name}/license.txt`);
|
fs.copySync("license.txt", `${distDir}/${name}/license.txt`);
|
||||||
fs.copySync("scripts/" + scriptName + ".qs", `${distDir}/${name}/installscript.qs`);
|
fs.copySync("scripts/" + scriptName + ".qs", `${distDir}/${name}/installscript.qs`);
|
||||||
@ -127,10 +135,8 @@ async function execute() {
|
|||||||
const sha = sha1("meta.7z");
|
const sha = sha1("meta.7z");
|
||||||
|
|
||||||
// Setup final structure
|
// Setup final structure
|
||||||
mkdirIfNotExists(`${distDir}/${name}`);
|
|
||||||
fs.moveSync("meta.7z", `${distDir}/${name}/${version}meta.7z`);
|
|
||||||
|
|
||||||
logger.debug(`Creating target metadata for ${name}`);
|
logger.debug(`Creating target metadata for ${name}`);
|
||||||
|
fs.moveSync("meta.7z", targetMetadataPath);
|
||||||
|
|
||||||
// Create metadata
|
// Create metadata
|
||||||
let target = [];
|
let target = [];
|
||||||
@ -158,18 +164,21 @@ async function execute() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatesXml = xml({"Updates": updates}, {indent: " "});
|
if (updatesAvailable) {
|
||||||
|
const updatesXml = xml({"Updates": updates}, {indent: " "});
|
||||||
|
|
||||||
// Save Updates.xml
|
// Save Updates.xml
|
||||||
fs.writeFile(`${distDir}/Updates.xml`, updatesXml, function (err) {
|
fs.writeFile(`${distDir}/Updates.xml`, updatesXml, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
logger.info('Wrote a new Updates.xml file -- updates are available.');
|
||||||
|
} else {
|
||||||
|
logger.info('No updates are available -- nothing to do.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
execute().then(function() {
|
execute().catch((err) => {
|
||||||
logger.info(`Completed repository creation at ${distDir}.`);
|
|
||||||
}).catch((err) => {
|
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user