You are not logged in.

#1 2021-06-12 07:51:55

aquilarubra
Member
From: Trieste, Italy
Registered: 2018-11-24
Posts: 86

help with PKGBUILD

Hi, I submitted a package to the AUR and it was deleted. The requester said: "particularly horrible pkgbuild, what is installed as /usr/bin/pgadmin4 is a shell script that perform "pip install
pgadmin4" and other commands"

I need help figuring out what is so horrible in my pkgbuild and how to improve it.

Secondary thing is, why should be a package that performs a pip install be deleted? Nowhere in pkgbuild guidelines is specified that pip installations are not allowed. Is that a reason to ban a package?

Here is my PKGBUILD (some parts are similar to another package that was not deleted):

_pkgname=pgadmin4
pkgname=${_pkgname}-latest
pkgver=999
pkgrel=0
pkgdesc='Comprehensive design and management interface for PostgreSQL. Self-updating. Opens the server in a terminal and launches the default browser'
url='https://www.pgadmin.org/'
arch=('x86_64')
license=('custom')
replaces=("${_pkgname}")
conflicts=("${_pkgname}" "pgadmin4-last")
provides=("${_pkgname}=${pkgver}")
depends=('postgresql-libs' 'hicolor-icon-theme' 'python' 'python-pip' 'xterm')
makedepends=('imagemagick')
source=('pgadmin4'
	'pgadmin4.desktop'
	'pgadmin4.png')
sha512sums=('b130d1fcd787f2dcfbe868a615a7bc1374583740020c08191ecb8ac97542346279b27362baf5fea4bb54fba1317c9dbc04b922b85e8c0b8e97b8d8294a19abec'
            'cf0a738031ed11456a3f0fd554af76c81a5ecd707c59f4510e80692bc5feb75d9eba7503fe8f73fc8525733fa2c884b02593af113a6f2b8b8edd60735ae5205f'
            '583348ae0786ed948abc8416afd9f10e989b08fd3b6fd357c3d1c42e1235e303656e8d324a11515d19aa8dd60a1cfaf8b50da534eb2456ba777b604f5c580d93')

package() {
  cd ${pkgdir}
  install -Dm 755 "${srcdir}/pgadmin4" -t "${pkgdir}/usr/bin"
  install -dm 755 "${pkgdir}/usr/share/icons/hicolor/"{'256x256/apps','48x48/apps','32x32/apps','16x16/apps'}
  convert "${srcdir}/pgadmin4.png" -resize 256x265 "${pkgdir}/usr/share/icons/hicolor/256x256/apps/pgadmin4.png"
  convert "${srcdir}/pgadmin4.png" -resize 48x48 "${pkgdir}/usr/share/icons/hicolor/48x48/apps/pgadmin4.png"
  convert "${srcdir}/pgadmin4.png" -resize 32x32 "${pkgdir}/usr/share/icons/hicolor/32x32/apps/pgadmin4.png"
  convert "${srcdir}/pgadmin4.png" -resize 16x16 "${pkgdir}/usr/share/icons/hicolor/16x16/apps/pgadmin4.png"
  install -Dm 644 "${srcdir}/pgadmin4.desktop" -t "${pkgdir}/usr/share/applications"
}

Offline

#2 2021-06-12 08:07:36

Awebb
Member
Registered: 2010-05-06
Posts: 6,268

Re: help with PKGBUILD

Every time you type "pgadmin4", it tries to install pgadmin4 in the default system tree, /usr in this case.it will also pull in all the dependencies, potentially overwriting system libraries, leading to package management inconsistencies and possibly catastrophic failure.

The PKGBUILD itself is probably not horrible or it is even fine, but the software you're trying to add (the script, not the management tool itself) borders on malware in the context of Arch package management.

If you want pgadmin4 in the AUR, consider maintaining the actual package and not the auto updater. See the wiki for information regarding python packaging.

Offline

#3 2021-06-12 09:01:27

aquilarubra
Member
From: Trieste, Italy
Registered: 2018-11-24
Posts: 86

Re: help with PKGBUILD

Actually, my bash script pulls everything in the HOME directory of the user using it. It is not system-wide, so there should be no clash issue.
After environment setup, it calls pgadmin4 from where it is installed in the HOME directory, which has precedence over the PATH (otherwise, the script would call itself and do nothing).
Here it is:

#!/bin/sh

cd $HOME && \
kdesu sh -c "mkdir -p /var/lib/pgadmin && mkdir -p /var/log/pgadmin && chown $USER /var/lib/pgadmin && chown $USER /var/log/pgadmin" && \
xterm -iconic -e "python3 -m venv pgadmin4 && \
source pgadmin4/bin/activate && \
pip install pgadmin4 && \
python3 -m venv pgadmin4 && \
source pgadmin4/bin/activate && \
(pgadmin4 &) && \
sleep 5s && \
xdg-open http://127.0.0.1:5050"

Definitely I could rename the pgadmin4 script to something else, to grant compatibility with other packages. But I don't think people would use multiple pgadmin4 packages at the same time. More so as the package in community is not updated and does not work.
The script is just a launcher. It follows the installation procedure outlined on the pgadmin website. But it won't run like that, it still needs the environment to be configured every time you launch it.

I don't think the actual package is well written. According to Arch philosophy, things should be kept simple, as my script does. Community package takes a complex route that often breaks, so I don't consider it worth. The maintainer of pgadmin4-last has the same issues.

Offline

#4 2021-06-12 09:49:47

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,848

Re: help with PKGBUILD

archwiki on Python package guidelines wrote:

Warning: Use of pip and/or wheel packages is discouraged in favor of setuptools source packages, and should only be used when the latter is not a viable option (for example, packages which only come with wheel sources, and therefore cannot be installed using setuptools).


See https://wiki.archlinux.org/title/Python … elines#pip for details including which settings should be used for pip install in PKGBUILDs.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#5 2021-06-12 11:15:00

loqs
Member
Registered: 2014-03-06
Posts: 17,169

Re: help with PKGBUILD

I tried updating the PKGBUILD from community to the current version,  then applied fixes for remaining issues.  This has only been build tested:

diff --git a/trunk/065a3aa2f5a22024746419596de7de8dff34440c.patch b/trunk/065a3aa2f5a22024746419596de7de8dff34440c.patch
new file mode 100644
index 0000000..f6be5e7
--- /dev/null
+++ b/trunk/065a3aa2f5a22024746419596de7de8dff34440c.patch
@@ -0,0 +1,175 @@
+From 065a3aa2f5a22024746419596de7de8dff34440c Mon Sep 17 00:00:00 2001
+From: Aditya Toshniwal <aditya.toshniwal@enterprisedb.com>
+Date: Sun, 6 Jun 2021 13:58:06 +0530
+Subject: [PATCH] Updated Flask-Security-Too to the latest v4. Fixes #6225
+
+---
+ docs/en_US/release_notes_5_4.rst         |  1 +
+ requirements.txt                         |  2 +-
+ web/migrations/versions/c465fee44968_.py | 57 ++++++++++++++++++++++++
+ web/pgadmin/__init__.py                  |  4 +-
+ web/pgadmin/browser/__init__.py          |  6 +--
+ web/pgadmin/model/__init__.py            |  6 ++-
+ 6 files changed, 69 insertions(+), 7 deletions(-)
+ create mode 100644 web/migrations/versions/c465fee44968_.py
+
+diff --git a/requirements.txt b/requirements.txt
+index ebdb1b21e..3ed3f7800 100644
+--- a/requirements.txt
++++ b/requirements.txt
+@@ -29,7 +29,7 @@ psycopg2==2.8.*
+ python-dateutil==2.*
+ SQLAlchemy==1.3.*
+ itsdangerous<=1.1.0
+-Flask-Security-Too==3.*
++Flask-Security-Too==4.*
+ bcrypt==3.*
+ cryptography==3.*
+ sshtunnel==0.*
+diff --git a/web/migrations/versions/c465fee44968_.py b/web/migrations/versions/c465fee44968_.py
+new file mode 100644
+index 000000000..07459675d
+--- /dev/null
++++ b/web/migrations/versions/c465fee44968_.py
+@@ -0,0 +1,57 @@
++
++"""empty message
++
++Revision ID: c465fee44968
++Revises: d0bc9f32b2b9
++Create Date: 2021-06-04 14:42:12.843116
++
++"""
++from pgadmin.model import db, User
++import uuid
++
++
++# revision identifiers, used by Alembic.
++revision = 'c465fee44968'
++down_revision = 'd0bc9f32b2b9'
++branch_labels = None
++depends_on = None
++
++
++def upgrade():
++    db.engine.execute("ALTER TABLE user RENAME TO user_old")
++
++    db.engine.execute("""
++        CREATE TABLE user (
++            id INTEGER NOT NULL,
++            username VARCHAR(256) NOT NULL,
++            email VARCHAR(256),
++            password VARCHAR(256),
++            active BOOLEAN NOT NULL,
++            confirmed_at DATETIME,
++            masterpass_check VARCHAR(256),
++            auth_source VARCHAR(256) NOT NULL DEFAULT 'internal',
++            fs_uniquifier NOT NULL UNIQUE,
++            PRIMARY KEY (id),
++            UNIQUE (username, auth_source, fs_uniquifier),
++            CHECK (active IN (0, 1))
++        );
++        """)
++
++    user_old = db.engine.execute(
++        'select id, username, email, password, active, '
++        'confirmed_at, masterpass_check, auth_source '
++        'from user_old')
++
++    db.engine.execute(User.__table__.insert(), [
++        {
++            **row,
++            'fs_uniquifier': uuid.uuid4().hex
++        } for row in user_old
++    ])
++
++    db.engine.execute("DROP TABLE user_old")
++
++
++def downgrade():
++    # pgAdmin only upgrades, downgrade not implemented.
++    pass
+diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
+index 6e395f42f..dfc034c93 100644
+--- a/web/pgadmin/__init__.py
++++ b/web/pgadmin/__init__.py
+@@ -305,7 +305,7 @@ def get_locale():
+             if current_user.is_authenticated:
+                 user_id = current_user.id
+             else:
+-                user = user_datastore.get_user(config.DESKTOP_USER)
++                user = user_datastore.find_user(email=config.DESKTOP_USER)
+                 if user is not None:
+                     user_id = user.id
+             user_language = Preferences.raw_value(
+@@ -697,7 +697,7 @@ def before_request():
+             abort(401)
+ 
+         if not config.SERVER_MODE and not current_user.is_authenticated:
+-            user = user_datastore.get_user(config.DESKTOP_USER)
++            user = user_datastore.find_user(email=config.DESKTOP_USER)
+             # Throw an error if we failed to find the desktop user, to give
+             # the sysadmin a hint. We'll continue to try to login anyway as
+             # that'll through a nice 500 error for us.
+diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
+index edbd491e7..d6cf78cac 100644
+--- a/web/pgadmin/browser/__init__.py
++++ b/web/pgadmin/browser/__init__.py
+@@ -32,7 +32,7 @@
+ from flask_security.signals import reset_password_instructions_sent
+ from flask_security.utils import config_value, do_flash, get_url, \
+     get_message, slash_url_suffix, login_user, send_mail, logout_user
+-from flask_security.views import _security, _commit, _ctx
++from flask_security.views import _security, view_commit, _ctx
+ from werkzeug.datastructures import MultiDict
+ 
+ import config
+@@ -1144,7 +1144,7 @@ def change_password():
+                 has_error = True
+ 
+             if request.json is None and not has_error:
+-                after_this_request(_commit)
++                after_this_request(view_commit)
+                 do_flash(*get_message('PASSWORD_CHANGE'))
+ 
+                 old_key = get_crypt_key()[1]
+@@ -1310,7 +1310,7 @@ def reset_password(token):
+                 has_error = True
+ 
+             if not has_error:
+-                after_this_request(_commit)
++                after_this_request(view_commit)
+                 do_flash(*get_message('PASSWORD_RESET'))
+                 login_user(user)
+                 return redirect(get_url(_security.post_reset_view) or
+diff --git a/web/pgadmin/model/__init__.py b/web/pgadmin/model/__init__.py
+index bd90077b7..3afef96eb 100644
+--- a/web/pgadmin/model/__init__.py
++++ b/web/pgadmin/model/__init__.py
+@@ -20,6 +20,7 @@
+ 
+ from flask_security import UserMixin, RoleMixin
+ from flask_sqlalchemy import SQLAlchemy
++import uuid
+ 
+ ##########################################################################
+ #
+@@ -29,7 +30,7 @@
+ #
+ ##########################################################################
+ 
+-SCHEMA_VERSION = 29
++SCHEMA_VERSION = 30
+ 
+ ##########################################################################
+ #
+@@ -76,6 +77,9 @@ class User(db.Model, UserMixin):
+     roles = db.relationship('Role', secondary=roles_users,
+                             backref=db.backref('users', lazy='dynamic'))
+     auth_source = db.Column(db.String(16), unique=True, nullable=False)
++    # fs_uniquifier is required by flask-security-too >= 4.
++    fs_uniquifier = db.Column(db.String(255), unique=True, nullable=False,
++                              default=(lambda _: uuid.uuid4().hex))
+ 
+ 
+ class Setting(db.Model):
diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD
index f0d5c40..29c3af7 100644
--- a/trunk/PKGBUILD
+++ b/trunk/PKGBUILD
@@ -2,14 +2,13 @@
 # Maintainer: Jerome Leclanche <jerome@leclan.ch>
 
 pkgname=pgadmin4
-pkgver=4.30
+pkgver=5.3
 pkgrel=1
 pkgdesc='Comprehensive design and management interface for PostgreSQL'
 url='https://www.pgadmin.org/'
-arch=('x86_64')
+arch=('any')
 license=('custom')
-depends=('qt5-base' 'postgresql-libs' 'hicolor-icon-theme' 'python'
-         'libxcrypt' 'libcrypt.so' 'glibc' 'gcc-libs'
+depends=('postgresql-libs' 'hicolor-icon-theme' 'python'
          'python-blinker' 'python-flask' 'python-flask-login'
          'python-flask-migrate' 'python-flask-sqlalchemy' 'python-flask-wtf'
          'python-passlib' 'python-pytz' 'python-simplejson' 'python-six'
@@ -20,67 +19,60 @@ depends=('qt5-base' 'postgresql-libs' 'hicolor-icon-theme' 'python'
          'python-flask-gravatar' 'python-flask-mail' 'python-flask-principal'
          'python-flask-paranoid' 'python-sshtunnel' 'python-flask-security-too'
          'python-werkzeug' 'python-flask-compress' 'python-ldap3' 'python-cryptography'
-         'python-flask-babelex' 'python-gssapi')
+         'python-flask-babelex' 'python-gssapi' 'python-email-validator')
 makedepends=('python-setuptools' 'python-sphinx' 'python-extras' 'python-fixtures'
              'python-html5lib' 'python-pbr' 'python-mimeparse' 'python-pyrsistent'
              'imagemagick')
 source=(https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v${pkgver}/source/${pkgname}-${pkgver}.tar.gz{,.asc}
+        065a3aa2f5a22024746419596de7de8dff34440c.patch
         pgAdmin4.desktop
         config_distro.py
         config_local.py
-        pgadmin4-python-de-vendor-venv-paths.patch)
+        test.patch)
 validpgpkeys=('E8697E2EEF76C02D3A6332778881B2A8210976F2') # Package Manager (Package Signing Key) <packages@pgadmin.org>
-sha512sums=('7ce12f65ce9dbfe4af9e92dd7f9327a05be8b8436ef495a0634043158417f3af5f457b88ee5422ede59f517c197668094454c6d7b7c33e255068479ce6ec13d9'
+sha512sums=('229a42c709c59e57408b2226c76301ddcde9b8ed045d6bb2faefdcfee9a3c9eee0e3a33e4a4be02004a3bdad35429f705d529ffd8969e81d98c1dec86e970f51'
             'SKIP'
+            '74545f52cd59d4f3a34576701b2625c5bef2f5c0d1361675f9a2cb10f54c2b360282ad675ef9690d6965c6bc0515b522c6acc7af06e8422c0420eef9d23664f3'
             'b19dda3331585010c759099eb09f4db288ce4cd3d36882b56748e1e3756dc7bee2899d7438d496280498ec6a60f6e1ba90309d49fc599403f1fdc7e8817b6645'
             '16d00dc2095904a6b12da7039458f632873829ad98d4d7653eac5804032ba92097ccae4488d56467d0ea9bd64e2654a3dead73eb7924c947ff1737ff6e3b4745'
             'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'
-            'a8c1a3762469b02b745da4e3b30f7534ad6bb94e91d43f7e63604fef24f638e09575e2c9336e753e5b6dbe167c55bb49fb6247a16431415318479eb3a3712adc')
+            'a8c1a3762469b02b745da4e3b30f7534ad6bb94e91d43f7e63604fef24f638e09575e2c9336e753e5b6dbe167c55bb49fb6247a16431415318479eb3a3712adc'
+            'b9a5382146f014576ae5aba880c552bcb1f9f6487005e112d60f3218cc421cfb076562cfa3d12cabecb0112723cbd7da637c9908c7fd4ec535d693e069550de5')
 
 prepare() {
   cd ${pkgname}-${pkgver}
 
-  patch -Np1 < ../pgadmin4-python-de-vendor-venv-paths.patch
-
-  local PYTHONVERSION="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
-  sed -E "s|/usr/pgadmin4/web|/usr/lib/pgadmin4/web|g;
-          s|/usr/pgadmin4/lib/python[0-9\\.]+|/usr/lib/python${PYTHONVERSION}|g" \
-      -i runtime/ConfigWindow.ui
-  sed "s|##PYTHONVERSION##|${PYTHONVERSION}|g" -i runtime/Server.cpp
+  patch -Np1 < ../065a3aa2f5a22024746419596de7de8dff34440c.patch
+  patch -Np1 < ../test.patch
 
   sed -E -i requirements.txt \
-    -e '/blinker>?=/d' \
-    -e '/extras>?=/d' \
+    -e '/cheroot>?=/d' \
     -e '/Flask>?=/d' \
+    -e '/Flask-Gravatar>?=/d' \
     -e '/Flask-Login>?=/d' \
+    -e '/Flask-Mail>?=/d' \
     -e '/Flask-Migrate>?=/d' \
     -e '/Flask-SQLAlchemy>?=/d' \
     -e '/Flask-WTF>?=/d' \
-    -e '/pycrypto>?=/d' \
+    -e '/Flask-Compress>?=/d' \
     -e '/passlib>?=/d' \
     -e '/pytz>?=/d' \
     -e '/simplejson>?=/d' \
     -e '/six>?=/d' \
-    -e '/speaklater>?=/d' \
+    -e '/speaklater3>?=/d' \
     -e '/sqlparse>?=/d' \
     -e '/WTForms>?=/d' \
+    -e '/Flask-Paranoid>?=/d' \
     -e '/psutil>?=/d' \
     -e '/psycopg2>?=/d' \
     -e '/python-dateutil>?=/d' \
     -e '/SQLAlchemy>?=/d' \
-    -e '/Flask-Gravatar>?=/d' \
-    -e '/Flask-Mail>?=/d' \
-    -e '/Flask-Principal>?=/d' \
-    -e '/Flask-Paranoid>?=/d' \
-    -e '/htmlmin>?=/d' \
+    -e '/itsdangerous>?<?=/d' \
     -e '/Flask-Security-Too>?=/d' \
-    -e '/Flask-HTMLmin>?=/d' \
-    -e '/Flask-Compress>?=/d' \
-    -e '/sshtunnel>?=/d' \
-    -e '/Werkzeug>?=/d' \
-    -e '/ldap3>?=/d' \
     -e '/bcrypt>?<?=/d' \
     -e '/cryptography>?<?=/d' \
+    -e '/sshtunnel>?<?=/d' \
+    -e '/ldap3>?<?=/d' \
     -e '/Flask-BabelEx>?<?=/d' \
     -e '/gssapi>?<?=/d' \
     -e '/^#.*/d' \
@@ -98,28 +90,25 @@ build() {
   export PGADMIN_PYTHON_DIR=/usr
 
   cd ${pkgname}-${pkgver}
-  convert +set date:create +set date:modify runtime/pgAdmin4.{ico,png}
+  convert +set date:create +set date:modify  -resize 256x265 runtime/assets/pgAdmin4.png runtime/assets/pgAdmin4-0.png
+  convert +set date:create +set date:modify  -resize 48x48 runtime/assets/pgAdmin4.png runtime/assets/pgAdmin4-1.png
+  convert +set date:create +set date:modify  -resize 32x32 runtime/assets/pgAdmin4.png runtime/assets/pgAdmin4-2.png
+  convert +set date:create +set date:modify  -resize 16x16 runtime/assets/pgAdmin4.png runtime/assets/pgAdmin4-3.png
   # override doctree directory
   make docs SPHINXOPTS='-d /tmp/'
-
-  cd runtime
-  export CFLAGS+=" ${CPPFLAGS}"
-  export CXXFLAGS+=" ${CPPFLAGS}"
-  qmake CONFIG+=release
-  make
 }
 
 package() {
   cd ${pkgname}-${pkgver}
 
-  install -Dm 755 runtime/pgAdmin4 "${pkgdir}/usr/lib/pgadmin4/runtime/pgAdmin4"
+  install -dm 755 "${pkgdir}/usr/lib/pgadmin4"
   cp -a docs web "${pkgdir}/usr/lib/pgadmin4"
   install -Dm 644 "${srcdir}"/config_{distro,local}.py -t "${pkgdir}/usr/lib/pgadmin4/web"
 
-  install -Dm 644 runtime/pgAdmin4-0.png "${pkgdir}/usr/share/icons/hicolor/256x256/apps/pgAdmin4.png"
-  install -Dm 644 runtime/pgAdmin4-1.png "${pkgdir}/usr/share/icons/hicolor/48x48/apps/pgAdmin4.png"
-  install -Dm 644 runtime/pgAdmin4-2.png "${pkgdir}/usr/share/icons/hicolor/32x32/apps/pgAdmin4.png"
-  install -Dm 644 runtime/pgAdmin4-3.png "${pkgdir}/usr/share/icons/hicolor/16x16/apps/pgAdmin4.png"
+  install -Dm 644 runtime/assets/pgAdmin4-0.png "${pkgdir}/usr/share/icons/hicolor/256x256/apps/pgAdmin4.png"
+  install -Dm 644 runtime/assets/pgAdmin4-1.png "${pkgdir}/usr/share/icons/hicolor/48x48/apps/pgAdmin4.png"
+  install -Dm 644 runtime/assets/pgAdmin4-2.png "${pkgdir}/usr/share/icons/hicolor/32x32/apps/pgAdmin4.png"
+  install -Dm 644 runtime/assets/pgAdmin4-3.png "${pkgdir}/usr/share/icons/hicolor/16x16/apps/pgAdmin4.png"
   install -Dm 644 "${srcdir}/pgAdmin4.desktop" -t "${pkgdir}/usr/share/applications"
 
   install -D /dev/stdin "${pkgdir}/usr/bin/pgadmin4" <<END
diff --git a/trunk/pgadmin4-python-de-vendor-venv-paths.patch b/trunk/pgadmin4-python-de-vendor-venv-paths.patch
deleted file mode 100644
index fb0b7c5..0000000
--- a/trunk/pgadmin4-python-de-vendor-venv-paths.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 3edbde6534e3e819e47075c196c533d88cdbf786 Mon Sep 17 00:00:00 2001
-From: anthraxx <levente@leventepolyak.net>
-Date: Wed, 19 Dec 2018 01:10:25 +0100
-Subject: [PATCH] python: de-vendor venv paths
-
----
- runtime/Server.cpp | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/runtime/Server.cpp b/runtime/Server.cpp
-index f053cbb00..fd120f36a 100644
---- a/runtime/Server.cpp
-+++ b/runtime/Server.cpp
-@@ -131,11 +131,11 @@ Server::Server(quint16 port, QString key, QString logFileName)
-     add_to_path(pythonHome, venvPath.canonicalFilePath());
- #else
-     // Build (and canonicalise) the virtual environment path
--    QFileInfo venvBinPath(app_dir + "/../venv/bin");
--    QFileInfo venvLibPath(app_dir + "/../venv/lib/python");
--    QFileInfo venvDynLibPath(app_dir + "/../venv/lib/python/lib-dynload");
--    QFileInfo venvSitePackagesPath(app_dir + "/../venv/lib/python/site-packages");
--    QFileInfo venvPath(app_dir + "/../venv");
-+    QFileInfo venvBinPath("/usr/bin");
-+    QFileInfo venvLibPath("/usr/lib/python##PYTHONVERSION##");
-+    QFileInfo venvDynLibPath("/usr/lib/python##PYTHONVERSION##/lib-dynload");
-+    QFileInfo venvSitePackagesPath("/usr/lib/python##PYTHONVERSION##/site-packages");
-+    QFileInfo venvPath("/usr/lib/python##PYTHONVERSION##");
- 
-     // Prepend the bin directory to the path
-     add_to_path(path_env, venvBinPath.canonicalFilePath(), true);
--- 
-2.27.0
-
diff --git a/trunk/test.patch b/trunk/test.patch
new file mode 100644
index 0000000..539f47c
--- /dev/null
+++ b/trunk/test.patch
@@ -0,0 +1,22 @@
+diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
+index 312b0ee..948663c 100644
+--- a/web/pgadmin/browser/utils.py
++++ b/web/pgadmin/browser/utils.py
+@@ -13,7 +13,7 @@ from abc import abstractmethod
+ 
+ import flask
+ from flask import render_template, current_app
+-from flask.views import View, MethodViewType, with_metaclass
++from flask.views import View, MethodViewType
+ from flask_babelex import gettext
+ 
+ from config import PG_DEFAULT_DRIVER
+@@ -142,7 +142,7 @@ class PGChildModule(object):
+         pass
+ 
+ 
+-class NodeView(with_metaclass(MethodViewType, View)):
++class NodeView(View,metaclass=MethodViewType):
+     """
+     A PostgreSQL Object has so many operaions/functions apart from CRUD
+     (Create, Read, Update, Delete):

Last edited by loqs (2021-06-12 11:16:53)

Offline

#6 2021-06-12 15:59:56

aquilarubra
Member
From: Trieste, Italy
Registered: 2018-11-24
Posts: 86

Re: help with PKGBUILD

Thank you all for input. I renamed the package and script to pgadmin4-launcher, since it is really all about the bash script doing the work. I specified the local folder for installation, so that nothing in the system is touched, except the session data, which is shared with *any* pgadmin4 install. So, it can even live with other pgadmin4 installs.
I also followed the guidelines for pip.

Do you think I can publish it again like this?

pkgname=pgadmin4-launcher
pkgver=999
pkgrel=0
pkgdesc='Comprehensive design and management interface for PostgreSQL. Pip self-updating installation for local user. Opens the server in a terminal, and launches the default browser'
url='https://www.pgadmin.org/'
arch=('x86_64')
license=('custom')
provides=("${pkgname}=${pkgver}")
depends=('postgresql-libs' 'hicolor-icon-theme' 'python' 'python-pip' 'xterm')
makedepends=('imagemagick')
source=('pgadmin4-launcher'
	'pgadmin4.desktop'
	'pgadmin4.png')
sha512sums=('b130d1fcd787f2dcfbe868a615a7bc1374583740020c08191ecb8ac97542346279b27362baf5fea4bb54fba1317c9dbc04b922b85e8c0b8e97b8d8294a19abec'
            'cf0a738031ed11456a3f0fd554af76c81a5ecd707c59f4510e80692bc5feb75d9eba7503fe8f73fc8525733fa2c884b02593af113a6f2b8b8edd60735ae5205f'
            '583348ae0786ed948abc8416afd9f10e989b08fd3b6fd357c3d1c42e1235e303656e8d324a11515d19aa8dd60a1cfaf8b50da534eb2456ba777b604f5c580d93')

package() {
  cd ${pkgdir}
  install -Dm 755 "${srcdir}/pgadmin4-launcher" -t "${pkgdir}/usr/bin"
  install -dm 755 "${pkgdir}/usr/share/icons/hicolor/"{'256x256/apps','48x48/apps','32x32/apps','16x16/apps'}
  convert "${srcdir}/pgadmin4.png" -resize 256x265 "${pkgdir}/usr/share/icons/hicolor/256x256/apps/pgadmin4.png"
  convert "${srcdir}/pgadmin4.png" -resize 48x48 "${pkgdir}/usr/share/icons/hicolor/48x48/apps/pgadmin4.png"
  convert "${srcdir}/pgadmin4.png" -resize 32x32 "${pkgdir}/usr/share/icons/hicolor/32x32/apps/pgadmin4.png"
  convert "${srcdir}/pgadmin4.png" -resize 16x16 "${pkgdir}/usr/share/icons/hicolor/16x16/apps/pgadmin4.png"
  install -Dm 644 "${srcdir}/pgadmin4.desktop" -t "${pkgdir}/usr/share/applications"
}
#!/bin/sh

cd $HOME && \
kdesu sh -c "mkdir -p /var/lib/pgadmin && mkdir -p /var/log/pgadmin && chown $USER /var/lib/pgadmin && chown $USER /var/log/pgadmin" && \
xterm -iconic -e "python -m venv pgadmin4 && \
source $HOME/pgadmin4/bin/activate && \
PIP_CONFIG_FILE=/dev/null pip install --isolated --root="$pkgdir" --ignore-installed --no-deps pgadmin4 && \
python -m venv pgadmin4 && \
source $HOME/pgadmin4/bin/activate && \
(pgadmin4 &) && \
sleep 5s && \
xdg-open http://127.0.0.1:5050"

Offline

#7 2021-06-12 16:16:42

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,443

Re: help with PKGBUILD

The problem is that that is an absolutely terrible script, and won't work at all. You make all kinds of assumptions that aren't true. Please don't upload it.

Online

#8 2021-06-12 16:46:02

seth
Member
Registered: 2012-09-03
Posts: 49,601

Re: help with PKGBUILD

Secondary thing is, why should be a package that performs a pip install be deleted?

That's not the problem.
Read https://wiki.archlinux.org/title/Python … management *closely*

That won't salvage the rest of the script, though.
- kdesu
- xterm
- sleep random time hoping that the port will be available by then

Also, is the entire purpose of the package to make users install a python package (in a terribly wrong way)?

Offline

#9 2021-06-12 17:47:06

aquilarubra
Member
From: Trieste, Italy
Registered: 2018-11-24
Posts: 86

Re: help with PKGBUILD

Scimmia wrote:

The problem is that that is an absolutely terrible script, and won't work at all. You make all kinds of assumptions that aren't true. Please don't upload it.

Are you saying the instructions on the pgadmin website are terrible? Because my script does just that. I removed some clutter. And I find it perfectly working.

#!/bin/sh

cd $HOME && \
kdesu sh -c "mkdir -p /var/lib/pgadmin && mkdir -p /var/log/pgadmin && chown $USER /var/lib/pgadmin && chown $USER /var/log/pgadmin" && \
xterm -iconic -e "python -m venv pgadmin4 && \
source $HOME/pgadmin4/bin/activate && \
PIP_CONFIG_FILE=/dev/null pip install --isolated --root="$pkgdir" --ignore-installed --no-deps pgadmin4 && \
(pgadmin4 &) && \
sleep 5s && \
xdg-open http://127.0.0.1:5050"

Now, the session folders need to be chowned for the user launching pgadmin4. Kdesu allows to do that, in order for other users to be able to launch the application. If you have better ways, you can advise.
xterm is used iconized simply so that, once the browser is launched, when you close it the entire process (read server) dies. Otherwise, it will keep running.
sleep is just the easiest way, despite I could improve that definitely.

I don't pretend to do it the best way, just the effective way. But I appreciate suggestions. Thanks

Offline

#10 2021-06-12 18:01:17

seth
Member
Registered: 2012-09-03
Posts: 49,601

Re: help with PKGBUILD

Are you saying the instructions on the pgadmin website are terrible?

idk whether that's actually on their webpage, but if so, then yes: that's terrible.

What if kdesu isn't installed?
Relying on a specific TE is even more moronic than using one here itfp - the lan is to run a daemon in a minimized window so you can kill it by closing the window?.
And again: this is a terrible way to use pip - read the link I posted.

Offline

#11 2021-06-12 18:14:39

loqs
Member
Registered: 2014-03-06
Posts: 17,169

Re: help with PKGBUILD

The upstream instructions you are basing this off are https://www.pgadmin.org/download/pgadmin-4-python/ ?
https://www.pgadmin.org/faq/#8 the default log location ~/.pgadmin/pgadmin4.log.  So is anything actually written to  /var/log/pgadmin or /var/lib/pgadmin or are the instructions out of date?

Last edited by loqs (2021-06-12 18:15:03)

Offline

#12 2021-06-12 19:23:35

aquilarubra
Member
From: Trieste, Italy
Registered: 2018-11-24
Posts: 86

Re: help with PKGBUILD

loqs wrote:

The upstream instructions you are basing this off are https://www.pgadmin.org/download/pgadmin-4-python/ ?

Yes.

I followed pip instructions for Arch and I think I am compliant now. I don't know what else is the problem. I forgot to put kdesu in depends, good find.

AUR was never supposed to be the official repository. So, some degree of freedom is assumed. Some may like something, some may not. Some may contribute to make a script better. So, what's the problem?

Frankly, censorship is a bigger problem. I maintain some important packages and I am rethinking to contribute to Arch now.

Offline

#13 2021-06-12 19:36:20

seth
Member
Registered: 2012-09-03
Posts: 49,601

Re: help with PKGBUILD

QA isn't censorship - the script you originally presented stands, next to the clumsy aspectts, a good chance to harm its users.
You think if somebody uploads malware to the AUR and this gets noticed, it should not be "censored"?

Ultimately, what you're looking to do can be done w/o certainly kdesu (if you follow the PIP remarks in the wiki and this is local approach anyway) or xterm (any TE - you can either store the daemons PID or pkill it and offer yet another desktop entry for that)

Where's your updated script?

Offline

#14 2021-06-12 19:45:19

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: help with PKGBUILD

aquilarubra wrote:

So, some degree of freedom is assumed. Some may like something, some may not.

It has nothing to do with what you like. It is about correctness. What you are attempting to do is not subjectively unlikable, it is objectively wrong. So you aren't being censored, you are being sanctioned. There is a difference.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#15 2021-06-12 19:48:00

loqs
Member
Registered: 2014-03-06
Posts: 17,169

Re: help with PKGBUILD

aquilarubra what is in /var/lib/pgadmin on your system?  Which I assume uses your script to create that directory.

Offline

#16 2021-06-12 20:17:43

aquilarubra
Member
From: Trieste, Italy
Registered: 2018-11-24
Posts: 86

Re: help with PKGBUILD

loqs wrote:

aquilarubra what is in /var/lib/pgadmin on your system?  Which I assume uses your script to create that directory.

Sessions are recorded there. Every pgadmin4 installation looks there. So, it ensures that you don't have to retype all your data. My script only checks that the path exists and chowns it for current user.

Offline

#17 2021-06-12 20:29:23

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,443

Re: help with PKGBUILD

chowing a dir like that to the current user is one of the MAJOR defects in the script.

Online

#18 2021-06-12 20:29:58

loqs
Member
Registered: 2014-03-06
Posts: 17,169

Re: help with PKGBUILD

Only when run in SERVER_MODE so the files will be managed by an external webserver which is expected to authenticate the session:
https://github.com/postgres/pgadmin4/bl … ig.py#L105
otherwise see:
https://github.com/postgres/pgadmin4/bl … ig.py#L251
https://github.com/postgres/pgadmin4/bl … ig.py#L287
Edit:
Which is why the official package does not need those directories because it supplies:
https://github.com/archlinux/svntogit-c … _distro.py
Edit:
See also
https://github.com/postgres/pgadmin4/bl … ig.py#L646

Last edited by loqs (2021-06-12 20:34:53)

Offline

#19 2021-06-12 20:41:43

seth
Member
Registered: 2012-09-03
Posts: 49,601

Re: help with PKGBUILD

https://www.pgadmin.org/download/pgadmin-4-python/ seems to suggest that the server mode is implied for the python package:

A Python package is available for those wishing to run pgAdmin as a web application in a Python environment. Note that the packages do not include the Desktop Runtime.

And

Note that pgAdmin will run in server mode, using system-wide paths so you may need to create them first:

what leads them to

$ sudo mkdir /var/lib/pgadmin
$ sudo mkdir /var/log/pgadmin
$ sudo chown $USER /var/lib/pgadmin
$ sudo chown $USER /var/log/pgadmin

and I *assume* that "$USER" relates to the UID of the web/postgresserver - not some joe user clicking on an icon.

Offline

#20 2021-06-13 09:11:09

aquilarubra
Member
From: Trieste, Italy
Registered: 2018-11-24
Posts: 86

Re: help with PKGBUILD

seth wrote:

and I *assume* that "$USER" relates to the UID of the web/postgresserver - not some joe user clicking on an icon.

Wrong assumption. I would assume that there is no more than one user a time using a DE. I understand that pgadmin instructions are a bit difficult to put into a package safely.

It seems that it is quite impossible to bend the python package to a level of safety.
Maybe the PKGBUILD could create a system service. Then, just the browser would be launched. But that still does not solve the chowning of the system dirs. And the server would be running even when not required. Unless other sudos are used.

Offline

#21 2021-06-13 13:52:15

seth
Member
Registered: 2012-09-03
Posts: 49,601

Re: help with PKGBUILD

Wrong assumption.

Do you actually have detailed knowledge of the authors intention or is this just something you say boldy because then it's right by definition?
Since we're exclusively talking about the explicitly distinct "SERVER_MODE" here, the idea that pgadmin4 is run by Joe S. Desktopuser seems a bit far fetched?
Why wouldn't  J. Some Desktopuser use the desktop mode which utilizes their $HOME instead of a system path?

Maybe the PKGBUILD could create a system service.

A *system* service can chown the paths because it runs as root, it can then su into a specified user and it can also be socket activated (ie. when you open the url in the browser)
chown'ing a system path to a random user is however such a massively huge red flag, that I'd double and triple and quadruple check whether you're actually using pgadmin4 the way it's intended before chasing that goose.

I would assume that there is no more than one user a time using a DE.

https://wiki.archlinux.org/title/Xorg_multiseat
Also the "desktop" aspect is only introduced by your pgadmin4.desktop - it's not inherent to the use of pgadmin4 itself.

Offline

#22 2021-06-13 19:18:24

aquilarubra
Member
From: Trieste, Italy
Registered: 2018-11-24
Posts: 86

Re: help with PKGBUILD

Very instructive, thank you. You gave me many good ideas.

Offline

#23 2021-06-16 11:07:41

phollox
Member
Registered: 2013-05-04
Posts: 61

Re: help with PKGBUILD

If you make a package that runs a script to do a pip install, then do a pip install and skip the package.

You see, the problem is that pip and pacman are not compatible. So keeping a python install system wide and installing something there via pip is usually a bad idea. So, it's always better to do systemwide install with pacman and AUR

pip is recommended to install stuff in Python virtual environments

If you really want a system wide install of the python package, creating a AUR is the way to go. But again, avoiding the pip install step.

The other stuff, the dependecies, the semantics of the script, etc, are fixable. The main issue is mixing pip and pacman. Too many cooks. You will end up with files written by pip than python can't upgrade or remove, and viceversa.


I divide by zero, multiple times per day. Also, I don't believe in tipping
Arch + i3wm (still learning)

Offline

#24 2021-06-20 18:04:15

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: help with PKGBUILD

aquilarubra wrote:

Here is my PKGBUILD (some parts are similar to another package that was not deleted):

Which package? The TUs don't automatically know everything that happens on the AUR but isn't reported.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB