From 935f052bea10779de3e0e4cd39b390987bb6db7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Wed, 29 Jun 2005 21:52:43 +0000 Subject: [PATCH] =?UTF-8?q?Bug=C3=BCn=20s=C3=B6yledi=C4=9Fim=20gibi=20acti?= =?UTF-8?q?ons=20API'ye=20biraz=20dokundurdum.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DİKKAT: Özellikle buradaki tüm modüllerin ve fonksiyonların çok çok iyi belgelenmesi gerekiyor. Daha sonra belgeleriz diye düşünmemek lazım. Bir süre sonra işin içinden çıkılmaz bir hal alabilir. Bu yüzden fonksiyonları/modülleri yazdıkça belgelerini de yazalım! --- pisi/actionsapi/autotools.py | 54 ++++++++++++++++++++++----------- pisi/actionsapi/config.py | 51 +++++++++++++++++++++++++++++++ pisi/actionsapi/gnuconfig.py | 11 +++++-- pisi/actionsapi/kde.py | 12 ++++---- pisi/actionsapi/pisitools.py | 58 +++++++++++++++++++++++------------- pisi/actionsapi/shell.py | 4 ++- pisi/actionsapi/utils.py | 1 + 7 files changed, 144 insertions(+), 47 deletions(-) create mode 100644 pisi/actionsapi/config.py diff --git a/pisi/actionsapi/autotools.py b/pisi/actionsapi/autotools.py index 805b7e59..a9379ac4 100644 --- a/pisi/actionsapi/autotools.py +++ b/pisi/actionsapi/autotools.py @@ -1,21 +1,33 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# standard python modules import os -from pisi.context import const + +# actions api modules +from config import config def configure(parameters = ''): ''' FIXME: Düzgün hale getirilecek ''' ''' parameters = '--with-nls --with-libusb --with-something-usefull ''' + dirs = config.dirs + flags = config.flags - configure_string = './configure --prefix=/usr \ - --host=i686-pc-linux-gnu \ - --mandir=/usr/share/man \ - --infodir=/usr/share/info \ - --datadir=/usr/share \ - --sysconfdir=/etc \ - --localstatedir=/var/lib \ - %s' % parameters + configure_string = './configure --prefix=%s \ + --host=%s \ + --mandir=%s \ + --infodir=%s \ + --datadir=%s \ + --sysconfdir=%s \ + --localstatedir=%s \ + %s' % (dirs.defaultprefix, + flags.host, + dirs.man, + dirs.info, + dirs.data, + dirs.conf, + dirs.localstate, + parameters) os.system(configure_string) @@ -26,17 +38,23 @@ def make(): def install(): ''' FIXME: Düzgün hale getirilecek ''' ''' dir_suffix = /var/tmp/pisi/ _paket_adı_ /image/ ''' - global const + dirs = config.dirs dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \ - const.install_dir_suffix + config.const.install_dir_suffix - install_string = 'make prefix=%(prefix)s/usr \ - datadir=%(prefix)s/usr/share \ - infodir=%(prefix)s/usr/share/info \ - localstatedir=%(prefix)s/var/lib \ - mandir=%(prefix)s/usr/share/man \ - sysconfdir=%(prefix)s/etc \ - install' % {'prefix': dir_suffix} + install_string = 'make prefix=%(prefix)s/%(defaultprefix)s \ + datadir=%(prefix)s/%(data)s \ + infodir=%(prefix)s/%(info)s \ + localstatedir=%(prefix)s/%(localstate)s \ + mandir=%(prefix)s/%(man)s \ + sysconfdir=%(prefix)s/%(conf)s \ + install' % {'prefix': dir_suffix, + 'defaultprefix': dirs.defaultprefix, + 'man': dirs.man, + 'info': dirs.info, + 'localstate': dirs.localstate, + 'conf': dirs.conf, + 'data': dirs.data} os.system(install_string) diff --git a/pisi/actionsapi/config.py b/pisi/actionsapi/config.py new file mode 100644 index 00000000..0b9dead1 --- /dev/null +++ b/pisi/actionsapi/config.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# standard python modules +import os + +# pisi modules +import pisi.config +import pisi.constants + + +# Set individual information, that are generally needed for actions +# api. + +class Env: + """General environment variables used in actions API""" + install_dir = os.getenv('INSTALL_DIR') + src_name = os.getenv('SRC_NAME') + src_version = os.getenv('SRC_VERSION') + src_release = os.getenv('SRC_RELEASE') + +class Dirs: + """General directories used in actions API.""" + # TODO: Eventually we should consider getting these from a/the + # configuration file + doc = "usr/share/doc" + sbin = "usr/sbin" + man = "usr/share/man" + info = "usr/share/info" + data = "usr/share" + conf = "etc" + localstate = "var/lib" + defaultprefix = "usr" + +class Flags: + """General flags used in actions API""" + # TODO: Eventually we should consider getting these from a/the + # configuration file + + # bu çok çirkin, bunu burada yazmamak gerekiyor, yine de actions + # api içerisinde tekrarlanmasından iyidir. Yeri geldiğinde + # standart config dosyasından build-arch'ı alıp ona göre + # oluştururuz... + host = "i686-pc-linux-gnu" + +class ActionsConfig(pisi.config.Config): + const = pisi.constants.const + env = Env() + dirs = Dirs() + flags = Flags() + +config = ActionsConfig() diff --git a/pisi/actionsapi/gnuconfig.py b/pisi/actionsapi/gnuconfig.py index 05d51a85..86a6f55d 100644 --- a/pisi/actionsapi/gnuconfig.py +++ b/pisi/actionsapi/gnuconfig.py @@ -1,11 +1,18 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -import os, string, re, shutil -from shell import * +# standard python modules +import os +import string +import re +import shutil +# pisi modules from pisi.ui import ui +# actions api modules +from shell import * + def gnuconfig_findnewest(): ''' find the newest config.* file according to timestamp and return it''' diff --git a/pisi/actionsapi/kde.py b/pisi/actionsapi/kde.py index 28d7606b..5513fce5 100644 --- a/pisi/actionsapi/kde.py +++ b/pisi/actionsapi/kde.py @@ -1,8 +1,11 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# standard python modules import os -from pisi.context import const + +# actions api modules +from config import config # Global variables for compiling KDE programs... kde_dir = os.getenv('KDEDIR') @@ -14,13 +17,13 @@ def configure(parameters = ''): ''' parameters = '--with-nls --with-libusb --with-something-usefull ''' configure_string = './configure --prefix=%s \ - --host=i686-pc-linux-gnu \ + --host=%s \ --with-x \ --enable-mitshm \ --with-qt-dir=%s \ --enable-mt \ --with-qt-libraries=%s \ - %s' % (kde_dir, qt_dir, qt_libdir, parameters) + %s' % (kde_dir, config.flags.host, qt_dir, qt_libdir, parameters) os.system(configure_string) @@ -31,10 +34,9 @@ def make(): def install(): ''' FIXME: Düzgün hale getirilecek ''' ''' dir_suffix = /var/tmp/pisi/ _paket_adı_ /image/ ''' - global const dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \ - const.install_dir_suffix + config.const.install_dir_suffix install_string = 'make prefix=%s/%s install' % (dir_suffix, kde_dir) os.system(install_string) diff --git a/pisi/actionsapi/pisitools.py b/pisi/actionsapi/pisitools.py index 730aad34..8f0c0f8b 100644 --- a/pisi/actionsapi/pisitools.py +++ b/pisi/actionsapi/pisitools.py @@ -1,52 +1,67 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -import os, shutil +# standard python modules +import os +import shutil import gzip +# actions api modules +from config import config + def dodoc(*documentList): + env = config.env + dirs = config.dirs - install_dir = os.getenv('INSTALL_DIR') - src_name = os.getenv('SRC_NAME') - src_version = os.getenv('SRC_VERSION') - src_release = os.getenv('SRC_RELEASE') - - srcTag = src_name + '-' + src_version + '-' + src_release + srcTag = env.src_name + '-' \ + + env.src_version + '-' \ + + env.src_release try: - os.makedirs(install_dir + '/' + 'usr/share/doc/' + srcTag) + os.makedirs(os.path.join(env.install_dir, + dirs.doc, + srcTag)) except OSError: pass for document in documentList: if os.access(document, os.F_OK): - shutil.copyfile(document, os.path.join(install_dir, \ - 'usr/share/doc/' + srcTag + '/' + os.path.basename(document))) + shutil.copyfile(document, + os.path.join(env.install_dir, + dirs.doc, + srcTag, + os.path.basename(document))) def dosed(filename, *sedPattern): #FIXME: Convert to python for pattern in sedPattern: os.system('sed -i -e \'' + pattern + '\' ' + filename) -def dosbin(filename, destination='/usr/sbin'): - install_dir = os.getenv('INSTALL_DIR') +def dosbin(filename, destination=None): + env = config.env + + if not destination: + destination = config.dirs.sbin try: - os.makedirs(install_dir + destination) + os.makedirs(env.install_dir + destination) except OSError: pass if os.access(filename, os.F_OK): - shutil.copyfile(filename, install_dir + destination + '/' \ - + os.path.basename(filename)) + shutil.copyfile(filename, + os.path.join(env.install_dir, + destination, + os.path.basename(filename))) def doman(filename): - install_dir = os.getenv('INSTALL_DIR') - - man, postfix = filename.split('.') + env = config.env + dirs = config.dirs + man, postfix = filename.split('.') + destDir = os.path.join(env.install_dir, dirs.man, "man"+postfix) try: - os.makedirs(install_dir + '/usr/share/man/man' + postfix) + os.makedirs(destDir) except OSError: pass @@ -55,6 +70,7 @@ def doman(filename): gzfile.close() if os.access(filename, os.F_OK): - shutil.copyfile(filename + '.gz', install_dir + '/usr/share/man/man' \ - + postfix + '/' + os.path.basename(filename)) + shutil.copyfile(filename + '.gz', + os.path.join(destDir, + os.path.basename(filename))) diff --git a/pisi/actionsapi/shell.py b/pisi/actionsapi/shell.py index e82d7557..11acba2f 100644 --- a/pisi/actionsapi/shell.py +++ b/pisi/actionsapi/shell.py @@ -1,7 +1,9 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -import sys, re +# standard python modules +import sys +import re from itertools import izip, imap, count, ifilter, ifilterfalse def cat(filename): diff --git a/pisi/actionsapi/utils.py b/pisi/actionsapi/utils.py index ce4807c9..cbd04880 100644 --- a/pisi/actionsapi/utils.py +++ b/pisi/actionsapi/utils.py @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# stadard python modules import os import time from tempfile import mkstemp, mkdtemp