Example #1
0
func aptlyMirrorCreate(cmd *commander.Command, args []string) {
	if len(args) < 3 {
		cmd.Usage()
		return
	}

	var architectures []string
	archs := cmd.Flag.Lookup("architecture").Value.String()
	if len(archs) > 0 {
		architectures = strings.Split(archs, ",")
	}

	repo, err := debian.NewRemoteRepo(args[0], args[1], args[2], args[3:], architectures)
	if err != nil {
		log.Fatalf("Unable to create mirror: %s", err)
	}

	err = repo.Fetch(context.downloader)
	if err != nil {
		log.Fatalf("Unable to fetch mirror: %s", err)
	}

	repoCollection := debian.NewRemoteRepoCollection(context.database)

	err = repoCollection.Add(repo)
	if err != nil {
		log.Fatalf("Unable to add mirror: %s", err)
	}

	fmt.Printf("\nMirror %s successfully added.\nYou can run 'aptly mirror update %s' to download repository contents.\n", repo, repo.Name)
}
Example #2
0
func aptlyMirrorCreate(cmd *commander.Command, args []string) error {
	var err error
	if len(args) < 3 {
		cmd.Usage()
		return err
	}

	downloadSources := utils.Config.DownloadSourcePackages || cmd.Flag.Lookup("with-sources").Value.Get().(bool)

	repo, err := debian.NewRemoteRepo(args[0], args[1], args[2], args[3:], context.architecturesList, downloadSources)
	if err != nil {
		return fmt.Errorf("unable to create mirror: %s", err)
	}

	verifier, err := getVerifier(cmd)
	if err != nil {
		return fmt.Errorf("unable to initialize GPG verifier: %s", err)
	}

	err = repo.Fetch(context.downloader, verifier)
	if err != nil {
		return fmt.Errorf("unable to fetch mirror: %s", err)
	}

	repoCollection := debian.NewRemoteRepoCollection(context.database)

	err = repoCollection.Add(repo)
	if err != nil {
		return fmt.Errorf("unable to add mirror: %s", err)
	}

	fmt.Printf("\nMirror %s successfully added.\nYou can run 'aptly mirror update %s' to download repository contents.\n", repo, repo.Name)
	return err
}