diff --git a/requirements.txt b/requirements.txt index 32042d42..840037ee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,3 +10,5 @@ pynliner==0.8.0 Babel==2.6.0 bleach==3.1.4 PyYAML==3.13 +zstandard==0.23.0 +rpmfile==2.1.0 diff --git a/templates/downloads/js/yum.js b/templates/downloads/js/yum.js index ddcff2fd..577dc616 100644 --- a/templates/downloads/js/yum.js +++ b/templates/downloads/js/yum.js @@ -55,112 +55,135 @@ function uses_systemd(plat) { } function get_platform_text(p) { - var a = p.split('-'); + const a = p.split('-'); return get_platform_name(a[0], a[1]) + ' version ' + a[1]; } window.onload = function() { - for (var p in supported_versions) { - var opt = document.createElement('option'); - opt.text = supported_versions[p]; - document.getElementById('version').add(opt); - } - - loadPlatforms(); - archChanged(); + const platbox = document.getElementById('platform'); + const platkeys = Object.keys(repodata['platforms']).sort(); + + let opt = document.createElement('option'); + opt.text = '* Select your platform'; + opt.value = "-1"; + platbox.add(opt); + + for (const pp in platkeys) { + opt = document.createElement('option'); + opt.text = get_platform_text(platkeys[pp]); + opt.value = platkeys[pp]; + platbox.add(opt); + } + + platChanged(); } -function verChanged() { - /* Just update like the architecture changed */ +function platChanged() { + const plat = document.getElementById('platform').value; + const archbox = document.getElementById('arch'); + + while (archbox.options.length > 0) { + archbox.options.remove(0); + } + + if (!plat || plat === "-1") { archChanged(); -} + return; + } -function loadPlatforms() { - var platbox = document.getElementById('platform'); - - while (platbox.options.length > 0) { - platbox.options.remove(0); - } - var opt = document.createElement('option'); - opt.text = '* Select your platform'; - opt.value = -1; - platbox.add(opt); - - platkeys = Object.keys(repodata['platforms']).sort(); - for (var pp in platkeys) { - var opt = document.createElement('option'); - opt.text = get_platform_text(platkeys[pp]); - opt.value = platkeys[pp]; - platbox.add(opt); - } - - platChanged(); -} + let opt = document.createElement('option'); + opt.text = '* Select your architecture'; + opt.value = "-1"; + archbox.add(opt); -function platChanged() { - var plat = document.getElementById('platform').value; - var archbox = document.getElementById('arch'); + for (const a in repodata['platforms'][plat].sort((a, b) => a['arch'].localeCompare(b['arch']))) { + opt = document.createElement('option'); + opt.text = opt.value = repodata['platforms'][plat][a]['arch']; + archbox.add(opt); + } - while (archbox.options.length > 0) { - archbox.options.remove(0); - } + archChanged(); +} - if (plat == -1) { - archChanged(); - return; - } +function archChanged() { + const plat = document.getElementById('platform').value; + const arch = document.getElementById('arch').value; + const verbox = document.getElementById('version'); + + while (verbox.options.length > 0) { + verbox.options.remove(0); + } + + if (!arch || arch === "-1") { + verChanged(); + return; + } + + let opt = document.createElement('option'); + opt.text = '* Select your required PostgreSQL version'; + opt.value = "-1"; + verbox.add(opt); + + let versions = []; + for (const a in repodata['platforms'][plat]) { + if (repodata['platforms'][plat][a]['arch'] === arch) { + versions = repodata['platforms'][plat][a]['versions']; + break; + } + } - for (a in repodata['platforms'][plat].sort().reverse()) { - var opt = document.createElement('option'); - opt.text = opt.value = repodata['platforms'][plat][a]; - archbox.add(opt); - } + for (const a in versions.sort((a, b) => parseInt(a) - parseInt(b))) { + if (supported_versions.includes(parseInt(versions[a]))) { + opt = document.createElement('option'); + opt.text = opt.value = versions[a]; + verbox.add(opt); + } + } - archChanged(); + verChanged(); } -function archChanged() { - var ver = document.getElementById('version').value; - var plat = document.getElementById('platform').value; - var arch = document.getElementById('arch').value; - var scriptBox = document.getElementById('script-box') - - if (!plat || plat == -1) { - document.getElementById('copy-btn').style.display = 'none'; - scriptBox.innerHTML = 'Select version and platform above'; - return; - } - - var pinfo = repodata['platforms'][plat]; - var shortver = ver.replace('.', ''); - - var url = 'https://download.postgresql.org/pub/repos/yum/reporpms/' + plat + '-' + arch + '/pgdg-' + get_rpm_prefix(plat) +'-repo-latest.noarch.rpm'; - - var installer = get_installer(plat); - scriptBox.innerHTML = '# Install the repository RPM:\n'; - scriptBox.innerHTML += 'sudo ' + installer + ' install -y ' + url + '\n\n'; - - if (disable_module_on(plat)) { - scriptBox.innerHTML += '# Disable the built-in PostgreSQL module:\n'; - scriptBox.innerHTML += 'sudo dnf -qy module disable postgresql\n\n'; - } - - scriptBox.innerHTML += '# Install PostgreSQL:\n'; - scriptBox.innerHTML += 'sudo ' + installer + ' install -y postgresql' + shortver + '-server\n\n'; - - scriptBox.innerHTML += '# Optionally initialize the database and enable automatic start:\n'; - if (uses_systemd(plat)) { - var setupcmd = 'postgresql-' + shortver + '-setup'; - if (ver < 10) { - setupcmd = 'postgresql' + shortver + '-setup'; - } - scriptBox.innerHTML += 'sudo /usr/pgsql-' + ver + '/bin/' + setupcmd + ' initdb\nsudo systemctl enable postgresql-' + ver + '\nsudo systemctl start postgresql-' + ver; - } - else { - scriptBox.innerHTML += 'sudo service postgresql-' + ver + ' initdb\nsudo chkconfig postgresql-' + ver + ' on\nsudo service postgresql-' + ver + ' start'; - } - - document.getElementById('copy-btn').style.display = 'block'; +function verChanged() { + const ver = document.getElementById('version').value; + const plat = document.getElementById('platform').value; + const arch = document.getElementById('arch').value; + const scriptBox = document.getElementById('script-box'); + + if (!ver || ver === "-1") { + document.getElementById('copy-btn').style.display = 'none'; + scriptBox.innerHTML = 'Select platform, architecture, and version above'; + return; + } + + const shortver = ver.replace('.', ''); + + const url = 'https://download.postgresql.org/pub/repos/yum/reporpms/' + plat + '-' + arch + '/pgdg-' + get_rpm_prefix(plat) +'-repo-latest.noarch.rpm'; + + const installer = get_installer(plat); + scriptBox.innerHTML = '# Install the repository RPM:\n'; + scriptBox.innerHTML += 'sudo ' + installer + ' install -y ' + url + '\n\n'; + + if (disable_module_on(plat)) { + scriptBox.innerHTML += '# Disable the built-in PostgreSQL module:\n'; + scriptBox.innerHTML += 'sudo dnf -qy module disable postgresql\n\n'; + } + + scriptBox.innerHTML += '# Install PostgreSQL:\n'; + scriptBox.innerHTML += 'sudo ' + installer + ' install -y postgresql' + shortver + '-server\n\n'; + + scriptBox.innerHTML += '# Optionally initialize the database and enable automatic start:\n'; + if (uses_systemd(plat)) { + let setupcmd = 'postgresql-' + shortver + '-setup'; + if (ver < 10) { + setupcmd = 'postgresql' + shortver + '-setup'; + } + scriptBox.innerHTML += 'sudo /usr/pgsql-' + ver + '/bin/' + setupcmd + ' initdb\nsudo systemctl enable postgresql-' + ver + '\nsudo systemctl start postgresql-' + ver; + } + else { + scriptBox.innerHTML += 'sudo service postgresql-' + ver + ' initdb\nsudo chkconfig postgresql-' + ver + ' on\nsudo service postgresql-' + ver + ' start'; + } + + document.getElementById('copy-btn').style.display = 'block'; } /* Event handlers */ diff --git a/templates/pages/download/linux/redhat.html b/templates/pages/download/linux/redhat.html index 3623bb50..e352dccb 100644 --- a/templates/pages/download/linux/redhat.html +++ b/templates/pages/download/linux/redhat.html @@ -54,9 +54,9 @@ using Fedora for server deployments. To use the PostgreSQL Yum Repository, follow these steps: