rgm

package module
v0.0.0-...-715d39d Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 8 Imported by: 0

README

NAME

rgm - A tool for mirroring multiple RPM Git repos in to one.

PkgGoDev Test Status codecov

DESCRIPTION

A common situation with Git repos for RPM packages is that there are multiple repos for different distros with similar contents. CentOS is similar to Redhat is similar to Fedora, etc.

https://src.fedoraproject.org/rpms/patch
https://git.centos.org/rpms/patch

Because they are in different repos it is difficult to perform Git operations (e.g. diff) that would be easy if they were in one repo. This tool mirrors these multiple git repos in to one repo.

$ cat config.json
[...]
    "Remotes": [
        {
            "Name": "fedora",
            "URLs": ["https://src.fedoraproject.org/rpms/{{.RPM}}.git"]
        },
        {
            "Name": "centos",
            "URLs": ["https://git.centos.org/rpms/{{.RPM}}.git"]
        }
    ]
[...]
$ rgm -C patch.rpm -c config.json -r patch
$ cd patch.rpm/
$ git branch
[...]
centos/c4
centos/c5
[...]
fedora/f30
fedora/f31

INSTALL HOWTO

This is a summary of the install steps that can also be found by looking at the Github workflow (.github/workflows/test.yml).

The following steps were verified using a plain Ubuntu 18.04 Docker container. It is different than the Github Workflow because it doesn't have all the extras included with workflows.

First, get a host or Docker container with Ubuntu 18.04.

$ docker pull ubuntu:18.04
$ docker run -it ubuntu:18.04 /bin/bash

Install the necessary system packages.

$ apt install git golang cmake libssh2-1-dev libssl-dev zlib1g-dev libpcre3-dev
$ apt install tzdata

Setup Go and build the packages.

$ mkdir $HOME/go
$ export GOPATH="$HOME/go:/usr/share/gocode"
$ export GOBIN="$HOME/go/bin"

$ go get -d github.com/jmahler/rgm

$ go get -d github.com/libgit2/git2go
$ go get -d github.com/pborman/getopt/v2
$ go get -d golang.org/x/crypto/openpg

$ cd $HOME/go/src/github.com/libgit2/git2go/
$ make test-static
$ make install-static

Build and install rgm.

$ go build github.com/jmahler/rgm github.com/jmahler/rgm/rgm
$ go install github.com/jmahler/rgm/rgm

Confirm that it can be run from the command line.

$ ~/go/bin/rgm -h
Usage: rgm [-h] [-C value] [-c value] [-r value] [parameters ...]
 -C value  path to git repo for rpm
 -c value  config file (e.g. config.json)
 -h        help
 -r value  rpm name (e.g. patch)

AUTHOR

Jeremiah Mahler <jmmahler@gmail.com>

LICENSE

Copyright © 2020, Jeremiah Mahler.
Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchAll

func FetchAll(repo *git.Repository) error

func PullAll

func PullAll(repo *git.Repository) error

Walk all the local branches and perform a git pull.

func RpmMirror

func RpmMirror(config string, rpm string, path string) error

Does all the steps to mirror an RPM: clone, setup branches, fetch, pull, etc. Will get the existing repo, in whatever state it may be in, in to an updated state.

func SetupRpmBranches

func SetupRpmBranches(repo *git.Repository) error

Setup a local branch corresponding to each remote branch.

git branch -a
...
fedora/31 -> remotes/fedora/f31

This makes sure all the local branches exist and are up to date.

func SetupRpmRemotes

func SetupRpmRemotes(repo *git.Repository, rcs []RemoteConfig) error

For an existing Git repo and an RPM (e.g. cowsay) Setup the remotes.

This is a best effort procedure. Not all remotes will be available (fedora might not have package x). As long as at least one remote works it is a success.

Types

type Config

type Config struct {
	Origin  RemoteConfig
	Remotes []RemoteConfig
}

func ExecConfigTemplate

func ExecConfigTemplate(cfg Config, rpm string) (Config, error)

Given a config object (template), fill out the variables.

"URL": ["https://src.fedoraproject.org/rpms/{{.RPM}}.git"]

func LoadConfig

func LoadConfig(config_file string) (Config, error)

type RemoteConfig

type RemoteConfig struct {
	Name string
	URL  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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