Commit 34095019 authored by hanwen's avatar hanwen
Browse files

initial import

parents
foo:
python driver.py
import sys
sys.path.insert (0, 'specs/')
import re
import os
import gub
class Settings:
def __init__ (self):
pass
settings = Settings()
settings.target_architecture = 'powerpc-apple-darwin'
settings.topdir = os.getcwd()
settings.downloaddir = os.getcwd() + '/downloads/'
settings.srcdir = os.path.join (settings.topdir, 'src')
settings.specdir = settings.topdir + '/specs/'
settings.targetdir = settings.topdir + '/target/%s/' % settings.target_architecture
settings.systemdir = settings.targetdir + '/system/'
settings.builddir = settings.targetdir + '/build/'
settings.installdir = settings.targetdir + '/install/'
settings.statusdir = settings.targetdir + '/status/'
settings.tooldir = settings.targetdir + '/tools/'
os.environ["PATH"] = '%s/%s:%s' % (settings.tooldir, 'bin', os.environ["PATH"])
def create_dirs (settings):
for a in ['topdir', 'statusdir',
'downloaddir', 'srcdir', 'specdir',
'targetdir', 'systemdir']:
try:
gub.system ('mkdir -p %s' % settings.__dict__[a], ignore_error = True)
except OSError:
pass
def process_package (package):
package.download ()
for stage in ['unpack', 'patch', 'configure', 'compile', 'install']:
# if not package.done (stage):
# (package.__class__.__dict__[stage]) (package)
# package.set_done (stage)
if not package.done (stage):
if stage == 'unpack': package.unpack()
elif stage == 'configure': package.configure ()
elif stage == 'patch': package.patch ()
elif stage == 'compile': package.compile ()
elif stage == 'install': package.install ()
package.set_done (stage)
def process_packages (ps):
for p in ps:
process_package (p)
if not os.path.exists (settings.targetdir):
create_dirs (settings)
import darwintools
import framework
process_packages (darwintools.get_packages (settings))
process_packages (framework.get_packages (settings))
import re
import gub
class Darwin_sdk (gub.Package):
def file_name (self):
return 'darwin-sdk.tar.gz'
def __init__ (self, settings):
gub.Package.__init__ (self, settings)
def name (self):
return 'darwin-sdk'
def unpack_destination (self):
return self.settings.systemdir
def download (self):
pass
def configure (self):
pass
def compile (self):
pass
def install (self):
pass
class Odcc_tools (gub.Package):
def __init__ (self, settings):
gub.Package.__init__ (self, settings)
self.url = 'http://www.opendarwin.org/downloads/odcctools-20051031.tar.bz2'
def name (self):
return "odcctools"
def installdir (self):
return self.settings.tooldir
def configure_command (self):
cmd = gub.Package.configure_command (self)
cmd += ' --target=%s --with-sysroot=%s ' % (self.settings.target_architecture, self.settings.systemdir)
return cmd
class Gcc (gub.Package):
def __init__ (self, settings):
gub.Package.__init__ (self,settings)
self.url = 'ftp://dl.xs4all.nl/pub/mirror/gnu/gcc/gcc-4.0.2/gcc-4.0.2.tar.bz2'
def patch (self):
fn ='%s/gcc/config/darwin.h' % self.srcdir()
str = open (fn).read ()
# backup file.
open (fn + "~", 'w').write (str)
str = re.sub ('/usr/bin/libtool', '%s/bin/powerpc-apple-darwin-libtool' % self.settings.tooldir, str)
open (fn,'w').write (str)
def configure_command (self):
cmd = gub.Package.configure_command (self)
cmd += ''' --prefix=%(tooldir)s \
--program-prefix=%(target_architecture)s- \
--target=%(target_architecture)s \
--with-as=%(tooldir)s/bin/powerpc-apple-darwin-as \
--with-ld=%(tooldir)s/bin/powerpc-apple-darwin-ld \
--with-sysroot=%(systemdir)s --enable-static --enable-shared \
--enable-languages=c ''' % self.settings.__dict__ # let's skip c++ for the moment.
return cmd
def get_packages (settings):
return [Darwin_sdk (settings),
Odcc_tools (settings),
Gcc (settings)]
import re
import gub
class Gettext (gub.Package):
def __init__ (self, settings):
gub.Package.__init__ (self, settings)
self.url = 'ftp://dl.xs4all.nl/pub/mirror/gnu/gettext/gettext-0.14.tar.gz'
def install_dir (self):
return self.settings.installdir
def get_packages (settings):
return [Gettext (settings),
]
import os
import sys
import re
def system (cmd, ignore_error = False):
sys.stderr.write ('invoking %s\n' % cmd)
stat = os.system (cmd)
if stat and not ignore_error:
sys.stderr.write ('fail\n')
sys.exit (1)
return 0
class Package:
def __init__ (self, settings):
self.settings = settings
def download (self):
dir = self.settings.downloaddir
if not os.path.exists (dir + '/' + self.file_name ()):
system ('cd %s ; wget %s ' % (dir, self.url))
def unpack_destination (self):
return self.settings.srcdir
def basename (self):
f = self.file_name ()
f = re.sub ("\.tar.*", '', f)
return f
def name (self):
s = self.basename()
s = re.sub ('-?[0-9][^-]+$', '', s)
return s
def srcdir (self):
return self.unpack_destination () + '/' + self.basename ()
def builddir (self):
return self.settings.builddir + '/' + self.basename ()
def installdir (self):
return self.settings.installdir + '/' + self.name ()
def file_name (self):
file = re.sub (".*/([^/]+)", '\\1', self.url)
return file
def done (self, stage):
return os.path.exists ('%s/%s-%s' % (self.settings.statusdir, self.name (), stage))
def set_done (self, stage):
open ('%s/%s-%s' % (self.settings.statusdir, self.name(), stage), 'w').write ('')
def configure_command (self):
return ("%s/configure --prefix=%s "
% (self.srcdir (), self.installdir ()))
def configure (self):
system ("mkdir -p %s; cd %s && %s" % (self.builddir(),
self.builddir(),
self.configure_command ()))
def install_command (self):
return 'make install'
def install (self):
system ("cd %s && %s" % (self.builddir (), self.install_command ()))
def compile_command (self):
return 'make'
def compile (self):
system ("cd %s && %s" % (self.builddir(), self.compile_command ()))
def patch (self):
pass
def unpack (self):
file = self.settings.downloaddir + '/' + self.file_name ()
cmd = ""
if re.search (".tar$", file):
cmd = "-xf "
elif re.search (".tar.bz2", file):
cmd = "-jxf "
elif re.search ('.tar.gz', file):
cmd = '-xzf '
cmd = "tar %s %s -C %s " % (cmd, file, self.unpack_destination ())
system (cmd)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment