├── .gitignore ├── AUTHORS ├── CODING ├── COPYING ├── ChangeLog ├── ChangeLog.OLD ├── MANIFEST.in ├── PKG-INFO ├── README.md ├── doc ├── algorithm.sty ├── algorithmic.sty ├── component-notes.txt ├── dependency.pdf ├── dependency.tex ├── introduction-to-pisi.odp ├── package_versions.pdf ├── package_versions.tex ├── pisi-db.xmi └── prettyref.sty ├── eopkg-cli ├── eopkg.xml.in ├── gen_docs.sh ├── man ├── eopkg.1 ├── eopkg.1.html └── eopkg.1.md ├── pisi-spec.dtd ├── pisi-spec.rng ├── pisi ├── __init__.py ├── actionsapi │ ├── __init__.py │ ├── autotools.py │ ├── cmaketools.py │ ├── coreutils.py │ ├── get.py │ ├── kde.py │ ├── kde4.py │ ├── kerneltools.py │ ├── libtools.py │ ├── perlmodules.py │ ├── pisitools.py │ ├── pisitoolsfunctions.py │ ├── pythonmodules.py │ ├── qt4.py │ ├── rubymodules.py │ ├── scons.py │ ├── shelltools.py │ ├── texlivemodules.py │ ├── variables.py │ └── waftools.py ├── api.py ├── archive.py ├── atomicoperations.py ├── blacklist.py ├── cli │ ├── __init__.py │ ├── addrepo.py │ ├── autoremove.py │ ├── blame.py │ ├── build.py │ ├── check.py │ ├── clean.py │ ├── command.py │ ├── configurepending.py │ ├── deletecache.py │ ├── delta.py │ ├── disablerepo.py │ ├── emerge.py │ ├── enablerepo.py │ ├── fetch.py │ ├── help.py │ ├── history.py │ ├── index.py │ ├── info.py │ ├── install.py │ ├── listavailable.py │ ├── listcomponents.py │ ├── listinstalled.py │ ├── listnewest.py │ ├── listpending.py │ ├── listrepo.py │ ├── listsources.py │ ├── listupgrades.py │ ├── pisicli.py │ ├── rebuilddb.py │ ├── remove.py │ ├── removeorphans.py │ ├── removerepo.py │ ├── search.py │ ├── searchfile.py │ ├── updaterepo.py │ └── upgrade.py ├── comariface.py ├── component.py ├── config.py ├── configfile.py ├── conflict.py ├── constants.py ├── context.py ├── db │ ├── __init__.py │ ├── componentdb.py │ ├── filesdb.py │ ├── groupdb.py │ ├── historydb.py │ ├── installdb.py │ ├── itembyrepo.py │ ├── lazydb.py │ ├── packagedb.py │ ├── repodb.py │ └── sourcedb.py ├── dependency.py ├── errors.py ├── fetcher.py ├── file.py ├── files.py ├── graph.py ├── group.py ├── history.py ├── index.py ├── metadata.py ├── mirrors.py ├── oo.py ├── operations │ ├── __init__.py │ ├── build.py │ ├── check.py │ ├── delta.py │ ├── emerge.py │ ├── helper.py │ ├── history.py │ ├── install.py │ ├── remove.py │ └── upgrade.py ├── package.py ├── pgraph.py ├── pxml │ ├── __init__.py │ ├── autoxml.py │ ├── xmlext.py │ └── xmlfile.py ├── relation.py ├── replace.py ├── scenarioapi │ ├── __init__.py │ ├── actions.py │ ├── constants.py │ ├── package.py │ ├── pisiops.py │ ├── pspec.py │ ├── repoops.py │ ├── scenario.py │ └── withops.py ├── signalhandler.py ├── sourcearchive.py ├── specfile.py ├── ui.py ├── uri.py ├── util.py └── version.py ├── po ├── ca.po ├── de.po ├── es.po ├── fr.po ├── hr.po ├── hu.po ├── it.po ├── nl.po ├── pisi.pot ├── pl.po ├── pt_BR.po ├── ru.po ├── sv.po ├── tr.po └── uk.po ├── scenarios ├── bug11406scen.py ├── bug3237scen.py ├── bug3390scen.py ├── bug3465scen.py ├── bug3481scen.py ├── bug3558scen.py ├── bug3732scen.py ├── bug3865scen.py ├── bug4211scen.py ├── bug9991scen.py └── run.py ├── scripts ├── check-newconfigs.py ├── cleanArchives.py ├── cleanCache.py ├── convert_history.py ├── createdelta.py ├── fix_old_metadata_files.py ├── lseopkg ├── make-changelog.py ├── newpisipackage ├── package-signing │ ├── README │ ├── pisi-key.py │ └── pisign.py ├── pisi-sandbox ├── pisisdr ├── revdep-rebuild ├── svndist-v0.2.py ├── svndist.py ├── sync-licenses └── uneopkg ├── setup.py └── tests ├── README ├── archivetests.py ├── configfiletest.py ├── conflicttests.py ├── constanttest.py ├── database ├── .gitignore ├── __init__.py ├── componentdbtest.py ├── filesdbtest.py ├── installdbtest.py ├── itembyrepotest.py ├── lazydbtest.py ├── packagedbtest.py ├── repodbtest.py ├── sourcedbtest.py └── testcase.py ├── dependencytest.py ├── fetchtest.py ├── filestest.py ├── filetest.py ├── graphtest.py ├── history ├── 001_upgrade.xml ├── 002_remove.xml ├── 003_install.xml └── 004_snapshot.xml ├── historytest.py ├── metadata.xml ├── metadatatest.py ├── mirrors.conf ├── mirrorstest.py ├── packagetest.py ├── relationtest.py ├── replacetest.py ├── repos ├── createrepo.py ├── repo1 │ ├── components.xml │ ├── distribution.xml │ ├── system │ │ ├── base │ │ │ ├── bash │ │ │ │ ├── actions.py │ │ │ │ └── pspec.xml │ │ │ ├── component.xml │ │ │ ├── jpeg │ │ │ │ ├── actions.py │ │ │ │ └── pspec.xml │ │ │ └── openssl │ │ │ │ ├── actions.py │ │ │ │ └── pspec.xml │ │ └── component.xml │ └── util │ │ ├── component.xml │ │ └── misc │ │ ├── bar │ │ ├── actions.py │ │ └── pspec.xml │ │ ├── component.xml │ │ ├── dialog │ │ ├── actions.py │ │ └── pspec.xml │ │ ├── foo │ │ ├── actions.py │ │ └── pspec.xml │ │ └── spam │ │ ├── actions.py │ │ └── pspec.xml └── repo2 │ ├── components.xml │ ├── distribution.xml │ ├── system │ ├── base │ │ └── component.xml │ └── component.xml │ └── util │ ├── component.xml │ └── misc │ ├── bar │ ├── actions.py │ └── pspec.xml │ ├── component.xml │ ├── dialog │ ├── actions.py │ └── pspec.xml │ ├── foo │ ├── actions.py │ └── pspec.xml │ └── spam │ ├── actions.py │ └── pspec.xml ├── runtests.py ├── shelltest.py ├── specfiletests.py ├── srcarchivetest.py ├── uritest.py ├── utiltest.py └── versiontest.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.mo 2 | *.pyc 3 | /build/ 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Maintainers 2 | ----------- 3 | Fatih Aşıcı 4 | 5 | Developers 6 | ---------- 7 | A. Murat Eren 8 | Bahadır Kandemir 9 | Barış Metin 10 | Eray Özkural 11 | Faik Uygur 12 | Fatih Aşıcı 13 | Gürer Özen 14 | İsmail Dönmez 15 | Mehmet D. Akın 16 | Onur Küçük 17 | Ozan Çağlayan 18 | S. Çağlar Onur 19 | Serdar Dalgıç 20 | 21 | Contributors 22 | ------------ 23 | Ahmet Aygun 24 | Ali Erdinç Köroğlu 25 | Amine Chadly 26 | Andre van der Lubben 27 | Andrea Decorte 28 | Anton Tolboom 29 | Beyza Ermiş 30 | Christian Faure 31 | Davide Siciliano 32 | Eren Türkay 33 | Furkan Duman 34 | Gökhan Göktürk 35 | Gökmen Göksel 36 | Gökmen Görgen 37 | Gökçen Eraslan 38 | Görkem Çetin 39 | H. İbrahim Güngör 40 | Klemens Häckel 41 | Mustafa Ölçerman 42 | Necmettin Begiter 43 | Patrik Karlsson 44 | Pedro Leite 45 | Philippe Svetoslavsky 46 | Piotr Maliński 47 | Pınar Yanardağ 48 | Rinse de Vries 49 | Semen Cirit 50 | Stefan Wilhelm 51 | Uğur Çetin 52 | Willem Gielen 53 | 54 | Solus Duration: 55 | --------------- 56 | 57 | Ikey Doherty 58 | Former: ikey AT evolve-os DOT com ikey AT solusos DOT com 59 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 04-03-2013 Ikey Doherty 2 | * pisi 3.0 3 | 4 | We've now taken ownership of the PiSi Package Manager within SolusOS 5 | All PiSi patches have been imported, and initial Clang support has been 6 | added. 7 | 8 | We intend to ship SolusOS 2 with pisi 3.x, given a stable updated API 9 | and full compiler switching + Clang Support 10 | 11 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include doc * 2 | recursive-include po * 3 | recursive-include scenarios * 4 | recursive-include scripts * 5 | recursive-include tests * 6 | include *.dtd *.rng *.in 7 | include AUTHORS ChangeLog* CODING COPYING INSTALL README* TODO 8 | -------------------------------------------------------------------------------- /PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: pisi 3 | Version: 3.6 4 | Summary: eopkg (Packages Installed Successfully as Intended) 5 | Home-page: https://www.solus-project.com 6 | Author: Ikey Doherty 7 | Author-email: ikey@solus-project.com 8 | License: GNU GPL2 9 | Description: eopkg is the package management system of Solus Operating System, originally written for Pardus Linux by the Pardus Developers. 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | eopkg package manager 2 | --------------------- 3 | 4 | Fork of the PiSi Package Manager, originally from Pardus Linux, 5 | and adapted/maintained during the lifetime of SolusOS, EvolveOS and Solus. 6 | 7 | Please note that we plan to replace eopkg with [`sol`](https://github.com/solus-project/sol). 8 | -------------------------------------------------------------------------------- /doc/algorithm.sty: -------------------------------------------------------------------------------- 1 | % ALGORITHM STYLE -- Released 8 April 1996 2 | % for LaTeX-2e 3 | % Copyright -- 1994 Peter Williams 4 | % E-mail Peter.Williams@dsto.defence.gov.au 5 | \NeedsTeXFormat{LaTeX2e} 6 | \ProvidesPackage{algorithm} 7 | \typeout{Document Style `algorithm' - floating environment} 8 | 9 | \RequirePackage{float} 10 | \RequirePackage{ifthen} 11 | \newcommand{\ALG@within}{nothing} 12 | \newboolean{ALG@within} 13 | \setboolean{ALG@within}{false} 14 | \newcommand{\ALG@floatstyle}{ruled} 15 | \newcommand{\ALG@name}{Algorithm} 16 | \newcommand{\listalgorithmname}{List of \ALG@name s} 17 | 18 | % Declare Options 19 | % first appearance 20 | \DeclareOption{plain}{ 21 | \renewcommand{\ALG@floatstyle}{plain} 22 | } 23 | \DeclareOption{ruled}{ 24 | \renewcommand{\ALG@floatstyle}{ruled} 25 | } 26 | \DeclareOption{boxed}{ 27 | \renewcommand{\ALG@floatstyle}{boxed} 28 | } 29 | % then numbering convention 30 | \DeclareOption{part}{ 31 | \renewcommand{\ALG@within}{part} 32 | \setboolean{ALG@within}{true} 33 | } 34 | \DeclareOption{chapter}{ 35 | \renewcommand{\ALG@within}{chapter} 36 | \setboolean{ALG@within}{true} 37 | } 38 | \DeclareOption{section}{ 39 | \renewcommand{\ALG@within}{section} 40 | \setboolean{ALG@within}{true} 41 | } 42 | \DeclareOption{subsection}{ 43 | \renewcommand{\ALG@within}{subsection} 44 | \setboolean{ALG@within}{true} 45 | } 46 | \DeclareOption{subsubsection}{ 47 | \renewcommand{\ALG@within}{subsubsection} 48 | \setboolean{ALG@within}{true} 49 | } 50 | \DeclareOption{nothing}{ 51 | \renewcommand{\ALG@within}{nothing} 52 | \setboolean{ALG@within}{true} 53 | } 54 | \DeclareOption*{\edef\ALG@name{\CurrentOption}} 55 | 56 | % ALGORITHM 57 | % 58 | \ProcessOptions 59 | \floatstyle{\ALG@floatstyle} 60 | \ifthenelse{\boolean{ALG@within}}{ 61 | \ifthenelse{\equal{\ALG@within}{part}} 62 | {\newfloat{algorithm}{htbp}{loa}[part]}{} 63 | \ifthenelse{\equal{\ALG@within}{chapter}} 64 | {\newfloat{algorithm}{htbp}{loa}[chapter]}{} 65 | \ifthenelse{\equal{\ALG@within}{section}} 66 | {\newfloat{algorithm}{htbp}{loa}[section]}{} 67 | \ifthenelse{\equal{\ALG@within}{subsection}} 68 | {\newfloat{algorithm}{htbp}{loa}[subsection]}{} 69 | \ifthenelse{\equal{\ALG@within}{subsubsection}} 70 | {\newfloat{algorithm}{htbp}{loa}[subsubsection]}{} 71 | \ifthenelse{\equal{\ALG@within}{nothing}} 72 | {\newfloat{algorithm}{htbp}{loa}}{} 73 | }{ 74 | \newfloat{algorithm}{htbp}{loa} 75 | } 76 | \floatname{algorithm}{\ALG@name} 77 | 78 | \newcommand{\listofalgorithms}{\listof{algorithm}{\listalgorithmname}} 79 | 80 | -------------------------------------------------------------------------------- /doc/dependency.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/solus-project/package-management/f7b05b6ad06d8482563d9970016aeb138dc6a997/doc/dependency.pdf -------------------------------------------------------------------------------- /doc/introduction-to-pisi.odp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/solus-project/package-management/f7b05b6ad06d8482563d9970016aeb138dc6a997/doc/introduction-to-pisi.odp -------------------------------------------------------------------------------- /doc/package_versions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/solus-project/package-management/f7b05b6ad06d8482563d9970016aeb138dc6a997/doc/package_versions.pdf -------------------------------------------------------------------------------- /doc/prettyref.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `prettyref.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% prettyref.dtx (with options: `style') 8 | %% 9 | %% Copyright (c) 1995 Kevin Ruland 10 | %% 11 | %% 12 | %% prettyref v3.0 13 | %% 14 | %% Copyright 1995,1998. by Kevin Ruland kevin@rodin.wustl.edu 15 | %% 16 | \ProvidesPackage{prettyref}[1998/07/09 v3.0] 17 | \def\newrefformat#1#2{% 18 | \@namedef{pr@#1}##1{#2}} 19 | \newrefformat{eq}{\textup{(\ref{#1})}} 20 | \newrefformat{lem}{Lemma \ref{#1}} 21 | \newrefformat{thm}{Theorem \ref{#1}} 22 | \newrefformat{cha}{Chapter \ref{#1}} 23 | \newrefformat{sec}{Section \ref{#1}} 24 | \newrefformat{tab}{Table \ref{#1} on page \pageref{#1}} 25 | \newrefformat{fig}{Figure \ref{#1} on page \pageref{#1}} 26 | \def\prettyref#1{\@prettyref#1:} 27 | \def\@prettyref#1:#2:{% 28 | \expandafter\ifx\csname pr@#1\endcsname\relax% 29 | \PackageWarning{prettyref}{Reference format #1\space undefined}% 30 | \ref{#1:#2}% 31 | \else% 32 | \csname pr@#1\endcsname{#1:#2}% 33 | \fi% 34 | } 35 | \endinput 36 | %% 37 | %% End of file `prettyref.sty'. 38 | -------------------------------------------------------------------------------- /eopkg-cli: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (C) 2005 - 2010, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import sys 14 | import errno 15 | import traceback 16 | import exceptions 17 | import signal 18 | 19 | import pisi 20 | import pisi.context as ctx 21 | import pisi.cli.pisicli as pisicli 22 | 23 | import gettext 24 | gettext.bindtextdomain('pisi', "/usr/share/locale") 25 | gettext.textdomain('pisi') 26 | __trans = gettext.translation('pisi', fallback=True) 27 | _ = __trans.ugettext 28 | 29 | def sig_handler(sig, frame): 30 | if sig == signal.SIGTERM: 31 | exit() 32 | 33 | def exit(): 34 | sys.exit(1) 35 | 36 | def handle_exception(exception, value, tb): 37 | signal.signal(signal.SIGINT, signal.SIG_IGN) # disable further interrupts 38 | ui = pisi.cli.CLI() # make a temporary UI 39 | show_traceback = False 40 | 41 | if exception == exceptions.KeyboardInterrupt: 42 | ui.error(_("Keyboard Interrupt: Exiting...")) 43 | exit() 44 | elif isinstance(value, pisi.Error): 45 | ui.error(_("Program terminated.")) 46 | elif isinstance(value, pisi.Exception): 47 | show_traceback = True 48 | ui.error(_("Unhandled internal exception.\n" 49 | "Please file a bug report to .")) 50 | elif isinstance(value, IOError) and value.errno == errno.EPIPE: 51 | # Ignore broken pipe errors 52 | sys.exit(0) 53 | else: 54 | # For any other exception (possibly Python exceptions) show 55 | # the traceback! 56 | show_traceback = ctx.get_option('debug') 57 | ui.error(_("System error. Program terminated.")) 58 | 59 | if show_traceback: 60 | ui.error("%s: %s" % (exception, str(value))) 61 | else: 62 | msg = str(value) 63 | if msg: 64 | ui.error(msg) 65 | 66 | ui.info(_("Please use 'eopkg help' for general help.")) 67 | 68 | if show_traceback: 69 | ui.info(_("\nTraceback:")) 70 | traceback.print_tb(tb) 71 | elif not isinstance(value, pisi.Error): 72 | ui.info(_("Use --debug to see a traceback.")) 73 | 74 | exit() 75 | 76 | if __name__ == "__main__": 77 | sys.excepthook = handle_exception 78 | 79 | signal.signal(signal.SIGTERM, sig_handler) 80 | 81 | cli = pisicli.PisiCLI() 82 | cli.run_command() 83 | -------------------------------------------------------------------------------- /eopkg.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | <_comment>Solus Operating System package 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gen_docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Credit to swupd developers: https://github.com/clearlinux/swupd-client 4 | 5 | MANPAGES="man/eopkg.1" 6 | 7 | for MANPAGE in ${MANPAGES}; do \ 8 | ronn --roff < ${MANPAGE}.md > ${MANPAGE}; \ 9 | ronn --html < ${MANPAGE}.md > ${MANPAGE}.html; \ 10 | done 11 | -------------------------------------------------------------------------------- /pisi/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005-2011, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | # eopkg version 14 | 15 | import os 16 | import sys 17 | import atexit 18 | import logging 19 | import logging.handlers 20 | 21 | __version__ = "3.2" 22 | 23 | __all__ = [ 'api', 'configfile', 'db'] 24 | 25 | # FIXME: Exception shadows builtin Exception. This is no good. 26 | class Exception(Exception): 27 | """Class of exceptions that must be caught and handled within eopkg""" 28 | def __str__(self): 29 | s = u'' 30 | for x in self.args: 31 | if s != '': 32 | s += '\n' 33 | s += unicode(x) 34 | return s 35 | 36 | class Error(Exception): 37 | """Class of exceptions that lead to program termination""" 38 | pass 39 | 40 | import pisi.api 41 | import pisi.config 42 | import pisi.context as ctx 43 | 44 | def init_logging(): 45 | log_dir = os.path.join(ctx.config.dest_dir(), ctx.config.log_dir()) 46 | if os.access(log_dir, os.W_OK) and not sys.modules.has_key("distutils.core"): 47 | handler = logging.handlers.RotatingFileHandler('%s/eopkg.log' % log_dir) 48 | formatter = logging.Formatter('%(asctime)-12s: %(levelname)-8s %(message)s') 49 | handler.setFormatter(formatter) 50 | ctx.log = logging.getLogger('pisi') 51 | ctx.log.addHandler(handler) 52 | ctx.loghandler = handler 53 | ctx.log.setLevel(logging.DEBUG) 54 | 55 | def _cleanup(): 56 | """Close the database cleanly and do other cleanup.""" 57 | ctx.disable_keyboard_interrupts() 58 | if ctx.log: 59 | ctx.loghandler.flush() 60 | ctx.log.removeHandler(ctx.loghandler) 61 | 62 | filesdb = pisi.db.filesdb.FilesDB() 63 | if filesdb.is_initialized(): 64 | filesdb.close() 65 | 66 | if ctx.build_leftover and os.path.exists(ctx.build_leftover): 67 | os.unlink(ctx.build_leftover) 68 | 69 | ctx.ui.close() 70 | ctx.enable_keyboard_interrupts() 71 | 72 | # Hack for pisi to work with non-patched Python. pisi needs 73 | # lots of work for not doing this. 74 | reload(sys) 75 | sys.setdefaultencoding('utf-8') 76 | 77 | atexit.register(_cleanup) 78 | 79 | ctx.config = pisi.config.Config() 80 | init_logging() 81 | -------------------------------------------------------------------------------- /pisi/actionsapi/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005-2010 TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import pisi 14 | 15 | class Error(pisi.Error): 16 | pass 17 | 18 | class Exception(pisi.Exception): 19 | pass 20 | 21 | import pisi.context as ctx 22 | 23 | def error(msg): 24 | if ctx.config.get_option('ignore_action_errors'): 25 | ctx.ui.error(msg) 26 | else: 27 | raise Error(msg) 28 | -------------------------------------------------------------------------------- /pisi/actionsapi/coreutils.py: -------------------------------------------------------------------------------- 1 | #-*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005-2010 TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | # Standard Python Modules 13 | import re 14 | import sys 15 | from itertools import izip 16 | from itertools import imap 17 | from itertools import count 18 | from itertools import ifilter 19 | from itertools import ifilterfalse 20 | 21 | # ActionsAPI 22 | import pisi.actionsapi 23 | 24 | def cat(filename): 25 | return file(filename).xreadlines() 26 | 27 | class grep: 28 | '''keep only lines that match the regexp''' 29 | def __init__(self, pat, flags = 0): 30 | self.fun = re.compile(pat, flags).match 31 | def __ror__(self, input): 32 | return ifilter(self.fun, input) 33 | 34 | class tr: 35 | '''apply arbitrary transform to each sequence element''' 36 | def __init__(self, transform): 37 | self.tr = transform 38 | def __ror__(self, input): 39 | return imap(self.tr, input) 40 | 41 | class printto: 42 | '''print sequence elements one per line''' 43 | def __init__(self, out = sys.stdout): 44 | self.out = out 45 | def __ror__(self,input): 46 | for line in input: 47 | print >> self.out, line 48 | 49 | printlines = printto(sys.stdout) 50 | 51 | class terminator: 52 | def __init__(self,method): 53 | self.process = method 54 | def __ror__(self,input): 55 | return self.process(input) 56 | 57 | aslist = terminator(list) 58 | asdict = terminator(dict) 59 | astuple = terminator(tuple) 60 | join = terminator(''.join) 61 | enum = terminator(enumerate) 62 | 63 | class sort: 64 | def __ror__(self,input): 65 | ll = list(input) 66 | ll.sort() 67 | return ll 68 | sort = sort() 69 | 70 | class uniq: 71 | def __ror__(self,input): 72 | for i in input: 73 | try: 74 | if i == prev: 75 | continue 76 | except NameError: 77 | pass 78 | prev = i 79 | yield i 80 | uniq = uniq() 81 | -------------------------------------------------------------------------------- /pisi/actionsapi/kde.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005-2010 TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | # standard python modules 13 | import os 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | # Pisi Modules 20 | import pisi.context as ctx 21 | 22 | # ActionsAPI Modules 23 | import pisi.actionsapi 24 | import pisi.actionsapi.get as get 25 | from pisi.actionsapi.shelltools import system 26 | from pisi.actionsapi.shelltools import can_access_file 27 | 28 | class ConfigureError(pisi.actionsapi.Error): 29 | def __init__(self, value=''): 30 | pisi.actionsapi.Error.__init__(self, value) 31 | self.value = value 32 | ctx.ui.error(value) 33 | if can_access_file('config.log'): 34 | ctx.ui.error(_('\n!!! Please attach the config.log to your bug report:\n%s/config.log') % os.getcwd()) 35 | 36 | class MakeError(pisi.actionsapi.Error): 37 | def __init__(self, value=''): 38 | pisi.actionsapi.Error.__init__(self, value) 39 | self.value = value 40 | ctx.ui.error(value) 41 | 42 | class InstallError(pisi.actionsapi.Error): 43 | def __init__(self, value=''): 44 | pisi.actionsapi.Error.__init__(self, value) 45 | self.value = value 46 | ctx.ui.error(value) 47 | 48 | def configure(parameters = ''): 49 | ''' parameters = '--with-nls --with-libusb --with-something-usefull ''' 50 | if can_access_file('configure'): 51 | args = './configure \ 52 | --prefix=%s \ 53 | --build=%s \ 54 | --with-x \ 55 | --enable-mitshm \ 56 | --with-xinerama \ 57 | --with-qt-dir=%s \ 58 | --enable-mt \ 59 | --with-qt-libraries=%s/lib \ 60 | --disable-dependency-tracking \ 61 | --disable-debug \ 62 | %s' % (get.kdeDIR(), get.HOST(), get.qtDIR(), get.qtDIR(), parameters) 63 | 64 | if system(args): 65 | raise ConfigureError(_('Configure failed.')) 66 | else: 67 | raise ConfigureError(_('No configure script found.')) 68 | 69 | def make(parameters = ''): 70 | '''make source with given parameters = "all" || "doc" etc.''' 71 | if system('make %s %s' % (get.makeJOBS(), parameters)): 72 | raise MakeError(_('Make failed.')) 73 | 74 | def install(parameters = 'install'): 75 | if can_access_file('Makefile'): 76 | args = 'make DESTDIR=%s destdir=%s %s' % (get.installDIR(), get.installDIR(), parameters) 77 | 78 | if system(args): 79 | raise InstallError(_('Install failed.')) 80 | else: 81 | raise InstallError(_('No Makefile found.')) 82 | -------------------------------------------------------------------------------- /pisi/actionsapi/kde4.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2010 TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | # ActionsAPI Modules 13 | from pisi.actionsapi import get 14 | from pisi.actionsapi import cmaketools 15 | from pisi.actionsapi import shelltools 16 | 17 | basename = "kde4" 18 | 19 | prefix = "/%s" % get.defaultprefixDIR() 20 | libdir = "%s/lib" % prefix 21 | bindir = "%s/bin" % prefix 22 | modulesdir = "%s/%s" % (libdir, basename) 23 | libexecdir = "%s/libexec" % modulesdir 24 | iconsdir = "%s/share/icons" % prefix 25 | applicationsdir = "%s/share/applications/%s" % (prefix, basename) 26 | mandir = "/%s" % get.manDIR() 27 | sharedir = "%s/share/%s" % (prefix, basename) 28 | appsdir = "%s/apps" % sharedir 29 | configdir = "%s/config" % sharedir 30 | sysconfdir= "/etc" 31 | servicesdir = "%s/services" % sharedir 32 | servicetypesdir = "%s/servicetypes" % sharedir 33 | includedir = "%s/include/%s" % (prefix, basename) 34 | docdir = "/%s/%s" % (get.docDIR(), basename) 35 | htmldir = "%s/html" % docdir 36 | wallpapersdir = "%s/share/wallpapers" % prefix 37 | 38 | def configure(parameters = '', installPrefix = prefix, sourceDir = '..'): 39 | ''' parameters -DLIB_INSTALL_DIR="hede" -DSOMETHING_USEFUL=1''' 40 | 41 | shelltools.makedirs("build") 42 | shelltools.cd("build") 43 | 44 | cmaketools.configure("-DDATA_INSTALL_DIR:PATH=%s \ 45 | -DINCLUDE_INSTALL_DIR:PATH=%s \ 46 | -DCONFIG_INSTALL_DIR:PATH=%s \ 47 | -DLIBEXEC_INSTALL_DIR:PATH=%s \ 48 | -DSYSCONF_INSTALL_DIR:PATH=%s \ 49 | -DHTML_INSTALL_DIR:PATH=%s \ 50 | -DMAN_INSTALL_DIR:PATH=%s \ 51 | -DCMAKE_SKIP_RPATH:BOOL=ON \ 52 | -DLIB_INSTALL_DIR:PATH=%s %s" % (appsdir, includedir, configdir, libexecdir, sysconfdir, htmldir, mandir, libdir, parameters), installPrefix, sourceDir) 53 | 54 | shelltools.cd("..") 55 | 56 | def make(parameters = ''): 57 | cmaketools.make('-C build %s' % parameters) 58 | 59 | def install(parameters = '', argument = 'install'): 60 | cmaketools.install('-C build %s' % parameters, argument) 61 | -------------------------------------------------------------------------------- /pisi/actionsapi/libtools.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005-2010 TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | # Standard Python Modules 13 | import os 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | # Pisi-Core Modules 20 | import pisi.context as ctx 21 | from pisi.util import join_path 22 | 23 | # ActionsAPI Modules 24 | import pisi.actionsapi 25 | from pisi.actionsapi.shelltools import * 26 | import pisi.actionsapi.get as get 27 | 28 | class RunTimeError(pisi.actionsapi.Error): 29 | def __init__(self, value=''): 30 | pisi.actionsapi.Error.__init__(self, value) 31 | self.value = value 32 | ctx.ui.error(value) 33 | 34 | def preplib(sourceDirectory = '/usr/lib'): 35 | sourceDirectory = join_path(get.installDIR(), sourceDirectory) 36 | if can_access_directory(sourceDirectory): 37 | if system('/sbin/ldconfig -n -N %s' % sourceDirectory): 38 | raise RunTimeError(_('Running ldconfig failed.')) 39 | 40 | def gnuconfig_update(): 41 | ''' copy newest config.* onto source\'s ''' 42 | for root, dirs, files in os.walk(os.getcwd()): 43 | for fileName in files: 44 | if fileName in ['config.sub', 'config.guess']: 45 | targetFile = os.path.join(root, fileName) 46 | if os.path.islink(targetFile): 47 | unlink(targetFile) 48 | copy('/usr/share/gnuconfig/%s' % fileName, join_path(root, fileName)) 49 | ctx.ui.info(_('GNU Config Update Finished.')) 50 | 51 | def libtoolize(parameters = ''): 52 | if system('/usr/bin/libtoolize %s' % parameters): 53 | raise RunTimeError(_('Running libtoolize failed.')) 54 | 55 | def gen_usr_ldscript(dynamicLib): 56 | 57 | makedirs('%s/usr/lib' % get.installDIR()) 58 | 59 | destinationFile = open('%s/usr/lib/%s' % (get.installDIR(), dynamicLib), 'w') 60 | content = ''' 61 | /* GNU ld script 62 | Since Pardus has critical dynamic libraries 63 | in /lib, and the static versions in /usr/lib, 64 | we need to have a "fake" dynamic lib in /usr/lib, 65 | otherwise we run into linking problems. 66 | */ 67 | GROUP ( /lib/%s ) 68 | ''' % dynamicLib 69 | 70 | destinationFile.write(content) 71 | destinationFile.close() 72 | chmod('%s/usr/lib/%s' % (get.installDIR(), dynamicLib)) 73 | -------------------------------------------------------------------------------- /pisi/actionsapi/qt4.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2010 TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | import glob 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | # Pisi Modules 18 | import pisi.context as ctx 19 | 20 | # ActionsAPI Modules 21 | import pisi.actionsapi 22 | 23 | # ActionsAPI Modules 24 | from pisi.actionsapi import get 25 | from pisi.actionsapi import cmaketools 26 | from pisi.actionsapi import shelltools 27 | 28 | basename = "qt4" 29 | 30 | prefix = "/%s" % get.defaultprefixDIR() 31 | libdir = "%s/lib" % prefix 32 | bindir = "%s/bin" % prefix 33 | datadir = "%s/share/%s" % (prefix, basename) 34 | includedir = "%s/include" % prefix 35 | docdir = "/%s/%s" % (get.docDIR(), basename) 36 | examplesdir = "%s/%s/examples" % (libdir, basename) 37 | demosdir = "%s/%s/demos" % (libdir, basename) 38 | importdir = "%s/%s/imports" % (libdir, basename) 39 | plugindir = "%s/%s/plugins" % (libdir, basename) 40 | translationdir = "%s/translations" % datadir 41 | sysconfdir= "/etc" 42 | qmake = "%s/qmake" % bindir 43 | 44 | class ConfigureError(pisi.actionsapi.Error): 45 | def __init__(self, value=''): 46 | pisi.actionsapi.Error.__init__(self, value) 47 | self.value = value 48 | ctx.ui.error(value) 49 | 50 | def configure(projectfile='', parameters='', installPrefix=prefix): 51 | if projectfile != '' and not shelltools.can_access_file(projectfile): 52 | raise ConfigureError(_("Project file '%s' not found.") % projectfile) 53 | 54 | profiles = glob.glob("*.pro") 55 | if len(profiles) > 1 and projectfile == '': 56 | raise ConfigureError(_("It seems there are more than one .pro file, you must specify one. (Possible .pro files: %s)") % ", ".join(profiles)) 57 | 58 | shelltools.system("%s -makefile %s PREFIX='%s' QMAKE_CFLAGS+='%s' QMAKE_CXXFLAGS+='%s' %s" % (qmake, projectfile, installPrefix, get.CFLAGS(), get.CXXFLAGS(), parameters)) 59 | 60 | def make(parameters=''): 61 | cmaketools.make(parameters) 62 | 63 | def install(parameters='', argument='install'): 64 | cmaketools.install('INSTALL_ROOT="%s" %s' % (get.installDIR(), parameters), argument) 65 | 66 | -------------------------------------------------------------------------------- /pisi/actionsapi/scons.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005-2010 TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | 13 | # Pisi Modules 14 | import pisi.context as ctx 15 | 16 | import gettext 17 | __trans = gettext.translation('pisi', fallback=True) 18 | _ = __trans.ugettext 19 | 20 | # ActionsAPI Modules 21 | import pisi.actionsapi 22 | import pisi.actionsapi.get as get 23 | from pisi.actionsapi.shelltools import system 24 | 25 | class MakeError(pisi.actionsapi.Error): 26 | def __init__(self, value=''): 27 | pisi.actionsapi.Error.__init__(self, value) 28 | self.value = value 29 | ctx.ui.error(value) 30 | 31 | class InstallError(pisi.actionsapi.Error): 32 | def __init__(self, value=''): 33 | pisi.actionsapi.Error.__init__(self, value) 34 | self.value = value 35 | ctx.ui.error(value) 36 | 37 | def make(parameters = ''): 38 | if system('scons %s %s' % (get.makeJOBS(), parameters)): 39 | raise MakeError(_('Make failed.')) 40 | 41 | def install(parameters = 'install', prefix = get.installDIR(), argument='prefix'): 42 | if system('scons %s=%s %s' % (argument, prefix, parameters)): 43 | raise InstallError(_('Install failed.')) 44 | -------------------------------------------------------------------------------- /pisi/actionsapi/waftools.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2013 Ikey Doherty 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | # Standard Python Modules 13 | import os 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | # Pisi Modules 20 | import pisi.context as ctx 21 | 22 | # ActionsAPI Modules 23 | import pisi.actionsapi 24 | import pisi.actionsapi.get as get 25 | from pisi.actionsapi.shelltools import system 26 | from pisi.actionsapi.shelltools import can_access_file 27 | from pisi.actionsapi.shelltools import unlink 28 | from pisi.actionsapi.shelltools import export 29 | from pisi.actionsapi.shelltools import isDirectory 30 | from pisi.actionsapi.shelltools import ls 31 | from pisi.actionsapi.pisitools import dosed 32 | from pisi.actionsapi.pisitools import removeDir 33 | 34 | class ConfigureError(pisi.actionsapi.Error): 35 | def __init__(self, value=''): 36 | pisi.actionsapi.Error.__init__(self, value) 37 | self.value = value 38 | ctx.ui.error(value) 39 | 40 | class MakeError(pisi.actionsapi.Error): 41 | def __init__(self, value=''): 42 | pisi.actionsapi.Error.__init__(self, value) 43 | self.value = value 44 | ctx.ui.error(value) 45 | 46 | class InstallError(pisi.actionsapi.Error): 47 | def __init__(self, value=''): 48 | pisi.actionsapi.Error.__init__(self, value) 49 | self.value = value 50 | ctx.ui.error(value) 51 | 52 | class RunTimeError(pisi.actionsapi.Error): 53 | def __init__(self, value=''): 54 | pisi.actionsapi.Error.__init__(self, value) 55 | self.value = value 56 | ctx.ui.error(value) 57 | 58 | def _presetup(): 59 | export ("JOBS", get.makeJOBS().replace("-j","")) 60 | export ("DESTDIR", get.installDIR()) 61 | 62 | def configure(parameters = ''): 63 | '''configure source with given parameters "''' 64 | _presetup () 65 | cmd = "./waf configure --prefix=/usr %s" % parameters 66 | 67 | if can_access_file('waf'): 68 | if system(cmd): 69 | raise ConfigureError(_('Configure failed.')) 70 | else: 71 | raise ConfigureError(_('No configure script found.')) 72 | 73 | def make(parameters = ''): 74 | '''make source with given parameters = "all" || "doc" etc.''' 75 | _presetup () 76 | if system('./waf build %s' % parameters): 77 | raise MakeError(_('Make failed.')) 78 | 79 | 80 | def install(parameters = ''): 81 | '''install source into install directory with given parameters''' 82 | _presetup () 83 | cmd = "./waf install %s" % parameters 84 | 85 | if system(cmd): 86 | raise InstallError(_('Install failed.')) 87 | -------------------------------------------------------------------------------- /pisi/blacklist.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2008, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import os 14 | import fnmatch 15 | 16 | import pisi.db 17 | 18 | def exclude_from(packages, exfrom): 19 | 20 | if not os.path.exists(exfrom): 21 | return packages 22 | 23 | patterns = [] 24 | if os.path.exists(exfrom): 25 | for line in open(exfrom, "r").readlines(): 26 | if not line.startswith('#') and not line == '\n': 27 | patterns.append(line.strip()) 28 | if patterns: 29 | return exclude(packages, patterns) 30 | 31 | return packages 32 | 33 | def exclude(packages, patterns): 34 | packages = set(packages) 35 | componentdb = pisi.db.componentdb.ComponentDB() 36 | 37 | for pattern in patterns: 38 | # match pattern in package names 39 | match = fnmatch.filter(packages, pattern) 40 | packages = packages - set(match) 41 | 42 | if not match: 43 | # match pattern in component names 44 | for compare in fnmatch.filter(componentdb.list_components(), pattern): 45 | packages = packages - set(componentdb.get_union_packages(compare, walk=True)) 46 | 47 | return list(packages) 48 | -------------------------------------------------------------------------------- /pisi/cli/autoremove.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # Copyright (C) 2013-2017 Solus Project 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | # 13 | 14 | import optparse 15 | 16 | import gettext 17 | __trans = gettext.translation('pisi', fallback=True) 18 | _ = __trans.ugettext 19 | 20 | import pisi.cli.command as command 21 | import pisi.context as ctx 22 | import pisi.api 23 | import pisi.db 24 | 25 | class AutoRemove(command.PackageOp): 26 | __doc__ = _("""Remove eopkg packages 27 | 28 | Usage: autoremove ... 29 | 30 | Remove package(s) from your system. Just give the package names to remove. 31 | 32 | You can also specify components instead of package names, which will be 33 | expanded to package names. 34 | 35 | Any additional packages that were automatically installed as a result of 36 | installing the packages being removed, will also be removed if it is 37 | safe to do so. 38 | """) 39 | __metaclass__ = command.autocommand 40 | 41 | def __init__(self, args): 42 | super(AutoRemove, self).__init__(args) 43 | self.componentdb = pisi.db.componentdb.ComponentDB() 44 | 45 | name = ("autoremove", "rmf") 46 | 47 | def options(self): 48 | group = optparse.OptionGroup(self.parser, _("autoremove options")) 49 | super(AutoRemove, self).options(group) 50 | group.add_option("--purge", action="store_true", 51 | default=False, help=_("Removes everything including changed config files of the package")) 52 | self.parser.add_option_group(group) 53 | 54 | def run(self): 55 | self.init() 56 | 57 | if not self.args: 58 | self.help() 59 | return 60 | 61 | packages = [] 62 | packages.extend(self.args) 63 | 64 | pisi.api.autoremove(packages) 65 | -------------------------------------------------------------------------------- /pisi/cli/blame.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2009, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.cli.command as command 20 | import pisi.context as ctx 21 | import pisi.db 22 | 23 | class Blame(command.Command): 24 | __doc__ = _("""Information about the package owner and release 25 | 26 | Usage: blame ... 27 | 28 | """) 29 | 30 | __metaclass__ = command.autocommand 31 | 32 | def __init__(self, args=None): 33 | super(Blame, self).__init__(args) 34 | self.installdb = pisi.db.installdb.InstallDB() 35 | 36 | name = ("blame", "bl") 37 | 38 | def options(self): 39 | group = optparse.OptionGroup(self.parser, _("blame options")) 40 | group.add_option("-r", "--release", action="store", type="int", help=_("Blame for the given release")) 41 | group.add_option("-a", "--all", action="store_true", default=False, 42 | help=_("Blame for all of the releases")) 43 | self.parser.add_option_group(group) 44 | 45 | def run(self): 46 | self.init(database=False, write=False) 47 | 48 | if not self.args: 49 | self.help() 50 | return 51 | 52 | for package in self.args: 53 | if self.installdb.has_package(package): 54 | pkg = self.installdb.get_package(package) 55 | release = ctx.get_option('release') 56 | if not release and not ctx.get_option('all'): 57 | self.print_package_info(pkg) 58 | elif ctx.get_option('all'): 59 | for hno, update in enumerate(pkg.history): 60 | self.print_package_info(pkg, hno) 61 | else: 62 | for hno, update in enumerate(pkg.history): 63 | if int(update.release) == release: 64 | self.print_package_info(pkg, hno) 65 | return 66 | 67 | def print_package_info(self, package, hno=0): 68 | s = _('Name: %s, version: %s, release: %s\n') % ( 69 | package.name, package.history[hno].version, package.history[hno].release) 70 | s += _('Package Maintainer: %s <%s>\n') % (unicode(package.source.packager.name), package.source.packager.email) 71 | s += _('Release Updater: %s <%s>\n') % (package.history[hno].name, package.history[hno].email) 72 | s += _('Update Date: %s\n') % package.history[hno].date 73 | s += '\n%s\n' % package.history[hno].comment 74 | ctx.ui.info(s) 75 | -------------------------------------------------------------------------------- /pisi/cli/clean.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi.cli.command as command 18 | 19 | class Clean(command.Command): 20 | __doc__ = _("""Clean stale locks 21 | 22 | Usage: clean 23 | 24 | eopkg uses filesystem locks for managing database access. 25 | This command deletes unused locks from the database directory.""") 26 | 27 | __metaclass__ = command.autocommand 28 | 29 | def __init__(self, args=None): 30 | super(Clean, self).__init__(args) 31 | 32 | name = ("clean", None) 33 | 34 | def run(self): 35 | self.init() 36 | 37 | -------------------------------------------------------------------------------- /pisi/cli/configurepending.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.api 20 | import pisi.cli.command as command 21 | 22 | class ConfigurePending(command.PackageOp): 23 | __doc__ = _("""Configure pending packages 24 | 25 | If COMAR configuration of some packages were not 26 | done at installation time, they are added to a list 27 | of packages waiting to be configured. This command 28 | configures those packages. 29 | """) 30 | 31 | __metaclass__ = command.autocommand 32 | 33 | def __init__(self, args): 34 | super(ConfigurePending, self).__init__(args) 35 | 36 | name = ("configure-pending", "cp") 37 | 38 | def options(self): 39 | group = optparse.OptionGroup(self.parser, _("configure-pending options")) 40 | super(ConfigurePending, self).options(group) 41 | self.parser.add_option_group(group) 42 | 43 | def run(self): 44 | 45 | self.init() 46 | pisi.api.configure_pending(self.args) 47 | -------------------------------------------------------------------------------- /pisi/cli/deletecache.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi 18 | import pisi.api 19 | import pisi.cli.command as command 20 | 21 | class DeleteCache(command.Command): 22 | __doc__ = _("""Delete cache files 23 | 24 | Usage: delete-cache 25 | 26 | Sources, packages and temporary files are stored 27 | under /var directory. Since these accumulate they can 28 | consume a lot of disk space.""") 29 | 30 | __metaclass__ = command.autocommand 31 | 32 | def __init__(self, args=None): 33 | super(DeleteCache, self).__init__(args) 34 | 35 | name = ("delete-cache", "dc") 36 | 37 | def run(self): 38 | self.init(database=False, write=True) 39 | pisi.api.delete_cache() 40 | -------------------------------------------------------------------------------- /pisi/cli/disablerepo.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2009, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi.cli.command as command 18 | import pisi.api 19 | 20 | class DisableRepo(command.Command): 21 | __doc__ = _("""Disable repository 22 | 23 | Usage: disable-repo [ ... ] 24 | 25 | : repository name 26 | 27 | Disabled repositories are not taken into account in operations 28 | """) 29 | __metaclass__ = command.autocommand 30 | 31 | def __init__(self,args): 32 | super(DisableRepo, self).__init__(args) 33 | self.repodb = pisi.db.repodb.RepoDB() 34 | 35 | name = ("disable-repo", "dr") 36 | 37 | def run(self): 38 | self.init(database = True) 39 | 40 | if not self.args: 41 | self.help() 42 | return 43 | 44 | for repo in self.args: 45 | if self.repodb.has_repo(repo): 46 | pisi.api.set_repo_activity(repo, False) 47 | -------------------------------------------------------------------------------- /pisi/cli/emerge.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.cli.command as command 20 | import pisi.cli.build as build 21 | import pisi.context as ctx 22 | import pisi.api 23 | 24 | class Emerge(build.Build): 25 | __doc__ = _("""Build and install eopkg source packages from repository 26 | 27 | Usage: emerge ... 28 | 29 | You should give the name of a source package to be 30 | downloaded from a repository containing sources. 31 | 32 | You can also give the name of a component. 33 | """) 34 | __metaclass__ = command.autocommand 35 | 36 | def __init__(self, args): 37 | super(Emerge, self).__init__(args) 38 | 39 | name = ("emerge", "em") 40 | 41 | def options(self): 42 | 43 | group = optparse.OptionGroup(self.parser, _("emerge options")) 44 | super(Emerge, self).add_options(group) 45 | group.add_option("-c", "--component", action="store", 46 | default=None, help=_("Emerge available packages under given component")) 47 | group.add_option("--ignore-file-conflicts", action="store_true", 48 | default=False, help=_("Ignore file conflicts")) 49 | group.add_option("--ignore-package-conflicts", action="store_true", 50 | default=False, help=_("Ignore package conflicts")) 51 | group.add_option("--ignore-comar", action="store_true", 52 | default=False, help=_("Bypass comar configuration agent")) 53 | self.parser.add_option_group(group) 54 | 55 | def run(self): 56 | self.init(database = True) 57 | 58 | component = ctx.get_option('component') 59 | if not self.args and not component: 60 | self.help() 61 | return 62 | 63 | if component: 64 | componentdb = pisi.db.componentdb.ComponentDB() 65 | sources = componentdb.get_union_sources(component, walk=True) 66 | else: 67 | sources = self.args 68 | 69 | if ctx.get_option('output_dir'): 70 | ctx.ui.info(_('Output directory: %s') % ctx.config.options.output_dir) 71 | else: 72 | ctx.ui.info(_('Outputting binary packages in the package cache.')) 73 | ctx.config.options.output_dir = ctx.config.cached_packages_dir() 74 | 75 | pisi.api.set_can_configure(not ctx.get_option('ignore_comar')) 76 | pisi.api.emerge(sources) 77 | 78 | -------------------------------------------------------------------------------- /pisi/cli/enablerepo.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2009, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi.cli.command as command 18 | import pisi.api 19 | 20 | class EnableRepo(command.Command): 21 | __doc__ = _("""Enable repository 22 | 23 | Usage: enable-repo [ ... ] 24 | 25 | : repository name 26 | 27 | Disabled repositories are not taken into account in operations 28 | """) 29 | __metaclass__ = command.autocommand 30 | 31 | def __init__(self,args): 32 | super(EnableRepo, self).__init__(args) 33 | self.repodb = pisi.db.repodb.RepoDB() 34 | 35 | name = ("enable-repo", "er") 36 | 37 | def run(self): 38 | self.init(database = True) 39 | 40 | if not self.args: 41 | self.help() 42 | return 43 | 44 | for repo in self.args: 45 | if self.repodb.has_repo(repo): 46 | pisi.api.set_repo_activity(repo, True) 47 | -------------------------------------------------------------------------------- /pisi/cli/fetch.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2009, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import os 14 | import optparse 15 | 16 | import gettext 17 | __trans = gettext.translation('pisi', fallback=True) 18 | _ = __trans.ugettext 19 | 20 | import pisi.cli.command as command 21 | import pisi.context as ctx 22 | import pisi.api 23 | 24 | class Fetch(command.Command): 25 | __doc__ = _("""Fetch a package 26 | 27 | Usage: fetch [ ... ] 28 | 29 | : package name 30 | 31 | Downloads the given pisi packages to working directory 32 | """) 33 | __metaclass__ = command.autocommand 34 | 35 | def __init__(self,args): 36 | super(Fetch, self).__init__(args) 37 | 38 | name = ("fetch", "fc") 39 | 40 | def options(self): 41 | group = optparse.OptionGroup(self.parser, _("fetch options")) 42 | self.add_options(group) 43 | self.parser.add_option_group(group) 44 | 45 | def add_options(self, group): 46 | group.add_option("-o", "--output-dir", action="store", default=os.path.curdir, 47 | help=_("Output directory for the fetched packages")) 48 | 49 | def run(self): 50 | self.init(database = False, write = False) 51 | 52 | if not self.args: 53 | self.help() 54 | return 55 | 56 | pisi.api.fetch(self.args, ctx.config.options.output_dir) 57 | -------------------------------------------------------------------------------- /pisi/cli/help.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi.cli 18 | import pisi.cli.command as command 19 | import pisi.context as ctx 20 | 21 | class Help(command.Command): 22 | __doc__ = _("""Prints help for given commands 23 | 24 | Usage: help [ ... ] 25 | 26 | If run without parameters, it prints the general help.""") 27 | 28 | __metaclass__ = command.autocommand 29 | 30 | def __init__(self, args = None): 31 | super(Help, self).__init__(args) 32 | 33 | name = ("help", "?") 34 | 35 | def run(self): 36 | 37 | if not self.args: 38 | self.parser.set_usage(usage_text) 39 | pisi.cli.printu(self.parser.format_help()) 40 | return 41 | 42 | self.init(database = False, write = False) 43 | 44 | for arg in self.args: 45 | obj = command.Command.get_command(arg, True) 46 | obj.help() 47 | ctx.ui.info('') 48 | 49 | usage_text1 = _("""%prog [options] [arguments] 50 | 51 | where is one of: 52 | 53 | """) 54 | 55 | usage_text2 = _(""" 56 | Use \"%prog help \" for help on a specific command. 57 | """) 58 | 59 | usage_text = (usage_text1 + command.Command.commands_string() + usage_text2) 60 | -------------------------------------------------------------------------------- /pisi/cli/listcomponents.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.cli.command as command 20 | import pisi.context as ctx 21 | import pisi.db 22 | 23 | class ListComponents(command.Command): 24 | __doc__ = _("""List available components 25 | 26 | Usage: list-components 27 | 28 | Gives a brief list of eopkg components published in the 29 | repositories. 30 | """) 31 | __metaclass__ = command.autocommand 32 | 33 | def __init__(self, args): 34 | super(ListComponents, self).__init__(args) 35 | self.componentdb = pisi.db.componentdb.ComponentDB() 36 | 37 | name = ("list-components", "lc") 38 | 39 | def options(self): 40 | group = optparse.OptionGroup(self.parser, _("list-components options")) 41 | group.add_option("-l", "--long", action="store_true", 42 | default=False, help=_("Show in long format")) 43 | group.add_option("-r", "--repository", action="store", 44 | type="string", default=None, help=_('Name of the source or package repository')) 45 | self.parser.add_option_group(group) 46 | 47 | def run(self): 48 | 49 | self.init(database = True, write = False) 50 | 51 | l = self.componentdb.list_components(ctx.get_option('repository')) 52 | l.sort() 53 | for p in l: 54 | component = self.componentdb.get_component(p) 55 | if self.options.long: 56 | ctx.ui.info(unicode(component)) 57 | else: 58 | lenp = len(p) 59 | #if p in installed_list: 60 | # p = util.colorize(p, 'cyan') 61 | p = p + ' ' * max(0, 15 - lenp) 62 | ctx.ui.info('%s - %s ' % (component.name, unicode(component.summary))) 63 | -------------------------------------------------------------------------------- /pisi/cli/listpending.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi.cli.command as command 18 | import pisi.context as ctx 19 | import pisi.api 20 | 21 | class ListPending(command.Command): 22 | __doc__ = _("""List pending packages 23 | 24 | Lists packages waiting to be configured. 25 | """) 26 | __metaclass__ = command.autocommand 27 | 28 | def __init__(self, args): 29 | super(ListPending, self).__init__(args) 30 | 31 | name = ("list-pending", "lp") 32 | 33 | def run(self): 34 | self.init(database = True, write = False) 35 | 36 | A = pisi.api.list_pending() 37 | if len(A): 38 | for p in pisi.api.generate_pending_order(A): 39 | print p 40 | else: 41 | ctx.ui.info(_('There are no packages waiting to be configured')) 42 | -------------------------------------------------------------------------------- /pisi/cli/listrepo.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi.cli.command as command 18 | import pisi.context as ctx 19 | import pisi.util as util 20 | import pisi.db 21 | 22 | class ListRepo(command.Command): 23 | __doc__ = _("""List repositories 24 | 25 | Usage: list-repo 26 | 27 | Lists currently tracked repositories. 28 | """) 29 | __metaclass__ = command.autocommand 30 | 31 | def __init__(self, args): 32 | super(ListRepo, self).__init__(args) 33 | self.repodb = pisi.db.repodb.RepoDB() 34 | 35 | name = ("list-repo", "lr") 36 | 37 | def run(self): 38 | 39 | self.init(database = True, write = False) 40 | for repo in self.repodb.list_repos(only_active=False): 41 | active = _("active") if self.repodb.repo_active(repo) else _("inactive") 42 | if active == _("active"): 43 | ctx.ui.info(util.colorize(_("%s [%s]") % (repo, active), 'green')) 44 | else: 45 | ctx.ui.info(util.colorize(_("%s [%s]") % (repo, active), 'red')) 46 | print ' ', self.repodb.get_repo_url(repo) 47 | 48 | -------------------------------------------------------------------------------- /pisi/cli/listsources.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.cli.command as command 20 | import pisi.context as ctx 21 | import pisi.db 22 | 23 | class ListSources(command.Command): 24 | __doc__ = _("""List available sources 25 | 26 | Usage: list-sources 27 | 28 | Gives a brief list of sources published in the repositories. 29 | """) 30 | __metaclass__ = command.autocommand 31 | 32 | def __init__(self, args): 33 | super(ListSources, self).__init__(args) 34 | self.sourcedb = pisi.db.sourcedb.SourceDB() 35 | 36 | name = ("list-sources", "ls") 37 | 38 | def options(self): 39 | group = optparse.OptionGroup(self.parser, _("list-sources options")) 40 | group.add_option("-l", "--long", action="store_true", 41 | default=False, help=_("Show in long format")) 42 | self.parser.add_option_group(group) 43 | 44 | def run(self): 45 | 46 | self.init(database = True, write = False) 47 | 48 | l = self.sourcedb.list_sources() 49 | l.sort() 50 | for p in l: 51 | sf, repo = self.sourcedb.get_spec_repo(p) 52 | if self.options.long: 53 | ctx.ui.info('[Repository: ' + repo + ']') 54 | ctx.ui.info(unicode(sf.source)) 55 | else: 56 | lenp = len(p) 57 | #if p in installed_list: 58 | # p = util.colorize(p, 'cyan') 59 | p = p + ' ' * max(0, 15 - lenp) 60 | ctx.ui.info('%s - %s' % (sf.source.name, unicode(sf.source.summary))) 61 | -------------------------------------------------------------------------------- /pisi/cli/rebuilddb.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.cli.command as command 20 | import pisi.context as ctx 21 | import pisi.api 22 | 23 | class RebuildDb(command.Command): 24 | __doc__ = _("""Rebuild Databases 25 | 26 | Usage: rebuilddb [ ... ] 27 | 28 | Rebuilds the eopkg databases 29 | 30 | If package specs are given, they should be the names of package 31 | dirs under /var/lib/eopkg 32 | """) 33 | __metaclass__ = command.autocommand 34 | 35 | def __init__(self, args): 36 | super(RebuildDb, self).__init__(args) 37 | 38 | name = ("rebuild-db", "rdb") 39 | 40 | def options(self): 41 | 42 | group = optparse.OptionGroup(self.parser, _("rebuild-db options")) 43 | 44 | group.add_option("-f", "--files", action="store_true", 45 | default=False, help=_("Rebuild files database")) 46 | 47 | self.parser.add_option_group(group) 48 | 49 | def run(self): 50 | self.init(database=True) 51 | if ctx.ui.confirm(_('Rebuild eopkg databases?')): 52 | pisi.api.rebuild_db(ctx.get_option('files')) 53 | -------------------------------------------------------------------------------- /pisi/cli/remove.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.cli.command as command 20 | import pisi.context as ctx 21 | import pisi.api 22 | import pisi.db 23 | 24 | class Remove(command.PackageOp): 25 | __doc__ = _("""Remove eopkg packages 26 | 27 | Usage: remove ... 28 | 29 | Remove package(s) from your system. Just give the package names to remove. 30 | 31 | You can also specify components instead of package names, which will be 32 | expanded to package names. 33 | """) 34 | __metaclass__ = command.autocommand 35 | 36 | def __init__(self, args): 37 | super(Remove, self).__init__(args) 38 | self.componentdb = pisi.db.componentdb.ComponentDB() 39 | 40 | name = ("remove", "rm") 41 | 42 | def options(self): 43 | group = optparse.OptionGroup(self.parser, _("remove options")) 44 | super(Remove, self).options(group) 45 | group.add_option("--purge", action="store_true", 46 | default=False, help=_("Removes everything including changed config files of the package")) 47 | group.add_option("-c", "--component", action="append", 48 | default=None, help=_("Remove component's and recursive components' packages")) 49 | self.parser.add_option_group(group) 50 | 51 | def run(self): 52 | self.init() 53 | 54 | components = ctx.get_option('component') 55 | if not components and not self.args: 56 | self.help() 57 | return 58 | 59 | packages = [] 60 | if components: 61 | for name in components: 62 | if self.componentdb.has_component(name): 63 | packages.extend(self.componentdb.get_union_packages(name, walk=True)) 64 | packages.extend(self.args) 65 | 66 | pisi.api.remove(packages) 67 | 68 | -------------------------------------------------------------------------------- /pisi/cli/removeorphans.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.cli.command as command 20 | import pisi.context as ctx 21 | import pisi.api 22 | import pisi.db 23 | 24 | class RemoveOrphans(command.PackageOp): 25 | __doc__ = _("""Remove orphaned packages 26 | 27 | Usage: remove-orphans 28 | 29 | Remove any unused orphan packages from the system that were automatically 30 | installed as a dependency of another package. 31 | 32 | Only packages that have no reverse dependencies outside of the automatically 33 | installed list will be removed. 34 | """) 35 | __metaclass__ = command.autocommand 36 | 37 | def __init__(self, args): 38 | super(RemoveOrphans, self).__init__(args) 39 | 40 | name = ("remove-orphans", "rmo") 41 | 42 | def options(self): 43 | group = optparse.OptionGroup(self.parser, _("remove-orphans options")) 44 | super(RemoveOrphans, self).options(group) 45 | group.add_option("--purge", action="store_true", 46 | default=False, help=_("Removes everything including changed config files of the package")) 47 | self.parser.add_option_group(group) 48 | 49 | def run(self): 50 | self.init() 51 | 52 | pisi.api.remove_orphans() 53 | -------------------------------------------------------------------------------- /pisi/cli/removerepo.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi.cli.command as command 18 | import pisi.api 19 | 20 | class RemoveRepo(command.Command): 21 | __doc__ = _("""Remove repositories 22 | 23 | Usage: remove-repo ... 24 | 25 | Remove all repository information from the system. 26 | """) 27 | __metaclass__ = command.autocommand 28 | 29 | def __init__(self,args): 30 | super(RemoveRepo, self).__init__(args) 31 | 32 | name = ("remove-repo", "rr") 33 | 34 | def run(self): 35 | 36 | if len(self.args)>=1: 37 | self.init() 38 | for repo in self.args: 39 | pisi.api.remove_repo(repo) 40 | else: 41 | self.help() 42 | return 43 | -------------------------------------------------------------------------------- /pisi/cli/searchfile.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi 20 | import pisi.context as ctx 21 | import pisi.cli.command as command 22 | 23 | class SearchFile(command.Command): 24 | __doc__ = _("""Search for a file 25 | 26 | Usage: search-file ... 27 | 28 | Finds the installed package which contains the specified file. 29 | """) 30 | __metaclass__ = command.autocommand 31 | 32 | def __init__(self, args): 33 | super(SearchFile, self).__init__(args) 34 | 35 | name = ("search-file", "sf") 36 | 37 | def options(self): 38 | group = optparse.OptionGroup(self.parser, _("search-file options")) 39 | group.add_option("-l", "--long", action="store_true", 40 | default=False, help=_("Show in long format")) 41 | group.add_option("-q", "--quiet", action="store_true", 42 | default=False, help=_("Show only package name")) 43 | self.parser.add_option_group(group) 44 | 45 | def search_file(self, path): 46 | found = pisi.api.search_file(path) 47 | for pkg, files in found: 48 | for pkg_file in files: 49 | ctx.ui.info(_("Package %s has file /%s") % (pkg, pkg_file)) 50 | 51 | if not found: 52 | ctx.ui.error(_("Path '%s' does not belong to an installed package") % path) 53 | 54 | def run(self): 55 | 56 | self.init(database = True, write = False) 57 | 58 | if not self.args: 59 | self.help() 60 | return 61 | 62 | # search among existing files 63 | for path in self.args: 64 | if not ctx.config.options.quiet: 65 | ctx.ui.info(_('Searching for %s') % path) 66 | self.search_file(path) 67 | -------------------------------------------------------------------------------- /pisi/cli/updaterepo.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import optparse 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.cli.command as command 20 | import pisi.context as ctx 21 | import pisi.api 22 | 23 | class UpdateRepo(command.Command): 24 | __doc__ = _("""Update repository databases 25 | 26 | Usage: update-repo [ ... ] 27 | 28 | : repository name 29 | 30 | Synchronizes the eopkg databases with the current repository. 31 | If no repository is given, all repositories are updated. 32 | """) 33 | __metaclass__ = command.autocommand 34 | 35 | def __init__(self,args): 36 | super(UpdateRepo, self).__init__(args) 37 | 38 | name = ("update-repo", "ur") 39 | 40 | def options(self): 41 | 42 | group = optparse.OptionGroup(self.parser, _("update-repo options")) 43 | 44 | group.add_option("-f", "--force", action="store_true", 45 | default=False, 46 | help=_("Update database in any case")) 47 | 48 | self.parser.add_option_group(group) 49 | 50 | def run(self): 51 | self.init(database = True) 52 | 53 | if self.args: 54 | repos = self.args 55 | else: 56 | repos = pisi.api.list_repos() 57 | 58 | pisi.api.update_repos(repos, ctx.get_option('force')) 59 | -------------------------------------------------------------------------------- /pisi/context.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | # global variables here 14 | 15 | import signal 16 | import os 17 | 18 | import pisi.constants 19 | import pisi.signalhandler 20 | import pisi.ui 21 | 22 | import gettext 23 | __trans = gettext.translation('pisi', fallback=True) 24 | _ = __trans.ugettext 25 | 26 | const = pisi.constants.Constants() 27 | sig = pisi.signalhandler.SignalHandler() 28 | 29 | config = None 30 | 31 | log = None 32 | 33 | # used for bug #10568 34 | locked = False 35 | 36 | def set_option(opt, val): 37 | config.set_option(opt, val) 38 | 39 | def get_option(opt): 40 | return config and config.get_option(opt) 41 | 42 | ui = pisi.ui.UI() 43 | 44 | # stdout, stderr for eopkg API 45 | stdout = None 46 | stderr = None 47 | 48 | # usysconf binary 49 | usysconf_binary = "/usr/sbin/usysconf" 50 | can_usysconf = True 51 | 52 | # Bug #2879 53 | # FIXME: Maybe we can create a simple rollback mechanism. There are other 54 | # places which need this, too. 55 | # this is needed in build process to clean after if something goes wrong. 56 | build_leftover = None 57 | 58 | def disable_keyboard_interrupts(): 59 | sig and sig.disable_signal(signal.SIGINT) 60 | 61 | def enable_keyboard_interrupts(): 62 | sig and sig.enable_signal(signal.SIGINT) 63 | 64 | def keyboard_interrupt_disabled(): 65 | return sig and sig.signal_disabled(signal.SIGINT) 66 | 67 | def keyboard_interrupt_pending(): 68 | return sig and sig.signal_pending(signal.SIGINT) 69 | 70 | def exec_usysconf(): 71 | """ Just stick this all in the one place """ 72 | global ui 73 | global usysconf_binary 74 | global can_usysconf 75 | 76 | if not can_usysconf: 77 | return 78 | 79 | # We must survive not having usysconf just in case of derp. 80 | if not os.path.exists(usysconf_binary): 81 | ui.error(_('usysconf not installed. Please upgrade!')) 82 | return 83 | 84 | # Tell UI tools the system configuration is running 85 | try: 86 | ui.notify(pisi.ui.systemconf) 87 | except: 88 | pass 89 | 90 | try: 91 | os.system("{} run".format(usysconf_binary)) 92 | except Exception as e: 93 | if ctx: 94 | ctx.ui.error(_('Failed to configure system')) 95 | raise e 96 | -------------------------------------------------------------------------------- /pisi/db/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2009, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | def invalidate_caches(): 14 | # Invalidates pisi caches in use and forces to re-fill caches from disk when needed 15 | for db in [packagedb.PackageDB(), sourcedb.SourceDB(), componentdb.ComponentDB(), 16 | installdb.InstallDB(), historydb.HistoryDB(), groupdb.GroupDB(), repodb.RepoDB()]: 17 | db.invalidate() 18 | 19 | def flush_caches(): 20 | # Invalidate and flush caches to re-generate them when needed 21 | for db in [packagedb.PackageDB(), sourcedb.SourceDB(), 22 | componentdb.ComponentDB(), groupdb.GroupDB()]: 23 | db.invalidate() 24 | db.cache_flush() 25 | 26 | def update_caches(): 27 | # Updates ondisk caches 28 | for db in [packagedb.PackageDB(), sourcedb.SourceDB(), componentdb.ComponentDB(), 29 | installdb.InstallDB(), groupdb.GroupDB()]: 30 | if db.is_initialized(): 31 | db.cache_save() 32 | 33 | def regenerate_caches(): 34 | flush_caches() 35 | # Force cache regeneration 36 | for db in [packagedb.PackageDB(), sourcedb.SourceDB(), 37 | componentdb.ComponentDB(), groupdb.GroupDB()]: 38 | db.cache_regenerate() 39 | -------------------------------------------------------------------------------- /pisi/db/groupdb.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2009, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi 18 | import pisi.db.repodb 19 | import pisi.db.itembyrepo 20 | import pisi.group 21 | import pisi.db.lazydb as lazydb 22 | 23 | class GroupNotFound(Exception): 24 | pass 25 | 26 | class GroupDB(lazydb.LazyDB): 27 | 28 | def __init__(self): 29 | lazydb.LazyDB.__init__(self, cacheable=True) 30 | 31 | def init(self): 32 | group_nodes = {} 33 | group_components = {} 34 | 35 | repodb = pisi.db.repodb.RepoDB() 36 | 37 | for repo in repodb.list_repos(): 38 | doc = repodb.get_repo_doc(repo) 39 | group_nodes[repo] = self.__generate_groups(doc) 40 | group_components[repo] = self.__generate_components(doc) 41 | 42 | self.gdb = pisi.db.itembyrepo.ItemByRepo(group_nodes) 43 | self.gcdb = pisi.db.itembyrepo.ItemByRepo(group_components) 44 | 45 | def __generate_components(self, doc): 46 | groups = {} 47 | for c in doc.tags("Component"): 48 | group = c.getTagData("Group") 49 | if not group: 50 | group = "unknown" 51 | groups.setdefault(group, []).append(c.getTagData("Name")) 52 | return groups 53 | 54 | def __generate_groups(self, doc): 55 | return dict(map(lambda x: (x.getTagData("Name"), x.toString()), doc.tags("Group"))) 56 | 57 | def has_group(self, name, repo = None): 58 | return self.gdb.has_item(name, repo) 59 | 60 | def list_groups(self, repo=None): 61 | return self.gdb.get_item_keys(repo) 62 | 63 | def get_group(self, name, repo = None): 64 | 65 | if not self.has_group(name, repo): 66 | raise GroupNotFound(_('Group %s not found') % name) 67 | 68 | group = pisi.group.Group() 69 | group.parse(self.gdb.get_item(name, repo)) 70 | 71 | return group 72 | 73 | def get_group_components(self, name, repo=None): 74 | if not self.has_group(name, repo): 75 | raise GroupNotFound(_('Group %s not found') % name) 76 | 77 | if self.gcdb.has_item(name): 78 | return self.gcdb.get_item(name, repo) 79 | 80 | return [] 81 | -------------------------------------------------------------------------------- /pisi/dependency.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | """dependency analyzer""" 14 | 15 | import gettext 16 | __trans = gettext.translation('pisi', fallback=True) 17 | _ = __trans.ugettext 18 | 19 | import pisi.relation 20 | import pisi.db 21 | import pisi.pxml.autoxml as autoxml 22 | 23 | class Dependency(pisi.relation.Relation): 24 | 25 | a_type = [autoxml.String, autoxml.optional] 26 | 27 | def __str__(self): 28 | s = self.package 29 | if self.versionFrom: 30 | s += _(" version >= ") + self.versionFrom 31 | if self.versionTo: 32 | s += _(" version <= ") + self.versionTo 33 | if self.version: 34 | s += _(" version ") + self.version 35 | if self.releaseFrom: 36 | s += _(" release >= ") + self.releaseFrom 37 | if self.releaseTo: 38 | s += _(" release <= ") + self.releaseTo 39 | if self.release: 40 | s += _(" release ") + self.release 41 | if self.type: 42 | s += " (" + self.type + ")" 43 | return s 44 | 45 | def name(self): 46 | return self.package 47 | 48 | def satisfied_by_dict_repo(self, dict_repo): 49 | if not dict_repo.has_key(self.package): 50 | return False 51 | else: 52 | pkg = dict_repo[self.package] 53 | return self.satisfies_relation(pkg.version, pkg.release) 54 | 55 | def satisfied_by_installed(self): 56 | return pisi.relation.installed_package_satisfies(self) 57 | 58 | def satisfied_by_repo(self): 59 | packagedb = pisi.db.packagedb.PackageDB() 60 | pkgconfig32 = False 61 | if self.type == "pkgconfig" : 62 | pkg = packagedb.get_package_by_pkgconfig(self.package) 63 | if pkg: 64 | return self.satisfies_relation(pkg.version, pkg.release) 65 | else: 66 | return False 67 | elif self.type == "pkgconfig32" : 68 | pkg = packagedb.get_package_by_pkgconfig32(self.package) 69 | if pkg: 70 | return self.satisfies_relation(pkg.version, pkg.release) 71 | else: 72 | return False 73 | if not packagedb.has_package(self.package): 74 | return False 75 | else: 76 | pkg = packagedb.get_package(self.package) 77 | return self.satisfies_relation(pkg.version, pkg.release) 78 | 79 | # Added for AnyDependency, single Dependency always returns False 80 | def satisfied_by_any_installed_other_than(self, package): 81 | return False 82 | -------------------------------------------------------------------------------- /pisi/errors.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2008, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | class AnotherInstanceError(Exception): 13 | pass 14 | 15 | class PrivilegeError(Exception): 16 | pass 17 | -------------------------------------------------------------------------------- /pisi/files.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | '''Files module provides access to files.xml. files.xml is generated 14 | during the build process of a package and used in installation.''' 15 | 16 | 17 | import pisi.pxml.autoxml as autoxml 18 | 19 | class FileInfo: 20 | """File holds the information for a File node/tag in files.xml""" 21 | 22 | __metaclass__ = autoxml.autoxml 23 | 24 | t_Path = [ autoxml.String, autoxml.mandatory ] 25 | t_Type = [ autoxml.String, autoxml.mandatory ] 26 | t_Size = [ autoxml.Long, autoxml.optional ] 27 | t_Uid = [ autoxml.String, autoxml.optional ] 28 | t_Gid = [ autoxml.String, autoxml.optional ] 29 | t_Mode = [ autoxml.String, autoxml.optional ] 30 | t_Hash = [ autoxml.String, autoxml.optional, "SHA1Sum" ] 31 | t_Permanent = [ autoxml.String, autoxml.optional ] 32 | 33 | def __str__(self): 34 | s = "/%s, type: %s, size: %s, sha1sum: %s" % (self.path, self.type, 35 | self.size, self.hash) 36 | return s 37 | 38 | 39 | class Files(autoxml.xmlfile.XmlFile): 40 | 41 | __metaclass__ = autoxml.autoxml 42 | 43 | tag = "Files" 44 | 45 | t_List = [ [FileInfo], autoxml.optional, "File"] 46 | 47 | def append(self, fileinfo): 48 | self.list.append(fileinfo) 49 | 50 | 51 | -------------------------------------------------------------------------------- /pisi/group.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2009, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import pisi 14 | import pisi.pxml.xmlfile as xmlfile 15 | import pisi.pxml.autoxml as autoxml 16 | 17 | class Error(pisi.Error): 18 | pass 19 | 20 | __metaclass__ = autoxml.autoxml 21 | 22 | class Group(xmlfile.XmlFile): 23 | "representation for group declarations" 24 | 25 | __metaclass__ = autoxml.autoxml 26 | 27 | t_Name = [autoxml.String, autoxml.mandatory] 28 | t_LocalName = [autoxml.LocalText, autoxml.mandatory] 29 | t_Icon = [ autoxml.String, autoxml.optional] 30 | 31 | class Groups(xmlfile.XmlFile): 32 | "representation for component declarations" 33 | 34 | __metaclass__ = autoxml.autoxml 35 | 36 | tag = "PISI" 37 | 38 | t_Groups = [ [Group], autoxml.optional, "Groups/Group" ] 39 | -------------------------------------------------------------------------------- /pisi/mirrors.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2006, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | import os.path 13 | import pisi 14 | import pisi.context as ctx 15 | 16 | import gettext 17 | __trans = gettext.translation('pisi', fallback=True) 18 | _ = __trans.ugettext 19 | 20 | class Mirrors: 21 | def __init__(self, config=ctx.const.mirrors_conf): 22 | self.mirrors = {} 23 | self._parse(config) 24 | 25 | def get_mirrors(self, name): 26 | if self.mirrors.has_key(name): 27 | return list(self.mirrors[name]) 28 | 29 | return None 30 | 31 | def _add_mirror(self, name, url): 32 | if self.mirrors.has_key(name): 33 | self.mirrors[name].append(url) 34 | else: 35 | self.mirrors[name] = [url] 36 | 37 | def _parse(self, config): 38 | if os.path.exists(config): 39 | for line in open(config, "r").readlines(): 40 | if not line.startswith('#') and not line == '\n': 41 | mirror = line.strip().split() 42 | if len(mirror) == 2: 43 | (name, url) = mirror 44 | self._add_mirror(name, url) 45 | else: 46 | raise pisi.Error(_('Mirrors file %s does not exist. Could not resolve mirrors://') % config) 47 | 48 | -------------------------------------------------------------------------------- /pisi/oo.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | 4 | # Guido's cool metaclass examples. fair use. ahahah. 5 | # I find these quite handy. Use them :) 6 | 7 | class autoprop(type): 8 | def __init__(cls, name, bases, dict): 9 | super(autoprop, cls).__init__(name, bases, dict) 10 | props = {} 11 | for name in dict.keys(): 12 | if name.startswith("_get_") or name.startswith("_set_"): 13 | props[name[5:]] = 1 14 | for name in props.keys(): 15 | fget = getattr(cls, "_get_%s" % name, None) 16 | fset = getattr(cls, "_set_%s" % name, None) 17 | setattr(cls, name, property(fget, fset)) 18 | 19 | class autosuper(type): 20 | def __init__(cls, name, bases, dict): 21 | super(autosuper, cls).__init__(name, bases, dict) 22 | setattr(cls, "_%s__super" % name, super(cls)) 23 | 24 | class autosuprop(autosuper, autoprop): 25 | pass 26 | 27 | class autoeq(type): 28 | "useful for structures" 29 | def __init__(cls, name, bases, dict): 30 | super(autoeq, cls).__init__(name, bases, dict) 31 | def equal(self, other): 32 | return self.__dict__ == other.__dict__ 33 | cls.__eq__ = equal 34 | 35 | class Struct: 36 | __metaclass__ = autoeq 37 | 38 | def __init__(self, **entries): 39 | self.__dict__.update(entries) 40 | -------------------------------------------------------------------------------- /pisi/operations/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | -------------------------------------------------------------------------------- /pisi/pgraph.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | """eopkg package relation graph that represents the state of packagedb""" 14 | 15 | import graph 16 | 17 | # Cache the results from packagedb queries in a graph 18 | 19 | class PGraph(graph.Digraph): 20 | 21 | def __init__(self, packagedb): 22 | super(PGraph, self).__init__() 23 | self.packagedb = packagedb 24 | 25 | def add_package(self, pkg): 26 | pkg1 = self.packagedb.get_package(pkg) 27 | self.add_vertex(str(pkg), (pkg1.version, pkg1.release)) 28 | 29 | def add_plain_dep(self, pkg1name, pkg2name): 30 | pkg1data = None 31 | if not pkg1name in self.vertices(): 32 | pkg1 = self.packagedb.get_package(pkg1name) 33 | pkg1data = (pkg1.version, pkg1.release) 34 | pkg2data = None 35 | if not pkg2name in self.vertices(): 36 | pkg2 = self.packagedb.get_package(pkg2name) 37 | pkg2data = (pkg2.version, pkg2.release) 38 | self.add_edge(str(pkg1name), str(pkg2name), ('d', None), 39 | pkg1data, pkg2data ) 40 | 41 | def add_dep(self, pkg, depinfo): 42 | pkg1data = None 43 | if not pkg in self.vertices(): 44 | pkg1 = self.packagedb.get_package(pkg) 45 | pkg1data = (pkg1.version, pkg1.release) 46 | pkg2data = None 47 | if not depinfo.package in self.vertices(): 48 | pkg2 = self.packagedb.get_package(depinfo.package) 49 | pkg2data = (pkg2.version, pkg2.release) 50 | self.add_edge(str(pkg), str(depinfo.package), ('d', depinfo), 51 | pkg1data, pkg2data ) 52 | 53 | def write_graphviz_vlabel(self, f, u): 54 | (v, r) = self.vertex_data(u) 55 | f.write('[ label = \"' + str(u) + '(' + str(v) + ',' + str(r) + ')\" ]') 56 | 57 | -------------------------------------------------------------------------------- /pisi/pxml/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import pisi 14 | 15 | class Error(pisi.Error): 16 | pass 17 | -------------------------------------------------------------------------------- /pisi/relation.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2007 - 2010, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import pisi 14 | import pisi.version 15 | import pisi.db 16 | import pisi.pxml.autoxml as autoxml 17 | 18 | class Relation: 19 | 20 | __metaclass__ = autoxml.autoxml 21 | 22 | s_Package = [autoxml.String, autoxml.mandatory] 23 | a_version = [autoxml.String, autoxml.optional] 24 | a_versionFrom = [autoxml.String, autoxml.optional] 25 | a_versionTo = [autoxml.String, autoxml.optional] 26 | a_release = [autoxml.String, autoxml.optional] 27 | a_releaseFrom = [autoxml.String, autoxml.optional] 28 | a_releaseTo = [autoxml.String, autoxml.optional] 29 | 30 | def satisfies_relation(self, version, release): 31 | if self.version and version != self.version: 32 | return False 33 | else: 34 | v = pisi.version.make_version(version) 35 | 36 | if self.versionFrom and \ 37 | v < pisi.version.make_version(self.versionFrom): 38 | return False 39 | 40 | if self.versionTo and \ 41 | v > pisi.version.make_version(self.versionTo): 42 | return False 43 | 44 | if self.release and release != self.release: 45 | return False 46 | else: 47 | r = int(release) 48 | 49 | if self.releaseFrom and r < int(self.releaseFrom): 50 | return False 51 | 52 | if self.releaseTo and r > int(self.releaseTo): 53 | return False 54 | 55 | return True 56 | 57 | def installed_package_satisfies(relation): 58 | installdb = pisi.db.installdb.InstallDB() 59 | pkg_name = relation.package 60 | if hasattr(relation, "type") and relation.type == "pkgconfig": 61 | pkg = installdb.get_package_by_pkgconfig(pkg_name) 62 | if pkg: 63 | return relation.satisfies_relation(pkg.version, pkg.release) 64 | else: 65 | return False 66 | elif hasattr(relation, "type") and relation.type == "pkgconfig32": 67 | pkg = installdb.get_package_by_pkgconfig32(pkg_name) 68 | if pkg: 69 | return relation.satisfies_relation(pkg.version, pkg.release) 70 | else: 71 | return False 72 | if not installdb.has_package(pkg_name): 73 | return False 74 | else: 75 | pkg = installdb.get_package(pkg_name) 76 | return relation.satisfies_relation(pkg.version, pkg.release) 77 | -------------------------------------------------------------------------------- /pisi/replace.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import gettext 14 | __trans = gettext.translation('pisi', fallback=True) 15 | _ = __trans.ugettext 16 | 17 | import pisi.relation 18 | 19 | """ Replace relation """ 20 | class Replace(pisi.relation.Relation): 21 | def __str__(self): 22 | s = self.package 23 | if self.versionFrom: 24 | s += _(" version >= ") + self.versionFrom 25 | if self.versionTo: 26 | s += _(" version <= ") + self.versionTo 27 | if self.version: 28 | s += _(" version ") + self.version 29 | if self.releaseFrom: 30 | s += _(" release >= ") + self.releaseFrom 31 | if self.releaseTo: 32 | s += _(" release <= ") + self.releaseTo 33 | if self.release: 34 | s += _(" release ") + self.release 35 | return s 36 | 37 | def installed_package_replaced(repinfo): 38 | """determine if an installed package in *repository* replaced with 39 | given a package""" 40 | return pisi.relation.installed_package_satisfies(repinfo) 41 | 42 | -------------------------------------------------------------------------------- /pisi/scenarioapi/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2006, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import pisi 14 | 15 | class Error(pisi.Error): 16 | pass 17 | 18 | class Exception(pisi.Exception): 19 | pass 20 | 21 | import pisi.context as ctx 22 | 23 | def error(msg): 24 | if ctx.config.get_option('ignore_action_errors'): 25 | ctx.ui.error(msg) 26 | else: 27 | raise Error(msg) 28 | -------------------------------------------------------------------------------- /pisi/scenarioapi/actions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2006, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | class Actions: 14 | 15 | template = """ 16 | from pisi.actionsapi import pisitools 17 | 18 | WorkDir = "skeleton" 19 | 20 | def install(): 21 | pisitools.dobin("skeleton.py") 22 | pisitools.rename("/usr/bin/skeleton.py", "%s") 23 | """ 24 | 25 | def __init__(self, name, filepath): 26 | self.name = name 27 | self.filepath = filepath 28 | 29 | def write(self): 30 | open(self.filepath, "w").write(self.template % self.name) 31 | -------------------------------------------------------------------------------- /pisi/scenarioapi/constants.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2006, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | class _constant: 13 | "Constant members implementation" 14 | class ConstError(TypeError): 15 | pass 16 | 17 | def __setattr__(self, name, value): 18 | if self.__dict__.has_key(name): 19 | raise self.ConstError, "Can't rebind constant: %s" % name 20 | # Binding an attribute once to a const is available 21 | self.__dict__[name] = value 22 | 23 | def __delattr__(self, name): 24 | if self.__dict__.has_key(name): 25 | raise self.ConstError, "Can't unbind constant: %s" % name 26 | # we don't have an attribute by this name 27 | raise NameError, name 28 | 29 | class Constants: 30 | 31 | __c = _constant() 32 | 33 | def __getattr__(self, attr): 34 | return getattr(self.__c, attr) 35 | 36 | def __setattr__(self, attr, value): 37 | setattr(self.__c, attr, value) 38 | 39 | def __delattr__(self, attr): 40 | delattr(self.__c, attr) 41 | 42 | consts = Constants() 43 | 44 | consts.scenarios_path = "scenarios/" 45 | consts.pisi_db = "db/" 46 | consts.repo_name = "scenario-db" 47 | consts.repo_path = "repo/" 48 | consts.repo_url = consts.repo_path + "eopkg-index.xml" 49 | 50 | consts.glob_pisis = "*.eopkg" 51 | consts.pisi_suffix = ".eopkg" 52 | 53 | consts.pspec_path = "/tmp/pspec.xml" 54 | consts.actionspy_path = "/tmp/actions.py" 55 | 56 | consts.packager_name = "Faik Uygur" 57 | consts.packager_email = "faik@pardus.org.tr" 58 | 59 | consts.homepage = "http://cekirdek.uludag.org.tr/~faik/eopkg" 60 | consts.summary = "%s is a good application" 61 | consts.description = "%s is a free software that can do anything it wants" 62 | consts.license = ["GPL-2"] 63 | 64 | consts.skel_sha1sum = "cc64dfa6e068fe1f6fb68a635878b1ea21acfac7" 65 | consts.skel_type = "targz" 66 | consts.skel_uri = "http://cekirdek.uludag.org.tr/~faik/eopkg/skeleton.tar.gz" 67 | consts.skel_bindir = "/usr/bin" 68 | consts.skel_dirtype = "executable" 69 | -------------------------------------------------------------------------------- /pisi/scenarioapi/pisiops.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #-*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | # 13 | 14 | import os 15 | import pisi.util as util 16 | from pisi.scenarioapi.constants import * 17 | 18 | def pisi_upgraded(*args): 19 | packages = util.strlist(args).rstrip() 20 | os.system("pisi -D%s upgrade %s" % (consts.pisi_db, packages)) 21 | 22 | def pisi_info(package): 23 | os.system("pisi -D%s info %s" % (consts.pisi_db, package)) 24 | 25 | def pisi_removed(*args): 26 | packages = util.strlist(args).rstrip() 27 | os.system("pisi -D%s remove %s" % (consts.pisi_db, packages)) 28 | 29 | def pisi_added_repo(name, url): 30 | os.system("pisi -D%s add-repo -y %s %s" % (consts.pisi_db, name, url)) 31 | 32 | def pisi_updated_repo(): 33 | os.system("pisi -D%s update-repo" % consts.pisi_db) 34 | 35 | def pisi_installed(*args): 36 | packages = util.strlist(args).rstrip() 37 | os.system("pisi -D%s install %s" % (consts.pisi_db, packages)) 38 | 39 | def pisi_reinstalled(package): 40 | os.system("pisi -D%s install --reinstall %s" % (consts.pisi_db, package)) 41 | 42 | -------------------------------------------------------------------------------- /pisi/scenarioapi/repoops.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #-*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | # 13 | 14 | import os 15 | 16 | from pisi.scenarioapi.package import Package 17 | from pisi.scenarioapi.withops import * 18 | from pisi.scenarioapi.constants import * 19 | 20 | import gettext 21 | __trans = gettext.translation('pisi', fallback=True) 22 | _ = __trans.ugettext 23 | 24 | repodb = {} 25 | 26 | def repo_added_package(package, *args): 27 | if repodb.has_key(package): 28 | raise Exception(_("Repo already has package named %s.") % package) 29 | 30 | version = "1.0" 31 | partOf = "None" 32 | dependencies = [] 33 | conflicts = [] 34 | 35 | for _with in args: 36 | if _with.types == CONFLICT and _with.action == INIT: 37 | conflicts = _with.data 38 | 39 | if _with.types == DEPENDENCY and _with.action == INIT: 40 | dependencies = _with.data 41 | 42 | if _with.types == VERSION and _with.action == INIT: 43 | version = _with.data 44 | 45 | if _with.types == PARTOF and _with.action == INIT: 46 | partOf = _with.data 47 | 48 | repodb[package] = Package(package, dependencies, conflicts, ver=version, partOf=partOf) 49 | 50 | def repo_removed_package(package): 51 | if not repodb.has_key(package): 52 | raise Exception(_("Repo does not have package named %s.") % package) 53 | 54 | os.unlink(os.path.join(consts.repo_path, repodb[package].get_file_name())) 55 | del repodb[package] 56 | 57 | def repo_version_bumped(package, *args): 58 | if not repodb.has_key(package): 59 | raise Exception(_("Repo does not have package named %s.") % package) 60 | 61 | old_file = repodb[package].get_file_name() 62 | repodb[package].version_bump(*args) 63 | os.unlink(os.path.join(consts.repo_path, old_file)) 64 | 65 | def repo_updated_index(): 66 | cur = os.getcwd() 67 | path = os.path.join(cur, consts.repo_path) 68 | os.chdir(consts.repo_path) 69 | os.system("pisi index --skip-signing %s >/dev/null 2>&1" % path) 70 | os.chdir(cur) 71 | 72 | def repo_get_url(): 73 | return "." 74 | -------------------------------------------------------------------------------- /pisi/scenarioapi/scenario.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #-*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | # 13 | 14 | import os 15 | 16 | from pisi.scenarioapi.repoops import * 17 | from pisi.scenarioapi.pisiops import * 18 | from pisi.scenarioapi.constants import * 19 | 20 | def let_repo_had(package, *args): 21 | repo_added_package(package, *args) 22 | repo_updated_index() 23 | 24 | def let_pisi_had(*args): 25 | url = os.path.join(os.getcwd(), consts.repo_url) 26 | pisi_added_repo(consts.repo_name, url) 27 | packages = util.strlist(args).rstrip() 28 | os.system("pisi -D%s install --ignore-dependency %s" % (consts.pisi_db, packages)) 29 | -------------------------------------------------------------------------------- /pisi/scenarioapi/withops.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #-*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | # 13 | 14 | ADDED, REMOVED, INIT = range(3) 15 | PARTOF, VERSION, CONFLICT, DEPENDENCY, REQUIRES = range(5) 16 | 17 | class With: 18 | def __init__(self): 19 | pass 20 | 21 | def with_action(types, action, data): 22 | w = With() 23 | w.types = types 24 | w.action = action 25 | w.data = data 26 | return w 27 | 28 | def with_partof(partof): 29 | return with_action(PARTOF, INIT, partof) 30 | 31 | def with_version(version): 32 | return with_action(VERSION, INIT, version) 33 | 34 | def with_conflicts(*cons): 35 | return with_action(CONFLICT, INIT, cons) 36 | 37 | def with_requiring_actions(*action): 38 | return with_action(REQUIRES, ADDED, action) 39 | 40 | def with_dependencies(*deps): 41 | return with_action(DEPENDENCY, INIT, deps) 42 | 43 | def with_added_conflicts(*cons): 44 | return with_action(CONFLICT, ADDED, cons) 45 | 46 | def with_removed_conflicts(*cons): 47 | return with_action(CONFLICT, REMOVED, cons) 48 | 49 | def with_added_dependencies(*deps): 50 | return with_action(DEPENDENCY, ADDED, deps) 51 | 52 | def with_removed_dependencies(*deps): 53 | return with_action(DEPENDENCY, REMOVED, deps) 54 | 55 | def with_added_conflict(package, **kw): 56 | assert len(kw) <= 1 57 | 58 | if not len(kw): 59 | return with_action(CONFLICT, ADDED, [package]) 60 | 61 | if (kw.has_key("versionFrom") or 62 | kw.has_key("versionTo") or 63 | kw.has_key("version") or 64 | kw.has_key("releaseFrom") or 65 | kw.has_key("releaseTo") or 66 | kw.has_key("release")): 67 | return with_action(CONFLICT, ADDED, [kw, package]) 68 | 69 | # pass other keywords. 70 | return with_action(CONFLICT, ADDED, [package]) 71 | 72 | def with_added_dependency(package, **kw): 73 | assert len(kw) <= 1 74 | 75 | if not len(kw): 76 | return with_action(DEPENDENCY, ADDED, [package]) 77 | 78 | if (kw.has_key("versionFrom") or 79 | kw.has_key("versionTo") or 80 | kw.has_key("version") or 81 | kw.has_key("releaseFrom") or 82 | kw.has_key("releaseTo") or 83 | kw.has_key("release")): 84 | return with_action(DEPENDENCY, ADDED, [kw, package]) 85 | 86 | # pass other keywords. 87 | return with_action(DEPENDENCY, ADDED, [package]) 88 | -------------------------------------------------------------------------------- /pisi/signalhandler.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2006, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import signal 14 | 15 | exception = { 16 | signal.SIGINT:KeyboardInterrupt 17 | } 18 | 19 | class Signal: 20 | def __init__(self, sig): 21 | self.signal = sig 22 | self.oldhandler = signal.getsignal(sig) 23 | self.pending = False 24 | 25 | class SignalHandler: 26 | 27 | def __init__(self): 28 | self.signals = {} 29 | 30 | def signal_handler(self, sig, frame): 31 | signal.signal(sig, signal.SIG_IGN) 32 | self.signals[sig].pending = True 33 | 34 | def disable_signal(self, sig): 35 | if sig not in self.signals.keys(): 36 | self.signals[sig] = Signal(sig) 37 | signal.signal(sig, self.signal_handler) 38 | 39 | def enable_signal(self, sig): 40 | if sig in self.signals.keys(): 41 | if self.signals[sig].oldhandler: 42 | oldhandler = self.signals[sig].oldhandler 43 | else: 44 | oldhandler = signal.SIG_DFL 45 | pending = self.signals[sig].pending 46 | del self.signals[sig] 47 | signal.signal(sig, oldhandler) 48 | if pending: 49 | raise exception[sig] 50 | 51 | def signal_disabled(self, sig): 52 | return sig in self.signals.keys() 53 | 54 | def signal_pending(self, sig): 55 | return self.signal_disabled(sig) and self.signals[sig].pending 56 | -------------------------------------------------------------------------------- /scenarios/bug11406scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug11406scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=11406 6 | # 7 | # Problem : reverse strict deps upgrading not working 8 | # 9 | # Problem Description: 10 | # 11 | # pisi updates strict reverse deps if the reverse deps dependencies are not satisfied. For example if kernel is tried 12 | # to be upgraded all the reverse deps are forced to be upgraded automatically. When only one rev-dep module is 13 | # selected for an upgrade, kernel also comes as a strict dep for this module. But when kernel comes, all the rev-deps 14 | # should come with kernel, too. It is not coming. 15 | # 16 | # This creates a problem for a user when he/she tries to update only her graphics card driver: kernel comes but none 17 | # of the other drivers are updated. Sound becomes non-working as well as the other drivers. 18 | # 19 | # Expected: 20 | # 21 | # rev-deps of all the calculated to be upgraded packages should come 22 | 23 | 24 | from pisi.scenarioapi.scenario import * 25 | 26 | MODULE_ALSA_DRIVER = "module-alsa-driver" 27 | MODULE_FGLRX = "module-fglrx" 28 | KERNEL = "kernel" 29 | 30 | let_repo_had(KERNEL, with_version("2.6.30")) 31 | let_repo_had(MODULE_ALSA_DRIVER, with_added_dependency(KERNEL, version="2.6.30")) 32 | let_repo_had(MODULE_FGLRX, with_added_dependency(KERNEL, version="2.6.30")) 33 | 34 | let_pisi_had(KERNEL, MODULE_ALSA_DRIVER, MODULE_FGLRX) 35 | 36 | def run(): 37 | repo_version_bumped(KERNEL, with_version("2.6.31")) 38 | repo_version_bumped(MODULE_ALSA_DRIVER, with_added_dependency(KERNEL, version="2.6.31")) 39 | repo_version_bumped(MODULE_FGLRX, with_added_dependency(KERNEL, version="2.6.31")) 40 | repo_updated_index() 41 | pisi_upgraded(MODULE_FGLRX) 42 | -------------------------------------------------------------------------------- /scenarios/bug3237scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug3237scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=3237 6 | # 7 | # Problem : If the revdep of the "upgraded only packages"' dependency is not satisfied 8 | # it is also added to the upgrade list and creates "confusion" 9 | # 10 | # # pisi lu 11 | # amarok - KDE için müzik çalıcısı 12 | # ksynaptics - Synaptics touchpad yapılandırma aracı 13 | # libwmf - Microsoft Word gibi uygulamaların kullan..... 14 | # tunepimp - MusicBrainz uyumluluğu olan uygulamalar....... 15 | # 16 | # pisi up tunepimp libwmf ksynaptics 17 | # Depolar güncelleniyor 18 | # * pardus-1.1 deposu güncelleniyor 19 | # pardus-1.1 deposu için güncelleme yok. 20 | # Aşağıdaki paketlerde çakışmalar bulunuyor: [amarok: lastfm-player ile çakışıyor] 21 | # Bu çakışan paketler kaldırılsın mı? (evet/hayır)hayır 22 | # 23 | # Problem Description: 24 | # 25 | # There appears to be some upgrades needed. We only wanted to upgrade some of the packages. 26 | # But the package we did not include in the list of upgrades also is tried to be upgraded. 27 | # The purpose to not include it in the upgrade list, was, it was conflicting with another 28 | # package. 29 | # 30 | # Expected: 31 | # 32 | # pisi either should not upgrade packages out of the given upgrade list or should show 33 | # all the "to be upgraded" list before the conflict warning. 34 | 35 | from pisi.scenarioapi.scenario import * 36 | 37 | AMAROK = "amarok" 38 | KSYNAPTICS = "ksynaptics" 39 | LIBWMF = "libwmf" 40 | TUNEPIMP = "tunepimp" 41 | LASTFM = "lastfm-player" 42 | 43 | let_repo_had(AMAROK, with_conflicts(LASTFM)) 44 | let_repo_had(LASTFM) 45 | let_repo_had(TUNEPIMP, with_version("0.3.9")) 46 | let_repo_had(KSYNAPTICS) 47 | let_repo_had(LIBWMF) 48 | 49 | let_pisi_had(AMAROK, LASTFM, TUNEPIMP, KSYNAPTICS, LIBWMF) 50 | 51 | def run(): 52 | repo_version_bumped(TUNEPIMP, with_version("0.4.1")) 53 | repo_version_bumped(AMAROK, with_added_dependency(TUNEPIMP, versionFrom="0.4.1")) 54 | repo_version_bumped(KSYNAPTICS) 55 | repo_version_bumped(LIBWMF) 56 | repo_updated_index() 57 | pisi_upgraded(LIBWMF, TUNEPIMP, KSYNAPTICS) 58 | -------------------------------------------------------------------------------- /scenarios/bug3390scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug3390scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=3390 6 | # 7 | # Problem : Package reverse dependencies are not updated in pisi database 8 | # 9 | # caglar@zangetsu ~ $ pisi info valgrind 10 | # Yüklü paket: 11 | # Ad: valgrind, versiyon 3.2.0, sürüm 5, inşa 4 12 | # Özet: Valgrind, x86-GNU/Linux ve ppc-GNU/Linux için geliştirilmiş, bellek 13 | # hatalarını ayıklayıcı, açık kaynaklı bir yazılımdır. 14 | # Açıklama: Valgrind, x86-GNU/Linux ve ppc-GNU/Linux için geliştirilmiş, bellek 15 | # hatalarını ayıklayıcı, açık kaynaklı bir yazılımdır. 16 | # Bileşen: programming.tools 17 | # Sağladıkları: 18 | # Bağımlılıklar:xorg openmpi 19 | # Dağıtım: Pardus, Dağıtım Sürümü: 1.1 20 | # Mimari: Any, Yerleşik Boyut: 19128120 21 | # Ters bağımlılıklar: kdesdk 22 | # 23 | # Problem Description: 24 | # 25 | # Valgrind package had a dependency of openmpi package. It is version bumped with removed 26 | # dependeny of openmpi at the repository. Also openmpi is version bumped. After upgrading 27 | # pisi repository and trying to remove openmpi, it is seen that openmpi still has a reverse 28 | # dependency of valgrind. 29 | # 30 | # Expected: 31 | # 32 | # Pisi should have updated the reverse dependency informations correctly and should not show 33 | # a reverse dependency of valgrind while removing openmpi, after a succesfull repository upgrade. 34 | 35 | from pisi.scenarioapi.scenario import * 36 | 37 | VALGRIND = "valgrind" 38 | OPENMPI = "openmpi" 39 | 40 | let_repo_had(VALGRIND, with_dependencies(OPENMPI)) 41 | let_repo_had(OPENMPI) 42 | let_pisi_had(VALGRIND, OPENMPI) 43 | 44 | def run(): 45 | repo_version_bumped(VALGRIND, with_removed_dependencies(OPENMPI)) 46 | repo_version_bumped(OPENMPI) 47 | repo_updated_index() 48 | pisi_upgraded() 49 | pisi_removed(OPENMPI) 50 | -------------------------------------------------------------------------------- /scenarios/bug3465scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug3465scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=3465 6 | # 7 | # Problem : Pisi does not warn the user about updated packages in the repository. 8 | # 9 | # sudo pisi it wormux --reinstall 10 | # Bağımlılıkları sağlamak için bu paketler verilen sırada kurulacaktır: 11 | # wormux 12 | # Paketlerin toplam boyu: 17.62 MB 13 | # Paket wormux, pardus-1.1 deposunda bulundu 14 | # Program sonlandırıldı. 15 | # http://paketler.pardus.org.tr/pardus-1.1/wormux-0.7-2-1.pisi indirilemiyor; HTTP 16 | # Error 404: Not Found 17 | # 18 | # Problem Description: 19 | # 20 | # The user had not updated pisi's repository database for some time. Then, when pisi is asked 21 | # to reinstall an installed package, it failed to fetch the requested version of the package. 22 | # Because the package had been upgraded at the repository and the old package has been removed. 23 | # 24 | # Expected: 25 | # 26 | # Pisi should warn the user to update repository. 27 | 28 | from pisi.scenarioapi.scenario import * 29 | 30 | WORMUX = "wormux" 31 | 32 | let_repo_had(WORMUX) 33 | let_pisi_had(WORMUX) 34 | 35 | def run(): 36 | repo_version_bumped(WORMUX) 37 | repo_updated_index() 38 | pisi_reinstalled(WORMUX) 39 | -------------------------------------------------------------------------------- /scenarios/bug3481scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug3481scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=3481 6 | # 7 | # Problem : PISI asks if conflicting system.base application to be removed but does not 8 | # allow it without -S 9 | # 10 | # Aşağıdaki paketlerde çakışmalar bulunuyor: [coreutils: hashalot ile çakışıyor] 11 | # Bu çakışan paketler kaldırılsın mı? (evet/hayır)evet 12 | # Emniyet mandalı: taban sistem system.base deki bu paketler kaldırılamıyor: hashalot 13 | # Kaldıracak paket yok. 14 | # Program sonlandırıldı. 15 | # pisi.operations.Error: Çakışmalar var 16 | # Genel yardım için lütfen 'eopkg help' komutunu kullanınız. 17 | # 18 | # Problem Description: 19 | # 20 | # PISI upgrade command sees some system.base packages conflict with each other. It asks if you 21 | # want to remove the conflicting package but does not allow it to be removed without 22 | # --bypass-safety parameter. 23 | # 24 | # Expected: 25 | # 26 | # Pisi should remove the package if answered yes. 27 | # 28 | 29 | from pisi.scenarioapi.scenario import * 30 | 31 | HASHALOT="hashalot" 32 | COREUTILS="coreutils" 33 | GLIBC="glibc" 34 | UTIL_LINUX="util-linux" 35 | 36 | let_repo_had(HASHALOT, with_partof("system.base")) 37 | let_repo_had(COREUTILS, with_partof("system.base")) 38 | let_repo_had(GLIBC, with_partof("system.base")) 39 | let_repo_had(UTIL_LINUX, with_partof("system.base")) 40 | 41 | let_pisi_had(COREUTILS, HASHALOT, GLIBC, UTIL_LINUX) 42 | 43 | def run(): 44 | repo_version_bumped(GLIBC) 45 | repo_version_bumped(UTIL_LINUX) 46 | repo_version_bumped(COREUTILS, with_added_conflicts(HASHALOT)) 47 | repo_updated_index() 48 | pisi_upgraded() 49 | -------------------------------------------------------------------------------- /scenarios/bug3558scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug3558scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=3558 6 | # 7 | # Problem : reverse dependency information disappears 8 | # 9 | # faik@iago scenarios $ pisi info kdelibs 10 | # Yüklü paket: 11 | # Ad: kdelibs, versiyon 3.5.4, sürüm 35, inşa 17 12 | # Özet: Tüm KDE programlarının ihtiyaç duyduğu KDE kütüphaneleri 13 | # Açıklama: Tüm KDE programlarının ihtiyaç duyduğu KDE kütüphaneleri 14 | # Bileşen: desktop.kde.base 15 | # Sağladıkları: 16 | # Bağımlılıklar:qt arts freetype fontconfig libxslt libxml2 libpcre libart_lgpl libidn utempter alsa-lib cups tiff aspell 17 | # jasper mDNSResponder ghostscript acl zpspell openexr mit-kerberos tulliana2 18 | # Dağıtım: Pardus, Dağıtım Sürümü: 1.1 19 | # Mimari: Any, Yerleşik Boyut: 222414685 20 | # Ters bağımlılıklar: kdebase gwenview 21 | # 22 | # Problem Description: 23 | # 24 | # Package's reverse dependencies disappears unexpectedly. If a package which has reverse dependencies has been upgraded. 25 | # The revdep list is removed from revdep db. So upgraded package will have an empty revdep list. 26 | # 27 | # Expected: 28 | # 29 | # They should not. :) 30 | # 31 | 32 | from pisi.scenarioapi.scenario import * 33 | 34 | FLIGHTGEAR = "flightgear" 35 | FLIGHTGEAR_DATA = "flightgear-data" 36 | 37 | let_repo_had(FLIGHTGEAR, with_dependencies(FLIGHTGEAR_DATA)) 38 | let_repo_had(FLIGHTGEAR_DATA) 39 | 40 | let_pisi_had(FLIGHTGEAR, FLIGHTGEAR_DATA) 41 | 42 | def run(): 43 | pisi_info(FLIGHTGEAR_DATA) 44 | repo_version_bumped(FLIGHTGEAR_DATA) 45 | repo_updated_index() 46 | pisi_upgraded() 47 | pisi_info(FLIGHTGEAR_DATA) 48 | -------------------------------------------------------------------------------- /scenarios/bug3732scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug3732scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=3732 6 | # 7 | # Problem : If conflicting packages found while upgrading, by removing those prior to 8 | # fetching and installing the desktop may become unusable while upgrading 9 | # process 10 | # 11 | # Problem Description: 12 | # 13 | # This problem appeared in our xorg package split process. The divided packages were 14 | # all marked as conflicting packages to xorg package. But because the xorg package was 15 | # a conflicting package, it is removed before any fetch operation and installing began. 16 | # So some desktop processes could not be started or used properly until the upgrade 17 | # process ends. 18 | # 19 | # Expected: 20 | # 21 | # PiSi should not remove the conflicting packages unless fetching of all the new upgrade 22 | # packages has finished. 23 | 24 | from pisi.scenarioapi.scenario import * 25 | 26 | XORG = "xorg" 27 | QT = "qt" 28 | XORG_SERVER = "xorg-server" 29 | XORG_VIDEO = "xorg-video" 30 | XORG_FONT = "xorg-font" 31 | 32 | let_repo_had(XORG) 33 | let_repo_had(QT, with_dependencies(XORG)) 34 | let_pisi_had(XORG, QT) 35 | 36 | def run(): 37 | repo_added_package(XORG_VIDEO, with_conflicts(XORG)) 38 | repo_added_package(XORG_FONT, with_conflicts(XORG)) 39 | repo_added_package(XORG_SERVER, with_conflicts(XORG), with_dependencies(XORG_VIDEO, XORG_FONT)) 40 | repo_version_bumped(QT, with_removed_dependencies(XORG), with_added_dependencies(XORG_SERVER)) 41 | repo_updated_index() 42 | pisi_upgraded() 43 | -------------------------------------------------------------------------------- /scenarios/bug3865scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug3865scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=3865 6 | # 7 | # Problem : A need arised between the packages libmp4v2 and faad2 that libmp4v2 has to 8 | # define that it only conflicts with the faad2 until release 3. 9 | # 10 | # Problem Description: 11 | # 12 | # PiSi is incapable to define conflict versioning info. libmp4v2 only conflicts with faad2 13 | # package's release no 3. But because PiSi does not understand that, two packages can not 14 | # be installed together. 15 | # 16 | # Expected: 17 | # 18 | # Versioning info can be defined as in dependency informations. 19 | 20 | 21 | from pisi.scenarioapi.scenario import * 22 | 23 | LIBMP4V2 = "libmp4v2" 24 | FAAD2 = "faad2" 25 | 26 | let_repo_had(LIBMP4V2) 27 | let_repo_had(FAAD2, with_version("0.2.1")) 28 | 29 | let_pisi_had(LIBMP4V2, FAAD2) 30 | 31 | def run(): 32 | repo_version_bumped(LIBMP4V2, with_added_conflict(FAAD2, versionTo="0.2.1")) 33 | repo_version_bumped(FAAD2, with_version("0.2.5")) 34 | repo_updated_index() 35 | pisi_upgraded() 36 | -------------------------------------------------------------------------------- /scenarios/bug9991scen.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Scenario : bug9991scen.py 4 | # 5 | # Source : http://bugs.pardus.org.tr/show_bug.cgi?id=9991 6 | # 7 | # Problem : blacklisted system.base packages are still upgraded 8 | # 9 | # Problem Description: 10 | # 11 | # We may assume that the users which are aware of the blacklisting feature are totally aware of the consequences of 12 | # blacklisting a system.base package. Current code forces the upgrade of system.base packages even it's blacklisted. 13 | # 14 | # Expected: 15 | # 16 | # All blacklisted packages should be excluded from upgrade plans. 17 | 18 | 19 | from pisi.scenarioapi.scenario import * 20 | 21 | DBUS = "dbus" 22 | GRUB = "grub" 23 | PISI = "pisi" 24 | KERNEL = "kernel" 25 | BLUEZ = "bluez" 26 | 27 | let_repo_had(KERNEL) 28 | let_repo_had(BLUEZ) 29 | let_repo_had(DBUS, with_partof("system.base")) 30 | let_repo_had(PISI, with_partof("system.base")) 31 | let_pisi_had(DBUS, PISI, KERNEL, BLUEZ) 32 | 33 | def run(): 34 | repo_version_bumped(KERNEL) 35 | repo_version_bumped(BLUEZ) 36 | repo_version_bumped(DBUS) 37 | repo_version_bumped(PISI) 38 | repo_updated_index() 39 | 40 | # The packages in /etc/eopkg/blacklist should not be upgraded 41 | pisi_upgraded() 42 | -------------------------------------------------------------------------------- /scenarios/run.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | #-*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | # 13 | # Authors: Faik Uygur 14 | 15 | import os 16 | import shutil 17 | import glob 18 | import sys 19 | 20 | from pisi.scenarioapi.constants import * 21 | 22 | def clean_out(): 23 | for x in glob.glob(consts.repo_path + consts.glob_pisis): 24 | os.unlink(x) 25 | 26 | if os.path.exists(consts.pisi_db): 27 | shutil.rmtree(consts.pisi_db) 28 | 29 | def run_scen(scenario): 30 | scenario() 31 | 32 | def run_all(): 33 | print '** Running all scenarios' 34 | for root, dirs, files in os.walk("."): 35 | scensources = filter(lambda x:x.endswith('scen.py'), files) 36 | for scensource in scensources: 37 | clean_out() 38 | running = "\n* Running scenario in %s\n" % scensource 39 | print running 40 | print len(running) * "=" + "\n" 41 | module = __import__(scensource[:len(scensource)-3]) 42 | run_scen(module.run) 43 | 44 | if __name__ == "__main__": 45 | os.chdir(consts.scenarios_path) 46 | 47 | args = sys.argv 48 | if len(args) > 1: 49 | scens = sys.argv[1:] 50 | for scen in scens: 51 | clean_out() 52 | scen += 'scen.py' 53 | print "\n* Running scenario in %s\n" % scen 54 | module = __import__(scen[:len(scen)-3]) 55 | run_scen(module.run) 56 | else: 57 | run_all() 58 | -------------------------------------------------------------------------------- /scripts/check-newconfigs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | 13 | import os 14 | import sys 15 | import exceptions 16 | 17 | import pisi 18 | 19 | installdb = pisi.db.installdb.InstallDB() 20 | 21 | def ask_action(msg, actions, default): 22 | while True: 23 | s = raw_input(msg) 24 | if len(s) == 0: 25 | return default 26 | else: 27 | if s not in actions: 28 | continue 29 | 30 | return s 31 | 32 | def get_installed_packages(): 33 | return installdb.list_installed() 34 | 35 | def check_changed_config_files(package): 36 | 37 | all_files = installdb.get_files(package) 38 | config_files = filter(lambda x: x.type == 'config', all_files.list) 39 | config_paths = map(lambda x: "/" + str(x.path), config_files) 40 | 41 | newconfig = [] 42 | for path in config_paths: 43 | if os.path.exists(path) and os.path.exists(path + ".newconfig"): 44 | newconfig.append(path) 45 | 46 | return newconfig 47 | 48 | def show_changes(package, changed): 49 | prompt = "%s has new config files. Would you like to see them [Y/n] " % package 50 | if ask_action(prompt, ["y","n"], "y") == "n": 51 | return 52 | 53 | for file in changed: 54 | answer = "?" 55 | while answer == "?" or answer not in ["n", "y"]: 56 | prompt = " %s has changed. Would you like to overwrite new config file [N/y/?] " % file 57 | answer = ask_action(prompt, ["y", "n", "?"], "n") 58 | 59 | if answer == "y": 60 | os.rename(file+".newconfig", file) 61 | if answer == "n": 62 | break 63 | if answer == "?": 64 | os.system("diff -u %s %s | less" % (file, file + ".newconfig")) 65 | 66 | def check_package(package): 67 | changed = check_changed_config_files(package) 68 | if changed: 69 | show_changes(package, changed) 70 | 71 | def check_changes(): 72 | packages = get_installed_packages() 73 | for pkg in packages: 74 | check_package(pkg) 75 | 76 | if __name__ == "__main__": 77 | if len(sys.argv) == 1: 78 | print "Checking all packages" 79 | check_changes() 80 | if len(sys.argv) == 2: 81 | check_package(sys.argv[1]) 82 | if len(sys.argv) > 2: 83 | for pkg in sys.argv[1:]: 84 | check_package(pkg) 85 | -------------------------------------------------------------------------------- /scripts/cleanArchives.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright (C) 2005, 2006 TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | 12 | import os 13 | import sys 14 | 15 | import pisi.uri 16 | import pisi.specfile 17 | 18 | def scanPSPEC(folder): 19 | packages = [] 20 | for root, dirs, files in os.walk(folder): 21 | if "pspec.xml" in files: 22 | packages.append(root) 23 | # dont walk into the versioned stuff 24 | if ".svn" in dirs: 25 | dirs.remove(".svn") 26 | return packages 27 | 28 | def cleanArchives(file): 29 | try: 30 | os.remove(file) 31 | except OSError: 32 | print("Permission denied...") 33 | 34 | if __name__ == "__main__": 35 | try: 36 | packages = scanPSPEC(sys.argv[1]) 37 | except: 38 | print "Usage: cleanArchives.py path2repo" 39 | sys.exit(1) 40 | 41 | if "--dry-run" in sys.argv: 42 | clean = False 43 | elif "--clean" in sys.argv: 44 | clean = True 45 | else: 46 | sys.exit(0) 47 | 48 | files = [] 49 | for package in packages: 50 | spec = pisi.specfile.SpecFile() 51 | spec.read(os.path.join(package, "pspec.xml")) 52 | 53 | URI = pisi.uri.URI(spec.source.archive.uri) 54 | files.append(URI.filename()) 55 | 56 | archiveFiles = os.listdir("/var/cache/eopkg/archives/") 57 | unneededFiles = filter(lambda x:x not in files, archiveFiles) 58 | 59 | for i in unneededFiles: 60 | if not clean: 61 | print("/var/cache/eopkg/archives/%s" % i) 62 | else: 63 | cleanArchives("/var/cache/eopkg/archives/%s" % i) 64 | -------------------------------------------------------------------------------- /scripts/convert_history.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import os 5 | import codecs 6 | import xml.dom.minidom as mdom 7 | 8 | def find_pspecs(folder): 9 | paks = [] 10 | for root, dirs, files in os.walk(folder): 11 | if "pspec.xml" in files: 12 | paks.append(root) 13 | # dont walk into the versioned stuff 14 | if ".svn" in dirs: 15 | dirs.remove(".svn") 16 | return paks 17 | 18 | def addText(doc, parent, text): 19 | cdata =doc.createTextNode(text) 20 | parent.appendChild(cdata) 21 | 22 | def getTags(parent, childName): 23 | return [x for x in parent.childNodes if x.nodeType == x.ELEMENT_NODE if x.tagName == childName] 24 | 25 | def getNodeText(node, tag, default=None): 26 | try: 27 | c = getTags(node, tag)[0].firstChild.data 28 | except: 29 | c = default 30 | return c 31 | 32 | def newNode(doc, tag, text): 33 | node = doc.createElement(tag) 34 | cdata = doc.createTextNode(text) 35 | node.appendChild(cdata) 36 | return node 37 | 38 | def fixIndent(doc, node): 39 | for x in node.childNodes: 40 | if x.nodeType == x.ELEMENT_NODE: 41 | if x.tagName == "Update": 42 | fixIndent(doc, x) 43 | else: 44 | x.data = "\n" + x.data[5:] 45 | 46 | def fixTags(doc, hist): 47 | for update in hist.childNodes: 48 | if update.nodeType == update.ELEMENT_NODE: 49 | rno = getNodeText(update, "Release") 50 | update.setAttribute("release", rno) 51 | if rno == "1": 52 | comment = newNode(doc, "Comment", "First release.") 53 | paker = getTags(getTags(doc.documentElement, "Source")[0], "Packager")[0] 54 | name = newNode(doc, "Name", getNodeText(paker, "Name")) 55 | email = newNode(doc, "Email", getNodeText(paker, "Email")) 56 | else: 57 | comment = newNode(doc, "Comment", "FIXHISTORY") 58 | name = newNode(doc, "Name", "FIXHISTORY") 59 | email = newNode(doc, "Email", "FIXHISTORY") 60 | update.replaceChild(comment, getTags(update, "Release")[0]) 61 | addText(doc, update, " ") 62 | update.appendChild(name) 63 | addText(doc, update, "\n ") 64 | update.appendChild(email) 65 | addText(doc, update, "\n ") 66 | 67 | def fixPspec(path): 68 | doc = mdom.parse(path) 69 | pisi = doc.documentElement 70 | source = getTags(pisi, "Source")[0] 71 | history = getTags(source, "History")[0] 72 | item = source.removeChild(history) 73 | addText(doc, pisi, "\n ") 74 | fixIndent(doc, item) 75 | fixTags(doc, item) 76 | pisi.appendChild(item) 77 | addText(doc, pisi, "\n") 78 | f = codecs.open(path,'w', "utf-8") 79 | f.write(doc.toxml()) 80 | f.close() 81 | 82 | pakages = find_pspecs(sys.argv[1]) 83 | for pak in pakages: 84 | fixPspec(os.path.join(pak, "pspec.xml")) 85 | -------------------------------------------------------------------------------- /scripts/createdelta.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2005, 2006 TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | 13 | import os 14 | import glob 15 | import pisi 16 | import pisi.util as util 17 | from pisi.version import Version 18 | from pisi.delta import create_delta_package 19 | 20 | def minsandmaxes(): 21 | 22 | packages = map(lambda x: os.path.basename(x).split(".eopkg")[0], set(glob.glob("*.eopkg")) - set(glob.glob("*.delta.eopkg"))) 23 | 24 | versions = {} 25 | for file in packages: 26 | name, version = util.parse_package_name(file) 27 | versions.setdefault(name, []).append(Version(version)) 28 | 29 | mins = {} 30 | maxs = {} 31 | for pkg in versions.keys(): 32 | mins[pkg] = min(versions[pkg]) 33 | maxs[pkg] = max(versions[pkg]) 34 | 35 | return mins, maxs 36 | 37 | if __name__ == "__main__": 38 | 39 | mi, ma = minsandmaxes() 40 | for pkg in mi.keys(): 41 | old_pkg = "%s-%s.eopkg" % (pkg, str(mi[pkg])) 42 | new_pkg = "%s-%s.eopkg" % (pkg, str(ma[pkg])) 43 | name, version = util.parse_package_name(pkg) 44 | 45 | if not old_pkg == new_pkg: 46 | # skip if same 47 | if not os.path.exists("%s-%s-%s.delta.eopkg" % (name, str(mi[pkg].build), str(ma[pkg].build))): 48 | # skip if delta exists 49 | print "%s --> Min: %s Max: %s \n %s-%s-%s.delta.eopkg" % (pkg, old_pkg, new_pkg, name, str(mi[pkg].build), str(ma[pkg].build)) 50 | create_delta_package(old_pkg, new_pkg) 51 | -------------------------------------------------------------------------------- /scripts/fix_old_metadata_files.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | import xml.dom.minidom as mdom 5 | import codecs 6 | import os 7 | 8 | folder = "/var/lib/eopkg" 9 | 10 | def saveMetadata(data, file): 11 | if data: 12 | f = codecs.open(file, 'w', "utf-8") 13 | f.write(data) 14 | f.close() 15 | return True 16 | 17 | def getNodeText(node, tag, default=None): 18 | try : c = getTags(node, tag)[0].firstChild.data 19 | except: c = default 20 | return c 21 | 22 | def getTags(parent, childName): 23 | return [x for x in parent.childNodes if x.nodeType == x.ELEMENT_NODE if x.tagName == childName] 24 | 25 | def addText(dom, parent, text): 26 | cdata = dom.createTextNode(text) 27 | parent.appendChild(cdata) 28 | 29 | def fixMetadata(metadata): 30 | dom = mdom.parse(metadata) 31 | pisi = dom.documentElement 32 | 33 | package = getTags(pisi, "Package")[0] 34 | history = getTags(package, "History")[0] 35 | item = package.removeChild(history) 36 | 37 | for update in history.childNodes: 38 | if update.nodeType == update.ELEMENT_NODE: 39 | try: 40 | rno = getNodeText(update, "Release")[6:-5] 41 | except TypeError: 42 | return None 43 | update.setAttribute("release", rno) 44 | release = getTags(update, "Release")[0] 45 | update.removeChild(release) 46 | 47 | addText(dom, package, " ") 48 | package.appendChild(item) 49 | addText(dom, package, "\n ") 50 | return dom.toxml() 51 | 52 | def findMetadata(): 53 | for root, dirs, files in os.walk(folder): 54 | if "metadata.xml" in files: 55 | yield (root + '/metadata.xml') 56 | 57 | for file in findMetadata(): 58 | if saveMetadata(fixMetadata(file), file): 59 | print "Güncellendi : ", file 60 | else: 61 | print "Hiç bir şey yapılmadı: ", file 62 | -------------------------------------------------------------------------------- /scripts/lseopkg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | 13 | import os 14 | import sys 15 | import pisi 16 | 17 | def show_info(filename): 18 | metadata, files = pisi.api.info_file(filename) 19 | 20 | paths = [fileinfo.path for fileinfo in files.list] 21 | paths.sort() 22 | return paths 23 | 24 | def uniq(alist): 25 | set = {} 26 | return [set.setdefault(e, e) for e in alist if e not in set] 27 | 28 | def usage(errmsg): 29 | print """ 30 | Error: %s 31 | 32 | Usage: 33 | lseopkg eopkg_package.eopkg (lists the content of package) 34 | lseopkg dirs eopkg_package.eopkg (lists directories in the package for the package developer) 35 | """ % (errmsg) 36 | 37 | sys.exit(1) 38 | 39 | 40 | def main(): 41 | if len(sys.argv) < 2 or ("dirs" in sys.argv and len(sys.argv) < 3): 42 | usage("eopkg package required...") 43 | 44 | if sys.argv[1] == "dirs": 45 | dirlist = [] 46 | for file in show_info(sys.argv[2]): 47 | dirlist.append(os.path.dirname(file)) 48 | 49 | for dir in uniq(dirlist): 50 | print "/%s" % dir 51 | 52 | elif not os.path.exists(sys.argv[1]): 53 | print "File %s not found" % sys.argv[1] 54 | 55 | else: 56 | for file in show_info(sys.argv[1]): 57 | print "/%s" % file 58 | 59 | if __name__ == "__main__": 60 | sys.exit(main()) 61 | -------------------------------------------------------------------------------- /scripts/make-changelog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import urllib2 6 | 7 | import piksemel 8 | 9 | first_revision = "27898" 10 | accounts_url = "http://svn.pardus.org.tr/uludag/trunk/common/accounts" 11 | authors = {} 12 | 13 | def get_author_name_mail(author): 14 | if not authors: 15 | accounts = urllib2.urlopen(accounts_url) 16 | for line in accounts: 17 | if line.startswith("#"): 18 | continue 19 | elif line.count(":") != 3: 20 | continue 21 | 22 | account, name, mail, jabber = line.split(":") 23 | mail = mail.replace(" [at] ", "@") 24 | authors[account] = "%s <%s>" % (name, mail) 25 | 26 | return authors[author] 27 | 28 | def cleanup_msg_lines(lines): 29 | result = [] 30 | for line in lines: 31 | if line.startswith("BUG:FIXED:"): 32 | bug_number = line.split(":")[2] 33 | line = "Fixes the bug reported at http://bugs.pardus.org.tr/%s." % bug_number 34 | 35 | elif line.startswith("BUG:COMMENT:"): 36 | bug_number = line.split(":")[2] 37 | line = "See http://bugs.pardus.org.tr/%s." % bug_number 38 | 39 | elif line.startswith("Changes since "): 40 | return result[:-1] 41 | 42 | result.append(line) 43 | 44 | return result 45 | 46 | def strip_empty_lines(msg): 47 | result = [] 48 | for line in msg.splitlines(): 49 | if not line.strip(): 50 | line = "" 51 | 52 | result.append(line) 53 | 54 | return "\n".join(result) 55 | 56 | def create_log_entry(author, date, msg): 57 | if author == "transifex": 58 | return None 59 | 60 | author = get_author_name_mail(author) 61 | date = date.split("T", 1)[0] 62 | 63 | lines = msg.splitlines() 64 | lines = cleanup_msg_lines(lines) 65 | lines[0] = "\t* %s" % lines[0] 66 | msg = "\n\t".join(lines) 67 | 68 | msg = strip_empty_lines(msg) 69 | entry = "%s %s\n%s" % (date, author, msg) 70 | 71 | return entry 72 | 73 | if __name__ == "__main__": 74 | p = os.popen("svn log -r%s:HEAD --xml" % first_revision) 75 | doc = piksemel.parseString(p.read()) 76 | 77 | entries = [] 78 | for log_entry in doc.tags("logentry"): 79 | author = log_entry.getTagData("author") 80 | date = log_entry.getTagData("date") 81 | msg = log_entry.getTagData("msg") 82 | 83 | entry = create_log_entry(author, date, msg.strip()) 84 | if entry: 85 | entries.append(entry) 86 | 87 | entries.reverse() 88 | open("ChangeLog", "w").write("\n\n".join(entries)) 89 | -------------------------------------------------------------------------------- /scripts/package-signing/README: -------------------------------------------------------------------------------- 1 | # Generate encrypted private key and self signed certificate: 2 | # (Skip this step if you already have a key and a certificate) 3 | 4 | mkdir certs 5 | openssl genrsa -des3 -out certs/enc_key.pem 1024 6 | openssl req -new -subj '/C=TR/ST=Kocaeli/L=Gebze/CN=Pardus' -key certs/enc_key.pem -out certs/req.pem 7 | openssl req -x509 -key certs/enc_key.pem -in certs/req.pem -out certs/cert.pem -days 365 8 | 9 | # Feel free to share 'certs/cert.pem' and 'certs/pub_key.pem' with anyone, keep others to yourself. 10 | 11 | # Create a test file: 12 | 13 | mkdir -p dummy/a/b/c 14 | echo "abc" > dummy/test.txt 15 | echo "123" > dummy/a/test.txt 16 | echo "ABC" > dummy/a/b/test.txt 17 | echo "^+%" > dummy/a/b/c/test.txt 18 | zip -r test.zip dummy 19 | rm -rf dummy 20 | cp test.zip test2.zip 21 | 22 | # Sign ZIP files: 23 | 24 | ./pisign.py sign certs/enc_key.pem test.zip test2.zip abc.txt 25 | Password: 26 | 27 | # Make a directory for trusted certificates: 28 | 29 | mkdir certs_trusted/ 30 | cp certs/cert.pem certs_trusted/ 31 | 32 | # Verify ZIP files: 33 | 34 | ./pisign.py verify certs_trusted/ test.zip test2.zip abc.txt 35 | 36 | # Change *.zip contents and try to verify again. 37 | # Clear cert_trusted/ directory and try again. 38 | -------------------------------------------------------------------------------- /scripts/pisisdr: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | 13 | # a Simple helper script for eopkg to set default repo 14 | 15 | import os 16 | import sys 17 | 18 | import pisi 19 | import pisi.context as ctx 20 | 21 | def usage(): 22 | print """ 23 | Usage: 24 | pisisdr reponame 25 | """ 26 | sys.exit(1) 27 | 28 | def main(): 29 | if len(sys.argv) < 2: 30 | usage() 31 | 32 | repo = sys.argv[1] 33 | 34 | try: 35 | ctx.repodb.set_default_repo(repo) 36 | except pisi.lockeddbshelve.Error, e: 37 | print e 38 | 39 | if __name__ == "__main__": 40 | sys.exit(main()) 41 | -------------------------------------------------------------------------------- /scripts/svndist.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # a script to preare eopkg source tarball from svn 3 | # author: exa 4 | 5 | #TODO: arguments for svn snapshot with rev number, or a tag to override default 6 | 7 | import sys 8 | import os 9 | import shutil 10 | 11 | def run(cmd): 12 | print 'running', cmd 13 | os.system(cmd) 14 | 15 | sys.path.insert(0, '.') 16 | import pisi 17 | if not os.path.exists('svndist'): 18 | os.makedirs('svndist') 19 | 20 | ver = pisi.__version__ 21 | 22 | if os.path.exists('svndist/pisi-%s' % ver): 23 | shutil.rmtree('svndist/pisi-%s' % ver) 24 | 25 | print 'Exporting svn directory' 26 | run('svn export http://svn.uludag.org.tr/uludag/trunk/pisi svndist/pisi-%s' % ver) 27 | 28 | os.chdir('svndist') 29 | run('tar cjvf pisi-%s.tar.bz2 pisi-%s' % (ver, ver)) 30 | 31 | print 'Have a look at svndist directory' 32 | -------------------------------------------------------------------------------- /scripts/sync-licenses: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rsync -avz --delete rsync://rsync.gentoo.org/gentoo-portage/licenses ../licenses/ 3 | 4 | -------------------------------------------------------------------------------- /scripts/uneopkg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2006-2010, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | 13 | import os 14 | import sys 15 | from zipfile import BadZipfile 16 | 17 | from pisi.package import Package 18 | 19 | def usage(errmsg): 20 | print """ 21 | Error: %s 22 | 23 | Usage: 24 | uneopkg eopkg_package.eopkg [target_dir] 25 | """ % (errmsg) 26 | 27 | sys.exit(1) 28 | 29 | def main(): 30 | 31 | if len(sys.argv) < 2: 32 | usage("eopkg package required..") 33 | 34 | elif not os.path.exists(sys.argv[1]): 35 | usage("File %s not found" % sys.argv[1]) 36 | 37 | try: 38 | package = Package(sys.argv[1]) 39 | except BadZipfile, e: 40 | print e 41 | sys.exit(1) 42 | 43 | if not os.path.exists("install"): 44 | os.makedirs("install") 45 | 46 | target = '.' if len(sys.argv) == 2 else sys.argv[2] 47 | 48 | package.extract_pisi_files(target) 49 | package.extract_dir('comar', target) 50 | if not os.path.exists(os.path.join(target, 'install')): 51 | os.makedirs(os.path.join(target, 'install')) 52 | 53 | package.extract_install(os.path.join(target, 'install')) 54 | 55 | # FIXME: There is a Pisi bug, it already creates an install directory even its empty. 56 | if os.listdir('install') == []: 57 | os.rmdir('install') 58 | 59 | return 0 60 | 61 | if __name__ == "__main__": 62 | sys.exit(main()) 63 | -------------------------------------------------------------------------------- /tests/README: -------------------------------------------------------------------------------- 1 | 2 | PiSi UnitTests 3 | ############## 4 | 5 | Before running unittests you need to first go to repos directory and 6 | create test repositories. 7 | 8 | >>> pisi@pardus tests/repos# python createrepos.py 9 | 10 | Now you can return to tests folder and run tests. 11 | 12 | >>> pisi@pardus tests # python runtests.py 13 | 14 | -------------------------------------------------------------------------------- /tests/archivetests.py: -------------------------------------------------------------------------------- 1 | import pisi 2 | import unittest 3 | from pisi import util 4 | from pisi import uri 5 | from pisi import archive 6 | from pisi import sourcearchive 7 | from pisi import fetcher 8 | from pisi.specfile import SpecFile 9 | from os.path import join, exists 10 | 11 | class ArchiveTestCase(unittest.TestCase): 12 | 13 | def testTarUnpack(self): 14 | spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') 15 | targetDir = '/tmp/tests' 16 | archives = sourcearchive.SourceArchives(spec) 17 | archives.unpack(targetDir) 18 | for archive in spec.source.archive: 19 | assert archive.type == 'targz' 20 | 21 | 22 | def testUnpackTarCond(self): 23 | spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') 24 | targetDir = '/tmp' 25 | archives = sourcearchive.SourceArchives(spec) 26 | for archive in spec.source.archive: 27 | url = uri.URI(archive.uri) 28 | filePath = join(pisi.context.config.archives_dir(), url.filename()) 29 | if util.sha1_file(filePath) != archive.sha1sum: 30 | fetch = fetcher.Fetcher(archive.uri, targetDir) 31 | fetch.fetch() 32 | assert archive.type == 'targz' 33 | 34 | def testZipUnpack(self): 35 | spec = SpecFile('repos/pardus-2007/system/base/openssl/pspec.xml') 36 | targetDir = '/tmp/tests' 37 | archives = sourcearchive.SourceArchives(spec) 38 | archives.fetch() 39 | archives.unpack(targetDir) 40 | assert not exists(targetDir + '/openssl') 41 | 42 | def testMakeZip(self): 43 | spec = SpecFile('repos/pardus-2007/system/base/openssl/pspec.xml') 44 | targetDir = '/tmp/tests' 45 | archives = sourcearchive.SourceArchives(spec) 46 | archives.fetch(interactive = False) 47 | archives.unpack(targetDir, clean_dir=True) 48 | del archives 49 | 50 | newDir = targetDir + '/newZip' 51 | zip = archive.ArchiveZip(newDir, 'zip', 'w') 52 | sourceDir = '/tmp/pisi-root' 53 | zip.add_to_archive(sourceDir) 54 | zip.close() 55 | -------------------------------------------------------------------------------- /tests/configfiletest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from pisi.configfile import ConfigurationFile 3 | 4 | class ConfigFileTestCase(unittest.TestCase): 5 | 6 | def setUp(self): 7 | self.cf = ConfigurationFile('pisi.conf') 8 | 9 | def testGeneralDefaults(self): 10 | cf = self.cf 11 | self.assertEqual(cf.general.destinationDirectory, cf.general['destinationDirectory']) 12 | assert not cf.general.autoclean 13 | self.assertEqual(cf.general.http_proxy, cf.general['http_proxy']) 14 | assert not cf.general.package_cache 15 | 16 | def testBuildDefaults(self): 17 | cf = self.cf 18 | self.assertEqual(cf.build.jobs, cf.build['jobs']) 19 | assert not cf.build.defaults.generateDebug 20 | assert cf.build.defaults.enableSandbox #default is taken from 2009.2 21 | self.assertEqual(cf.build.compressionlevel, cf.build['compressionlevel']) 22 | self.assertEqual(cf.build.fallback, cf.build['fallback']) 23 | 24 | def testDirectoriesDefaults(self): 25 | cf = self.cf 26 | self.assertEqual(cf.dirs.lib_dir, cf.dirs['lib_dir']) 27 | self.assertEqual(cf.dirs.index_dir, cf.dirs['index_dir']) 28 | 29 | def testConfigurationSection(self): 30 | cf = self.cf 31 | if not cf.general: 32 | self.fail() 33 | if not cf.build: 34 | self.fail() 35 | if not cf.dirs: 36 | self.fail() 37 | 38 | def testPisiConfValues(self): 39 | cf = self.cf 40 | self.assertEqual(cf.dirs.kde_dir, '/usr/kde/4') 41 | self.assertEqual(cf.dirs.compiled_packages_dir, '/var/cache/eopkg/packages') 42 | self.assertEqual(cf.general.architecture, 'i686') 43 | self.assertEqual(cf.general.distribution_release, '2009') 44 | 45 | def testValuesExists(self): 46 | cf = self.cf 47 | assert cf.general.distribution 48 | assert not cf.general.targetDirectory 49 | assert cf.build.cxxflags 50 | assert not cf.build.configurationlevel 51 | assert cf.dirs.qt_dir 52 | assert not cf.dirs.cache_dir 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /tests/conflicttests.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import unittest 3 | import pisi 4 | import pisi.context as ctx 5 | import pisi.conflict 6 | 7 | class ConflictTestCase(unittest.TestCase): 8 | 9 | def testInstalledPackageConflicts(self): 10 | pisi.api.install(["ethtool"]) 11 | confinfo = pisi.conflict.Conflict() 12 | confinfo.package = "ethtool" 13 | confinfo.version = "6" 14 | confinfo.release = "1" 15 | assert not pisi.conflict.installed_package_conflicts(confinfo) 16 | pisi.api.remove(["ethtool"]) 17 | 18 | def testCalculateConflicts(self): 19 | packagedb = pisi.db.packagedb.PackageDB() 20 | packages = ["ethtool", "zlib", "ctorrent"] 21 | assert pisi.conflict.calculate_conflicts(packages, packagedb) 22 | 23 | def testConflictCheck(self): 24 | # In our sample repo1, spam conflicts with bar. 25 | # If this fails, it may affect database test case results. 26 | pisi.api.add_repo("repo1", "repos/repo1-bin/eopkg-index.xml") 27 | pisi.api.update_repo("repo1") 28 | pisi.api.install(["spam"]) 29 | 30 | myconflict = pisi.conflict.Conflict() 31 | myconflict.package = "bar" 32 | myconflict.version = "0.3" 33 | myconflict.release = "1" 34 | 35 | pisi.api.install(["bar"]) 36 | assert "bar" in pisi.api.list_installed() 37 | assert "spam" not in pisi.api.list_installed() 38 | 39 | pisi.api.remove(["bar"]) 40 | pisi.api.remove_repo("repo1") 41 | 42 | def testInterRepoCrossConflicts(self): 43 | #If this fails, it may affect database test case results 44 | pisi.api.add_repo("repo1", "repos/repo1-bin/eopkg-index.xml") 45 | pisi.api.update_repo("repo1") 46 | 47 | pisi.api.install(["spam", "foo"]) 48 | before = pisi.api.list_installed() 49 | pisi.api.remove_repo("repo1") 50 | 51 | pisi.api.add_repo("repo2", "repos/repo2-bin/eopkg-index.xml") 52 | pisi.api.update_repo("repo2") 53 | pisi.api.upgrade(["spam"]) 54 | after = pisi.api.list_installed() 55 | 56 | assert set(before) == set(after) 57 | 58 | idb = pisi.db.installdb.InstallDB() 59 | assert 3 == int(idb.get_package("foo").release) 60 | 61 | pisi.api.remove(["foo"]) 62 | pisi.api.remove(["spam"]) 63 | pisi.api.remove_repo("repo2") 64 | -------------------------------------------------------------------------------- /tests/constanttest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pisi.constants 3 | import pisi.context as ctx 4 | 5 | class ConstantTestCase(unittest.TestCase): 6 | 7 | def testConstants(self): 8 | constants = ctx.const 9 | constDict = {"actions": "actions.py", "setup":"setup","metadata":"metadata.xml"} 10 | 11 | for i in constDict.keys(): 12 | if hasattr(constants,i): 13 | value = getattr(constants,i) 14 | self.assertEqual(value, constDict[i]) 15 | 16 | -------------------------------------------------------------------------------- /tests/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /tests/database/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | -------------------------------------------------------------------------------- /tests/database/filesdbtest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2007, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import testcase 14 | import pisi 15 | 16 | class FilesDBTestCase(testcase.TestCase): 17 | 18 | filesdb = pisi.db.filesdb.FilesDB() 19 | 20 | def testHasFile(self): 21 | assert not self.filesdb.has_file("usr/bin/ethtool") 22 | pisi.api.install(["ethtool"]) 23 | assert self.filesdb.has_file("usr/bin/ethtool") 24 | pisi.api.remove(["ethtool"]) 25 | assert not self.filesdb.has_file("usr/bin/ethtool") 26 | 27 | def testGetFile(self): 28 | pisi.api.install(["ethtool"]) 29 | pkg, path = self.filesdb.get_file("usr/bin/ethtool") 30 | assert pkg == "ethtool" 31 | assert path == "usr/bin/ethtool" 32 | pisi.api.remove(["ethtool"]) 33 | assert not self.filesdb.has_file("usr/bin/ethtool") 34 | 35 | def testAddRemoveFiles(self): 36 | fileinfo1 = pisi.files.FileInfo() 37 | fileinfo1.path = "etc/eopkg/eopkg.conf" 38 | fileinfo2 = pisi.files.FileInfo() 39 | fileinfo2.path = "etc/eopkg/mirrors.conf" 40 | 41 | files = pisi.files.Files() 42 | files.list.append(fileinfo1) 43 | files.list.append(fileinfo2) 44 | 45 | assert not self.filesdb.has_file("etc/eopkg/eopkg.conf") 46 | assert not self.filesdb.has_file("etc/eopkg/mirrors.conf") 47 | 48 | self.filesdb.add_files("pisi", files) 49 | 50 | assert self.filesdb.has_file("etc/eopkg/eopkg.conf") 51 | assert self.filesdb.has_file("etc/eopkg/mirrors.conf") 52 | 53 | pkg, path = self.filesdb.get_file("etc/eopkg/eopkg.conf") 54 | assert pkg == "pisi" 55 | 56 | # FIXME: inconsistency in filesdb.py add_remove and remove_remove parameters 57 | self.filesdb.remove_files(files.list) 58 | 59 | assert not self.filesdb.has_file("etc/eopkg/eopkg.conf") 60 | assert not self.filesdb.has_file("etc/eopkg/mirrors.conf") 61 | 62 | def testSearchFile(self): 63 | assert not self.filesdb.search_file("ethtool") 64 | pisi.api.install(["ethtool"]) 65 | found = self.filesdb.search_file("ethtool") 66 | pkg, files = found[0] 67 | assert set(files) == set(['usr/bin/ethtool']) 68 | pisi.api.remove(["ethtool"]) 69 | -------------------------------------------------------------------------------- /tests/database/lazydbtest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2007-2010, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import unittest 14 | import pisi.db.lazydb as lazydb 15 | 16 | class TestDB(lazydb.LazyDB): 17 | 18 | def init(self): 19 | self.testfield = True 20 | 21 | def getTestField(self): 22 | return self.testfield 23 | 24 | class LazyDBTestCase(unittest.TestCase): 25 | 26 | def testDatabaseMethodForcingInit(self): 27 | db = TestDB() 28 | assert db.getTestField() 29 | assert db.__dict__.has_key("testfield") 30 | db._delete() 31 | 32 | def testDatabaseWithoutInit(self): 33 | db = TestDB() 34 | assert not db.__dict__.has_key("testfield") 35 | db._delete() 36 | 37 | def testSingletonBehaviour(self): 38 | db = TestDB() 39 | db2 = TestDB() 40 | assert id(db) == id(db2) 41 | -------------------------------------------------------------------------------- /tests/database/repodbtest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2007-2010, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import testcase 14 | import pisi 15 | 16 | class RepoDBTestCase(testcase.TestCase): 17 | 18 | def setUp(self): 19 | testcase.TestCase.setUp(self) 20 | self.repodb = pisi.db.repodb.RepoDB() 21 | 22 | def testAddRemoveRepo(self): 23 | assert "contrib-2007-src" not in self.repodb.list_repos() 24 | repo = pisi.db.repodb.Repo(pisi.uri.URI("repos/contrib-2007/eopkg-index.xml")) 25 | self.repodb.add_repo("contrib-2007-src", repo) 26 | assert "contrib-2007-src" in self.repodb.list_repos() 27 | self.repodb.remove_repo("contrib-2007-src") 28 | assert "contrib-2007" in self.repodb.list_repos() 29 | assert "pardus-2007" in self.repodb.list_repos() 30 | assert "contrib-2007-src" not in self.repodb.list_repos() 31 | 32 | def testAddRemoveCycle(self): 33 | for r in range(30): 34 | assert "test-repo" not in self.repodb.list_repos() 35 | repo = pisi.db.repodb.Repo(pisi.uri.URI("http://test-repo/eopkg-index.xml")) 36 | self.repodb.add_repo("test-repo", repo) 37 | assert "test-repo" in self.repodb.list_repos() 38 | self.repodb.remove_repo("test-repo") 39 | 40 | assert "test-repo" not in self.repodb.list_repos() 41 | 42 | def testListRepos(self): 43 | assert set(self.repodb.list_repos()) == set(['pardus-2007', 'contrib-2007', 'pardus-2007-src']) 44 | 45 | def testGetSourceRepos(self): 46 | assert set(self.repodb.get_source_repos()) == set(['pardus-2007-src']) 47 | 48 | def testGetBinaryRepos(self): 49 | assert set(self.repodb.get_binary_repos()) == set(['pardus-2007', 'contrib-2007']) 50 | 51 | def testGetRepo(self): 52 | repo = self.repodb.get_repo("pardus-2007") 53 | uri = repo.indexuri 54 | assert uri.get_uri() == "repos/pardus-2007-bin/eopkg-index.xml" 55 | 56 | def testRepoOrder(self): 57 | repoorder = pisi.db.repodb.RepoOrder() 58 | assert repoorder.get_order() == ['pardus-2007', 'contrib-2007', 'pardus-2007-src'] 59 | 60 | repoorder.add("test-repo", "http://test-repo/eopkg-index.xml") 61 | assert repoorder.get_order() == ['pardus-2007', 'contrib-2007', 'pardus-2007-src', 'test-repo'] 62 | 63 | repoorder.remove("test-repo") 64 | assert repoorder.get_order() == ['pardus-2007', 'contrib-2007', 'pardus-2007-src'] 65 | -------------------------------------------------------------------------------- /tests/database/sourcedbtest.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # Copyright (C) 2007-2010, TUBITAK/UEKAE 4 | # 5 | # This program is free software; you can redistribute it and/or modify it under 6 | # the terms of the GNU General Public License as published by the Free 7 | # Software Foundation; either version 2 of the License, or (at your option) 8 | # any later version. 9 | # 10 | # Please read the COPYING file. 11 | # 12 | 13 | import testcase 14 | import pisi 15 | 16 | class SourceDBTestCase(testcase.TestCase): 17 | 18 | def setUp(self): 19 | testcase.TestCase.setUp(self) 20 | 21 | self.sourcedb = pisi.db.sourcedb.SourceDB() 22 | 23 | 24 | def testListSources(self): 25 | assert set(self.sourcedb.list_sources()) == set(['ethtool', 'nfdump', 'shadow', 'libidn', 26 | 'zlib', 'db4', 'openssl', 'jpeg', 'gsl', 27 | 'curl', 'bogofilter', 'ncftp', 'pam', 28 | 'bash', 'cracklib']) 29 | 30 | def testHasSpec(self): 31 | assert self.sourcedb.has_spec("ethtool") 32 | assert not self.sourcedb.has_spec("hedehodo") 33 | 34 | def testGetSpec(self): 35 | spec = self.sourcedb.get_spec("ethtool") 36 | assert spec.source.name == "ethtool" 37 | assert spec.source.partOf == "applications.network" 38 | 39 | def testGetSpecOfRepository(self): 40 | spec = self.sourcedb.get_spec("ethtool", "pardus-2007-src") 41 | assert spec.source.name == "ethtool" 42 | assert spec.source.partOf == "applications.network" 43 | 44 | def testGetSpecAndRepository(self): 45 | spec, repo = self.sourcedb.get_spec_repo("ethtool") 46 | assert spec.source.name == "ethtool" 47 | assert spec.source.partOf == "applications.network" 48 | assert repo == "pardus-2007-src" 49 | 50 | def testGetSourceFromPackage(self): 51 | # FIXME: Add multi package from source to createrepo.py 52 | pkg = self.sourcedb.pkgtosrc("cracklib") 53 | assert pkg == "cracklib" 54 | 55 | def testSearchPackage(self): 56 | packages = self.sourcedb.search_spec(["open", "ssl"]) 57 | assert set(["openssl"]) == set(packages) 58 | 59 | packages = self.sourcedb.search_spec(["bogo", "filter"], repo="pardus-2007-src") 60 | assert set(["bogofilter"]) == set(packages) 61 | 62 | 63 | -------------------------------------------------------------------------------- /tests/database/testcase.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import pisi 4 | import pisi.context as ctx 5 | 6 | class TestCase(unittest.TestCase): 7 | 8 | def setUp(self): 9 | options = pisi.config.Options() 10 | options.destdir = 'repos/tmp' 11 | pisi.api.set_options(options) 12 | pisi.api.set_comar(False) 13 | 14 | ctx.config.values.general.distribution = "Pardus" 15 | ctx.config.values.general.distribution_release = "2007" 16 | 17 | if not pisi.api.list_repos(): 18 | pisi.api.add_repo("pardus-2007", "repos/pardus-2007-bin/eopkg-index.xml") 19 | pisi.api.add_repo("contrib-2007", "repos/contrib-2007-bin/eopkg-index.xml") 20 | pisi.api.add_repo("pardus-2007-src", "repos/pardus-2007/eopkg-index.xml") 21 | pisi.api.update_repo("pardus-2007") 22 | pisi.api.update_repo("contrib-2007") 23 | pisi.api.update_repo("pardus-2007-src") 24 | -------------------------------------------------------------------------------- /tests/dependencytest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pisi.relation 3 | import pisi.dependency 4 | 5 | class DependencyTestCase(unittest.TestCase): 6 | 7 | def testDictSatisfiesDep(self): 8 | pisi.api.install(["ethtool"]) 9 | relation = pisi.relation.Relation() 10 | relation.package = "ethtool" 11 | 12 | pisi.api.install(["zlib"]) 13 | rel = pisi.relation.Relation() 14 | rel.package = "zlib" 15 | 16 | depinfo = pisi.dependency.Dependency(relation) 17 | dictionary = {"ethtool": [" "],"zlib":["a","b"],"ctorrent":["c"]} 18 | assert not depinfo.satisfied_by_dict_repo(dictionary) 19 | depinf = pisi.dependency.Dependency(rel) 20 | assert not depinf.satisfied_by_dict_repo(dictionary) 21 | 22 | def testInstalledSatisfiesDep(self): 23 | pisi.api.install(["ctorrent"]) 24 | relation = pisi.relation.Relation() 25 | relation.package = "ctorrent" 26 | depinfo = pisi.dependency.Dependency(relation) 27 | assert not depinfo.satisfied_by_installed() 28 | 29 | def testRepoSatisfiesDependency(self): 30 | pisi.api.install(["ethtool"]) 31 | relation = pisi.relation.Relation() 32 | relation.package = "ctorrent" 33 | depinfo = pisi.dependency.Dependency(relation) 34 | assert not depinfo.satisfied_by_repo() 35 | -------------------------------------------------------------------------------- /tests/fetchtest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | import base64 4 | import pisi.context as ctx 5 | import pisi.api 6 | from pisi.specfile import SpecFile 7 | from pisi.fetcher import Fetcher 8 | from pisi import util 9 | from pisi import uri 10 | 11 | class FetchTestCase(unittest.TestCase): 12 | 13 | def setUp(self): 14 | unittest.TestCase.setUp(self) 15 | self.spec = SpecFile() 16 | self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml') 17 | self.url = uri.URI(self.spec.source.archive[0].uri) 18 | self.url.set_auth_info(("user", "pass")) 19 | self.destpath = ctx.config.archives_dir() 20 | self.fetch = Fetcher(self.url, self.destpath) 21 | 22 | def testFetch(self): 23 | self.fetch.fetch() 24 | fetchedFile = os.path.join(self.destpath, self.url.filename()) 25 | if os.access(fetchedFile, os.R_OK): 26 | self.assertEqual(util.sha1_file(fetchedFile),self.spec.source.archive[0].sha1sum) 27 | os.remove(fetchedFile) 28 | 29 | def testFetcherFunctions(self): 30 | enc = base64.encodestring('%s:%s' % self.url.auth_info()) 31 | self.assertEqual(self.fetch._get_http_headers(),(('Authorization', 'Basic %s' % enc),)) 32 | assert not self.fetch._get_ftp_headers() 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /tests/filestest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pisi.files 3 | 4 | class FilesTestCase(unittest.TestCase): 5 | 6 | def setUp(self): 7 | unittest.TestCase.setUp(self) 8 | 9 | def testFileInfo(self): 10 | file1 = pisi.files.FileInfo(path = '/usr/bin/acpi') 11 | file1.type = 'init' 12 | file1.size = '30' 13 | 14 | file2 = pisi.files.FileInfo(path = '/sbin/blkid', type = 'ctors', size = '8') 15 | 16 | def testFiles(self): 17 | self.files = pisi.files.Files() 18 | self.files.read('repos/pardus-2007/system/base/curl/pspec.xml') 19 | 20 | -------------------------------------------------------------------------------- /tests/filetest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from pisi.specfile import SpecFile 3 | from pisi import uri 4 | from pisi.file import File 5 | 6 | class FileTestCase(unittest.TestCase): 7 | 8 | def setUp(self): 9 | unittest.TestCase.setUp(self) 10 | 11 | def testMakeUri(self): 12 | spec = SpecFile("repos/pardus-2007/system/base/curl/pspec.xml") 13 | url = uri.URI(spec.source.archive[0].uri) 14 | self.assert_(File.make_uri(url)) 15 | 16 | def testChooseMethod(self): 17 | compress = File('repos/contrib-2007/eopkg-index.xml', File.read) 18 | self.assert_(File.choose_method('pisi.conf', compress)) 19 | 20 | def testDecompress(self): 21 | localfile = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read) 22 | compress = File('repos/contrib-2007/eopkg-index.xml', File.read) 23 | self.assert_(File.decompress(localfile,compress)) 24 | 25 | def testLocalFile(self): 26 | f = File('repos/pardus-2007/system/base/curl/pspec.xml', File.read) 27 | r = f.readlines() 28 | assert (len(r) > 0) 29 | 30 | def testRemoteRead(self): 31 | f = File('http://www.pardus.org.tr/urunler/pardus-2009.2-Geronticus_eremita-surum-notlari-tr.html', File.read) 32 | r = f.readlines() 33 | assert (len(r) > 0) 34 | 35 | 36 | -------------------------------------------------------------------------------- /tests/graphtest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | import pisi 4 | from pisi import graph 5 | 6 | class GraphTestCase(unittest.TestCase): 7 | def setUp(self): 8 | self.g0 = pisi.graph.Digraph() 9 | self.g0.add_edge(1,2) 10 | self.g0.add_edge(1,3) 11 | self.g0.add_edge(2,3) 12 | self.g0.add_edge(3,4) 13 | self.g0.add_edge(4,1) 14 | 15 | self.g1 = pisi.graph.Digraph() 16 | self.g1.add_edge(0,2) 17 | self.g1.add_edge(0,3) 18 | self.g1.add_edge(2,4) 19 | self.g1.add_edge(3,4) 20 | 21 | def testHasVertex(self): 22 | assert not self.g0.has_vertex(5) 23 | assert not self.g1.has_vertex(1) 24 | 25 | def testHasEdge(self): 26 | assert not self.g0.has_edge(5,6) 27 | assert not self.g0.has_edge(3,5) 28 | assert not self.g1.has_edge(2,3) 29 | 30 | def testCycle(self): 31 | assert not self.g0.cycle_free() 32 | assert self.g1.cycle_free() 33 | 34 | def testTopologicalSort(self): 35 | order = self.g1.topological_sort() 36 | assert order[0] == 0 37 | assert order[-1] == 4 38 | -------------------------------------------------------------------------------- /tests/history/001_upgrade.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | gdb 7 | 8 | 9 | 10 | 11 | 12 | rsync 13 | 14 | 15 | 16 | 17 | 18 | 19 | hashalot 20 | 21 | 22 | 23 | 24 | 25 | XML-DOM 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /tests/history/002_remove.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | gdb 7 | 8 | 9 | 10 | 11 | rsync 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/history/003_install.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | gdb 7 | 8 | 9 | 10 | 11 | 12 | rsync 13 | 14 | 15 | 16 | 17 | 18 | apackage 19 | 20 | 21 | 22 | 23 | 24 | xyz 25 | 26 | 27 | 28 | 29 | 30 | hashalot 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/history/004_snapshot.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | readline 7 | 8 | 9 | 10 | 11 | gdb 12 | 13 | 14 | 15 | 16 | rsync 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/historytest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pisi.relation 3 | 4 | class HistoryTestCase(unittest.TestCase): 5 | 6 | def testCreate(self): 7 | history = pisi.history.History() 8 | operation = 'upgrade' 9 | history.create(operation) 10 | history.create('install') 11 | history.create('snapshot') 12 | 13 | def testGetLatest(self): 14 | history = pisi.history.History() 15 | history.read('history/001_upgrade.xml') 16 | assert not '099' == history._get_latest() 17 | 18 | history.read('history/002_remove.xml') 19 | assert not '099' == history._get_latest() 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /tests/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | popt 6 | 7 | 8 | 9 | Kırmızı kafalar 10 | 11 | 12 | hotmail@redhat.com 13 | 14 | 15 | 16 | 17 | 18 | popt-libs 19 | 20 | 21 | Command line option parsing library 22 | 23 | 24 | library files for popt 25 | 26 | 27 | As-Is 28 | 29 | 30 | library:util:optparser 31 | 32 | 33 | rpm:archive 34 | 35 | 36 | 37 | gettext 38 | 39 | 40 | 41 | 42 | /usr/lib 43 | 44 | 45 | /usr/share/doc 46 | 47 | 48 | /usr/share/man 49 | 50 | 51 | /usr/share/locale 52 | 53 | 54 | /usr/include/popt.h 55 | 56 | 57 | 58 | 59 | 2005-06-14 60 | 1.7 61 | 62 | 63 | 2005-06-10 64 | 1.7 65 | 66 | 67 | 2005-05-05 68 | 1.7 69 | 70 | 71 | 72 | 0 73 | 74 | 75 | Pardus 76 | 77 | 78 | 0.1 79 | 80 | 81 | Any 82 | 83 | 84 | 149691 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /tests/metadatatest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | 4 | from pisi import metadata 5 | from pisi import util 6 | 7 | class MetadataTestCase(unittest.TestCase): 8 | 9 | def testRead(self): 10 | md = metadata.MetaData() 11 | md.read("metadata.xml") 12 | self.assertEqual(md.package.license,["As-Is"]) 13 | self.assertEqual(md.package.version,"1.7") 14 | self.assertEqual(md.package.installedSize,149691) 15 | return md 16 | 17 | def testVerify(self): 18 | md = self.testRead() 19 | if md.errors(): 20 | self.fail() 21 | 22 | def testWrite(self): 23 | md = self.testRead() 24 | md.write("/tmp/metadata-write.xml") 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tests/mirrors.conf: -------------------------------------------------------------------------------- 1 | apache http://www.eu.apache.org/dist/ 2 | cpan http://search.cpan.org/CPAN/ 3 | cpan http://cpan.ulak.net.tr/ 4 | gnu http://ftp.gnu.org/gnu/ 5 | -------------------------------------------------------------------------------- /tests/mirrorstest.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008, TUBITAK/UEKAE 2 | # 3 | # This program is free software; you can redistribute it and/or modify it under 4 | # the terms of the GNU General Public License as published by the Free 5 | # Software Foundation; either version 2 of the License, or (at your option) 6 | # any later version. 7 | # 8 | # Please read the COPYING file. 9 | # 10 | 11 | import unittest 12 | 13 | from pisi.mirrors import Mirrors 14 | 15 | class MirrorsTestCase(unittest.TestCase): 16 | def testGetMirrors(self): 17 | mirrors = Mirrors("mirrors.conf") 18 | assert ["http://www.eu.apache.org/dist/"] == mirrors.get_mirrors("apache") 19 | assert ['http://search.cpan.org/CPAN/', 'http://cpan.ulak.net.tr/'] == mirrors.get_mirrors("cpan") 20 | assert ["http://ftp.gnu.org/gnu/"] == mirrors.get_mirrors("gnu") 21 | -------------------------------------------------------------------------------- /tests/packagetest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | 4 | from pisi import util 5 | from pisi import package 6 | import pisi.context as ctx 7 | 8 | class PackageTestCase(unittest.TestCase): 9 | def setUp(self): 10 | unittest.TestCase.setUp(self) 11 | self.pkgName = "test-7.1-2-p11-x86_64.pisi" 12 | 13 | def testAddPackage(self): 14 | cur = os.getcwd() 15 | tmp = ctx.config.tmp_dir() 16 | test = os.path.join(cur, 'history') 17 | pkg_path = os.path.join(tmp, self.pkgName) 18 | pkg = package.Package(pkg_path, "w") 19 | 20 | os.chdir(test) 21 | pkg.add_to_package('002_remove.xml') 22 | pkg.add_to_package('003_install.xml') 23 | os.chdir(cur) 24 | 25 | pkg.extract_file('002_remove.xml', cur) 26 | if os.path.exists('files.xml'): 27 | self.fail("Package add error") 28 | 29 | os.remove('002_remove.xml') 30 | os.remove(pkg_path) 31 | 32 | def testExtractFile(self): 33 | cur = os.getcwd() 34 | tmp = ctx.config.tmp_dir() 35 | pkg_path = os.path.join(tmp, self.pkgName) 36 | pkg = package.Package(pkg_path,"w") 37 | pkg.extract_file("files.xml",cur) 38 | if os.path.exists("files.xml"): 39 | self.fail("File extract error") 40 | pkg.extract_pisi_files("002_remove.xml") 41 | if os.path.exists("002_remove.xml"): 42 | self.fail("Pisi files extract error") 43 | 44 | -------------------------------------------------------------------------------- /tests/relationtest.py: -------------------------------------------------------------------------------- 1 | 2 | import unittest 3 | import pisi.relation 4 | 5 | class RelationTestCase(unittest.TestCase): 6 | def testInstalledPackageSatisfies(self): 7 | pisi.api.install(["ethtool"]) 8 | relation = pisi.relation.Relation() 9 | 10 | relation.package = "ethtool" 11 | # Test version = X 12 | relation.version = "0.3" 13 | assert pisi.relation.installed_package_satisfies(relation) 14 | relation.version = None 15 | 16 | # Test versionFrom = X 17 | relation.versionFrom = "0.3" 18 | assert pisi.relation.installed_package_satisfies(relation) 19 | relation.versionFrom = "8" 20 | assert not pisi.relation.installed_package_satisfies(relation) 21 | relation.versionFrom = None 22 | 23 | #Test versionTo = X 24 | relation.versionTo = "8" 25 | assert pisi.relation.installed_package_satisfies(relation) 26 | relation.versionTo = "0.1" 27 | assert not pisi.relation.installed_package_satisfies(relation) 28 | relation.versionTo = None 29 | 30 | #Test release = X 31 | relation.release = "3" 32 | assert not pisi.relation.installed_package_satisfies(relation) 33 | relation.release = "1" 34 | assert pisi.relation.installed_package_satisfies(relation) 35 | relation.release = None 36 | 37 | #test releaseFrom = X 38 | relation.releaseFrom = "1" 39 | assert pisi.relation.installed_package_satisfies(relation) 40 | relation.releaseFrom = "7" 41 | assert not pisi.relation.installed_package_satisfies(relation) 42 | relation.releaseFrom = None 43 | 44 | #test releaseTo = X 45 | relation.releaseTo = "7" 46 | assert pisi.relation.installed_package_satisfies(relation) 47 | relation.releaseTo = "0" 48 | assert not pisi.relation.installed_package_satisfies(relation) 49 | relation.releaseTo = None 50 | 51 | pisi.api.remove(["ethtool"]) 52 | 53 | -------------------------------------------------------------------------------- /tests/replacetest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pisi.replace 3 | import pisi.relation 4 | 5 | class ReplaceTestCase(unittest.TestCase): 6 | def testInstalledPackageReplaced(self): 7 | pisi.api.install(["ethtool"]) 8 | relation = pisi.relation.Relation() 9 | relation.package = "ethtool" 10 | relation.version = "6" 11 | relation.release = "1" 12 | 13 | replace = pisi.replace.Replace(relation) 14 | replace.package = "zlib" 15 | # Check if the replaced package is installed 16 | self.assert_(pisi.replace.installed_package_replaced(replace)) 17 | repinfo = pisi.replace.Replace(relation) 18 | repinfo.package = "ctorrent" 19 | assert not pisi.replace.installed_package_replaced(repinfo) 20 | 21 | pisi.api.remove(["ethtool"]) 22 | -------------------------------------------------------------------------------- /tests/repos/repo1/components.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | system 5 | System 6 | System component 7 | System packages 8 | system 9 | 10 | Joe Maintainer 11 | joe@pardus.org.tr 12 | 13 | 14 | 15 | system.base 16 | Base System 17 | Sample Base System 18 | Base System Packages 19 | system 20 | 21 | Joe Maintainer 22 | joe@pardus.org.tr 23 | 24 | 25 | 26 | util 27 | FIXME 28 | FIXME 29 | FIXME 30 | accessories 31 | 32 | Joe Maintainer 33 | joe@pardus.org.tr 34 | 35 | 36 | 37 | util.misc 38 | FIXME 39 | FIXME 40 | FIXME 41 | accessories 42 | 43 | Joe Maintainer 44 | joe@pardus.org.tr 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/repos/repo1/distribution.xml: -------------------------------------------------------------------------------- 1 | 2 | Pardus 3 | 2007 4 | Sample Repository 1 5 | Core 6 | 7 | wengophone 8 | rar 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/repos/repo1/system/base/bash/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "bash") 9 | -------------------------------------------------------------------------------- /tests/repos/repo1/system/base/bash/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bash 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | bash is a very useful package 14 | bash is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | bash 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | 28 | 29 | 30 | 2010-07-12 31 | 0.3 32 | First release 33 | Joe Packager 34 | joe@pardus.org.tr 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /tests/repos/repo1/system/base/component.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | system.base 4 | 5 | -------------------------------------------------------------------------------- /tests/repos/repo1/system/base/jpeg/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "jpeg") 9 | -------------------------------------------------------------------------------- /tests/repos/repo1/system/base/jpeg/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | jpeg 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | jpeg is a very useful package 14 | jpeg is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | jpeg 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | 28 | 29 | 30 | 2010-07-12 31 | 0.3 32 | First release 33 | Joe Packager 34 | joe@pardus.org.tr 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /tests/repos/repo1/system/base/openssl/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "openssl") 9 | -------------------------------------------------------------------------------- /tests/repos/repo1/system/base/openssl/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | openssl 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | openssl is a very useful package 14 | openssl is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | openssl 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | 28 | 29 | 30 | 2010-07-12 31 | 0.3 32 | First release 33 | Joe Packager 34 | joe@pardus.org.tr 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /tests/repos/repo1/system/component.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | system 4 | 5 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/component.xml: -------------------------------------------------------------------------------- 1 | 2 | util 3 | 4 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/bar/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "bar") 9 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/bar/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bar 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | bar is a very useful package 14 | bar is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | bar 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | spam 28 | 29 | 30 | 31 | 32 | 33 | 2010-07-12 34 | 0.3 35 | First release 36 | Joe Packager 37 | joe@pardus.org.tr 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/component.xml: -------------------------------------------------------------------------------- 1 | 2 | util.misc 3 | 4 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/dialog/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "dialog") 9 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/dialog/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dialog 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:cli 13 | dialog is a very useful package 14 | dialog is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | dialog 20 | 21 | /usr/bin 22 | 23 | 24 | 25 | 26 | 27 | 2010-07-12 28 | 0.3 29 | First release 30 | Joe Packager 31 | joe@pardus.org.tr 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/foo/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "foo") 9 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/foo/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | foo 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | foo is a very useful package 14 | foo is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | foo 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | 28 | 29 | 30 | 2010-07-12 31 | 0.3 32 | First release 33 | Joe Packager 34 | joe@pardus.org.tr 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/spam/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "spam") 9 | -------------------------------------------------------------------------------- /tests/repos/repo1/util/misc/spam/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | spam 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | spam is a very useful package 14 | spam is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | spam 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | bar 28 | 29 | 30 | 31 | 32 | 33 | 2010-07-12 34 | 0.3 35 | First release 36 | Joe Packager 37 | joe@pardus.org.tr 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /tests/repos/repo2/components.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | system 5 | System 6 | System component 7 | System packages 8 | system 9 | 10 | Joe Maintainer 11 | joe@pardus.org.tr 12 | 13 | 14 | 15 | system.base 16 | Base System 17 | Sample Base System 18 | Base System Packages 19 | system 20 | 21 | Joe Maintainer 22 | joe@pardus.org.tr 23 | 24 | 25 | 26 | util 27 | FIXME 28 | FIXME 29 | FIXME 30 | accessories 31 | 32 | Joe Maintainer 33 | joe@pardus.org.tr 34 | 35 | 36 | 37 | util.misc 38 | FIXME 39 | FIXME 40 | FIXME 41 | accessories 42 | 43 | Joe Maintainer 44 | joe@pardus.org.tr 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /tests/repos/repo2/distribution.xml: -------------------------------------------------------------------------------- 1 | 2 | Pardus 3 | 2007 4 | Sample Repository 1 5 | Core 6 | 7 | wengophone 8 | rar 9 | 10 | 11 | -------------------------------------------------------------------------------- /tests/repos/repo2/system/base/component.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | system.base 4 | 5 | -------------------------------------------------------------------------------- /tests/repos/repo2/system/component.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | system 4 | 5 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/component.xml: -------------------------------------------------------------------------------- 1 | 2 | util 3 | 4 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/bar/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "bar") 9 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/bar/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bar 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | bar is a very useful package 14 | bar is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | bar 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | spam 28 | 29 | 30 | 31 | 32 | 33 | 2010-07-12 34 | 0.3 35 | First release 36 | Joe Packager 37 | joe@pardus.org.tr 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/component.xml: -------------------------------------------------------------------------------- 1 | 2 | util.misc 3 | 4 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/dialog/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "dialog") 9 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/dialog/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | dialog 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:cli 13 | dialog is a very useful package 14 | dialog is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | dialog 20 | 21 | /usr/bin 22 | 23 | 24 | 25 | 26 | 27 | 2010-07-12 28 | 0.3 29 | First release 30 | Joe Packager 31 | joe@pardus.org.tr 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/foo/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "foo") 9 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/foo/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | foo 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | foo is a very useful package 14 | foo is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | foo 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | 28 | 29 | 30 | 2010-08-12 31 | 0.3 32 | Last release 33 | Joe Packager 34 | joe@pardus.org.tr 35 | 36 | 37 | 2010-07-22 38 | 0.3 39 | Second release 40 | Joe Packager 41 | joe@pardus.org.tr 42 | 43 | 44 | 2010-07-12 45 | 0.3 46 | First release 47 | Joe Packager 48 | joe@pardus.org.tr 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/spam/actions.py: -------------------------------------------------------------------------------- 1 | 2 | from pisi.actionsapi import pisitools 3 | 4 | WorkDir = "skeleton" 5 | 6 | def install(): 7 | pisitools.dobin("skeleton.py") 8 | pisitools.rename("/usr/bin/skeleton.py", "spam") 9 | -------------------------------------------------------------------------------- /tests/repos/repo2/util/misc/spam/pspec.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | spam 6 | www.pardus.org.tr 7 | 8 | Joe Packager 9 | joe@pardus.org.tr 10 | 11 | GPL-2 12 | app:gui 13 | spam is a very useful package 14 | spam is a very useful package that is known for its usefulness. 15 | http://cekirdek.uludag.org.tr/~faik/pisi/skeleton.tar.gz 16 | 17 | 18 | 19 | spam 20 | 21 | 22 | 23 | 24 | /usr/bin 25 | 26 | 27 | foo 28 | 29 | 30 | 31 | 32 | 33 | 2010-07-22 34 | 0.4 35 | Second release 36 | Joe Packager 37 | joe@pardus.org.tr 38 | 39 | 40 | 2010-07-12 41 | 0.3 42 | First release 43 | Joe Packager 44 | joe@pardus.org.tr 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /tests/runtests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright (C) 2007-2010, TUBITAK/UEKAE 5 | # 6 | # This program is free software; you can redistribute it and/or modify it under 7 | # the terms of the GNU General Public License as published by the Free 8 | # Software Foundation; either version 2 of the License, or (at your option) 9 | # any later version. 10 | # 11 | # Please read the COPYING file. 12 | # 13 | 14 | import os 15 | import unittest 16 | import database 17 | 18 | import pisi 19 | import pisi.context as ctx 20 | 21 | from database.repodbtest import RepoDBTestCase 22 | from database.packagedbtest import PackageDBTestCase 23 | from database.sourcedbtest import SourceDBTestCase 24 | from database.installdbtest import InstallDBTestCase 25 | from database.componentdbtest import ComponentDBTestCase 26 | from database.filesdbtest import FilesDBTestCase 27 | from database.lazydbtest import LazyDBTestCase 28 | from database.itembyrepotest import ItemByRepoTestCase 29 | 30 | from archivetests import ArchiveTestCase 31 | from configfiletest import ConfigFileTestCase 32 | from conflicttests import ConflictTestCase 33 | from constanttest import ConstantTestCase 34 | from dependencytest import DependencyTestCase 35 | from fetchtest import FetchTestCase 36 | from filetest import FileTestCase 37 | from filestest import FilesTestCase 38 | from graphtest import GraphTestCase 39 | from historytest import HistoryTestCase 40 | from metadatatest import MetadataTestCase 41 | from mirrorstest import MirrorsTestCase 42 | from packagetest import PackageTestCase 43 | from relationtest import RelationTestCase 44 | from replacetest import ReplaceTestCase 45 | from shelltest import ShellTestCase 46 | from specfiletests import SpecFileTestCase 47 | from srcarchivetest import SourceArchiveTestCase 48 | from uritest import UriTestCase 49 | from utiltest import UtilTestCase 50 | from versiontest import VersionTestCase 51 | 52 | def setup(): 53 | options = pisi.config.Options() 54 | options.destdir = 'repos/tmp' 55 | pisi.api.set_options(options) 56 | pisi.api.set_comar(False) 57 | 58 | ctx.config.values.general.distribution = "Pardus" 59 | ctx.config.values.general.distribution_release = "2007" 60 | 61 | 62 | if __name__ == '__main__': 63 | if os.path.exists("repos/tmp"): 64 | import shutil 65 | shutil.rmtree("repos/tmp") 66 | 67 | suite = unittest.TestSuite() 68 | unittest.main() 69 | 70 | -------------------------------------------------------------------------------- /tests/specfiletests.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | import pisi.specfile as specfile 4 | import pisi.util as util 5 | 6 | class SpecFileTestCase(unittest.TestCase): 7 | def setUp(self): 8 | self.spec = specfile.SpecFile() 9 | self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml') 10 | 11 | def testGetSourceVersion(self): 12 | assert '0.3' == self.spec.getSourceVersion() 13 | 14 | def testGetSourceRelease(self): 15 | assert '1' == self.spec.getSourceRelease() 16 | 17 | def testVerify(self): 18 | if self.spec.errors(): 19 | self.fail() 20 | 21 | def testCopy(self): 22 | self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml') 23 | self.spec.write('repos/pardus-2007/system/base/curl/pspec.xml') 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/srcarchivetest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import pisi.sourcearchive 3 | from pisi.specfile import SpecFile 4 | 5 | class SourceArchiveTestCase(unittest.TestCase): 6 | 7 | def testFetch(self): 8 | spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') 9 | srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0]) 10 | self.assert_(not srcarch.fetch()) 11 | 12 | def testIscached(self): 13 | spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') 14 | srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0]) 15 | assert srcarch.is_cached() 16 | 17 | def testIscached(self): 18 | spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') 19 | targetDir = '/tmp/tests' 20 | srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0]) 21 | self.assert_(not srcarch.unpack(targetDir)) 22 | 23 | def testUnpack(self): 24 | spec = SpecFile('repos/pardus-2007/system/base/curl/pspec.xml') 25 | targetDir = '/tmp/tests' 26 | srcarch = pisi.sourcearchive.SourceArchive(spec.source.archive[0]) 27 | srcarch.unpack(targetDir) 28 | -------------------------------------------------------------------------------- /tests/uritest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | from pisi import uri 4 | from pisi.file import File 5 | from pisi.specfile import SpecFile 6 | 7 | class UriTestCase(unittest.TestCase): 8 | 9 | def setUp(self): 10 | unittest.TestCase.setUp(self) 11 | 12 | def testSetUri(self): 13 | self.url = uri.URI() 14 | self.url.set_uri('uri') 15 | assert 'uri' == self.url.get_uri() 16 | self.url.set_uri('urix') 17 | assert 'urix' == self.url.get_uri() 18 | 19 | def testIsLocalFile(self): 20 | uri1 = uri.URI() 21 | assert not uri1.is_local_file() 22 | uri1.set_uri('/usr/local') 23 | assert uri1.is_local_file() 24 | 25 | def testIsRemoteFile(self): 26 | uri2 = uri.URI() 27 | assert uri2.is_remote_file() 28 | uri2.set_uri('uri') 29 | assert not uri2.is_remote_file() 30 | 31 | def testSchemePath(self): 32 | uri3 = uri.URI() 33 | uri3.set_uri('/usr/bin') 34 | self.assertEqual('file', uri3.scheme()) 35 | assert '/usr/bin' == uri3.path() 36 | 37 | def testFileName(self): 38 | uri4 = uri.URI() 39 | uri4.set_uri('/usr/share/aclocal') 40 | assert 'aclocal' == uri4.filename() 41 | 42 | -------------------------------------------------------------------------------- /tests/utiltest.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import shutil 3 | from pisi.util import * 4 | import os 5 | 6 | class UtilTestCase(unittest.TestCase): 7 | 8 | def initialize(self): 9 | testcase.testCase.initialize(self, database=False) 10 | 11 | #process related functions 12 | def testRunBatch(self): 13 | assert (0, '', '') == run_batch('cd') 14 | assert (127, '', '/bin/sh: add: command not found\n') == run_batch('add') 15 | 16 | def testRunLogged(self): 17 | assert 0 == run_logged('ls') 18 | assert 1 == run_logged('rm') 19 | 20 | def testXtermTitle(self): 21 | xterm_title('pardus') 22 | xterm_title_reset() 23 | 24 | #path processing functions tests 25 | def testSplitPath(self): 26 | assert ['usr', 'local', 'src'] == splitpath('usr/local/src') 27 | assert ['usr', 'lib', 'pardus'] == splitpath('usr/lib/pardus') 28 | 29 | def testSubPath(self): 30 | self.assert_(subpath('usr','usr')) 31 | self.assert_(subpath('usr','usr/local/src')) 32 | self.assert_(not subpath('usr/local','usr')) 33 | 34 | def testRemovePathPrefix(self): 35 | pathname = removepathprefix('usr/local', 'usr/local/src') 36 | assert 'src' == pathname 37 | 38 | pathname = removepathprefix('usr/local','usr/local/bin') 39 | assert not 'bim' == pathname 40 | 41 | def testJoinPath(self): 42 | assert 'usr/local/src' == join_path('usr/local','src') 43 | assert not 'usr/lib/hal' == join_path('usr','hal') 44 | assert 'usr/sbin/lpc' == join_path('usr','sbin/lpc') 45 | 46 | #file/directory related functions tests 47 | def testCheckFile(self): 48 | assert check_file('/etc/eopkg/pisi.conf') 49 | assert check_file('/usr/bin/aatest') 50 | 51 | def testCleanDir(self): 52 | assert None == clean_dir('usr/lib') 53 | assert None == clean_dir('usr/local') 54 | assert not 'tmp/pisi-root' == clean_dir('usr/tmp') 55 | 56 | def testDirSize(self): 57 | self.assertNotEqual(dir_size('usr/lib/pardus'),2940) 58 | self.assertNotEqual(dir_size('usr/lib'),65) 59 | 60 | def testCopyFile(self): 61 | copy_file('/etc/eopkg/pisi.conf', '/tmp/pisi-test1') 62 | copy_file('/etc/eopkg/sandbox.conf', '/tmp/pisi-test2') 63 | copy_file_stat('/etc/eopkg/pisi.conf', '/tmp/pisi-test1') 64 | -------------------------------------------------------------------------------- /tests/versiontest.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2005 - 2007, TUBITAK/UEKAE 2 | # 3 | # This program is free software; you can redistribute it and/or modify it under 4 | # the terms of the GNU General Public License as published by the Free 5 | # Software Foundation; either version 2 of the License, or (at your option) 6 | # any later version. 7 | # 8 | # Please read the COPYING file. 9 | # 10 | 11 | import unittest 12 | 13 | from pisi.version import Version 14 | 15 | class VersionTestCase(unittest.TestCase): 16 | def setUp(self): 17 | pass 18 | 19 | def testSingle(self): 20 | v1 = Version("103") 21 | v2 = Version("90") 22 | self.assert_(v1 > v2) 23 | 24 | def testOpsNumerical(self): 25 | v1 = Version("0.3.1") 26 | v2 = Version("0.3.5") 27 | v3 = Version("1.5.2") 28 | v4 = Version("0.3.1") 29 | v5 = Version("2.07") 30 | self.assert_(v1 < v2) 31 | self.assert_(v3 > v2) 32 | self.assert_(v1 <= v3) 33 | self.assert_(v4 >= v4) 34 | self.assert_(v5 > v3) 35 | 36 | def testOpsKeywords(self): 37 | # with keywords 38 | v1 = Version("2.23_pre10") 39 | v2 = Version("2.23") 40 | v3 = Version("2.21") 41 | v4 = Version("2.23_p1") 42 | v5 = Version("2.23_beta1") 43 | v6 = Version("2.23_m1") 44 | v7 = Version("2.23_rc1") 45 | v8 = Version("2.23_rc2") 46 | self.assert_(v1 < v2) 47 | self.assert_(v1 > v3) 48 | self.assert_(v1 < v4) 49 | self.assert_(v1 > v5) 50 | self.assert_(v2 < v4) 51 | self.assert_(v2 > v5) 52 | self.assert_(v6 < v4) 53 | self.assert_(v6 > v5) 54 | self.assert_(v7 > v5) 55 | self.assert_(v8 > v7) 56 | 57 | v1 = Version("1.0_alpha1") 58 | v2 = Version("1.0_alpha2") 59 | self.assert_(v2 > v1) 60 | 61 | def testOpsCharacters(self): 62 | # with character 63 | v1 = Version("2.10a") 64 | v2 = Version("2.10") 65 | v3 = Version("2.10d") 66 | self.assert_(v1 > v2) 67 | self.assert_(v1 < v3) 68 | self.assert_(v2 < v3) 69 | 70 | def testGeBug(self): 71 | # bug 603 72 | v1 = Version('1.8.0') 73 | v2 = Version('1.9.1') 74 | self.assert_( not v1 > v2 ) 75 | self.assert_( not v1 >= v2 ) 76 | --------------------------------------------------------------------------------