bpm

package module
v0.0.0-...-a45bf93 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: GPL-3.0 Imports: 34 Imported by: 0

README

bpm is a package manager

  • bpm manages deploying files and trees of files, which it calls Assets to target paths in the filesystem.
  • bpm stores state in a single directory, which can be configured with the environment variable BPM_PATH. This defaults to $HOME/pkg.
  • Assets are labeled with key value pairs, called Labels. Assets can be searched for by label.
  • bpm knows about external Sources of assets which you can query with bpm search.
  • bpm keeps track of all the assets deployed at given time as a Snapshot.

For more information check out the docs

Getting Started

Installing BPM

Download the bpm binary and place it somewhere on your path.

It can also be built and installed with go. The entry point is at cmd/bpm in this repository. $GOBIN must be on your path for this to work.

go install github.com/blobcache/bpm/cmd/bpm
Initializing a BPM_PATH

Then initialize bpm in the default directory. If you choose a different directory, you will need to set an environment variable BPM_PATH to that directory.

$ bpm init $HOME/pkg

bpm will only operate on directories for which it has been explicitly initialized. These initialized directories will contain a .bpm directory.

Now you should be ready to go. If you ever want to uninstall bpm without leaving anything behind, you can remove the entire BPM_PATH

Installing Packages

Search is used to search a source for packages

$ bpm search --fetch github:protocolbuffers/protobuf '.git_tag > v0.0.5'

The fetch flag will access the remote over the network. It is necessary to pass --fetch the first time a source is accessed. By default, bpm search only accesses the local filesystem, not the network.

The first argument to bpm search is the source URL. The second argument is an option query, using the jq language. The query must resolve to a boolean. If the boolean is true, then the result is included.

Install
$ bpm install github:protocolbuffers/protobuf --id=asset/asdff

Creating Packages

$ bpm create [-t <tag>] <path>
<id>
$ bpm add-tag <id> <key> <value>
$ bpm rm-tag <id> <key> <value>

Distributing Packages

BPM will eventually support a way of natively distributing packages. For now developers should continue using GitHub releases, which bpm has support for.

BPM can distribute packages over both INET256 and QUIC

bpm serve --private-key=./path/to/key
bpm serve-quic --private-key=./path/to/key <listen-addr>

Documentation

Index

Constants

View Source
const MaxBlobSize = 1 << 21

Variables

This section is empty.

Functions

func GLFSExport

func GLFSExport(ctx context.Context, op *glfs.Operator, sem *semaphore.Weighted, s cadata.Getter, root glfs.Ref, fsx posixfs.FS, p string) error

GLFSExport exports a glfs object beneath p in the filesystem fsx.

func GLFSImport

func GLFSImport(ctx context.Context, op *glfs.Operator, sem *semaphore.Weighted, s cadata.Poster, fsx posixfs.FS, p string) (*glfs.Ref, error)

GLFSImport goes from a POSIX filesystem to GLFS

func Hash

func Hash(x []byte) cadata.ID

Hash is the hash function used by BPM

func Init

func Init(ctx context.Context, p string) error

Init creates a new repo under the path p, which must be a directory

func MakeSource

func MakeSource(u sources.URL) (sources.Source, error)

MakeSource creates a new source from a URL

Types

type Asset

type Asset struct {
	ID       uint64       `json:"id"`
	Labels   LabelSet     `json:"labels"`
	Root     glfs.Ref     `json:"root"`
	Upstream *UpstreamURL `json:"upstream"`
}

func (Asset) IsLocal

func (a Asset) IsLocal() bool

type Commit

type Commit struct {
	ID uint64 `json:"id"`

	Snapshot  SnapshotID `json:"snapshot"`
	CreatedAt time.Time  `json:"created_at"`
}

type DeploySpec

type DeploySpec struct {
	Source sources.URL `json:"source"`
	Query  string      `json:"query"`
}

type Label

type Label = bpmmd.Label

type LabelSet

type LabelSet = bpmmd.LabelSet

type Manifest

type Manifest map[string]DeploySpec

type Repo

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

func New

func New(db *sqlx.DB, dir posixfs.FS) *Repo

func Open

func Open(p string) (*Repo, error)

Open opens the repo in the directory at p

func (*Repo) CreateAsset

func (r *Repo) CreateAsset(ctx context.Context) (uint64, error)

CreateAsset creates an empty Asset.

func (*Repo) CreateAssetFS

func (r *Repo) CreateAssetFS(ctx context.Context, fsx posixfs.FS, p string) (uint64, error)

CreateAssetFS creates an Asset with data from the filesystem.

func (*Repo) Deploy

func (r *Repo) Deploy(ctx context.Context, id SnapshotID) (*Commit, error)

Deploy creates a new commit, and deploys the snapshot to the filesystem

func (*Repo) DeploymentDir

func (r *Repo) DeploymentDir() posixfs.FS

DeploymentDir is the directory in the filesystem used for deployments

func (*Repo) Fetch

func (r *Repo) Fetch(ctx context.Context, srcURL sources.URL) error

Fetch creates metadata-only assets for all of assets in the source.

func (*Repo) FetchAll

func (r *Repo) FetchAll(ctx context.Context) error

func (*Repo) GetAsset

func (r *Repo) GetAsset(ctx context.Context, aid uint64) (Asset, error)

func (*Repo) GetCommit

func (r *Repo) GetCommit(ctx context.Context, commitID uint64) (*Commit, error)

func (*Repo) GetCurrent

func (r *Repo) GetCurrent(ctx context.Context) (*Commit, error)

func (*Repo) GetLabels

func (r *Repo) GetLabels(ctx context.Context, aid uint64) ([]Label, error)

GetTags returns the labels for an asset

func (*Repo) GetSnapshot

func (r *Repo) GetSnapshot(ctx context.Context, id SnapshotID) (*Snapshot, error)

func (*Repo) Import

func (r *Repo) Import(ctx context.Context, aid uint64, fsx posixfs.FS, p string) error

Import adds an object outside the repository into an asset.

func (*Repo) ListAssets

func (r *Repo) ListAssets(ctx context.Context, span state.Span[uint64], limit int) ([]uint64, error)

func (*Repo) ListAssetsBySource

func (r *Repo) ListAssetsBySource(ctx context.Context, srcURL *sources.URL, code *gojq.Code) ([]Asset, error)

Search searches locally cached remote assets for a source. To search assets originating locally pass nil for srcURL

func (*Repo) ListAssetsFull

func (r *Repo) ListAssetsFull(ctx context.Context, span state.Span[uint64], limit int) ([]Asset, error)

func (*Repo) ListCommits

func (r *Repo) ListCommits(ctx context.Context) ([]Commit, error)

func (*Repo) ListSnapshots

func (r *Repo) ListSnapshots(ctx context.Context) ([]SnapshotID, error)

func (*Repo) ListSnapshotsFull

func (r *Repo) ListSnapshotsFull(ctx context.Context) ([]Snapshot, error)

func (*Repo) Modfiy

func (r *Repo) Modfiy(ctx context.Context, fn func(tlds map[string]glfs.Ref) error) (*Commit, error)

func (*Repo) ModifySnapshot

func (r *Repo) ModifySnapshot(ctx context.Context, id SnapshotID, fn func(tlds map[string]glfs.Ref) error) (*SnapshotID, error)

func (*Repo) PostSnapshot

func (r *Repo) PostSnapshot(ctx context.Context, tlds map[string]glfs.Ref) (*SnapshotID, error)

func (*Repo) Pull

func (r *Repo) Pull(ctx context.Context, u sources.URL, idstr string) (uint64, error)

Pull pulls the content for an asset from source

func (*Repo) PutLabels

func (r *Repo) PutLabels(ctx context.Context, aid uint64, labels []Label) error

PutTags inserts or replaces each label.

type Snapshot

type Snapshot struct {
	ID   SnapshotID          `json:"id"`
	TLDs map[string]glfs.Ref `json:"tlds"`
}

type SnapshotID

type SnapshotID = cadata.ID

type UpstreamURL

type UpstreamURL struct {
	sources.URL
	ID string `json:"id"`
}

UpstreamURL uniquely identifies a remote asset

func (UpstreamURL) String

func (u UpstreamURL) String() string

type WebRefStore

type WebRefStore interface {
	state.Putter[cadata.ID, webref.Ref]
	state.Getter[cadata.ID, webref.Ref]
}

Directories

Path Synopsis
Package bpmmd contains types for dealing with metadata
Package bpmmd contains types for dealing with metadata
cmd
bpm
internal

Jump to

Keyboard shortcuts

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