pkgtools

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

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 22 Imported by: 0

README

Slackware Package Tools Alternative

An alternative set of Slackware's core package management tools.

DO NOT USE! The project is experimental, and should not be used until tested adequately.

Benefits

Clear modifiable source code

These programs are written in a simple and easy to understand programming language called Golang. Slackware's official tools are written in a programming language (bash) which is harder to understand and customize.

Stable

Do you run Slackware Current? Ever mess up an update? This project will allow you to more reliably install or remove packages, making it easier to recover a broken system.

Slackware's package tools like 'installpkg' contain dependencies on commands like 'tar' and 'tar's library dependencies. These alternatives have no runtime dependencies, except when running a package's install/uninstall scripts, or ldconfig.

Contributing

Planned improvements and known issues are listed on the project's todo branch. Please check there before making any bug reports.

Whats included?

The commands 'installpkg' and 'removepkg' are included.

These tools are planned to be included:

  • explodepkg
  • upgradepkg

These tools will likely not be included:

  • makepkg
  • pkgdiff
  • pkgtool

Verifying source code

The latest project commit will be signed by the maintainer's GPG key. You will need to retreive the his key first. Pay extra attention to the key fingerprint which should remain the same.

  gpg2 --auto-key-locate=wkd --locate-keys slackcoder@server.ky
  # gpg: key 0x8D147EEA19EFF029: public key "Slack Coder <slackcoder@server.ky>" imported
  # [..]
  # sub   cv25519/0xDCA6C34C0A95B957 2022-07-17 [E] [expires: 2024-07-16]

  git -c gpg.program=gpg2 verify-commit HEAD
  # [..]
  # gpg: Good signature from "Slack Coder <slackcoder@server.ky>" [unknown]
  # [..]
  # Primary key fingerprint: D0CF FD10 75CA B8DA 3299  7507 8D14 7EEA 19EF F029

Install

The recommended way to build these tools is to call this command from within the directory. The additional parameters are recommended to minimize external dependencies.

You likely want to set the GOBIN environment variable to your preferred install location.

  go install \
    -ldflags="-linkmode external -extldflags -static" \
    -a ./cmd/...

Operation Notes

Unsupported tar attributes

These tools will exit with error in the unlikely event the package has unsupported file attributes, like PAX. You can opt to ignore them via an environment variable.

  export PKGTOOLS_GO_STRICT=NO
  installpkg some-cool-package.txz

Documentation

Index

Constants

View Source
const (
	PriorityNone        = ""
	PriorityAdditional  = "ADD"
	PriorityRecommended = "REC"
	PriorityOptional    = "OPT"
	PrioritySkip        = "SKP"
)
View Source
const (
	// InstallLockDir is used to prevent install script collisions.
	InstallLockDir = "/run/lock/pkgtools"

	// PackageInstallPath is the place for special package files.
	PackageInstallPath     = "install"
	PackageInstallScript   = "install/doinst.sh"
	PackageUninstallScript = "install/douinst.sh"
	PackageSlackDescFile   = "install/slack-desc"

	InstalledScriptPath  = "var/lib/pkgtools/scripts"
	InstalledPackagePath = "var/lib/pkgtools/packages"
	// ADMDir is the package database directories (packages, scripts).
	ADMDir = "var/lib/pkgtools"
	// Is the removed packages/scripts log files.
	TmpDir                              = "var/lib/pkgtools/setup/tmp"
	LogDir                              = "var/log/pkgtools"
	InstalledRemovedPackagePath         = "var/log/pkgtools/removed_packages"
	InstalledRemovedScriptsPath         = "var/log/pkgtools/removed_scripts"
	InstalledRemovedUninstallScriptPath = "var/log/pkgtools/removed_uninstall_scripts"
)
View Source
const (
	UnsupportedPackageFormat = "unsupported package format"
	TGZ                      = "tgz"
	TBZ                      = "tbz"
	TLZ                      = "tlz"
	TXZ                      = "txz"
)
View Source
const ADMDirPerms = 0755
View Source
const DefaultPerms = 0755
View Source
const DefaultTerseLength = 80

DefaultTerseLength is the default line length during terse mode.

View Source
const ExitStatusCorruptCompression = 2

ExitStatusCorruptCompression is when corrupt compression envelope.

View Source
const ExitStatusIncorrectExt = 3

ExitStatusIncorrectExt is when does not end in .tgz.

View Source
const ExitStatusMissingCompressionUtility = 5

ExitStatusMissingCompressionUtility is when external compression utility. missing

View Source
const ExitStatusNoSuchFile = 4

ExitStatusNoSuchFile is when no such file.

View Source
const ExitStatusTarError = 1

ExitStatusTarError is when tar returned error code.

View Source
const ExitStatusUserAbortFromMenu = 99

ExitStatusUserAbortFromMenu is when user abort from menu mode.

View Source
const LogDirPerms = 0755
View Source
const NewDirMod = 0755
View Source
const TmpDirPerms = 0700
View Source
const UninstallScript = "var/lib/pkgtools/douinst.sh"

Variables

View Source
var DefaultInstallPkgFlags = InstallPkgFlags{

	Ask:         false,
	InfoBox:     false,
	LockDir:     InstallLockDir,
	MD5Sum:      false,
	Menu:        false,
	NoOverwrite: false,
	Priority:    PriorityNone,
	Root:        "/",
	TagFile:     "",
	Terse:       false,
	TerseLength: DefaultTerseLength,
	Warn:        false,

	Strict: true,
	// contains filtered or unexported fields
}
View Source
var DefaultRemovePkgFlags = RemovePkgFlags{
	LockDir: InstallLockDir,
	Root:    "/",
}
View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var SupportedPackageTypes = []string{
	TGZ,
	TBZ,
	TXZ,
}

Functions

func CopyFile

func CopyFile(dst string, src string) error

func ExtractTar

func ExtractTar(
	cfg *TarCfg,
	fp string,
) error

func FileLockPath

func FileLockPath(dir string, f string) string

func FileSize

func FileSize(fp string) (int64, error)

func FilterTar

func FilterTar(
	r TarReader,
	filters ...TarFilter,
) error

func GetFullPackageName

func GetFullPackageName(
	root string,
	name string,
) (string, bool, error)
func GetPackageSoftLinks(root string, pkg string) ([]string, error)

func GetUncompressedSize

func GetUncompressedSize(fp string) (int64, error)

func HumanReadableSize

func HumanReadableSize(size int64) string

func InstallPkg

func InstallPkg(flags *InstallPkgFlags, pkgs ...string) error

func IsDir

func IsDir(path string) (bool, error)

func IsExist

func IsExist(path string) (bool, error)

func IsFile

func IsFile(path string) (bool, error)

func IsParentDir

func IsParentDir(parent, sub string) (bool, error)

func IsSlackwarePkg

func IsSlackwarePkg(fp string) bool
func IsSymlink(path string) (bool, error)

func ListPackages

func ListPackages(
	root string,
) ([]string, error)

func NewCompressedFileReader

func NewCompressedFileReader(
	r io.Reader,
	format PackageType,
) (io.Reader, error)

func PackageBase

func PackageBase(fp string) string

PackageBase is the package's filename without the (supported) extension.

func PackageName

func PackageName(fp string) (string, error)
func ParsePackageSoftLinks(
	str string,
) ([]string, error)
func ReadPackageSoftLinks(
	path string,
) ([]string, error)

func RemovePkg

func RemovePkg(
	flags *RemovePkgFlags,
	pkgNames ...string,
) error

func TargetPackageInfoPath

func TargetPackageInfoPath(root string, pkg string) string

func TargetPackagePath

func TargetPackagePath(root string, pkg string) string

func TargetRemovedPackagePath

func TargetRemovedPackagePath(root string, pkg string) string

func TargetRemovedUninstalllScriptPath

func TargetRemovedUninstalllScriptPath(root string, pkg string) string

func TargetScriptPath

func TargetScriptPath(root string, pkg string) string

func TargetTmpDir

func TargetTmpDir(root string) string

Types

type Encoder

type Encoder struct {
	MD5Sum bool
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) EnableMD5Sum

func (s *Encoder) EnableMD5Sum(arg bool)

func (*Encoder) Encode

func (s *Encoder) Encode(pkg *PackageInfo) error

type InstallPkgFlags

type InstallPkgFlags struct {
	Ask         bool
	InfoBox     bool
	LockDir     string
	MD5Sum      bool
	Menu        bool
	NoOverwrite bool
	Priority    string
	Root        string
	TagFile     string
	Terse       bool
	TerseLength int
	Warn        bool

	Strict bool
	// contains filtered or unexported fields
}

func (*InstallPkgFlags) SetEnvValues

func (s *InstallPkgFlags) SetEnvValues()

type PackageFormatKey

type PackageFormatKey string

type PackageInfo

type PackageInfo struct {
	Name string
	// TODO: Should be size
	CompressedPackageSize   string
	UncompressedPackageSize string
	PackageLocation         string
	PackageDescription      string
	MD5Sum                  string
	FileList                []string
}

func GetPackageInfo

func GetPackageInfo(root string, pkgName string) (*PackageInfo, error)

Use package name or package base for name

func ParsePackageInfo

func ParsePackageInfo(text string) (*PackageInfo, error)

func ReadPackageInfo

func ReadPackageInfo(fp string) (*PackageInfo, error)

type PackageType

type PackageType string

type RemovePkgFlags

type RemovePkgFlags struct {
	LockDir string
	Root    string
}

func (*RemovePkgFlags) SetEnvValues

func (s *RemovePkgFlags) SetEnvValues()

type SlackwarePkg

type SlackwarePkg struct {
	Format PackageType
	// contains filtered or unexported fields
}

func OpenSlackwarePkg

func OpenSlackwarePkg(fp string) (*SlackwarePkg, error)

func (*SlackwarePkg) Close

func (s *SlackwarePkg) Close() error

func (*SlackwarePkg) Next

func (s *SlackwarePkg) Next() (*tar.Header, error)

func (*SlackwarePkg) PkgInfo

func (s *SlackwarePkg) PkgInfo() *PackageInfo

func (*SlackwarePkg) Read

func (s *SlackwarePkg) Read(b []byte) (int, error)

type TarCfg

type TarCfg struct {
	Root  string
	Chown bool
	Chmod bool
	// Strict bails out when anything unexpected is encountered.
	Strict bool
}

type TarExtracter

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

func NewTarExtractor

func NewTarExtractor(cfg *TarCfg) *TarExtracter

func (*TarExtracter) FilterTar

func (s *TarExtracter) FilterTar(
	header *tar.Header,
	r io.Reader,
) error

type TarFilter

type TarFilter interface {
	FilterTar(header *tar.Header, r io.Reader) error
}

type TarFilterFunc

type TarFilterFunc func(
	header *tar.Header,
	r io.Reader,
) error

func (TarFilterFunc) FilterTar

func (f TarFilterFunc) FilterTar(h *tar.Header, r io.Reader) error

type TarReader

type TarReader interface {
	Next() (*tar.Header, error)
	Read([]byte) (int, error)
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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