ActionsAPI refactor, exception handling, use internal functions against external ones and etc.
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
ReFactor ActionsAPI:
|
ReFactor ActionsAPI:
|
||||||
|
|
||||||
pisitools.py - %80
|
pisitools.py - %90
|
||||||
autotools.py - %100
|
autotools.py - %100
|
||||||
get.py - %75
|
get.py - %75
|
||||||
kde.py - %0
|
kde.py - %75
|
||||||
libtools.py - %75
|
libtools.py - %90
|
||||||
pisitoolsfunctions.py - %75
|
pisitoolsfunctions.py - %75
|
||||||
shelltools.py - %50
|
shelltools.py - %75
|
||||||
variables.py - %100
|
variables.py - %100
|
||||||
coreutils.py - %100
|
coreutils.py - %100
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# Standard Python Modules
|
# Standard Python Modules
|
||||||
import os
|
import os
|
||||||
@@ -47,24 +46,30 @@ def configure(parameters = ''):
|
|||||||
if can_access_file('configure'):
|
if can_access_file('configure'):
|
||||||
gnuconfig_update()
|
gnuconfig_update()
|
||||||
|
|
||||||
configure_string = './configure --prefix=/%s --host=%s --mandir=/%s \
|
args = './configure \
|
||||||
--infodir=/%s --datadir=/%s --sysconfdir=/%s \
|
--prefix=/%s \
|
||||||
--localstatedir=/%s %s' \
|
--host=%s \
|
||||||
% (get.defaultprefixDIR(), get.HOST(), get.manDIR(),
|
--mandir=/%s \
|
||||||
get.infoDIR(), get.dataDIR(), get.confDIR(),
|
--infodir=/%s \
|
||||||
get.localstateDIR(), parameters)
|
--datadir=/%s \
|
||||||
|
--sysconfdir=/%s \
|
||||||
|
--localstatedir=/%s \
|
||||||
|
%s' % (get.defaultprefixDIR(), \
|
||||||
|
get.HOST(), get.manDIR(), \
|
||||||
|
get.infoDIR(), get.dataDIR(), \
|
||||||
|
get.confDIR(), get.localstateDIR(), parameters)
|
||||||
|
|
||||||
if system(configure_string):
|
if system(args):
|
||||||
raise ConfigureError('!!! Configure failed...\n')
|
raise ConfigureError('!!! Configure failed...\n')
|
||||||
else:
|
else:
|
||||||
raise ConfigureError('!!! No configure script found...\n')
|
raise ConfigureError('!!! No configure script found...\n')
|
||||||
|
|
||||||
def rawConfigure(parameters = '', prefix=''):
|
def rawConfigure(parameters = ''):
|
||||||
'''configure source with given parameters = "--prefix=/usr --libdir=/usr/lib --with-nls"'''
|
'''configure source with given parameters = "--prefix=/usr --libdir=/usr/lib --with-nls"'''
|
||||||
if can_access_file('configure'):
|
if can_access_file('configure'):
|
||||||
gnuconfig_update()
|
gnuconfig_update()
|
||||||
|
|
||||||
if system('%s ./configure %s' % (prefix, parameters)):
|
if system('./configure %s' % parameters):
|
||||||
raise ConfigureError('!!! Configure failed...\n')
|
raise ConfigureError('!!! Configure failed...\n')
|
||||||
else:
|
else:
|
||||||
raise ConfigureError('!!! No configure script found...\n')
|
raise ConfigureError('!!! No configure script found...\n')
|
||||||
@@ -81,7 +86,7 @@ def make(parameters = ''):
|
|||||||
def install(parameters = ''):
|
def install(parameters = ''):
|
||||||
'''install source into install directory with given parameters'''
|
'''install source into install directory with given parameters'''
|
||||||
if can_access_file('makefile') or can_access_file('Makefile') or can_access_file('GNUmakefile'):
|
if can_access_file('makefile') or can_access_file('Makefile') or can_access_file('GNUmakefile'):
|
||||||
install_string = 'make prefix=%(prefix)s/%(defaultprefix)s \
|
args = 'make prefix=%(prefix)s/%(defaultprefix)s \
|
||||||
datadir=%(prefix)s/%(data)s \
|
datadir=%(prefix)s/%(data)s \
|
||||||
infodir=%(prefix)s/%(info)s \
|
infodir=%(prefix)s/%(info)s \
|
||||||
localstatedir=%(prefix)s/%(localstate)s \
|
localstatedir=%(prefix)s/%(localstate)s \
|
||||||
@@ -97,7 +102,7 @@ def install(parameters = ''):
|
|||||||
'data': get.dataDIR(),
|
'data': get.dataDIR(),
|
||||||
'parameters': parameters}
|
'parameters': parameters}
|
||||||
|
|
||||||
if system(install_string):
|
if system(args):
|
||||||
raise InstallError('!!! Install failed...\n')
|
raise InstallError('!!! Install failed...\n')
|
||||||
else:
|
else:
|
||||||
raise InstallError('!!! No Makefile found...\n')
|
raise InstallError('!!! No Makefile found...\n')
|
||||||
@@ -113,14 +118,14 @@ def rawInstall(parameters = ''):
|
|||||||
def aclocal(parameters = ''):
|
def aclocal(parameters = ''):
|
||||||
'''generates an aclocal.m4 based on the contents of configure.in.'''
|
'''generates an aclocal.m4 based on the contents of configure.in.'''
|
||||||
if system('aclocal %s' % parameters):
|
if system('aclocal %s' % parameters):
|
||||||
raise RunTimeError("!!!! Running aclocal failed...")
|
raise RunTimeError('!!! Running aclocal failed...')
|
||||||
|
|
||||||
def autoconf(parameters = ''):
|
def autoconf(parameters = ''):
|
||||||
'''generates a configure script'''
|
'''generates a configure script'''
|
||||||
if system('autoconf %s' % parameters):
|
if system('autoconf %s' % parameters):
|
||||||
raise RunTimeError("!!!! Running autoconf failed...")
|
raise RunTimeError('!!! Running autoconf failed...')
|
||||||
|
|
||||||
def automake(parameters = ''):
|
def automake(parameters = ''):
|
||||||
'''generates a makefile'''
|
'''generates a makefile'''
|
||||||
if system('automake %s' % parameters):
|
if system('automake %s' % parameters):
|
||||||
raise RunTimeError("!!!! Running automake failed...")
|
raise RunTimeError('!!! Running automake failed...')
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# Standard Python Modules
|
# Standard Python Modules
|
||||||
import sys
|
import sys
|
||||||
@@ -17,7 +16,7 @@ import re
|
|||||||
from itertools import izip, imap, count, ifilter, ifilterfalse
|
from itertools import izip, imap, count, ifilter, ifilterfalse
|
||||||
|
|
||||||
# ActionsAPI
|
# ActionsAPI
|
||||||
import pisi.actionsapi as actionsapi
|
import pisi.actionsapi
|
||||||
|
|
||||||
def cat(filename):
|
def cat(filename):
|
||||||
return file(filename).xreadlines()
|
return file(filename).xreadlines()
|
||||||
|
|||||||
+10
-3
@@ -9,7 +9,6 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# Standart Python Modules
|
# Standart Python Modules
|
||||||
import os.path
|
import os.path
|
||||||
@@ -91,6 +90,15 @@ def localstateDIR():
|
|||||||
def defaultprefixDIR():
|
def defaultprefixDIR():
|
||||||
return dirs.defaultprefix
|
return dirs.defaultprefix
|
||||||
|
|
||||||
|
def kdeDIR():
|
||||||
|
return dirs.kde
|
||||||
|
|
||||||
|
def qtDIR():
|
||||||
|
return dirs.qt
|
||||||
|
|
||||||
|
def qtLIBDIR():
|
||||||
|
return '%s/lib/' % qtDIR()
|
||||||
|
|
||||||
# Binutils Variables
|
# Binutils Variables
|
||||||
|
|
||||||
def exists_binary(bin):
|
def exists_binary(bin):
|
||||||
@@ -105,10 +113,9 @@ def getBinutilsInfo(util):
|
|||||||
cross_build_name = '%s-%s' % (HOST(), util)
|
cross_build_name = '%s-%s' % (HOST(), util)
|
||||||
if not exists_binary(cross_build_name):
|
if not exists_binary(cross_build_name):
|
||||||
if not exists_binary(util):
|
if not exists_binary(util):
|
||||||
#ui.error('Error: util %s cannot be found' % util)
|
|
||||||
raise BinutilsError('util %s cannot be found' % util)
|
raise BinutilsError('util %s cannot be found' % util)
|
||||||
else:
|
else:
|
||||||
ui.debug('Warning: %s does not exist, using plain name %s'
|
ui.debug('Warning: %s does not exist, using plain name %s' \
|
||||||
% (cross_build_name, util))
|
% (cross_build_name, util))
|
||||||
return util
|
return util
|
||||||
else:
|
else:
|
||||||
|
|||||||
+38
-22
@@ -9,44 +9,60 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# standard python modules
|
# standard python modules
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# actions api modules
|
# Pisi Modules
|
||||||
from pisi.actionsapi.actionglobals import glb
|
from pisi.ui import ui
|
||||||
|
|
||||||
# Global variables for compiling KDE programs...
|
# ActionsAPI Modules
|
||||||
kde_dir = os.getenv('KDEDIR')
|
import pisi.actionsapi
|
||||||
qt_dir = os.getenv('QTDIR')
|
import pisi.actionsapi.get as get
|
||||||
qt_libdir = os.path.join(os.getenv('QTDIR') + '/lib/')
|
from pisi.actionsapi.shelltools import system
|
||||||
|
|
||||||
|
class ConfigureError(pisi.actionsapi.Error):
|
||||||
|
def __init__(self, Exception):
|
||||||
|
ui.error(Exception)
|
||||||
|
if can_access_file('config.log'):
|
||||||
|
ui.error('\n!!! Please attach the config.log to your bug report:\n%s/config.log\n' % os.getcwd())
|
||||||
|
|
||||||
|
class MakeError(pisi.actionsapi.Error):
|
||||||
|
def __init__(self, Exception):
|
||||||
|
ui.error(Exception)
|
||||||
|
|
||||||
|
class InstallError(pisi.actionsapi.Error):
|
||||||
|
def __init__(self, Exception):
|
||||||
|
ui.error(Exception)
|
||||||
|
|
||||||
def configure(parameters = ''):
|
def configure(parameters = ''):
|
||||||
''' FIXME: Düzgün hale getirilecek '''
|
|
||||||
''' parameters = '--with-nls --with-libusb --with-something-usefull '''
|
''' parameters = '--with-nls --with-libusb --with-something-usefull '''
|
||||||
|
if can_access_file('configure'):
|
||||||
configure_string = './configure --prefix=%s \
|
args = './configure \
|
||||||
|
--prefix=%s \
|
||||||
--host=%s \
|
--host=%s \
|
||||||
--with-x \
|
--with-x \
|
||||||
--enable-mitshm \
|
--enable-mitshm \
|
||||||
--with-qt-dir=%s \
|
--with-qt-dir=%s \
|
||||||
--enable-mt \
|
--enable-mt \
|
||||||
--with-qt-libraries=%s \
|
--with-qt-libraries=%s \
|
||||||
%s' % (kde_dir, glb.env.host, qt_dir, qt_libdir, parameters)
|
%s' % (get.kdeDIR(), get.HOST(), get.qtDIR(), get.qtLIBDIR(), parameters)
|
||||||
|
|
||||||
os.system(configure_string)
|
if system(args):
|
||||||
|
raise ConfigureError('!!! Configure failed...\n')
|
||||||
|
else:
|
||||||
|
raise ConfigureError('!!! No configure script found...\n')
|
||||||
|
|
||||||
def make():
|
def make(parameters = ''):
|
||||||
''' FIXME: Düzgün hale getirilecek '''
|
'''make source with given parameters = "all" || "doc" etc.'''
|
||||||
os.system('make')
|
if system('make %s' % parameters):
|
||||||
|
raise MakeError('!!! Make failed...\n')
|
||||||
|
|
||||||
def install():
|
def install():
|
||||||
''' FIXME: Düzgün hale getirilecek '''
|
if can_access_file('Makefile'):
|
||||||
''' dir_suffix = /var/tmp/pisi/ _paket_adı_ /image/ '''
|
args = 'make prefix=%s/%s install' % (get.installDIR(), get.kdeDIR())
|
||||||
|
|
||||||
dir_suffix = os.path.dirname(os.path.dirname(os.getcwd())) + \
|
if system(args):
|
||||||
glb.const.install_dir_suffix
|
raise InstallError('!!! Install failed...\n')
|
||||||
|
else:
|
||||||
install_string = 'make prefix=%s/%s install' % (dir_suffix, kde_dir)
|
raise InstallError('!!! No Makefile found...\n')
|
||||||
os.system(install_string)
|
|
||||||
|
|||||||
+12
-14
@@ -9,18 +9,16 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# Standard Python Modules
|
# Standard Python Modules
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
|
|
||||||
# Pisi-Core Modules
|
# Pisi-Core Modules
|
||||||
from pisi.ui import ui
|
from pisi.ui import ui
|
||||||
|
|
||||||
# ActionsAPI Modules
|
# ActionsAPI Modules
|
||||||
import pisi.actionsapi
|
import pisi.actionsapi
|
||||||
from pisi.actionsapi.shelltools import chmod, makedirs, can_access_directory
|
from pisi.actionsapi.shelltools import *
|
||||||
import pisi.actionsapi.get as get
|
import pisi.actionsapi.get as get
|
||||||
|
|
||||||
class RunTimeError(pisi.actionsapi.Error):
|
class RunTimeError(pisi.actionsapi.Error):
|
||||||
@@ -28,9 +26,10 @@ class RunTimeError(pisi.actionsapi.Error):
|
|||||||
ui.error(Exception)
|
ui.error(Exception)
|
||||||
|
|
||||||
def preplib(sourceDirectory = '/usr/lib'):
|
def preplib(sourceDirectory = '/usr/lib'):
|
||||||
sourceDirectory = '%s' % (get.installDIR() + sourceDirectory)
|
sourceDirectory = get.installDIR() + sourceDirectory
|
||||||
if can_access_directory(sourceDirectory):
|
if can_access_directory(sourceDirectory):
|
||||||
os.system('/sbin/ldconfig -n -N %s' % sourceDirectory)
|
if system('/sbin/ldconfig -n -N %s' % sourceDirectory):
|
||||||
|
raise RunTimeError('!!! Running ldconfig failed...')
|
||||||
|
|
||||||
def preplib_so(sourceDirectory):
|
def preplib_so(sourceDirectory):
|
||||||
pass
|
pass
|
||||||
@@ -39,20 +38,19 @@ def gnuconfig_update():
|
|||||||
''' copy newest config.* onto source's '''
|
''' copy newest config.* onto source's '''
|
||||||
for root, dirs, files in os.walk(os.getcwd()):
|
for root, dirs, files in os.walk(os.getcwd()):
|
||||||
for file in files:
|
for file in files:
|
||||||
if file == "config.sub" or file == "config.guess":
|
if file in ['config.sub', 'config.guess']:
|
||||||
shutil.copyfile('/usr/share/gnuconfig/%s' % file, os.path.join(root, file))
|
copy('/usr/share/gnuconfig/%s' % file, os.path.join(root, file))
|
||||||
|
ui.info('GNU Config Update Finished...\n')
|
||||||
ui.info('GNU Config Update Finished...\n')
|
|
||||||
|
|
||||||
def libtoolize(parameters = ''):
|
def libtoolize(parameters = ''):
|
||||||
if os.system('/usr/bin/libtoolize %s' % parameters):
|
if system('/usr/bin/libtoolize %s' % parameters):
|
||||||
raise RunTimeError("!!!! Running libtoolize failed...")
|
raise RunTimeError('!!! Running libtoolize failed...')
|
||||||
|
|
||||||
def gen_usr_ldscript(dynamicLib):
|
def gen_usr_ldscript(dynamicLib):
|
||||||
|
|
||||||
makedirs(get.installDIR() + '/usr/lib')
|
makedirs('%s/usr/lib' % get.installDIR())
|
||||||
|
|
||||||
destinationFile = open(get.installDIR() + '/usr/lib/' + dynamicLib, 'w')
|
destinationFile = open('%s/usr/lib/%s' % (get.installDIR(), dynamicLib), 'w')
|
||||||
content = '''
|
content = '''
|
||||||
/* GNU ld script
|
/* GNU ld script
|
||||||
Since Pardus has critical dynamic libraries
|
Since Pardus has critical dynamic libraries
|
||||||
@@ -65,4 +63,4 @@ GROUP ( /lib/%s )
|
|||||||
|
|
||||||
destinationFile.write(content)
|
destinationFile.write(content)
|
||||||
destinationFile.close()
|
destinationFile.close()
|
||||||
chmod(get.installDIR() + '/usr/lib/' + dynamicLib)
|
chmod('%s/usr/lib/%s' % (get.installDIR(), dynamicLib))
|
||||||
|
|||||||
@@ -9,16 +9,17 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# Standart Python Modules
|
# Standart Python Modules
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
|
||||||
import fileinput
|
import fileinput
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
# Pisi Modules
|
||||||
|
from pisi.ui import ui
|
||||||
|
|
||||||
# ActionsAPI Modules
|
# ActionsAPI Modules
|
||||||
import pisi.actionsapi
|
import pisi.actionsapi
|
||||||
import pisi.actionsapi.get as get
|
import pisi.actionsapi.get as get
|
||||||
@@ -66,13 +67,13 @@ def dohtml(*sourceFiles):
|
|||||||
for sourceFile in sourceFiles:
|
for sourceFile in sourceFiles:
|
||||||
for source in glob.glob(sourceFile):
|
for source in glob.glob(sourceFile):
|
||||||
if os.path.isfile(source) and os.path.splitext(source)[1] in allowed_extensions:
|
if os.path.isfile(source) and os.path.splitext(source)[1] in allowed_extensions:
|
||||||
os.system('install -m0644 %s %s' % (source, destionationDirectory))
|
system('install -m0644 %s %s' % (source, destionationDirectory))
|
||||||
if os.path.isdir(source) and os.path.basename(source) not in disallowed_directories:
|
if os.path.isdir(source) and os.path.basename(source) not in disallowed_directories:
|
||||||
for root, dirs, files in os.walk(source):
|
for root, dirs, files in os.walk(source):
|
||||||
for source in files:
|
for source in files:
|
||||||
if os.path.splitext(source)[1] in allowed_extensions:
|
if os.path.splitext(source)[1] in allowed_extensions:
|
||||||
makedirs(destionationDirectory)
|
makedirs(destionationDirectory)
|
||||||
os.system('install -m0644 %s %s' % (os.path.join(root, source), destionationDirectory))
|
system('install -m0644 %s %s' % (os.path.join(root, source), destionationDirectory))
|
||||||
|
|
||||||
def doinfo(*sourceFiles):
|
def doinfo(*sourceFiles):
|
||||||
'''inserts the into files in the list of files into /usr/share/info'''
|
'''inserts the into files in the list of files into /usr/share/info'''
|
||||||
@@ -87,7 +88,6 @@ def dolib(sourceFile, destinationDirectory = '/usr/lib'):
|
|||||||
|
|
||||||
'''example call: pisitools.dolib_a("libz.a")'''
|
'''example call: pisitools.dolib_a("libz.a")'''
|
||||||
'''example call: pisitools.dolib_a("libz.so")'''
|
'''example call: pisitools.dolib_a("libz.so")'''
|
||||||
#FIXME: Glob needed?
|
|
||||||
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
||||||
destinationDirectory = get.installDIR() + destinationDirectory
|
destinationDirectory = get.installDIR() + destinationDirectory
|
||||||
|
|
||||||
@@ -97,7 +97,6 @@ def dolib_a(sourceFile, destinationDirectory = '/usr/lib'):
|
|||||||
'''insert the static library into /usr/lib with permission 0644'''
|
'''insert the static library into /usr/lib with permission 0644'''
|
||||||
|
|
||||||
'''example call: pisitools.dolib_a("staticlib/libvga.a")'''
|
'''example call: pisitools.dolib_a("staticlib/libvga.a")'''
|
||||||
#FIXME: Glob needed?
|
|
||||||
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
||||||
destinationDirectory = get.installDIR() + destinationDirectory
|
destinationDirectory = get.installDIR() + destinationDirectory
|
||||||
|
|
||||||
@@ -107,7 +106,6 @@ def dolib_so(sourceFile, destinationDirectory = '/usr/lib'):
|
|||||||
'''insert the static library into /usr/lib with permission 0755'''
|
'''insert the static library into /usr/lib with permission 0755'''
|
||||||
|
|
||||||
'''example call: pisitools.dolib_so("pppd/plugins/minconn.so")'''
|
'''example call: pisitools.dolib_so("pppd/plugins/minconn.so")'''
|
||||||
#FIXME: Glob needed?
|
|
||||||
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
sourceFile = os.path.join(os.getcwd(), sourceFile)
|
||||||
destinationDirectory = get.installDIR() + destinationDirectory
|
destinationDirectory = get.installDIR() + destinationDirectory
|
||||||
|
|
||||||
@@ -127,20 +125,19 @@ def doman(*sourceFiles):
|
|||||||
pageName, pageDirectory = source[:source.rindex('.')], \
|
pageName, pageDirectory = source[:source.rindex('.')], \
|
||||||
source[source.rindex('.')+1:]
|
source[source.rindex('.')+1:]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print 'doman: Wrong man page file'
|
ui.error('\n!!! ActionsAPI [doman]: Wrong man page file...\n')
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
makedirs(manDIR + '/man%s' % pageDirectory)
|
makedirs(manDIR + '/man%s' % pageDirectory)
|
||||||
os.system('install -m0644 %s %s' % (source, manDIR + '/man%s' % pageDirectory))
|
system('install -m0644 %s %s' % (source, manDIR + '/man%s' % pageDirectory))
|
||||||
|
|
||||||
def domo(sourceFile, locale, destinationFile ):
|
def domo(sourceFile, locale, destinationFile ):
|
||||||
'''inserts the mo files in the list of files into /usr/share/locale/LOCALE/LC_MESSAGES'''
|
'''inserts the mo files in the list of files into /usr/share/locale/LOCALE/LC_MESSAGES'''
|
||||||
|
|
||||||
'''example call: pisitools.domo("po/tr.po", "tr", "pam_login.mo")'''
|
'''example call: pisitools.domo("po/tr.po", "tr", "pam_login.mo")'''
|
||||||
|
|
||||||
system("msgfmt %s" % sourceFile)
|
system('msgfmt %s' % sourceFile)
|
||||||
makedirs(get.installDIR() + "/usr/share/locale/%s/LC_MESSAGES/" % locale)
|
makedirs('%s/usr/share/locale/%s/LC_MESSAGES/' % (get.installDIR(), locale))
|
||||||
shutil.move("messages.mo", get.installDIR() + "/usr/share/locale/%s/LC_MESSAGES/%s" % (locale, destinationFile))
|
move('messages.mo', '%s/usr/share/locale/%s/LC_MESSAGES/%s' % (get.installDIR(), locale, destinationFile))
|
||||||
|
|
||||||
def domove(sourceFile, destination, destinationFile = ''):
|
def domove(sourceFile, destination, destinationFile = ''):
|
||||||
'''moves sourceFile/Directory into destinationFile/Directory'''
|
'''moves sourceFile/Directory into destinationFile/Directory'''
|
||||||
@@ -151,9 +148,9 @@ def domove(sourceFile, destination, destinationFile = ''):
|
|||||||
|
|
||||||
for file in glob.glob(get.installDIR() + sourceFile):
|
for file in glob.glob(get.installDIR() + sourceFile):
|
||||||
if not destinationFile:
|
if not destinationFile:
|
||||||
shutil.move(file, get.installDIR() + os.path.join(destination, os.path.basename(file)))
|
move(file, get.installDIR() + os.path.join(destination, os.path.basename(file)))
|
||||||
else:
|
else:
|
||||||
shutil.move(file, get.installDIR() + os.path.join(destination, destinationFile))
|
move(file, get.installDIR() + os.path.join(destination, destinationFile))
|
||||||
|
|
||||||
def dopython():
|
def dopython():
|
||||||
'''FIXME: What the hell is this?'''
|
'''FIXME: What the hell is this?'''
|
||||||
@@ -168,6 +165,7 @@ def dosed(sourceFile, findPattern, replacePattern = ''):
|
|||||||
|
|
||||||
if can_access_file(sourceFile):
|
if can_access_file(sourceFile):
|
||||||
for line in fileinput.input(sourceFile, inplace = 1):
|
for line in fileinput.input(sourceFile, inplace = 1):
|
||||||
|
#FIXME: In-place filtering is disabled when standard input is read
|
||||||
line = re.sub(findPattern, replacePattern, line)
|
line = re.sub(findPattern, replacePattern, line)
|
||||||
sys.stdout.write(line)
|
sys.stdout.write(line)
|
||||||
else:
|
else:
|
||||||
@@ -188,9 +186,7 @@ def dosym(sourceFile, destinationFile):
|
|||||||
try:
|
try:
|
||||||
os.symlink(sourceFile, get.installDIR() + destinationFile)
|
os.symlink(sourceFile, get.installDIR() + destinationFile)
|
||||||
except OSError:
|
except OSError:
|
||||||
print 'dosym: File exists...'
|
ui.error('\n!!! ActionsAPI [dosym]: File exists...\n')
|
||||||
|
|
||||||
''' ************************************************************************** '''
|
|
||||||
|
|
||||||
def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
||||||
'''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions'''
|
'''insert a sourceFile into destinationDirectory as a destinationFile with same uid/guid/permissions'''
|
||||||
@@ -199,24 +195,20 @@ def insinto(destinationDirectory, sourceFile, destinationFile = ''):
|
|||||||
if not destinationFile:
|
if not destinationFile:
|
||||||
for file in glob.glob(sourceFile):
|
for file in glob.glob(sourceFile):
|
||||||
if can_access_file(file):
|
if can_access_file(file):
|
||||||
shutil.copy(file, get.installDIR() + os.path.join(destinationDirectory, os.path.basename(file)))
|
copy(file, get.installDIR() + os.path.join(destinationDirectory, os.path.basename(file)))
|
||||||
else:
|
else:
|
||||||
shutil.copy(sourceFile, get.installDIR() + os.path.join(destinationDirectory, destinationFile))
|
copy(sourceFile, get.installDIR() + os.path.join(destinationDirectory, destinationFile))
|
||||||
|
|
||||||
''' ************************************************************************** '''
|
|
||||||
|
|
||||||
def newdoc(sourceFile, destinationFile):
|
def newdoc(sourceFile, destinationFile):
|
||||||
'''inserts a sourceFile into /usr/share/doc/PACKAGE/ directory as a destinationFile'''
|
'''inserts a sourceFile into /usr/share/doc/PACKAGE/ directory as a destinationFile'''
|
||||||
shutil.move(sourceFile, destinationFile)
|
move(sourceFile, destinationFile)
|
||||||
readable_insinto(os.path.join(get.installDIR(), 'usr/share/doc', get.srcTAG()), destinationFile)
|
readable_insinto(os.path.join(get.installDIR(), 'usr/share/doc', get.srcTAG()), destinationFile)
|
||||||
|
|
||||||
def newman(sourceFile, destinationFile):
|
def newman(sourceFile, destinationFile):
|
||||||
'''inserts a sourceFile into /usr/share/man/manPREFIX/ directory as a destinationFile'''
|
'''inserts a sourceFile into /usr/share/man/manPREFIX/ directory as a destinationFile'''
|
||||||
shutil.move(sourceFile, destinationFile)
|
move(sourceFile, destinationFile)
|
||||||
doman(destinationFile)
|
doman(destinationFile)
|
||||||
|
|
||||||
''' ************************************************************************** '''
|
|
||||||
|
|
||||||
def remove(sourceFile):
|
def remove(sourceFile):
|
||||||
'''removes sourceFile'''
|
'''removes sourceFile'''
|
||||||
unlink(get.installDIR() + sourceFile)
|
unlink(get.installDIR() + sourceFile)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# Generic functions for common usage of pisitools #
|
# Generic functions for common usage of pisitools #
|
||||||
|
|
||||||
@@ -38,11 +37,10 @@ def executable_insinto(sourceFile, destinationDirectory):
|
|||||||
if not can_access_file(sourceFile):
|
if not can_access_file(sourceFile):
|
||||||
raise FileError('File doesn\'t exists or permission denied...')
|
raise FileError('File doesn\'t exists or permission denied...')
|
||||||
|
|
||||||
if can_access_directory(destinationDirectory) and os.path.isdir(destinationDirectory):
|
if not can_access_directory(destinationDirectory):
|
||||||
os.system('install -m0755 -o root -g root %s %s' % (sourceFile, destinationDirectory))
|
|
||||||
else:
|
|
||||||
makedirs(destinationDirectory)
|
makedirs(destinationDirectory)
|
||||||
os.system('install -m0755 -o root -g root %s %s' % (sourceFile, destinationDirectory))
|
|
||||||
|
system('install -m0755 -o root -g root %s %s' % (sourceFile, destinationDirectory))
|
||||||
|
|
||||||
def readable_insinto(destinationDirectory, *sourceFiles):
|
def readable_insinto(destinationDirectory, *sourceFiles):
|
||||||
'''inserts file list into destinationDirectory'''
|
'''inserts file list into destinationDirectory'''
|
||||||
@@ -55,7 +53,7 @@ def readable_insinto(destinationDirectory, *sourceFiles):
|
|||||||
|
|
||||||
for sourceFile in sourceFiles:
|
for sourceFile in sourceFiles:
|
||||||
for source in glob.glob(sourceFile):
|
for source in glob.glob(sourceFile):
|
||||||
os.system('install -m0644 %s %s' % (source, destinationDirectory))
|
system('install -m0644 %s %s' % (source, destinationDirectory))
|
||||||
|
|
||||||
def lib_insinto(sourceFile, destinationDirectory, permission = 0644):
|
def lib_insinto(sourceFile, destinationDirectory, permission = 0644):
|
||||||
'''inserts a library fileinto destinationDirectory with given permission'''
|
'''inserts a library fileinto destinationDirectory with given permission'''
|
||||||
@@ -69,4 +67,4 @@ def lib_insinto(sourceFile, destinationDirectory, permission = 0644):
|
|||||||
if os.path.islink(sourceFile):
|
if os.path.islink(sourceFile):
|
||||||
os.symlink(os.path.realpath(sourceFile), os.path.join(destinationDirectory, sourceFile))
|
os.symlink(os.path.realpath(sourceFile), os.path.join(destinationDirectory, sourceFile))
|
||||||
else:
|
else:
|
||||||
os.system('install -m%s %s %s' % (permission, sourceFile, destinationDirectory))
|
system('install -m%s %s %s' % (permission, sourceFile, destinationDirectory))
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# Standart Python Modules
|
# Standart Python Modules
|
||||||
import os
|
import os
|
||||||
@@ -41,29 +40,82 @@ def makedirs(destinationDirectory):
|
|||||||
def chmod(sourceFile, mode = 0755):
|
def chmod(sourceFile, mode = 0755):
|
||||||
'''change the mode of sourceFile to the mode'''
|
'''change the mode of sourceFile to the mode'''
|
||||||
for file in glob.glob(sourceFile):
|
for file in glob.glob(sourceFile):
|
||||||
os.chmod(file, mode)
|
if can_access_file(file):
|
||||||
|
try:
|
||||||
|
os.chmod(file, mode)
|
||||||
|
except OSError:
|
||||||
|
ui.error('\n!!! ActionsAPI [chmod]: Operation not permitted...\n')
|
||||||
|
else:
|
||||||
|
ui.error('\n!!! ActionsAPI [chmod]: File doesn\'t exists...\n')
|
||||||
|
|
||||||
|
def chown(sourceFile, uid = 0, gid = 0):
|
||||||
|
'''change the owner and group id of sourceFile to the numeric uid and gid'''
|
||||||
|
if can_access_file(sourceFile):
|
||||||
|
try:
|
||||||
|
os.chown(sourceFile, uid, gid)
|
||||||
|
except OSError:
|
||||||
|
ui.error('\n!!! ActionsAPI [chown]: Operation not permitted...\n')
|
||||||
|
else:
|
||||||
|
ui.error('\n!!! ActionsAPI [chown]: File doesn\'t exists...\n')
|
||||||
|
|
||||||
|
def sym(sourceFile, destinationFile):
|
||||||
|
'''creates symbolic link'''
|
||||||
|
try:
|
||||||
|
os.symlink(sourceFile, destinationFile)
|
||||||
|
except OSError:
|
||||||
|
ui.error('\n!!! ActionsAPI [sym]: Permission denied...\n')
|
||||||
|
|
||||||
def unlink(sourceFile):
|
def unlink(sourceFile):
|
||||||
os.unlink(sourceFile)
|
'''remove the file path'''
|
||||||
|
if isFile(sourceFile) or isLink(sourceFile):
|
||||||
|
try:
|
||||||
|
os.unlink(sourceFile)
|
||||||
|
except OSError:
|
||||||
|
ui.error('\n!!! ActionsAPI [unlink]: Permission denied...\n')
|
||||||
|
else:
|
||||||
|
ui.error('\n!!! ActionsAPI [unlink]: File doesn\'t exists...\n')
|
||||||
|
|
||||||
def unlinkDir(sourceDirectory):
|
def unlinkDir(sourceDirectory):
|
||||||
if can_access_directory(sourceDirectory):
|
'''delete an entire directory tree'''
|
||||||
shutil.rmtree(sourceDirectory)
|
if isDirectory(sourceDirectory) or isLink(sourceDirectory):
|
||||||
|
try:
|
||||||
|
shutil.rmtree(sourceDirectory)
|
||||||
|
except OSError:
|
||||||
|
ui.error('\n!!! ActionsAPI [unlinkDir]: Operation not permitted...\n')
|
||||||
else:
|
else:
|
||||||
ui.error('unlinkDir: remove failed...')
|
ui.error('\n!!! ActionsAPI [unlinkDir]: File doesn\'t exists...\n')
|
||||||
|
|
||||||
def move(sourceFile, destinationFile):
|
def move(sourceFile, destinationFile):
|
||||||
'''recursively move a sourceFile or directory to destinationFile'''
|
'''recursively move a sourceFile or directory to destinationFile'''
|
||||||
for file in glob.glob(sourceFile):
|
for file in glob.glob(sourceFile):
|
||||||
shutil.move(file, destinationFile)
|
if can_access_file(file):
|
||||||
|
try:
|
||||||
|
shutil.move(file, destinationFile)
|
||||||
|
except OSError:
|
||||||
|
ui.error('\n!!! ActionsAPI [move]: Permission denied...\n')
|
||||||
|
else:
|
||||||
|
ui.error('\n!!! ActionsAPI [move]: File doesn\'t exists...\n')
|
||||||
|
|
||||||
def copy(sourceFile, destinationFile):
|
def copy(sourceFile, destinationFile):
|
||||||
'''recursively copy a sourceFile or directory to destinationFile'''
|
'''recursively copy a sourceFile or directory to destinationFile'''
|
||||||
for file in glob.glob(sourceFile):
|
for file in glob.glob(sourceFile):
|
||||||
shutil.copy(file, destinationFile)
|
if can_access_file(file):
|
||||||
|
try:
|
||||||
|
shutil.copy(file, destinationFile)
|
||||||
|
except IOError:
|
||||||
|
ui.error('\n!!! ActionsAPI [copy]: Permission denied...\n')
|
||||||
|
else:
|
||||||
|
ui.error('\n!!! ActionsAPI [copy]: File doesn\'t exists...\n')
|
||||||
|
|
||||||
def copytree(source, destination, sym=False):
|
def copytree(source, destination, sym = False):
|
||||||
shutil.copytree(source, destination, sym)
|
'''recursively copy an entire directory tree rooted at source'''
|
||||||
|
if can_access_directory(source):
|
||||||
|
try:
|
||||||
|
shutil.copytree(source, destination, sym)
|
||||||
|
except OSError:
|
||||||
|
ui.error('\n!!! ActionsAPI [copytree]: Permission denied...\n')
|
||||||
|
else:
|
||||||
|
ui.error('\n!!! ActionsAPI [copytree]: Directory doesn\'t exists...\n')
|
||||||
|
|
||||||
def touch(sourceFile):
|
def touch(sourceFile):
|
||||||
'''changes the access time of the 'sourceFile', or creates it if it is not exist'''
|
'''changes the access time of the 'sourceFile', or creates it if it is not exist'''
|
||||||
@@ -71,8 +123,11 @@ def touch(sourceFile):
|
|||||||
for file in glob.glob(sourceFile):
|
for file in glob.glob(sourceFile):
|
||||||
os.utime(file, None)
|
os.utime(file, None)
|
||||||
else:
|
else:
|
||||||
f = open(sourceFile, 'w')
|
try:
|
||||||
f.close()
|
f = open(sourceFile, 'w')
|
||||||
|
f.close()
|
||||||
|
except IOError:
|
||||||
|
ui.error('\n!!! ActionsAPI [touch]: Permission denied...\n')
|
||||||
|
|
||||||
def cd(directoryName = ''):
|
def cd(directoryName = ''):
|
||||||
'''change directory'''
|
'''change directory'''
|
||||||
@@ -90,9 +145,36 @@ def ls(source):
|
|||||||
return glob.glob(source)
|
return glob.glob(source)
|
||||||
|
|
||||||
def export(key, value):
|
def export(key, value):
|
||||||
|
'''export environ variable'''
|
||||||
os.environ[key] = value
|
os.environ[key] = value
|
||||||
|
|
||||||
|
def isLink(sourceFile):
|
||||||
|
'''return True if sourceFile refers to a symbolic link'''
|
||||||
|
return os.path.islink(sourceFile)
|
||||||
|
|
||||||
|
def isFile(sourceFile):
|
||||||
|
'''return True if sourceFile is an existing regular file'''
|
||||||
|
return os.path.isfile(sourceFile)
|
||||||
|
|
||||||
|
def isDirectory(sourceFile):
|
||||||
|
'''Return True if sourceFile is an existing directory'''
|
||||||
|
return os.path.isdir(sourceFile)
|
||||||
|
|
||||||
|
def realPath(sourceFile):
|
||||||
|
'''return the canonical path of the specified filename, eliminating any symbolic links encountered in the path'''
|
||||||
|
return os.path.realpath(sourceFile)
|
||||||
|
|
||||||
|
def baseName(sourceFile):
|
||||||
|
'''return the base name of pathname sourceFile'''
|
||||||
|
return os.path.basename(sourceFile)
|
||||||
|
|
||||||
|
def dirName(sourceFile):
|
||||||
|
'''return the directory name of pathname path'''
|
||||||
|
return os.path.dirname(sourceFile)
|
||||||
|
|
||||||
def system(command):
|
def system(command):
|
||||||
|
#FIXME: String formatting
|
||||||
|
command = command.replace(" ", " ")
|
||||||
ui.debug('executing %s\n' % command)
|
ui.debug('executing %s\n' % command)
|
||||||
p = os.popen(command)
|
p = os.popen(command)
|
||||||
while 1:
|
while 1:
|
||||||
@@ -102,19 +184,3 @@ def system(command):
|
|||||||
ui.debug(line)
|
ui.debug(line)
|
||||||
|
|
||||||
return p.close()
|
return p.close()
|
||||||
|
|
||||||
def isLink(sourceFile):
|
|
||||||
return os.path.islink(sourceFile)
|
|
||||||
|
|
||||||
def realPath(sourceFile):
|
|
||||||
return os.path.realpath(sourceFile)
|
|
||||||
|
|
||||||
def baseName(sourceFile):
|
|
||||||
return os.path.basename(sourceFile)
|
|
||||||
|
|
||||||
def dirName(sourceFile):
|
|
||||||
return os.path.dirname(sourceFile)
|
|
||||||
|
|
||||||
def sym(sourceFile, destinationFile):
|
|
||||||
os.symlink(sourceFile, destinationFile)
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,13 @@
|
|||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
#
|
|
||||||
|
|
||||||
# Standard Python Modules
|
# Standard Python Modules
|
||||||
from os import getenv, environ
|
from os import getenv, environ
|
||||||
|
|
||||||
# Pisi-Core Modules
|
# Pisi-Core Modules
|
||||||
import pisi.config # That was the only correct
|
import pisi.config
|
||||||
import pisi.constants # use before changing to abs. imports
|
import pisi.constants
|
||||||
|
|
||||||
# Set individual information, that are generally needed for ActionsAPI
|
# Set individual information, that are generally needed for ActionsAPI
|
||||||
|
|
||||||
@@ -72,6 +71,10 @@ class Dirs:
|
|||||||
localstate = 'var/lib'
|
localstate = 'var/lib'
|
||||||
defaultprefix = 'usr'
|
defaultprefix = 'usr'
|
||||||
|
|
||||||
|
#FIXME: Get these from config or somewhere else!
|
||||||
|
kde = '/usr/kde/3.4'
|
||||||
|
qt = '/usr/qt/3'
|
||||||
|
|
||||||
class Variables(pisi.config.Config):
|
class Variables(pisi.config.Config):
|
||||||
const = pisi.constants.const
|
const = pisi.constants.const
|
||||||
env = Env()
|
env = Env()
|
||||||
|
|||||||
Reference in New Issue
Block a user