diff --git a/pgweb/downloads/views.py b/pgweb/downloads/views.py index 63d69981..0ca19714 100644 --- a/pgweb/downloads/views.py +++ b/pgweb/downloads/views.py @@ -192,6 +192,13 @@ def mirrorselect(request, path): return HttpResponseRedirect("https://ftp.postgresql.org/pub/%s" % path) +# Render javascript for yum downloads +def yum_js(request): + with open(settings.YUM_JSON) as f: + jsonstr = f.read() + return render_to_response('downloads/js/yum.js', { + 'json': jsonstr, + }, content_type='application/json') ####### # Product catalogue diff --git a/pgweb/urls.py b/pgweb/urls.py index a8b18df1..d669f132 100644 --- a/pgweb/urls.py +++ b/pgweb/urls.py @@ -36,6 +36,7 @@ urlpatterns = patterns('', (r'^applications-v2.xml$', 'pgweb.downloads.views.applications_v2_xml'), (r'^download/uploadftp/', 'pgweb.downloads.views.uploadftp'), (r'^download/uploadyum/', 'pgweb.downloads.views.uploadyum'), + (r'^download/js/yum.js', 'pgweb.downloads.views.yum_js'), (r'^docs/$', 'pgweb.docs.views.root'), (r'^docs/manuals/$', 'pgweb.docs.views.manuals'), diff --git a/templates/downloads/js/yum.js b/templates/downloads/js/yum.js new file mode 100644 index 00000000..1a34f558 --- /dev/null +++ b/templates/downloads/js/yum.js @@ -0,0 +1,95 @@ +var repodata = {{json|safe}}; + +window.onload = function() { + versions = Object.keys(repodata['reporpms']).sort().reverse(); + for (var p in versions) { + var opt = document.createElement('option'); + opt.text = versions[p]; + document.getElementById('version').add(opt); + } + + verChanged(); +} + +function verChanged() { + var newver = document.getElementById('version').value; + 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); + + plats = Object.keys(repodata['reporpms'][newver]).sort( + function(a,b) { + return repodata['platforms'][a].s - repodata['platforms'][b].s; + } + ); + for (p in plats) { + var opt = document.createElement('option'); + opt.text = repodata['platforms'][plats[p]].t; + opt.value = plats[p]; + platbox.add(opt); + } + + platChanged(); +} + +function platChanged() { + var ver = document.getElementById('version').value; + var plat = document.getElementById('platform').value; + var archbox = document.getElementById('arch'); + + while (archbox.options.length > 0) { + archbox.options.remove(0); + } + + if (plat == -1) { + archChanged(); + return; + } + + var platname = repodata['platforms'][plat].t; + + archs = Object.keys(repodata['reporpms'][ver][plat]).sort().reverse(); + for (a in archs) { + var opt = document.createElement('option'); + opt.text = archs[a]; + opt.value = archs[a]; + archbox.add(opt); + } + + archChanged(); +} + +function archChanged() { + var ver = document.getElementById('version').value; + var plat = document.getElementById('platform').value; + var arch = document.getElementById('arch').value; + + if (plat == -1) { + document.getElementById('reporpm').innerHTML = 'Select version and platform above'; + document.getElementById('clientpackage').innerHTML = 'Select version and platform above'; + document.getElementById('serverpackage').innerHTML = 'Select version and platform above'; + document.getElementById('initdb').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/' + ver + '/' + pinfo['p'] + '-' + arch + '/pgdg-' + pinfo['f'] + shortver + '-' + ver + '-' + repodata['reporpms'][ver][plat][arch] + '.noarch.rpm'; + + document.getElementById('reporpm').innerHTML = pinfo['i'] + ' install ' + url; + document.getElementById('clientpackage').innerHTML = pinfo['i'] + ' install postgresql' + shortver; + document.getElementById('serverpackage').innerHTML = pinfo['i'] + ' install postgresql' + shortver + '-server'; + if (pinfo.d) { + document.getElementById('initdb').innerHTML = '/usr/pgsql-' + ver + '/bin/postgresql' + shortver + '-setup initdb
systemctl enable postgresql-' + ver + '
systemctl start postgresql-' + ver; + } + else { + document.getElementById('initdb').innerHTML = 'service postgresql-' + ver + ' initdb
chkconfig postgresql-' + ver + ' on
service postgresql-' + ver + ' start'; + } +} diff --git a/templates/pages/download/linux/redhat.html b/templates/pages/download/linux/redhat.html index 31141aa7..c2940550 100644 --- a/templates/pages/download/linux/redhat.html +++ b/templates/pages/download/linux/redhat.html @@ -1,5 +1,8 @@ {%extends "base/page.html"%} {%block title%}Linux downloads (Red Hat family){%endblock%} +{%block extrahead%} + +{%endblock%} {%block contents%}

Linux downloads (Red Hat family)

@@ -16,8 +19,7 @@ supported versions for the most common distributions.

PostgreSQL Yum Repository

-If the version supplied by your operating system is not the one you want, -you can use the PostgreSQL Yum Repository. This repository will integrate +This repository will integrate with your normal systems and patch management, and provide automatic updates for all supported versions of PostgreSQL throughout the support lifetime of PostgreSQL. @@ -30,58 +32,26 @@ on Fedora, all versions are not available on this platform, and we recommend not using Fedora for server deployments.

-To use the yum repository, you must first install the repository RPM. -To do this, download the correct RPM from the -repository RPM listing, -and install it with commands like: -

-

-On RHEL and its derivatives: - -yum install https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm - -

-

-On Fedora, - -dnf install https://download.postgresql.org/pub/repos/yum/9.6/fedora/fedora-25-x86_64/pgdg-fedora96-9.6-3.noarch.rpm - -

-

-Once this is done, you can proceed to install and update packages the -same way as the ones included in the distribution. -

-

-For RHEL and its derivatives: - -yum install postgresql96-server postgresql96-contrib
-(or yum groupinstall "PostgreSQL Database Server 9.6 PGDG")
-service postgresql-9.6 initdb
-chkconfig postgresql-9.6 on -service postgresql-9.6 start -
-or, on Fedora 24 and other later derived distributions:
- -dnf install postgresql96-server postgresql96-contrib
-(or dnf groupinstall "PostgreSQL Database Server 9.6 PGDG")
-/usr/pgsql-9.6/bin/postgresql96-setup initdb
-systemctl enable postgresql-9.6.service
-systemctl start postgresql-9.6.service -
-

-

-Package names in the -PostgreSQL yum repository follows the same standard as the ones included -in the main repositories, but include the version number, such as: +To use the yum repository, follow these steps:

-

Included in distribution

These distributions all include PostgreSQL by default. To install