Skip to content

Commit

Permalink
pisi: sync to v3.12.1, add dep on python2-ordered-set
Browse files Browse the repository at this point in the history
**Summary**
- Sync with pisi v3.12.1 upstream release, which always installs baselayout
  eopkg first if they are present in any given install/upgrade order.
- Add rundep on python2-ordered-set package
- Make pisi co-installable with the eopkg(py3) package
- Miscellaneous shebang and file name extension changes
- Sort pspec.xml file sections lexically for ease of reading/tweaking
- Change long_description to indicate that pisi is now considered legacy
- Create new comar/manager.py3 and comar/package.py3 build scripts in
  preparation for enabling building pisi with `eopkg.py3 build`.
  Thank you to @ultr4_l4s3r for the porting work.
  The current comar/*.py scripts are still python2 for now.

Signed-off-by: Rune Morling <[email protected]>
  • Loading branch information
ermo committed Jun 24, 2024
1 parent 62ca3b0 commit 02f1d61
Show file tree
Hide file tree
Showing 4 changed files with 321 additions and 18 deletions.
21 changes: 18 additions & 3 deletions packages/p/pisi/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,23 @@
def install():
pythonmodules.install()

pisitools.dosym("eopkg-cli", "/usr/bin/eopkg")
pisitools.dosym("uneopkg", "/usr/bin/unpisi")
pisitools.dosym("lseopkg", "/usr/bin/lspisi")
# BEGIN comment these out for the epoch bump build of pisi
pisitools.dosym("eopkg.py2", "/usr/bin/eopkg")
pisitools.dosym("eopkg.py2", "/usr/bin/eopkg-cli")
pisitools.dosym("lseopkg.py2", "/usr/bin/lseopkg")
pisitools.dosym("lseopkg.py2", "/usr/bin/lspisi.py2")
pisitools.dosym("uneopkg.py2", "/usr/bin/uneopkg")
pisitools.dosym("uneopkg.py2", "/usr/bin/unpisi.py2")
# END comment these out for the epoch bump build of pisi
pisitools.dodir("/etc/mudur")
shelltools.echo("%s/etc/mudur/locale" % get.installDIR(), "")

# Everything below here _removes_ stuff that we don't want installed.
# After the epoch bump, the goal is to make pisi own as little as
# practically possible, so that eopkg4 can own it instead for
# co-installability purposes as we deprecate pisi.
#
# Uncomment the line below for the epoch bump build of pisi
#shelltools.unlinkDir("%s/usr/share/defaults" % get.installDIR())
pisitools.remove("/usr/share/doc/pisi/dependency.pdf")
pisitools.remove("/usr/share/doc/pisi/package_versions.pdf")
253 changes: 253 additions & 0 deletions packages/p/pisi/comar/manager.py3
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2005-2009 TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#

# Disable cyclic garbage collector of Python to avoid comar segmentation
# faults under high load (#11110)
import gc
gc.disable()

import os
import os.path
import locale
import string

# FIXME: later this will be Comar's job
systemlocale = open("/etc/mudur/locale", "r").readline().strip()

# for pisi
os.environ["LC_ALL"] = systemlocale

# for system error messages
locale.setlocale(locale.LC_ALL, systemlocale)

try:
import pisi.api
import pisi.db
import pisi.ui
import pisi.util as util
import pisi.configfile
from pisi.version import Version
except KeyboardInterrupt:
notify("System.Manager", "cancelled", "")

class UI(pisi.ui.UI):
def error(self, msg):
notify("System.Manager", "error", str(msg))

def warning(self, msg):
notify("System.Manager", "warning", str(msg))

def notify(self, event, **keywords):
if event == pisi.ui.installing:
pkgname = keywords["package"].name
notify("System.Manager", "status", ("installing", pkgname, "", ""))
elif event == pisi.ui.configuring:
pkgname = keywords["package"].name
notify("System.Manager", "status", ("configuring", pkgname, "", ""))
elif event == pisi.ui.extracting:
pkgname = keywords["package"].name
notify("System.Manager", "status", ("extracting", pkgname, "", ""))
elif event == pisi.ui.updatingrepo:
reponame = keywords["name"]
notify("System.Manager", "status", ("updatingrepo", reponame, "", ""))
elif event == pisi.ui.removing:
pkgname = keywords["package"].name
notify("System.Manager", "status", ("removing", pkgname, "", ""))
elif event == pisi.ui.cached:
total = str(keywords["total"])
cached = str(keywords["cached"])
notify("System.Manager", "status", ("cached", total, cached, ""))
elif event == pisi.ui.installed:
notify("System.Manager", "status", ("installed", "", "", ""))
elif event == pisi.ui.removed:
notify("System.Manager", "status", ("removed", "", "", ""))
elif event == pisi.ui.upgraded:
notify("System.Manager", "status", ("upgraded", "", "", ""))
elif event == pisi.ui.packagestogo:
notify("System.Manager", "status", ("order", "", "", ""))
elif event == pisi.ui.desktopfile:
filepath = keywords["desktopfile"]
notify("System.Manager", "status", ("desktopfile", filepath, "", ""))
elif event == pisi.ui.systemconf:
notify("System.Manager", "status", ("systemconf", "", "", ""))
else:
return

def ack(self, msg):
return True

def confirm(self, msg):
return True

def display_progress(self, operation, percent, info="", **kw):
if operation == "fetching":
file_name = kw["filename"]
if not file_name.startswith("eopkg-index.xml"):
file_name = pisi.util.parse_package_name(file_name)[0]
out = (operation, file_name, str(percent), int(kw["rate"]), kw["symbol"], int(kw["downloaded_size"]), int(kw["total_size"]))
else:
out = (operation, str(percent), info, 0, 0, 0, 0)
notify("System.Manager", "progress", out)

def _init_pisi():
ui = UI()
try:
pisi.api.set_userinterface(ui)
except KeyboardInterrupt:
cancelled()

def _get_eopkg_config():
if os.path.exists("/etc/eopkg/eopkg.conf"):
return "/etc/eopkg/eopkg.conf"
return "/usr/share/defaults/eopkg/eopkg.conf"

def cancelled():
notify("System.Manager", "cancelled", None)

def started(operation=""):
notify("System.Manager", "started", operation)

def finished(operation=""):
if operation in ["System.Manager.setCache", "System.Manager.installPackage", "System.Manager.removePackage", "System.Manager.updatePackage"]:
__checkCacheLimits()

notify("System.Manager", "finished", operation)

def privileged(func):
"""
Decorator for synchronizing privileged functions
"""
def wrapper(*__args,**__kw):
operation = "System.Manager.%s" % func.__name__

started(operation)
_init_pisi()
try:
func(*__args,**__kw)
except KeyboardInterrupt:
cancelled()
return
except Exception(e):
notify("System.Manager", "error", str(e))
return
finished(operation)

return wrapper

@privileged
def installPackage(package=None):
if package:
package = package.split(",")
reinstall = package[0].endswith(".eopkg")
pisi.api.install(package, ignore_file_conflicts=True, reinstall=reinstall)

@privileged
def reinstallPackage(package=None):
if package:
package = package.split(",")
pisi.api.install(package, ignore_file_conflicts=True, reinstall=True)

@privileged
def updatePackage(package=None):
if package is None:
package = []
else:
package = package.split(",")
pisi.api.upgrade(package)

@privileged
def removePackage(package=None):
if package:
package = package.split(",")
pisi.api.remove(package)

@privileged
def updateRepository(repository=None):
if repository:
pisi.api.update_repo(repository)

@privileged
def updateAllRepositories():
repos = pisi.db.repodb.RepoDB().list_repos()
for repo in repos:
try:
pisi.api.update_repo(repo)
except pisi.db.repodb.RepoError(e):
notify("System.Manager", "error", str(e))

@privileged
def addRepository(name=None,uri=None):
if name and uri:
pisi.api.add_repo(name,uri)

@privileged
def removeRepository(repo=None):
if repo:
pisi.api.remove_repo(repo)

@privileged
def setRepoActivities(repos=None):
if repos:
for repo, active in list(repos.items()):
pisi.api.set_repo_activity(repo, active)

@privileged
def setRepositories(repos):
oldRepos = pisi.db.repodb.RepoDB().list_repos(only_active=False)

for repo in oldRepos:
pisi.api.remove_repo(repo)

for repo in repos:
pisi.api.add_repo(repo[0], repo[1])

@privileged
# ex: setConfig("general", "bandwidth_limit", "30")
def setConfig(category, name, value):
config = pisi.configfile.ConfigurationFile("/etc/eopkg/eopkg.conf")
config.set(category, name, value)

config.write_config()

@privileged
def setCache(enabled, limit):
config = pisi.configfile.ConfigurationFile("/etc/eopkg/eopkg.conf")
config.set("general", "package_cache", str(enabled))
config.set("general", "package_cache_limit", str(limit))

config.write_config()

@privileged
def takeSnapshot():
pisi.api.snapshot()

@privileged
def takeBack(operation):
pisi.api.takeback(operation)

@privileged
def clearCache(cacheDir, limit):
pisi.api.clearCache(int(limit) == 0)

def __checkCacheLimits():
cached_pkgs_dir = "/var/cache/eopkg/packages"
config = pisi.configfile.ConfigurationFile(_get_eopkg_config())
cache = config.get("general", "package_cache")
if cache == "True":
limit = config.get("general", "package_cache_limit")

# If PackageCache is used and limit is 0. It means limitless.
if limit and int(limit) != 0:
clearCache(cached_pkgs_dir, int(limit) * 1024 * 1024)
elif cache == "False":
clearCache(cached_pkgs_dir, 0)
9 changes: 9 additions & 0 deletions packages/p/pisi/comar/package.py3
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python3

import os

def postInstall(fromVersion, fromRelease, toVersion, toRelease):
if not os.path.exists("/var/lib/pisi/package"):
os.system("mkdir /var/lib/pisi/package")
os.system("mv /var/lib/pisi/* /var/lib/pisi/package/")
os.system("mv /var/lib/pisi/package/scripts /var/lib/pisi/")
56 changes: 41 additions & 15 deletions packages/p/pisi/pspec.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
<IsA>app:console</IsA>
<Summary>PISI</Summary>
<Description>PISI is a modern package management system implemented in Python. Some of its main features are: package sources are written in XML and python, implements all functions through a simple-to-use API, integrates low-level and high-level package management features.</Description>
<Archive sha1sum="3e71b2bbd5a3016c03ad52a5076a51b67dda9e09" type="targz">https://github.com/getsolus/eopkg/archive/refs/tags/v3.11.tar.gz</Archive>
<Archive sha1sum="e450fed1798e7d66c605f230cec9edfb8a022300" type="targz">https://github.com/getsolus/eopkg/archive/refs/tags/v3.12.1.tar.gz</Archive>
<BuildDependencies>
<Dependency>python</Dependency>
<Dependency>python2-xattr</Dependency>
<Dependency>db5</Dependency>
<Dependency>piksemel</Dependency>
<Dependency>intltool</Dependency>
<Dependency>piksemel</Dependency>
<Dependency>python</Dependency>
<Dependency>python2-ordered-set</Dependency>
<Dependency>python2-xattr</Dependency>
</BuildDependencies>

<Patches>
Expand All @@ -28,40 +29,65 @@
<Package>
<Name>pisi</Name>
<Files>
<Path fileType="config">/etc/pisi/pisi.conf</Path>
<Path fileType="config">/etc/mudur/locale</Path>
<Path fileType="data">/usr/lib/tmpfiles.d/pisi.conf</Path>
<Path fileType="data">/usr/share/defaults/eopkg</Path>
<Path fileType="data">/usr/share/factory/var/db/comar3/scripts/System.Manager/pisi.py</Path>
<Path fileType="data">/usr/share/mime/packages</Path>
<Path fileType="doc">/usr/share/doc</Path>
<Path fileType="doc">/usr/share/man/man1</Path>
<Path fileType="executable">/usr/bin</Path>
<Path fileType="executable">/usr/sbin</Path>
<Path fileType="library">/usr/lib/python*</Path>
<Path fileType="localedata">/usr/share/locale</Path>
<Path fileType="doc">/usr/share/doc</Path>
<Path fileType="doc">/usr/share/man/man1</Path>
<Path fileType="data">/usr/share/defaults/eopkg</Path>
<Path fileType="config">/etc/pisi/pisi.conf</Path>
<Path fileType="config">/etc/mudur/locale</Path>
<Path fileType="data">/usr/share/mime/packages</Path>
<Path fileType="data">/usr/share/factory/var/db/comar3/scripts/System.Manager/pisi.py</Path>
<Path fileType="data">/usr/lib/tmpfiles.d/pisi.conf</Path>
</Files>
<AdditionalFiles>
<AdditionalFile owner="root" permission="0644" target="/usr/lib/tmpfiles.d/pisi.conf">pisi.tmpfiles</AdditionalFile>
<!-- BEGIN should be owned by eopkg(py3) after the epoch bump -->
<AdditionalFile owner="root" permission="0644" target="/usr/share/defaults/eopkg/mirrors.conf">mirrors.conf</AdditionalFile>
<AdditionalFile owner="root" permission="0644" target="/usr/share/defaults/eopkg/sandbox.conf">sandbox.conf</AdditionalFile>
<AdditionalFile owner="root" permission="0644" target="/usr/lib/tmpfiles.d/pisi.conf">pisi.tmpfiles</AdditionalFile>
<!-- END should be owned by eopkg(py3) after the epoch bump -->
<AdditionalFile owner="root" permission="0644" target="/usr/share/factory/var/db/comar3/scripts/System.Manager/pisi.py">manager.py</AdditionalFile>
<!-- BEGIN should be owned by eopkg(py3) after the epoch bump -->
<AdditionalFile owner="root" permission="0644" target="/usr/share/man/man1/eopkg.1">eopkg.1</AdditionalFile>
<!-- END should be owned by eopkg(py3) after the epoch bump -->
</AdditionalFiles>
<Provides>
<COMAR script="package.py">System.Package</COMAR>
<COMAR script="manager.py">System.Manager</COMAR>
</Provides>
<RuntimeDependencies>
<Dependency>python</Dependency>
<Dependency>python2-xattr</Dependency>
<Dependency>db5</Dependency>
<!-- for documentation etc. once pisi / eopkg.py2 is the "lesser" twin (after epoch bump)
<Dependency>eopkg</Dependency>
-->
<Dependency>piksemel</Dependency>
<Dependency>python</Dependency>
<Dependency>python2-ordered-set</Dependency>
<Dependency>python2-xattr</Dependency>
<Dependency>usysconf</Dependency>
</RuntimeDependencies>
</Package>

<History>
<Update release="112">
<Date>24-06-2024</Date>
<Version>3.12.1</Version>
<Comment>sync to v3.12.1, add dep on python2-ordered-set
**Summary**
- Sync with pisi v3.12.1 upstream release, which always installs baselayout eopkg first if they are present in any given install/upgrade order.
- Add rundep on python2-ordered-set package
- Make pisi co-installable with the eopkg(py3) package
- Miscellaneous shebang and file name extension changes
- Sort pspec.xml file sections lexically for ease of reading/tweaking
- Change long_description to indicate that pisi is now considered legacy
- Create new comar/manager.py3 and comar/package.py3 build scripts in preparation for enabling building pisi with `eopkg.py3 build`.
Thank you to @ultr4_l4s3r for the porting work. The current comar/*.py scripts are still python2 for now.
</Comment>
<Name>Rune Morling</Name>
<Email>[email protected]</Email>
</Update>
<Update release="111">
<Date>10-06-2024</Date>
<Version>3.11</Version>
Expand Down

0 comments on commit 02f1d61

Please sign in to comment.