Exemple #1
0
def archive():
    sys.path.append(os.getcwd())
    control = __import__('control', globals(), locals(), [], 0)
    sys.path.remove(os.getcwd())
    control = control.Package()

    if os.path.exists(control.name):
        stream_logger.info('Package already archived')
        sys.exit(1)

    os.makedirs(control.name)

    with open(os.path.join(control.name, 'files.lst'), 'w') as list_file:
        _pwd = os.getcwd()
        os.chdir('build')
        for (p, d, f) in os.walk('.'):
            for _f in f:
                list_file.write(os.path.join(p, _f) + '\n')
        os.chdir(_pwd)

    create_tar('build',
               os.path.join(control.name, 'files.bz2'),
               change_dir=True,
               mode='w:bz2')
    shutil.copyfile('control.py', os.path.join(control.name, 'control.py'))
    create_tar(control.name, '%s.tar' % control.name)
Exemple #2
0
    def build(self):
        stream_logger.info('Building...')
        
        os.makedirs('%s/bin' % self.src_dir)
        os.chdir('%s/bin' % self.src_dir)

        os.system('curl -o spilleliste https://raw.github.com/Socketubs/Spilleliste/master/spilleliste')
        os.system('chmod +x spilleliste')
Exemple #3
0
    def build(self):
        stream_logger.info('Building...')
        os.chdir(self.src_dir)

        os.system('curl -k -L https://github.com/max-horvath/htop-osx/tarball/%s-2012-04-18 | tar zx' % self.version)
        os.chdir('max-horvath-htop-osx-d92a7d4')
        os.system('./autogen.sh')
        os.system('./configure --disable-dependency-tracking --prefix=%s' % conf.get('settings', 'packages'))
        os.system('make')
Exemple #4
0
 def build(self):
     stream_logger.info('Building...')
     if not os.path.exists(os.path.join(self.src_dir, self.archive_name)):
         os.system('wget %s' % self.url)
     else:
         if get_md5(os.path.join(self.src_dir, self.archive_name)) != self.md5:
             os.system('wget %s' % self.url)
     rmtree(self.dir_name)
     os.system('tar xvf %s' % self.archive_name)
Exemple #5
0
    def build(self):
        stream_logger.info('Building...')

        os.makedirs('%s/bin' % self.src_dir)
        os.chdir('%s/bin' % self.src_dir)

        os.system(
            'curl -o spilleliste https://raw.github.com/Socketubs/Spilleliste/master/spilleliste'
        )
        os.system('chmod +x spilleliste')
Exemple #6
0
 def build(self):
     stream_logger.info('Building...')
     if not os.path.exists(os.path.join(self.src_dir, self.archive_name)):
         os.system('wget %s' % self.url)
     else:
         if get_md5(os.path.join(self.src_dir,
                                 self.archive_name)) != self.md5:
             os.system('wget %s' % self.url)
     rmtree(self.dir_name)
     os.system('tar xvf %s' % self.archive_name)
Exemple #7
0
    def build(self):
        stream_logger.info('Building...')
        os.chdir(self.src_dir)

        os.system('wget http://ftp.gnu.org/gnu/wget/wget-%s.tar.gz' % self.version)
        os.system('tar xvf wget-%s.tar.gz' % self.version)
        os.system('rm wget-%s.tar.gz' % self.version)
        os.chdir('wget-%s' % self.version)
        os.system('./configure --prefix=%s' % conf.get('settings', 'packages'))
        os.system('make')
Exemple #8
0
    def build(self):
        stream_logger.info("Building...")
        os.chdir(self.src_dir)

        os.system("wget http://ftp.gnu.org/gnu/wget/wget-%s.tar.gz" % self.version)
        os.system("tar xvf wget-%s.tar.gz" % self.version)
        os.system("rm wget-%s.tar.gz" % self.version)
        os.chdir("wget-%s" % self.version)
        os.system("./configure --prefix=%s" % conf.get("settings", "packages"))
        os.system("make")
Exemple #9
0
    def build(self):
        stream_logger.info('Building...')
        os.chdir(self.src_dir)

        os.system(
            'curl -k -L https://github.com/max-horvath/htop-osx/tarball/%s-2012-04-18 | tar zx'
            % self.version)
        os.chdir('max-horvath-htop-osx-d92a7d4')
        os.system('./autogen.sh')
        os.system('./configure --disable-dependency-tracking --prefix=%s' %
                  conf.get('settings', 'packages'))
        os.system('make')
Exemple #10
0
 def pre_install(self):
     if which('pip-2.7'):
         os.system('pip-2.7 install jinja2 requests docopt appscript')
     elif which('pip2'):
         os.system('pip2 install jinja2 requests docopt appscript')
     elif which('easy_install2'):
         os.system('easy_install install jinja2 requests docopt appscript')
     elif which('easy_install-2.7'):
         os.system('easy_install-2.7 install jinja2 requests docopt appscript')
     else:
         stream_logger.info('Error: I cant find you Python package command (pip, easy_install).')
         sys.exit(1)
Exemple #11
0
 def pre_install(self):
     if which('pip-2.7'):
         os.system('pip-2.7 install jinja2 requests docopt appscript')
     elif which('pip2'):
         os.system('pip2 install jinja2 requests docopt appscript')
     elif which('easy_install2'):
         os.system('easy_install install jinja2 requests docopt appscript')
     elif which('easy_install-2.7'):
         os.system(
             'easy_install-2.7 install jinja2 requests docopt appscript')
     else:
         stream_logger.info(
             'Error: I cant find you Python package command (pip, easy_install).'
         )
         sys.exit(1)
Exemple #12
0
def archive():
    sys.path.append(os.getcwd())
    control = __import__('control', globals(), locals(), [], 0)
    sys.path.remove(os.getcwd())
    control = control.Package()

    if os.path.exists(control.name):
        stream_logger.info('Package already archived')
        sys.exit(1)

    os.makedirs(control.name)

    with open(os.path.join(control.name, 'files.lst'), 'w') as list_file:
        _pwd = os.getcwd()
        os.chdir('build')
        for (p,d,f) in os.walk('.'):
            for _f in f:
                list_file.write(os.path.join(p, _f) + '\n')
        os.chdir(_pwd)

    create_tar('build', os.path.join(control.name, 'files.bz2'), change_dir=True, mode='w:bz2')
    shutil.copyfile('control.py', os.path.join(control.name, 'control.py'))
    create_tar(control.name, '%s.tar' % control.name)
Exemple #13
0
def create(repo_name):

	if os.path.exists(repo_name):
		stream_logger.info(' :: Dir already exist')
		sys.exit(1)

	stream_logger.info(' :: Create repositorie structure')
	os.makedirs(repo_name)
	os.chdir(repo_name)
	open('.repo_root', 'w').close

	stream_logger.info(' :: Create default "stable" branch and two examples')
	os.makedirs('stable')
	os.makedirs('stable/noarch/nodist/novers')
	os.makedirs('stable/x86_64/debian/6')
Exemple #14
0
def create(repo_name):

	if os.path.exists(repo_name) and repo_name != ".":
		stream_logger.info(' :: Dir already exist')
		sys.exit(1)

	stream_logger.info(' :: Create repository structure')
	if repo_name != '.':
		os.makedirs(repo_name)
		os.chdir(repo_name)
	open('.repo_root', 'w').close

	stream_logger.info(' :: Create default "stable" branch and two examples')
	os.makedirs('stable')
	os.makedirs('stable/noarch/nodist/novers')
	os.makedirs('stable/x86_64/debian/6')
Exemple #15
0
def get_package_infos(prefix, path, name):
	infos = {}

	sys.path.append(os.path.join(path, name))
	control_module =  __import__('control')
	sys.path.remove(os.path.join(path, name))
	sys.modules.pop('control')
	control = control_module.Package()

	infos['name'] = control.name
	infos['version'] = control.version
	infos['release'] = control.release
	infos['description'] = control.description
	infos['requires'] = control.requires

	infos['arch'] = path.split('/')[1]
	infos['dist'] = path.split('/')[2]
	infos['vers'] = path.split('/')[3]

	if control.arch:
		if control.arch != infos['arch']:
			stream_logger.info('Bad arch (ignore it)')
			return False

		if control.dist:
			if control.dist != infos['dist']:
				stream_logger.info('Bad dist (ignore it)')
				return False

			if control.vers:
				if control.vers != infos['vers']:
					stream_logger.info('Bad vers (ignore it)')
					return False

	infos['md5'] = get_md5(path + '/' + name + '.tar')
	return infos
Exemple #16
0
 def package(self):
     stream_logger.info('Packaging...')
     if not os.path.exists(os.path.join(self.pkg_dir, 'tmp', 'ubik')):
         os.makedirs(os.path.join(self.pkg_dir, 'tmp', 'ubik'))
     copy(os.path.join(self.src_dir, self.archive_name), os.path.join(self.pkg_dir, 'tmp', 'ubik'))
Exemple #17
0
def create(package_name):
	name = package_name

	control_skel = """#!/bin/bash

NAME="%s"
VERSION=0.1
RELEASE=0
DESCRIPTION=""
REQUIRES=""

function pre_install(){
    echo "Pre-install $NAME $VERSION-$RELEASE ..."
}

function post_install(){
    echo "Post-install $NAME $VERSION-$RELEASE ..."
}

function pre_remove(){
    echo "Pre-remove $NAME $VERSION-$RELEASE ..."
}

function post_remove(){
    echo "Post-remove $NAME $VERSION-$RELEASE ..."
}

function pre_update(){
    echo "Pre-update $NAME $VERSION-$RELEASE ..."
}

function post_update(){
    echo "Post-update $NAME $VERSION-$RELEASE ..."
}

function purge(){
    echo "Purge $NAME $VERSION-$RELEASE ..."
}""" % name

	make_sh_skel = """#!/bin/bash

#################################
# Variables
#################################
SRC="$(pwd)/src"
DST="$(pwd)/build"
#################################

#################################
# Install
#################################
function install(){
	# Here your install procedure
	# Never forget to user $SRC and $DST
	true
}
#################################

if [ -z "$(ls -a | grep .libs.sh)" ]; then
	echo "Need to be in package root"
	exit 1
else
	. .libs.sh
fi"""

	libs_sh_skel = """#!/bin/bash

#
# This file contains libs to create package archive
# Be carefull
#

function files_listing(){
	cd build
	find ./ -type f > ../$NAME/files.lst
	find ./ -type l >> ../$NAME/files.lst
	cd ..
}

function files_blacklist(){
	for line in $(cat ./blacklist); do
		cat ./$NAME/files.lst | grep -v "$line" > ./$NAME/files.lst.tmp
		mv ./$NAME/files.lst.tmp ./$NAME/files.lst
	done
	rm ./$NAMEfiles.lst.tmp > /dev/null 2>&1
}

function help(){
	echo "Usage: make.sh (install|package|purge)"
	echo ""
	echo "  install     Build package"
	echo "  package     Create package archive"
	echo "  clean       Clean old archives"
	echo ""
}

#################################
# Make Package
#################################
function package(){
	touch ./control
	chmod +x ./control
	mkdir $NAME

	files_listing
	files_blacklist

	cd build
	tar cfj ../$NAME/files.bz2 -T ../$NAME/files.lst
	cd ..
	cp ./control $NAME
	cp ./blacklist $NAME
	tar cf $NAME.tar $NAME 
}
#################################

#################################
# Clean
#################################
function clean(){
	rm -rf $NAME > /dev/null 2>&1
	rm $NAME.tar > /dev/null 2>&1
	rm files.bz2 > /dev/null 2>&1
	rm files.lst > /dev/null 2>&1
}
#################################

. control
if [ "$1" == "install" ]; then
	install
elif [ "$1" == "package" ]; then
	package
elif [ "$1" == "clean" ]; then
	clean
else
	help
fi"""

	stream_logger.info(' :: Create %s package structure' % name)
	os.makedirs(name)
	os.chdir(name)
	os.makedirs('build')
	os.makedirs('src')
	open('blacklist', 'w').close()
	with open('control', 'w') as control:
		control.write(control_skel)
	with open('make.sh', 'w') as make_sh:
		make_sh.write(make_sh_skel)
	with open('.libs.sh', 'w') as libs_sh:
		libs_sh.write(libs_sh_skel)
	os.chmod('control', 0755)
	os.chmod('make.sh', 0755)
	stream_logger.info(' :: Done')
Exemple #18
0
    def build(self):
        stream_logger.info('=> Building...')
        os.chdir(self.src_dir)
        if not os.path.exists(self.archive_name):
            stream_logger.info('=> Downloading %s' % self.archive_name)
            os.system('wget http://www.python.org/ftp/python/%s/%s' % (self.version, self.archive_name))
        elif get_md5(self.archive_name) != self.archive_md5:
            stream_logger.info('!! Invalid archive md5')
            os.remove(self.archive_name)
            stream_logger.info('=> Downloading %s' % self.archive_name)
            os.system('wget http://www.python.org/ftp/python/%s/%s' % (self.version, self.archive_name))

        if os.path.exists(self.dir_name):
            stream_logger.info('=> Clean old builds')
            shutil.rmtree(self.dir_name)
        stream_logger.info('=> Extract archive')
        os.system('tar xvf %s' % self.archive_name)
        os.chdir(self.dir_name)
        os.system('./configure --prefix=/usr/local/ubik')
        os.system('make')
Exemple #19
0
 def package(self):
     stream_logger.info('=> Packaging...')
     os.chdir(self.src_dir)
     os.chdir(self.dir_name)
     os.system('make prefix=%s install' % self.pkg_dir)
Exemple #20
0
 def post_install(self):
     stream_logger.info(self.caveats)
Exemple #21
0
def generate(branches=False, old_format=False, tmp_dir=False):
	if not os.path.exists('.repo_root'):
		stream_logger.info(' :: Need to be at repository root')
		sys.exit(1)

	if not tmp_dir:
		prefix = os.getcwd()
	else:
		prefix = tmp_dir
		if not os.path.exists(prefix):
			os.makedirs(prefix)

	if not branches:
		branches = filter(os.path.isdir, os.listdir('.'))
	elif not isinstance(branches, list):
		branches = [branches]

	for branch in branches:
		if branch[0] == ".":
			continue
		_json = []

		for (path, dirs, files) in os.walk(branch):
			if len(path.split('/')) == 1:
				stream_logger.info(' + %s' % path.split('/')[0])
			elif len(path.split('/')) == 2:
				stream_logger.info('   |_ %s' % path.split('/')[1])
			elif len(path.split('/')) == 3:
				stream_logger.info('     |_ %s' % path.split('/')[2])
			elif len(path.split('/')) == 4:
				stream_logger.info('       |_ %s' % path.split('/')[3])
				for package in files:
					if package[-4:] != '.tar':
						stream_logger.info('         |_ %s (ignored)' % package[:-4])
						continue
					package = package[:-4]
					stream_logger.info('         |_ %s' % package)
					unarchiver(prefix, path, package)
					_json.append(get_package_infos(prefix, path, package))
					clean("%s/%s" % (prefix, path), package)
		write_packages_json(_json, branch)

	if tmp_dir:
		shutil.rmtree(prefix)
Exemple #22
0
 def build(self):
     stream_logger.info('Building...')
Exemple #23
0
    def package(self):
        stream_logger.info('Packaging...')
        os.chdir(self.src_dir)
        os.chdir('max-horvath-htop-osx-d92a7d4')

        os.system('make prefix=%s install' % self.pkg_dir)
Exemple #24
0
def create(package_name):
	name = package_name

	control_py = """# coding: utf-8
import os

from ubik_toolbelt.logger import stream_logger
from ubik_toolbelt.control import Control

class Package(Control):
    \"\"\"
        Control object attributs ::
            self.cur_dir    Current directory
            self.src_dir    Source directory
            self.pkg_dir    Build directory

        Help ::
            http://ubik.socketubs.net/toolbelt/packager.html
    \"\"\"
    def __init__(self):
        Control.__init__(self)
        self.name = '%s'
        self.version = ''
        self.release = '0'
        self.requires = []
        self.arch = ''
        self.dist = ''
        self.vers = ''
        self.description = ''

    def build(self):
        stream_logger.info('Building...')

    def package(self):
        stream_logger.info('Packaging...')

    def pre_install(self):
        pass

    def post_install(self):
        pass

    def pre_upgrade(self):
        pass

    def post_upgrade(self):
        pass

    def pre_remove(self):
        pass

    def post_remove(self):
        pass
""" % name

	stream_logger.info(' :: Create %s package structure' % name)
	os.makedirs(name)
	os.chdir(name)
	os.makedirs('build')
	os.makedirs('source')
	with open('control.py', 'w') as control:
		control.write(control_py)
	stream_logger.info(' :: Done')
Exemple #25
0
 def package(self):
     stream_logger.info('Packaging...')
     os.system('cp -p -R %s/* %s' % (self.src_dir, self.pkg_dir))
Exemple #26
0
 def package(self):
     stream_logger.info('Packaging...')
     if not os.path.exists(os.path.join(self.pkg_dir, 'tmp', 'ubik')):
         os.makedirs(os.path.join(self.pkg_dir, 'tmp', 'ubik'))
     copy(os.path.join(self.src_dir, self.archive_name),
          os.path.join(self.pkg_dir, 'tmp', 'ubik'))
Exemple #27
0
def create(package_name):
    name = package_name

    control_py = """# coding: utf-8
import os

from ubik_toolbelt.logger import stream_logger
from ubik_toolbelt.control import Control

class Package(Control):
    \"\"\"
        Control object attributs ::
            self.cur_dir    Current directory
            self.src_dir    Source directory
            self.pkg_dir    Build directory

        Help ::
            http://github.com/toxinu/ubik
    \"\"\"
    def __init__(self):
        Control.__init__(self)
        self.name = '%s'
        self.version = ''
        self.release = '0'
        self.requires = []
        self.arch = ''
        self.dist = ''
        self.vers = ''
        self.description = ''

    def build(self):
        stream_logger.info('Building...')

    def package(self):
        stream_logger.info('Packaging...')

    def pre_install(self):
        pass

    def post_install(self):
        pass

    def pre_upgrade(self):
        pass

    def post_upgrade(self):
        pass

    def pre_remove(self):
        pass

    def post_remove(self):
        pass
""" % name

    stream_logger.info(' :: Create %s package structure' % name)
    os.makedirs(name)
    os.chdir(name)
    os.makedirs('build')
    os.makedirs('source')
    with open('control.py', 'w') as control:
        control.write(control_py)
    stream_logger.info(' :: Done')
Exemple #28
0
    def package(self):
        stream_logger.info("Packaging...")
        os.chdir(self.src_dir)
        os.chdir("wget-%s" % self.version)

        os.system("make prefix=%s install" % self.pkg_dir)
Exemple #29
0
 def package(self):
     stream_logger.info("Packaging...")
     if not os.path.exists(os.path.join(self.pkg_dir, "tmp", "ubik")):
         os.makedirs(os.path.join(self.pkg_dir, "tmp", "ubik"))
     copy(os.path.join(self.src_dir, self.archive_name), os.path.join(self.pkg_dir, "tmp", "ubik"))
Exemple #30
0
    def package(self):
        stream_logger.info('Packaging...')
        os.chdir(self.src_dir)
        os.chdir('max-horvath-htop-osx-d92a7d4')

        os.system('make prefix=%s install' % self.pkg_dir)
Exemple #31
0
    def package(self):
        stream_logger.info('Packaging...')
        os.chdir(self.src_dir)
        os.chdir('wget-%s' % self.version)

        os.system('make prefix=%s install' % self.pkg_dir)
Exemple #32
0
 def post_install(self):
     stream_logger.info(self.caveats)
Exemple #33
0
 def package(self):
     stream_logger.info('Packaging...')
     os.system('cp -p -R %s/* %s' % (self.src_dir, self.pkg_dir))
Exemple #34
0
 def post_upgrade(self):
     stream_logger.info(self.caveats)
Exemple #35
0
 def package(self):
     stream_logger.info("Packaging...")
     os.system("cp -p -R %s/* %s" % (self.src_dir, self.pkg_dir))
Exemple #36
0
 def package(self):
     stream_logger.info('Packaging...')
Exemple #37
0
 def build(self):
     stream_logger.info('Building...')
Exemple #38
0
 def post_upgrade(self):
     stream_logger.info(self.caveats)
Exemple #39
0
    def package(self):
        stream_logger.info('Packaging...')
        os.chdir(self.src_dir)
        os.chdir('wget-%s' % self.version)

        os.system('make prefix=%s install' % self.pkg_dir)
Exemple #40
0
 def build(self):
     stream_logger.info("Building...")