Example #1
0
def InstallComputeImagePackages(packages_dir):
    utils.LogStep('Install compute-image-packages')
    utils.Run([
        "egrep -lRZ 'python' %s | "
        "xargs -0 -l sed -i -e '/#!.*python/c\#!/usr/bin/env python2'" %
        packages_dir
    ],
              shell=True)
    utils.CopyFiles(os.path.join(packages_dir, 'google-daemon', '*'), '/')
    utils.CopyFiles(os.path.join(packages_dir, 'google-startup-scripts', '*'),
                    '/')
    utils.SecureDeleteFile('/README.md')
    # TODO: Fix gcimagebundle does not work with Arch yet.
    #InstallGcimagebundle(packages_dir)

    # Patch Google services to run after the network is actually available.
    PatchGoogleSystemdService(
        '/usr/lib/systemd/system/google-startup-scripts.service')
    PatchGoogleSystemdService(
        '/usr/lib/systemd/system/google-accounts-manager.service')
    PatchGoogleSystemdService(
        '/usr/lib/systemd/system/google-address-manager.service')
    PatchGoogleSystemdService('/usr/lib/systemd/system/google.service')
    utils.EnableService('google-accounts-manager.service')
    utils.EnableService('google-address-manager.service')
    utils.EnableService('google.service')
    utils.EnableService('google-startup-scripts.service')
    utils.DeleteDirectory(packages_dir)
def ConfigureArchInstall(args, mount_path, parent_path, disk_uuid, aur_packages):
  relative_builder_path = utils.CopyBuilder(mount_path)
  packages_dir = utils.CreateTempDirectory(mount_path)
  utils.Run(['git', 'clone', COMPUTE_IMAGE_PACKAGES_GIT_URL, packages_dir])
  utils.CreateDirectory(os.path.join(mount_path, ''))
  aur_packages_dir = os.path.join(packages_dir, 'aur')
  for aur_package in aur_packages:
    utils.CopyFiles(aur_package, aur_packages_dir + '/')
  packages_dir = os.path.relpath(packages_dir, mount_path)
  params = {
    'packages_dir': '/%s' % packages_dir,
    'device': parent_path,
    'disk_uuid': disk_uuid,
    'accounts': args.accounts,
    'debugmode': args.debug,
    'quiet': args.quiet,
    'verbose': args.verbose,
    'packages': args.packages,
    'size_gb': args.size_gb
  }
  config_arch_py = os.path.join(
      '/', relative_builder_path, 'arch-image.py')
  utils.RunChroot(mount_path,
                  '%s "%s"' % (config_arch_py, utils.EncodeArgs(params)),
                  use_custom_path=False)
  utils.DeleteDirectory(os.path.join(mount_path, relative_builder_path))
Example #3
0
def InstallBootloader(device, uuid, debugmode):
    utils.LogStep('Install Syslinux bootloader')
    '''
  utils.Run(['syslinux-install_update', '-i', '-a', '-m'])
  '''
    utils.Run(['blkid', '-s', 'PTTYPE', '-o', 'value', device])
    utils.CreateDirectory('/boot/syslinux')
    utils.CopyFiles('/usr/lib/syslinux/bios/*.c32', '/boot/syslinux/')
    utils.Run(['extlinux', '--install', '/boot/syslinux'])
    utils.Replace('/boot/syslinux/syslinux.cfg', 'sda3', 'sda1')
    utils.Run(['fdisk', '-l', device])
    utils.Run([
        'dd', 'bs=440', 'count=1', 'conv=notrunc',
        'if=/usr/lib/syslinux/bios/mbr.bin',
        'of=%s' % device
    ])

    boot_params = [
        'console=ttyS0,38400',
        'CONFIG_KVM_GUEST=y',
        'CONFIG_KVM_CLOCK=y',
        'CONFIG_VIRTIO_PCI=y',
        'CONFIG_SCSI_VIRTIO=y',
        'CONFIG_VIRTIO_NET=y',
        'CONFIG_STRICT_DEVMEM=y',
        'CONFIG_DEVKMEM=n',
        'CONFIG_DEFAULT_MMAP_MIN_ADDR=65536',
        'CONFIG_DEBUG_RODATA=y',
        'CONFIG_DEBUG_SET_MODULE_RONX=y',
        'CONFIG_CC_STACKPROTECTOR=y',
        'CONFIG_COMPAT_VDSO=n',
        'CONFIG_COMPAT_BRK=n',
        'CONFIG_X86_PAE=y',
        'CONFIG_SYN_COOKIES=y',
        'CONFIG_SECURITY_YAMA=y',
        'CONFIG_SECURITY_YAMA_STACKED=y',
    ]
    if debugmode:
        boot_params += [
            'systemd.log_level=debug',
            'systemd.log_target=console',
            'systemd.journald.forward_to_syslog=yes',
            'systemd.journald.forward_to_kmsg=yes',
            'systemd.journald.forward_to_console=yes',
        ]
    boot_params = ' '.join(boot_params)
    boot_spec = '    APPEND root=UUID=%s rw append %s' % (uuid, boot_params)
    utils.ReplaceLine('/boot/syslinux/syslinux.cfg', 'APPEND root=', boot_spec)
Example #4
0
def Run():
    #################
    # Configuration #
    #################

    # Name of .sln file for the current project
    projectName = "GITechDemo"

    defaultForceRebuild = False
    defaultBuildConfiguration = "Release"
    defaultArchitecture = "x64"
    defaultPlatform = "Windows"

    #################

    ########
    # Main #
    ########

    # Start timer
    start = time.clock()

    # Process command arguments
    for opt in sys.argv:
        if (opt.lower() == "rebuild"):
            defaultForceRebuild = True
        if (opt.lower() == "release"):
            defaultBuildConfiguration = "Release"
        if (opt.lower() == "profile"):
            defaultBuildConfiguration = "Profile"
        if (opt.lower() == "x64"):
            defaultArchitecture = "x64"
        if (opt.lower() == "x86"):
            defaultArchitecture = "x86"
        if (opt.lower() == "windows"):
            defaultPlatform = "Windows"

    # Compile tools, if required
    build_tools.Run()
    logging.info("")

    # Compile data, if required
    build_data.Run()
    logging.info("")

    # Setup build tools
    buildEnvPath = utils.FindBuildEnvironment()
    if buildEnvPath == "":
        logging.error("No compatible version of Visual Studio found!")
        return 1

    # Compile project
    logging.info("Starting project build process...")
    logging.info("Force rebuild: " + str(defaultForceRebuild))
    logging.info("Build configuration: " + defaultBuildConfiguration)
    logging.info("Architecture: " + defaultArchitecture)
    logging.info("")

    startProjectBuild = time.clock()
    if utils.BuildSLN(projectName, buildEnvPath,
                      defaultPlatform + "_" + defaultArchitecture,
                      defaultBuildConfiguration, defaultForceRebuild) != 0:
        logging.error("Could not complete project build process")
        return 1
    else:
        logging.info( \
            "Done building " + projectName + \
            " (" + defaultBuildConfiguration + "|" + defaultArchitecture + ") in " + \
            str(time.clock() - startProjectBuild) + " seconds.")
        logging.info("")

    # Copy and organize build files
    logging.info("Configuring build:")

    # Create directory structure
    logging.info("Creating directory structure...")
    rootBuildDir = os.path.realpath(utils.GetScriptAbsolutePath() + "/" +
                                    defaultPlatform + "/" + projectName + "/")
    utils.MakeDir(rootBuildDir)

    # Copy binaries
    logging.info("Copying binaries...")
    pathToBinaries = [
        utils.GetScriptAbsolutePath() + "/../Bin/" + defaultArchitecture +
        "/" + defaultBuildConfiguration + "/" + projectName + "/", rootBuildDir
    ]
    utils.CopyFiles(pathToBinaries[0], pathToBinaries[1], "*.exe")
    utils.CopyFiles(pathToBinaries[0], pathToBinaries[1], "*.dll")

    # Copy data
    logging.info("Copying data...")
    utils.CopyTree(utils.GetScriptAbsolutePath() + "/../Data/", rootBuildDir)

    logging.info("")

    # Done! Print some info.
    logging.info("Done building project " + projectName + " (" +
                 defaultBuildConfiguration + "|" + defaultArchitecture +
                 ") in " + str(time.clock() - start) + " seconds.")

    return 0