mirror of
https://github.com/Slava-Shchipunov/awg-openwrt.git
synced 2026-03-14 01:13:09 +00:00
fix index.js to obtain pkgarch value from index.json instead of package name (#113)
This commit is contained in:
30
index.js
30
index.js
@@ -52,19 +52,27 @@ async function getSubtargets(target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getDetails(target, subtarget) {
|
async function getDetails(target, subtarget) {
|
||||||
const packagesUrl = `${url}${target}/${subtarget}/packages/`;
|
// pkgarch from packages/index.json
|
||||||
const $ = await fetchHTML(packagesUrl);
|
// for apk-based is required change (should work also for ipk-based)
|
||||||
let vermagic = '';
|
const indexUrl = `${url}${target}/${subtarget}/packages/index.json`;
|
||||||
let pkgarch = '';
|
let pkgarch = '';
|
||||||
|
try {
|
||||||
$('a').each((index, element) => {
|
const { data } = await axios.get(indexUrl, { responseType: 'json' });
|
||||||
const name = $(element).attr('href');
|
pkgarch = data.architecture || '';
|
||||||
if (name && name.startsWith('kernel_')) {
|
} catch (e) {
|
||||||
const vermagicMatch = name.match(/kernel_\d+\.\d+\.\d+(?:-\d+)?[-~]([a-f0-9]+)(?:-r\d+)?_([a-zA-Z0-9_-]+)\.ipk$/);
|
// keep pkgarch empty
|
||||||
if (vermagicMatch) {
|
|
||||||
vermagic = vermagicMatch[1];
|
|
||||||
pkgarch = vermagicMatch[2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vermagic from kmods directory name (more reliable than parsing kernel filename)
|
||||||
|
const kmodsUrl = `${url}${target}/${subtarget}/kmods/`;
|
||||||
|
const $ = await fetchHTML(kmodsUrl);
|
||||||
|
let vermagic = '';
|
||||||
|
|
||||||
|
$('table tr td.n a').each((_, el) => {
|
||||||
|
const name = $(el).attr('href');
|
||||||
|
if (name && name.endsWith('/')) {
|
||||||
|
vermagic = name.slice(0, -1);
|
||||||
|
return false; // break
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user