Exemple #1
0
def update_package():

    import requests,BeautifulSoup
    page = requests.get('http://www.piriform.com/ccleaner/download/standard',headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'}).text
    bs = BeautifulSoup.BeautifulSoup(page)
    download = bs.find(id="BigDownload").a["href"]
    filename = download.rsplit('/',1)[1]

    # on ne telecharge que si on ne l'a pas deja
    if not isfile(filename):
        wget(download, filename)
    else:
        print(u'Le setup %s est déjà présent dans le paquet.' % filename)

    # on enleve les vieux exes
    for fn in glob.glob('*.exe'):
        if fn != filename :
            print('Suppression du vieux exe %s'%fn)
            remove_file(fn)

    vers = get_file_properties(filename)['ProductVersion']
    os.chdir(os.path.dirname(__file__))
    from waptpackage import PackageEntry
    pe = PackageEntry()
    pe.load_control_from_wapt(os.getcwd())
    pe.version = vers + '-0'
    pe.save_control_to_wapt(os.getcwd())
Exemple #2
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()
Exemple #3
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()
Exemple #4
0
def update_sources():

    import urllib2
    import requests

    """I download the file >>>"""

    sock = urllib2.urlopen("http://www.7-zip.org/download.html",timeout=10)
    htmlSource = sock.readlines()
    sock.close()
    for line in htmlSource :
        if  'x64.msi'  in line :
            start = line.find('href=')
            end = line.find('">D')
            x64 = line[start + 6:end]
            x86 = x64.replace("-x64.msi",".msi")
            break

    allmsi = glob.glob('*.msi')
    for msi in allmsi:
        remove_file(msi)

    wget('http://www.7-zip.org/%s' % x64, x64.rsplit('/')[-1])
    wget('http://www.7-zip.org/%s' % x86, x86.rsplit('/')[-1])



    """I retrieve the current version from the msi """

    allmsi = glob.glob('*.msi')
    for msi in allmsi:
        vers = get_msi_properties(msi)['ProductVersion']
        break

    """I write the version in the control file >>>"""

    os.chdir(os.path.dirname(__file__))

    from waptpackage import PackageEntry
    pe = PackageEntry()
    pe.load_control_from_wapt(os.getcwd())

    pe.version = vers + '-0'
    pe.save_control_to_wapt(os.getcwd())
Exemple #5
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()