diff options
author | Slack Coder <slackcoder@server.ky> | 2022-03-11 13:08:24 -0500 |
---|---|---|
committer | Slack Coder <slackcoder@server.ky> | 2022-03-30 11:34:46 -0500 |
commit | 29589a24b13fb223b113e94eca2c4fff0e56a4d9 (patch) | |
tree | e1754d195463439ae2834cd502b170648e47cdb8 /cmd | |
download | pkgtools-go-29589a24b13fb223b113e94eca2c4fff0e56a4d9.tar.xz |
Initial commit
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/installpkg/main.go | 72 | ||||
-rw-r--r-- | cmd/removepkg/main.go | 28 |
2 files changed, 100 insertions, 0 deletions
diff --git a/cmd/installpkg/main.go b/cmd/installpkg/main.go new file mode 100644 index 0000000..a1561e1 --- /dev/null +++ b/cmd/installpkg/main.go @@ -0,0 +1,72 @@ +package main + +import ( + "fmt" + "os" + + "github.com/pborman/getopt/v2" + + "git.server.ky/slackcoder/pkgtools" +) + +//Usage: installpkg [options] <package_filename> +// +//Installpkg is used to install a .t{gz,bz,lz,xz} package like this: +// installpkg slackware-package-1.0.0-i486-1.tgz (or .tbz, .tlz, .txz) +// +//options: --warn (warn if files will be overwritten, but do not install) +// --root /mnt (install someplace else, like /mnt) +// --infobox (use dialog to draw an info box) +// --terse (display a one-line short description for install) +// --terselength <length> (line length in terse mode - default is +// the number of columns available) +// --menu (confirm package installation with a menu, unless +// the priority is [required] or ADD) +// --ask (used with menu mode: always ask if a package should be +// installed regardless of what the package's priority is) +// --priority ADD|REC|OPT|SKP (provide a priority for the entire +// package list to use instead of the priority in the +// tagfile) +// --tagfile /somedir/tagfile (specify a different file to use +// for package priorities. The default is "tagfile" in +// the package's directory) +// --threads <number> For xz/plzip compressed packages, set the max +// number of threads to be used for decompression. Only has +// an effect if a multithreaded compressor was used, and then +// only on large packages. For plzip, the default is equal to +// the number of CPU threads available on the machine. For xz, +// the default is equal to 2. +// --md5sum (record the package's md5sum in the metadata file) +// --no-overwrite When extracting the package, do not overwrite +// existing files. Usually, this option should not be used. +// It exists so that upgradepkg can use it for the second +// installation pass. The first pass has already overwritten +// the previous package's files, and this will catch the few +// corner cases without generating unnecessary writes. + +func ParseFlags() *pkgtools.InstallPkgFlags { + flags := pkgtools.DefaultInstallPkgFlags + flags.SetEnvValues() + + getopt.FlagLong(&flags.Root, "root", 0, "/mnt (install someplace else, like /mnt)") + //getopt.FlagLong(&flags.NoOverwrite, "no-overwrite", 0, "When extracting the package, do not overwrite existing files. Usually, this option should not be used. It exists so that upgradepkg can use it for the second installation pass. The first pass has already overwritten the previous package's files, and this will catch the few corner cases without generating unnecessary writes.") + getopt.Parse() + + return &flags +} + +func main() { + flags := ParseFlags() + if len(getopt.Args()) == 0 { + getopt.PrintUsage(os.Stdout) + return + } + + for _, pkg := range getopt.Args() { + err := pkgtools.InstallPkg(flags, pkg) + if err != nil { + fmt.Println(err) + os.Exit(-1) + } + } +} diff --git a/cmd/removepkg/main.go b/cmd/removepkg/main.go new file mode 100644 index 0000000..5970112 --- /dev/null +++ b/cmd/removepkg/main.go @@ -0,0 +1,28 @@ +package main + +import ( + "flag" + "fmt" + "os" + + "git.server.ky/slackcoder/pkgtools" +) + +func ParseFlags() *pkgtools.RemovePkgFlags { + flags := pkgtools.DefaultRemovePkgFlags + flags.SetEnvValues() + + flag.Parse() + + return &flags +} + +func main() { + flags := ParseFlags() + + err := pkgtools.RemovePkg(flags, flag.Args()...) + if err != nil { + fmt.Println(err) + os.Exit(-1) + } +} |