def main():
    args = ParseArgs()
    utils.SetupLogging(quiet=args.quiet, verbose=args.verbose)
    logging.info('Arch Linux Image Builder')
    logging.info('========================')

    nobody_tmp_dir = utils.CreateTempDirectory()
    utils.ChangeDirectoryOwner('nobody', nobody_tmp_dir)

    aur_packages = InstallPackagesOnHostMachine()
    aur_packages.append(
        utils.AurBuild('google-cloud-sdk',
                       {'CLOUDSDK_CONFIG': nobody_tmp_dir})[0])
    aur_packages.append(utils.AurBuild('gce-compute-image-packages')[0])
    aur_packages.append(utils.AurBuild('google-compute-engine-oslogin-git')[0])
    aur_packages.append(utils.AurBuild('python2-google-compute-engine-git')[0])
    image_path = CreateArchImage(args, aur_packages)
    image_name, image_filename, image_description = GetImageNameAndDescription(
        args.outfile)
    image_file = SaveImage(image_path, image_filename)
    if args.upload and image_file:
        UploadImage(image_file, args.upload, make_public=args.public)
        if args.register:
            AddImageToComputeEngineProject(image_name, args.upload,
                                           image_description)
Example #2
0
def main():
    args = utils.DecodeArgs(sys.argv[1])
    utils.SetupLogging(quiet=args['quiet'], verbose=args['verbose'])
    logging.info('Setup Bootstrapper Environment')
    utils.SetupArchLocale()
    InstallPackagesForStagingEnvironment()
    image_path = os.path.join(os.getcwd(), IMAGE_FILE)
    CreateImage(image_path, size_gb=int(args['size_gb']))
    mount_path = utils.CreateTempDirectory(base_dir='/')
    image_mapping = utils.ImageMapper(image_path, mount_path)
    try:
        image_mapping.Map()
        primary_mapping = image_mapping.GetFirstMapping()
        image_mapping_path = primary_mapping['path']
        FormatImage(image_mapping_path)
        try:
            image_mapping.Mount()
            utils.CreateDirectory('/run/shm')
            utils.CreateDirectory(os.path.join(mount_path, 'run', 'shm'))
            InstallArchLinux(mount_path)
            disk_uuid = SetupFileSystem(mount_path, image_mapping_path)
            ConfigureArchInstall(args, mount_path, primary_mapping['parent'],
                                 disk_uuid)
            utils.DeleteDirectory(os.path.join(mount_path, 'run', 'shm'))
            PurgeDisk(mount_path)
        finally:
            image_mapping.Unmount()
        ShrinkDisk(image_mapping_path)
    finally:
        image_mapping.Unmap()
    utils.Run(['parted', image_path, 'set', '1', 'boot', 'on'])
    utils.Sync()
Example #3
0
def main():
    args = utils.DecodeArgs(sys.argv[1])
    utils.SetupLogging(quiet=args['quiet'], verbose=args['verbose'])
    logging.info('Setup Bootstrapper Environment')
    SetupLocale()
    ConfigureTimeZone()
    ConfigureKernel()
    InstallBootloader(args['device'], args['disk_uuid'], args['debugmode'])
    ForwardSystemdToConsole()
    SetupNtpServer()
    SetupNetwork()
    SetupSsh()
    #SetupFail2ban()
    SetupAccounts(args)
    InstallGcePackages(args['packages_dir'])
    ConfigMessageOfTheDay()
    ConfigureSecurity()
    ConfigureSerialPortOutput()
    OptimizePackages()
def main():
  args = ParseArgs()
  utils.SetupLogging(quiet=args.quiet, verbose=args.verbose)
  logging.info('Arch Linux Image Builder')
  logging.info('========================')
  
  workspace_dir = None
  image_file = None
  try:
    aur_packages = InstallPackagesOnHostMachine()
    image_path = CreateArchImage(args, aur_packages)
    image_name, image_filename, image_description = GetImageNameAndDescription(
        args.outfile)
    image_file = SaveImage(image_path, image_filename)
    if args.upload and image_file:
      UploadImage(image_file, args.upload, make_public=args.public)
      if args.register:
        AddImageToComputeEngineProject(
            image_name, args.upload, image_description)
  finally:
    if not args.nocleanup and workspace_dir:
      utils.DeleteDirectory(workspace_dir)
def main():
    args = ParseArgs()
    utils.SetupLogging(quiet=args.quiet, verbose=args.verbose)
    workspace_dir = None
    image_file = None
    try:
        workspace_dir = utils.CreateTempDirectory()
        bootstrap_file = DownloadArchBootstrap(args.bootstrap)
        utils.Untar(bootstrap_file, workspace_dir)
        arch_root = PrepareBootstrap(workspace_dir, args.mirror,
                                     not args.nopacmankeys)
        relative_builder_path = utils.CopyBuilder(arch_root)
        ChrootIntoArchAndBuild(arch_root, relative_builder_path, args)
        image_name, image_filename, image_description = GetImageNameAndDescription(
            args.outfile)
        image_file = SaveImage(arch_root, image_filename)
        if args.upload and image_file:
            UploadImage(image_file, args.upload, make_public=args.public)
            if args.register:
                AddImageToComputeEngineProject(image_name, args.upload,
                                               image_description)
    finally:
        if not args.nocleanup and workspace_dir:
            utils.DeleteDirectory(workspace_dir)
Example #6
0
        for script in dataBuildScript:
            logging.info("Running script: \"" + script + "\"")
            proc = subprocess.Popen( \
                ['python.exe', '-u', absDataSrcDir + "/" + script] + sys.argv[1:], \
                stdout = subprocess.PIPE, \
                stderr = subprocess.STDOUT, \
                cwd = absDataSrcDir)
            for line in iter(proc.stdout.readline, ""):
                logging.info(line.replace('\n', '').replace('\r', ''))
            if proc.wait() != 0:
                logging.info(script + " has failed!")
                return 1
            logging.info("")

    # Done! Print some info.
    logging.info("Done compiling data in " + str(time.clock() - start) +
                 " seconds.")

    return 0


########

##############
# Run script #
##############

if __name__ == "__main__":
    utils.SetupLogging("DataBuild")
    sys.exit(Run())
Example #7
0
    logging.info("Starting tools build process...")
    logging.info("Force rebuild: " + str(defaultForceRebuild))
    logging.info("Architecture: " + defaultArchitecture)
    logging.info("")
    for dep in toolsName:
        startPerTool = time.clock()
        if utils.BuildSLN(dep, buildEnvPath, defaultPlatform + "_" + defaultArchitecture, "Release", defaultForceRebuild) != 0:
            logging.error("Could not complete tool build process")
            return 1
        # Done! Print some info.
        infoStr = "Done building"
        infoStr += " " + dep
        logging.info(infoStr + " (" + defaultArchitecture + ") in " + str(time.clock() - startPerTool) + " seconds.")
        logging.info("")

    logging.info("Done building tools in " + str(time.clock() - start) + " seconds.")

    return 0

########



##############
# Run script #
##############

if __name__ == "__main__":
    utils.SetupLogging("ToolsBuild")
    sys.exit(Run())
Example #8
0
    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


########

##############
# Run script #
##############

if __name__ == "__main__":
    utils.SetupLogging("ProjectBuild")
    sys.exit(Run())