Ejemplo n.º 1
0
def build_function(target, source, env):
    top = source[0]
    if 1 < len(source): extra = ' -z ' + ' -z '.join(map(str, source[1:]))
    else: extra = ''

    action = CommandAction('$CXFREEZE $SOURCE --target-dir $TARGET' + extra)
    return action.execute(target, [top], env)
Ejemplo n.º 2
0
def build_function(target, source, env):
    nsi = str(source[0])

    env.Replace(package = str(target[0]))

    tmp = nsi + '.tmp'
    input = None
    output = None
    try:
        input = open(nsi, 'r')
        output = open(tmp, 'w')
        output.write(input.read() % env)

    finally:
        if input is not None: input.close()
        if output is not None: output.close()

    action = CommandAction('$NSISCOM $NSISOPTS ' + tmp)
    ret = action.execute(target, [tmp], env)
    if ret != 0: return ret

    if env.get('code_sign_key', None):
        cmd = '"$SIGNTOOL" sign /f "%s"' % env.get('code_sign_key')
        if 'code_sign_key_pass' in env:
            cmd += ' /p "%s"' % env.get('code_sign_key_pass')
        if 'summary' in env: cmd += ' /d "%s"' % env.get('summary')
        if 'url' in env: cmd += ' /du "%s"' % env.get('url')
        if 'timestamp_url' in env: cmd += ' /t "%s"' % env.get('timestamp_url')
        cmd += ' $TARGET'

        action = CommandAction(cmd)
        return action.execute(target, [], env)

    return 0
Ejemplo n.º 3
0
def build_function(target, source, env):
    top = source[0]
    if 1 < len(source): extra = ' -z ' + ' -z '.join(map(str, source[1:]))
    else: extra = ''

    action = CommandAction('$CXFREEZE $SOURCE --target-dir $TARGET' + extra)
    return action.execute(target, [top], env)
Ejemplo n.º 4
0
def build_function(target, source, env):
    nsi = str(source[0])

    install_files = env.get('nsis_install_files', [])

    # Find DLLs
    if 'nsi_dll_deps' in env:
        for path in env.FindDLLs(env.get('nsi_dll_deps')):
            install_files += [path]

    # Install files
    files = '\n'
    for path in install_files:
        if os.path.isdir(path):
            files += '  SetOutPath "$INSTDIR\\%s"\n' % os.path.basename(path)
            files += '  File /r "%s\\*.*"\n' % path
            files += '  SetOutPath "$INSTDIR"\n'

        else: files += '  File "%s"\n' % path

    env['NSIS_INSTALL_FILES'] = files

    # Set package name
    env.Replace(package = str(target[0]))

    if not 'PACKAGE_ARCH' in env:
        import platform
        env['PACKAGE_ARCH'] = platform.architecture()[0][:2]

    tmp = nsi + '.tmp'
    input = None
    output = None
    try:
        input = open(nsi, 'r')
        output = open(tmp, 'w')
        output.write(input.read() % env)

    finally:
        if input is not None: input.close()
        if output is not None: output.close()

    action = CommandAction('$NSISCOM $NSISOPTS ' + tmp)
    ret = action.execute(target, [tmp], env)
    if ret != 0: return ret

    if env.get('code_sign_key', None):
        cmd = '"$SIGNTOOL" sign /f "%s"' % env.get('code_sign_key')
        if 'code_sign_key_pass' in env:
            cmd += ' /p "%s"' % env.get('code_sign_key_pass')
        if 'summary' in env: cmd += ' /d "%s"' % env.get('summary')
        if 'url' in env: cmd += ' /du "%s"' % env.get('url')
        if 'timestamp_url' in env: cmd += ' /t "%s"' % env.get('timestamp_url')
        cmd += ' $TARGET'

        action = CommandAction(cmd)
        return action.execute(target, [], env)

    return 0
Ejemplo n.º 5
0
def unlock_keychain(env, keychain=None, password=None):
    if keychain is None: keychain = env.get('sign_keychain', None)
    if keychain: name = keychain
    else: name = 'default-keychain'
    if password is None:
        passfile = os.path.expanduser('~/.ssh/p')
        if os.path.isfile(passfile):
            f = None
            try:
                f = open(passfile, 'r')
                password = f.read().strip('\n')
            finally:
                if f is not None: f.close()
    if password:
        cmd = ['security', 'unlock-keychain', '-p', password]
        if keychain: cmd += [keychain]
        try:
            sanitized_cmd = cmd[:3] + ['xxxxxx']
            if keychain: sanitized_cmd += [keychain]
            print('@', sanitized_cmd)
            # returns 0 if keychain already unlocked, even if pass is wrong
            ret = CommandAction(cmd).execute(None, [], env)
            if ret:
                raise Exception('unlock-keychain failed, return code %s' %
                                str(ret))
        except Exception as e:
            print('unable to unlock keychain "%s"' % name)
            raise e
    else:
        print('skipping unlock "%s"' % name + '; no password given')
Ejemplo n.º 6
0
def build_function(target, source, env):
    nsi = str(source[0])

    env.Replace(package = str(target[0]))

    tmp = nsi + '.tmp'
    input = None
    output = None
    try:
        input = open(nsi, 'r')
        output = open(tmp, 'w')
        output.write(input.read() % env)

    finally:
        if input is not None: input.close()
        if output is not None: output.close()

    action = CommandAction('$NSISCOM $NSISOPTS ' + tmp)
    return action.execute(target, [tmp], env)
Ejemplo n.º 7
0
def build_function(target, source, env):
    nsi = str(source[0])

    env.Replace(package=str(target[0]))

    tmp = nsi + '.tmp'
    input = None
    output = None
    try:
        input = open(nsi, 'r')
        output = open(tmp, 'w')
        output.write(input.read() % env)

    finally:
        if input is not None: input.close()
        if output is not None: output.close()

    action = CommandAction('$NSISCOM $NSISOPTS ' + tmp)
    return action.execute(target, [tmp], env)
Ejemplo n.º 8
0
def build_function(target, source, env):
    nsi = str(source[0])

    install_files = env.get('nsis_install_files', [])

    # Find DLLs
    if 'nsi_dll_deps' in env:
        for path in env.FindDLLs(env.get('nsi_dll_deps')):
            install_files += [path]

    # Install files
    files = '\n'
    for path in install_files:
        if os.path.isdir(path):
            files += '  SetOutPath "$INSTDIR\\%s"\n' % os.path.basename(path)
            files += '  File /r "%s\\*.*"\n' % path
            files += '  SetOutPath "$INSTDIR"\n'

        else:
            files += '  File "%s"\n' % path

    env['NSIS_INSTALL_FILES'] = files

    # Set package name
    env.Replace(package=str(target[0]))

    if not 'PACKAGE_ARCH' in env:
        import platform
        env['PACKAGE_ARCH'] = platform.architecture()[0][:2]

    tmp = nsi + '.tmp'
    input = None
    output = None
    try:
        input = open(nsi, 'r')
        output = open(tmp, 'w')
        output.write(input.read() % env)

    finally:
        if input is not None: input.close()
        if output is not None: output.close()

    action = CommandAction('$NSISCOM $NSISOPTS ' + tmp)
    ret = action.execute(target, [tmp], env)
    if ret != 0: return ret

    if env.get('code_sign_key', None):
        cmd = '"$SIGNTOOL" sign /f "%s"' % env.get('code_sign_key')
        if 'code_sign_key_pass' in env:
            cmd += ' /p "%s"' % env.get('code_sign_key_pass')
        if 'summary' in env: cmd += ' /d "%s"' % env.get('summary')
        if 'url' in env: cmd += ' /du "%s"' % env.get('url')
        if 'timestamp_url' in env: cmd += ' /t "%s"' % env.get('timestamp_url')
        cmd += ' $TARGET'

        action = CommandAction(cmd)
        return action.execute(target, [], env)

    return 0
Ejemplo n.º 9
0
def CompileSharedLibrary(self, extra_sources = [], 
                         ctfconvert = True):
    objects = self.SharedObject(Glob('*.c') +                              \
                                Glob(PathJoin(env['PLATDIR'], '*/*.c')) +  \
                                extra_sources)
    
    # In Solaris we need to convert types from DWARF into CTF
    if self['DEBUG'] and ctfconvert and self.SupportedPlatform('solaris') and self['CTFCONVERT']:
        # ctfobjs = filter(lambda o: str(o.srcnode).endswith('.cpp'), ctfobjs)
        
        self.AddPostAction(objects, CommandAction('$CTFCONVERT -l $TSVERSION $TARGET'))
    
    return objects
Ejemplo n.º 10
0
def build_function(target, source, env):
    target = str(target[0])
    name = env.get('package_name_lower')

    # Create package build dir
    build_dir = 'build/%s-deb' % name
    if os.path.exists(build_dir): shutil.rmtree(build_dir)
    os.makedirs(build_dir, 0755)

    # Create debian control files
    shutil.copytree(env.get('deb_directory'),
                    build_dir + '/DEBIAN',
                    ignore=shutil.ignore_patterns('.svn', '*~'))

    write_control(build_dir + '/DEBIAN/control', env)

    # Copy files into package
    install_files(env, 'documents', build_dir + '/usr/share/doc/' + name)
    install_files(env, 'programs', build_dir + '/usr/bin', 0755)
    install_files(env, 'desktop_menu', build_dir + '/usr/share/applications')
    install_files(env, 'init_d', build_dir + '/etc/init.d', 0755)
    install_files(env, 'config', build_dir + '/etc/' + name)
    install_files(env, 'icons', build_dir + '/usr/share/pixmaps')

    # Dirs
    docs_dir = build_dir + '/usr/share/doc/' + name

    # Create conffiles
    filename = build_dir + '/DEBIAN/conffiles'
    f = None
    try:
        conffiles = get_files(env, 'init_d', '/etc/init.d')
        if conffiles is not None:
            for src, dst, mode in conffiles:
                if f is None: f = open(filename, 'w')
                f.write(dst + '\n')
    finally:
        if f is not None:
            f.close()
            os.chmod(filename, 0644)

    # Debian changelog
    changelog = build_dir + '/DEBIAN/changelog'
    if os.path.exists(changelog):
        dest = docs_dir + '/changelog.Debian'

        shutil.move(changelog, dest)
        cmd = 'gzip -9 ' + dest
        CommandAction(cmd).execute(dest + '.gz', [dest], env)

    # ChangeLog
    if 'changelog' in env:
        changelog = env.get('changelog')
        for changelog in [docs_dir + '/' + changelog, changelog]:
            if os.path.exists(changelog):
                dest = docs_dir + '/changelog'

                if changelog != dest: shutil.move(changelog, dest)

                # Compress
                cmd = 'gzip -9 ' + dest
                CommandAction(cmd).execute(dest + '.gz', [dest], env)

                break

    # Strip exectuables
    for src, dst, mode in get_files(env, 'programs', build_dir + '/usr/bin'):
        CommandAction('strip ' + dst).execute(dst, [dst], env)

    # Execute
    if 'deb_execute' in env:
        print env.get('deb_execute')
        cmd = string.Template(env.get('deb_execute'))
        cmd = cmd.substitute(package_root=os.path.realpath(build_dir))
        CommandAction(cmd).execute(None, [None], env)

    # Fix permissions
    for path in env.FindFiles(build_dir + '/DEBIAN'):
        mode = os.stat(path).st_mode & 0700
        mode = (mode | (mode >> 3) | (mode >> 6)) & 0755
        os.chmod(path, mode)

    # Build the package
    cmd = 'fakeroot dpkg-deb -b %s .' % build_dir
    CommandAction(cmd).execute(target, [build_dir], env)

    # Rename if necessary
    if 'package_build' in env:
        build = replace_underscore(env.get('package_build'))
        name = target.replace(build + '_', '')
        if os.path.exists(target): os.unlink(target)
        shutil.move(name, target)
Ejemplo n.º 11
0
def RunCommandOrRaise(env, cmd):
    print('@', cmd)
    ret = CommandAction(cmd).execute(None, [], env)
    if ret: raise Exception('command failed, return code %s' % str(ret))
Ejemplo n.º 12
0
def run_command(env, cmd):
    print '@', cmd
    CommandAction(cmd).execute(None, [], env)
Ejemplo n.º 13
0
def build_function(target, source, env):
    name = env.get('package_name_lower')

    # Create package build dir
    build_dir = 'build/%s-RPM' % name
    if os.path.exists(build_dir): shutil.rmtree(build_dir)
    os.makedirs(build_dir)

    # Create the SPEC file
    spec_file = 'build/%s.spec' % name
    f = None
    try:
        f = open(spec_file, 'w')

        # Create the preamble
        write_var = env.WriteVariable
        write_var(env, f, 'Summary', 'summary')
        write_var(env, f, 'Name', 'package_name_lower', None, replace_dash)
        write_var(env, f, 'Version', 'version', None, replace_dash)
        write_var(env, f, 'Release', 'package_build', '1', replace_dash)
        write_var(env, f, 'License', 'rpm_license')
        write_var(env, f, 'Group', 'rpm_group')
        write_var(env, f, 'URL', 'url')
        write_var(env, f, 'Vendor', 'vendor')
        write_var(env, f, 'Packager', 'maintainer')
        write_var(env, f, 'Icon', 'icon')
        write_var(env, f, 'Prefix', 'prefix')
        #write_var(env, f, 'BuildArch', 'package_arch', env.GetPackageArch())
        write_var(env, f, 'Provides', 'rpm_provides', multi = True)
        write_var(env, f, 'Conflicts', 'rpm_conflicts', multi = True)
        write_var(env, f, 'Obsoletes', 'rpm_obsoletes', multi = True)
        write_var(env, f, 'BuildRequires', 'rpm_build_requires', multi = True)
        write_var(env, f, 'Requires(pre)', 'rpm_pre_requires', multi = True)
        write_var(env, f, 'Requires', 'rpm_requires', multi = True)
        write_var(env, f, 'Requires(postun)', 'rpm_postun_requires',
                  multi = True)

        # Description
        write_spec_text_section(f, env, 'description', 'description')

        # Scripts
        for script in ['prep', 'build', 'install', 'clean', 'pre', 'post',
                       'preun', 'postun', 'verifyscript']:
            write_spec_script(f, env, script, 'rpm_' + script)

        # Files
        if 'rpm_filelist' in env:
            f.write('%%files -f %s\n' % env.get('rpm_filelist'))
        else: f.write('%files\n')
        f.write('%defattr(- root root)\n')

        for files in [
            ['documents', '/usr/share/doc/' + name, '%doc', None],
            ['programs', '/usr/bin', '%attr(0775 root root)', 0755],
            ['scripts', '/usr/bin', '%attr(0775 root root)', 0755],
            ['desktop_menu', '/usr/share/applications', None, None],
            ['init_d', '/etc/init.d', '%config %attr(0775 root root)', None],
            ['config', '/etc/' + name, '%config', None],
            ['icons', '/usr/share/pixmaps', None, None],
            ['mime', '/usr/share/mime/packages', None, None],
            ['platform_independent', '/usr/share/' + name, None, None],
            ]:
            install_files(f, env, files[0], build_dir, files[1], files[2],
                          files[3])

        # ChangeLog
        write_spec_text_section(f, env, 'changelog', 'rpm_changelog')

    finally:
        if f is not None: f.close()

    # Create directories needed by rpmbuild
    for dir in ['BUILD', 'BUILDROOT', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS']:
        dir = 'build/' + dir
        if not os.path.exists(dir): os.makedirs(dir)


    # Build the package
    build_dir = os.path.realpath(build_dir)
    cmd = 'rpmbuild -bb --buildroot %s --define "_topdir %s/build" ' \
        '--target %s %s' % (
        build_dir, os.getcwd(), env.GetPackageArch(), spec_file)
    CommandAction(cmd).execute(target, [build_dir], env)

    # Move the package
    target = str(target[0])
    path = 'build/RPMS/' + env.GetPackageArch() + '/' + target
    shutil.move(path, target)
Ejemplo n.º 14
0
def RunCommand(env, cmd):
    print('@', cmd)
    CommandAction(cmd).execute(None, [], env)