Beispiel #1
0
def set_app_ico(lpi_path, edition):
    (lpi_rootname, lpi_ext) = os.path.splitext(lpi_path)
    appico_path = lpi_rootname + '.ico'
    source_ico = setuphelpers.makepath(wapt_root_dir, 'wapt-%s.ico' % edition)
    if not os.path.isfile(source_ico):
        source_ico = setuphelpers.makepath(wapt_root_dir, 'wapt.ico')
    setuphelpers.filecopyto(source_ico, appico_path)
Beispiel #2
0
def set_app_ico(lpi_path,edition):
    (lpi_rootname,lpi_ext) = os.path.splitext(lpi_path)
    appico_path = lpi_rootname+'.ico'
    source_ico = setuphelpers.makepath(wapt_root_dir,'wapt-%s.ico'%edition)
    if not os.path.isfile(source_ico):
        source_ico = setuphelpers.makepath(wapt_root_dir,'wapt.ico')
    setuphelpers.filecopyto(source_ico,appico_path)
Beispiel #3
0
def build_waptupgrade_package(waptconfigfile,
                              target_directory=None,
                              wapt_server_user=None,
                              wapt_server_passwd=None,
                              key_password=None,
                              sign_digests=None):
    if target_directory is None:
        target_directory = tempfile.gettempdir()

    if not wapt_server_user:
        wapt_server_user = raw_input('WAPT Server user :'******'WAPT Server password :'******'ascii')

    wapt = common.Wapt(config_filename=waptconfigfile,
                       disable_update_server_status=True)
    wapt.dbpath = r':memory:'
    wapt.use_hostpackages = False

    if sign_digests is None:
        sign_digests = wapt.sign_digests

    if not wapt.personal_certificate_path or not os.path.isfile(
            wapt.personal_certificate_path):
        raise Exception(
            u'No personal certificate provided or not found (%s) for signing waptupgrade package'
            % wapt.personal_certificate_path)

    waptget = get_file_properties('wapt-get.exe')
    entry = PackageEntry(waptfile=makepath(wapt.wapt_base_dir, 'waptupgrade'))
    patchs_dir = makepath(entry.sourcespath, 'patchs')
    mkdirs(patchs_dir)
    filecopyto(makepath(wapt.wapt_base_dir, 'waptdeploy.exe'),
               makepath(patchs_dir, 'waptdeploy.exe'))

    entry.package = '%s-waptupgrade' % wapt.config.get(
        'global', 'default_package_prefix')
    rev = entry.version.split('-')[1]
    entry.version = '%s-%s' % (waptget['FileVersion'], rev)
    entry.inc_build()
    entry.save_control_to_wapt()
    entry.build_package(target_directory=target_directory)
    certs = wapt.personal_certificate()
    key = wapt.private_key(private_key_password=key_password)
    if not certs[0].is_code_signing:
        raise Exception(u'%s is not a code signing certificate' %
                        wapt.personal_certificate_path)
    entry.sign_package(private_key=key,
                       certificate=certs,
                       private_key_password=key_password,
                       mds=ensure_list(sign_digests))

    wapt.http_upload_package(entry.localpath,
                             wapt_server_user=wapt_server_user,
                             wapt_server_passwd=wapt_server_passwd)
    return entry.as_dict()
Beispiel #4
0
def build_waptupgrade_package(waptconfigfile,target_directory=None,wapt_server_user=None,wapt_server_passwd=None,key_password=None,sign_digests=None,priority='critical'):
    if target_directory is None:
        target_directory = tempfile.gettempdir()

    if not wapt_server_user:
        wapt_server_user = raw_input('WAPT Server user :'******'WAPT Server password :'******'ascii')

    wapt = common.Wapt(config_filename=waptconfigfile,disable_update_server_status=True)
    wapt.dbpath = r':memory:'
    wapt.use_hostpackages = False

    # try to get a progress hook inside waptconsole
    try:
        import waptconsole
        progress_hook = waptconsole.UpdateProgress
    except ImportError:
        def print_progress(show=False,n=0,max=100,msg=''):
            if show:
                print('%s %s/%s\r' % (msg,n,max),end='')
            else:
                if not msg:
                    msg='Done'
                print("%s%s"%(msg,' '*(80-len(msg))))
        progress_hook = print_progress

    wapt.progress_hook = progress_hook

    if sign_digests is None:
        sign_digests = wapt.sign_digests

    if not wapt.personal_certificate_path or not os.path.isfile(wapt.personal_certificate_path):
        raise Exception(u'No personal certificate provided or not found (%s) for signing waptupgrade package' % wapt.personal_certificate_path)

    waptget = get_file_properties('wapt-get.exe')
    entry = PackageEntry(waptfile = makepath(wapt.wapt_base_dir,'waptupgrade'))
    patchs_dir = makepath(entry.sourcespath,'patchs')
    mkdirs(patchs_dir)
    filecopyto(makepath(wapt.wapt_base_dir,'waptdeploy.exe'),makepath(patchs_dir,'waptdeploy.exe'))

    entry.package = '%s-waptupgrade' % wapt.config.get('global','default_package_prefix')
    rev = entry.version.split('-')[1]
    entry.version = '%s-%s' % (waptget['FileVersion'],rev)
    entry.inc_build()
    entry.save_control_to_wapt()
    entry.build_package(target_directory=target_directory)
    entry.priority = priority
    certs = wapt.personal_certificate()
    key = wapt.private_key(private_key_password=key_password)
    if not certs[0].is_code_signing:
        raise Exception(u'%s is not a code signing certificate' % wapt.personal_certificate_path)
    entry.sign_package(private_key=key,certificate = certs,private_key_password=key_password,mds = ensure_list(sign_digests))

    wapt.http_upload_package(entry.localpath,wapt_server_user=wapt_server_user,wapt_server_passwd=wapt_server_passwd,progress_hook=progress_hook)
    return entry.as_dict()
Beispiel #5
0
def create_wapt_setup(wapt,default_public_cert='',default_repo_url='',default_wapt_server='',destination='',company=''):
    r"""Build a customized waptsetup with provided certificate included.
    Returns filename

    >>> from common import Wapt
    >>> wapt = Wapt(config_filename=r'C:\Users\htouvet\AppData\Local\waptconsole\waptconsole.ini')
    >>> create_wapt_setup(wapt,r'C:\private\ht.crt',destination='c:\\tranquilit\\wapt\\waptsetup')
    u'c:\\tranquilit\\wapt\\waptsetup\\waptsetup.exe'
    """
    if not company:
        company = registered_organization()
    outputfile = ''
    iss_template = makepath(wapt.wapt_base_dir,'waptsetup','waptsetup.iss')
    custom_iss = makepath(wapt.wapt_base_dir,'waptsetup','custom_waptsetup.iss')
    iss = codecs.open(iss_template,'r',encoding='utf8').read().splitlines()
    new_iss=[]
    for line in iss:
        if line.startswith('#define default_repo_url'):
            new_iss.append('#define default_repo_url "%s"' % (default_repo_url))
        elif line.startswith('#define default_wapt_server'):
            new_iss.append('#define default_wapt_server "%s"' % (default_wapt_server))
        elif line.startswith('#define output_dir'):
            new_iss.append('#define output_dir "%s"' % (destination))
        elif line.startswith('#define Company'):
            new_iss.append('#define Company "%s"' % (company))
        elif line.startswith('#define install_certs'):
            new_iss.append('#define install_certs')
        elif line.startswith('WizardImageFile='):
            pass
        elif not line.startswith('#define signtool'):
            new_iss.append(line)
            if line.startswith('OutputBaseFilename'):
                outputfile = makepath(wapt.wapt_base_dir,'waptsetup','%s.exe' % line.split('=')[1])
    source = os.path.normpath(default_public_cert)
    target = os.path.join(os.path.dirname(iss_template),'..','ssl')
    if not (os.path.normcase(os.path.abspath( os.path.dirname(source))) == os.path.normcase(os.path.abspath(target))):
        filecopyto(source,target)
    codecs.open(custom_iss,'wb',encoding='utf8').write('\n'.join(new_iss))
    #inno_directory = '%s\\Inno Setup 5\\Compil32.exe' % programfiles32
    inno_directory =  makepath(wapt.wapt_base_dir,'waptsetup','innosetup','ISCC.exe')
    if not os.path.isfile(inno_directory):
        raise Exception(u"Innosetup n'est pas disponible (emplacement %s), veuillez l'installer" % inno_directory)
    run('"%s"  %s' % (inno_directory,custom_iss))
    #print('%s compiled successfully' % (outputfile, ))

    # create a sha256 file for waptupgrade package
    result = os.path.abspath(os.path.join(destination,os.path.basename(outputfile)))
    with open(makepath(wapt.wapt_base_dir,'waptupgrade','waptagent.sha256'),'wb') as f:
        f.write("%s %s\n" % (sha256_for_file(result),'waptagent.exe'))
    return result
Beispiel #6
0
def set_app_ico(lpi_path, edition):
    (lpi_rootname, lpi_ext) = os.path.splitext(lpi_path)
    appico_path = lpi_rootname + '.ico'
    if not lpi_rootname.endswith('waptself'):
        source_ico = setuphelpers.makepath(wapt_root_dir,
                                           'wapt-%s.ico' % edition)
        if not os.path.isfile(source_ico):
            source_ico = setuphelpers.makepath(wapt_root_dir, 'wapt.ico')
    else:
        source_ico = setuphelpers.makepath(wapt_root_dir, 'waptself',
                                           'waptself-%s.ico' % edition.lower())
        if not os.path.isfile(source_ico):
            source_ico = setuphelpers.makepath(wapt_root_dir, 'waptself',
                                               'waptself-community.ico')
    setuphelpers.filecopyto(source_ico, appico_path)
Beispiel #7
0
def build_waptupgrade_package(wapt,
                              mainrepo,
                              sources_directory=None,
                              target_directory=None,
                              wapt_server_user=None,
                              wapt_server_passwd=None,
                              key_password=None,
                              sign_digests=None,
                              priority='critical'):
    if target_directory is None:
        target_directory = tempfile.gettempdir()

    if not wapt_server_user:
        wapt_server_user = raw_input('WAPT Server user :'******'WAPT Server password :'******'ascii')

    if sign_digests is None:
        sign_digests = wapt.sign_digests

    if not wapt.personal_certificate_path or not os.path.isfile(
            wapt.personal_certificate_path):
        raise Exception(
            u'No personal certificate provided or not found (%s) for signing waptupgrade package'
            % wapt.personal_certificate_path)

    waptget = get_file_properties('wapt-get.exe')
    if sources_directory is None:
        sources_directory = makepath(wapt.wapt_base_dir, 'waptupgrade')
    entry = PackageEntry(waptfile=sources_directory)
    patchs_dir = makepath(entry.sourcespath, 'patchs')
    mkdirs(patchs_dir)
    filecopyto(makepath(wapt.wapt_base_dir, 'waptdeploy.exe'),
               makepath(patchs_dir, 'waptdeploy.exe'))
    mainrepo.update()
    entry.package = '%s-waptupgrade' % wapt.config.get(
        'global', 'default_package_prefix')
    existing = mainrepo.packages_matching(PackageRequest(entry.package))
    if existing:
        rev = sorted(existing)[-1].version.split('-')[1]
    else:
        rev = entry.version.split('-')[1]
    entry.version = '%s-%s' % (waptget['FileVersion'], rev)
    entry.inc_build()
    entry.priority = priority
    entry.save_control_to_wapt()
    entry.build_package(target_directory=target_directory)
    certs = wapt.personal_certificate()
    key = wapt.private_key(private_key_password=key_password)
    if not certs[0].is_code_signing:
        raise Exception(u'%s is not a code signing certificate' %
                        wapt.personal_certificate_path)
    entry.sign_package(private_key=key,
                       certificate=certs,
                       private_key_password=key_password,
                       mds=ensure_list(sign_digests))

    wapt.http_upload_package(entry.localpath,
                             wapt_server_user=wapt_server_user,
                             wapt_server_passwd=wapt_server_passwd,
                             progress_hook=wapt.progress_hook)
    mainrepo.update()
    return entry.as_dict()
Beispiel #8
0
def create_wapt_setup(wapt,
                      default_public_cert='',
                      default_repo_url='',
                      default_wapt_server='',
                      destination='',
                      company=''):
    r"""Build a customized waptsetup with provided certificate included.
    Returns filename

    >>> from common import Wapt
    >>> wapt = Wapt(config_filename=r'C:\Users\htouvet\AppData\Local\waptconsole\waptconsole.ini')
    >>> create_wapt_setup(wapt,r'C:\private\ht.crt',destination='c:\\tranquilit\\wapt\\waptsetup')
    u'c:\\tranquilit\\wapt\\waptsetup\\waptsetup.exe'
    """
    if not company and sys.platform == 'win32':
        company = registered_organization()
    outputfile = ''
    iss_template = makepath(wapt.wapt_base_dir, 'waptsetup', 'waptsetup.iss')
    custom_iss = makepath(wapt.wapt_base_dir, 'waptsetup',
                          'custom_waptsetup.iss')
    iss = codecs.open(iss_template, 'r', encoding='utf8').read().splitlines()
    new_iss = []
    for line in iss:
        if line.startswith('#define default_repo_url'):
            new_iss.append('#define default_repo_url "%s"' %
                           (default_repo_url))
        elif line.startswith('#define default_wapt_server'):
            new_iss.append('#define default_wapt_server "%s"' %
                           (default_wapt_server))
        elif line.startswith('#define output_dir'):
            new_iss.append('#define output_dir "%s"' % (destination))
        elif line.startswith('#define Company'):
            new_iss.append('#define Company "%s"' % (company))
        elif line.startswith('#define install_certs'):
            new_iss.append('#define install_certs')
        elif line.startswith('WizardImageFile='):
            pass
        elif not line.startswith('#define signtool'):
            new_iss.append(line)
            if line.startswith('OutputBaseFilename'):
                outputfile = makepath(wapt.wapt_base_dir, 'waptsetup',
                                      '%s.exe' % line.split('=')[1])
    source = os.path.normpath(default_public_cert)
    target = os.path.join(os.path.dirname(iss_template), '..', 'ssl')
    if not (os.path.normcase(os.path.abspath(os.path.dirname(source)))
            == os.path.normcase(os.path.abspath(target))):
        filecopyto(source, target)
    codecs.open(custom_iss, 'wb', encoding='utf8').write('\n'.join(new_iss))
    #inno_directory = '%s\\Inno Setup 5\\Compil32.exe' % programfiles32
    inno_directory = makepath(wapt.wapt_base_dir, 'waptsetup', 'innosetup',
                              'ISCC.exe')
    if not os.path.isfile(inno_directory):
        raise Exception(
            u"Innosetup n'est pas disponible (emplacement %s), veuillez l'installer"
            % inno_directory)
    run('"%s"  %s' % (inno_directory, custom_iss))
    #print('%s compiled successfully' % (outputfile, ))

    # create a sha256 file for waptupgrade package
    result = os.path.abspath(
        os.path.join(destination, os.path.basename(outputfile)))
    with open(makepath(wapt.wapt_base_dir, 'waptupgrade', 'waptagent.sha256'),
              'wb') as f:
        f.write("%s %s\n" % (sha256_for_file(result), 'waptagent.exe'))
    return result