createrepo

package module
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

README

createrepo

Go Reference Go Report Card

Package createrepo implements methods for creating and maintaing an RPM repo.

Installation

The recommended way to install createrepo

go get github.com/stianwa/createrepo

Examples

// Package main implements the CLI of createrepo - a program used for
// creating RPM repositories on a local file system.
package main

import (
	"createrepo/internal/createrepo"
	"flag"
	"fmt"
	"os"
)

var opt struct {
	Group   string
	Verbose bool
	Expunge int64
}

func init() {
	flag.String("", "", "Path to repo base")
	flag.StringVar(&opt.Group, "g", "", "Comps group `file`")
	flag.BoolVar(&opt.Verbose, "v", false, "Verbose output")
	flag.Int64Var(&opt.Expunge, "e", 172800, "Expunge dead meta data older than `n` seconds.")
	flag.Parse()
}

func main() {
	config := &createrepo.Config{WriteConfig: true, CompsFile: opt.Group, ExpungeOldMetadata: opt.Expunge}

	for _, arg := range flag.Args() {
		r, err := createrepo.NewRepo(arg, config)
		if err != nil {
			abortProgram("new repo: %v", err)
		}

		summary, err := r.Create()
		if err != nil {
			abortProgram("create repo: %v", err)
		}

		fmt.Println(summary)
	}

	return
}

func abortProgram(format string, a ...any) {
	fmt.Fprintf(os.Stderr, format + "\n", a...)
	os.Exit(-1)
}

State

The createrepo module is currently under development. Do not use for production.

License

GPLv3, see LICENSE.md

Documentation

Overview

Package createrepo provides methods for creating and maintaining an RPM repository.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// CompressAlgo specifies which compression algorithm to be
	// used for compressing the meta files. Supported algorithms
	// are: xz (default) and gz.
	CompressAlgo string `yaml:"compressAlgo,omitempty"`

	// CompsFile specifies a path to a comps group (yumgroup)
	// file, if used.
	CompsFile string `yaml:"compsFile,omitempty"`

	// ExpungeOldMetadata specifies the time in seconds when old
	// metadata should be deleted from disk and history. The
	// default is 172800 (48 hours).
	ExpungeOldMetadata int64 `yaml:"expungeOldMetadata"`

	// WriteConfig writes this Config to disk.
	WriteConfig bool `yaml:"-"`
}

Config represents a configuration for repo.

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo represents the repo handler.

func NewRepo

func NewRepo(dir string, config *Config) (*Repo, error)

NewRepo returns a new repo handler. The directory is mandatory, and must exists. If *Config is nil, the config file in the repodata will be read. If the file doesn't exist, a new default Config will be created and saved to disk.

func (*Repo) Create

func (r *Repo) Create() (*Summary, error)

Create creates or updates the epository.

type Summary

type Summary struct {
	Dir      string
	RPMs     int
	Updated  bool
	Expunged int
}

Summary represents the Create summary.

func (*Summary) String

func (s *Summary) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL