├── LICENSE ├── Makefile ├── README.md ├── doc └── print.png ├── man ├── vpsm.1 └── vpsm.md └── vpsm /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) [2018] [Sinésio Santos da Silva Neto] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PREFIX ?= /usr/local 2 | DESTDIR= 3 | 4 | .PHONY: all 5 | all: 6 | @echo 'nothing to do.' 7 | 8 | .PHONY: man 9 | man: man/vpsm.1 10 | man/vsv.8: man/vpsm.md 11 | go-md2man -in $^ -out $@ 12 | 13 | .PHONY: clean 14 | clean: 15 | rm -f man/vpsm.1 16 | 17 | .PHONY: install 18 | install: 19 | install -Dm4755 vpsm $(DESTDIR)$(PREFIX)/bin/vpsm 20 | install -Dm644 man/vpsm.1 $(DESTDIR)/$(PREFIX)/share/man/man1/vpsm.1 21 | 22 | .PHONY: uninstall 23 | uninstall: 24 | rm -f $(PREFIX)/bin/vpsm 25 | rm -f $(PREFIX)/share/man/man1/vpsm.1 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Void-Packages Sources Management wrapper for XBPS-SRC. 2 | ![vpsm](https://github.com/sinetoami/vpsm/raw/master/doc/print.png) 3 | **vpsm** was made specifically for [Void Linux][0]. Is a simple wrapper for [**xbps-src**][1] commands that allows handling binary packages sources, query, smooth the workflow of the creation of new packages - and a little more. Also used to substitute some commands from [**xtools**][2] collection utilities. 4 | 5 | ## Motivation 6 | Strongly inspired by [vpm][3] (originally created by [Armin Jenewein][4]) and [vsv][5] wrappers to management *xbps-** and *sv* commands respectively. I felt encouraged to write some similar idea after learning about the creation of new packages to Void Linux. I noticed the workflow is very repetitive and it's also necessary to be inside the [void-packages][6] local repository to make things work. This bothered me a little... ~~because I'm lazy~~. So, with the purpose to make things work easily and from anywhere in the terminal, I started it. 7 | 8 | ## Dependencies 9 | * Void Linux 10 | * git 11 | * void-packages repository [cloned] 12 | * ripgrep 13 | * xtools 14 | 15 | ## Instalation 16 | ### 0. Fork Void Linux’s void-packages repository 17 | ### 1. Clone the void-packages repository forked 18 | On my enviroment I like keep it inside my `$HOME` path 19 | ```bash 20 | $ git clone git@github.com:my-github-username/void-packages.git ~/.void-packages 21 | ``` 22 | 23 | ### 2. export `XBPS_DISTDIR` 24 | Export in your `.bashrc` or `.zshrc`, or any other _rc_ file what you want, the `XBPS_DISTDIR=/path/to/void-packages/`. 25 | ```bash 26 | $ echo "export XBPS_DISTDIR=$HOME/.void-packages" >> ~/.zshrc 27 | ``` 28 | 29 | ### 3. Clone this repository 30 | ```bash 31 | $ git clone https://github.com/sinetoami/vpsm.git 32 | ``` 33 | 34 | ### 4. Add the `vspm` executable to `PATH` 35 | For example, exporting inside `.zshrc` file 36 | ```bash 37 | export PATH=$PATH:/path/to/vpsm/directory 38 | ``` 39 | I like to create a hidden `.bin` directory on my `$HOME` path and add it to `$PATH` var, move/copy/link the `vpsm` executable. But you can do it any way you like. 40 | ```bash 41 | $ mkdir ~/.bin 42 | $ git clone https://github.com/sinetoami/vpsm.git ~/vpsm 43 | $ cd vpsm 44 | $ ln -s ~/vpsm/vpsm ~/.bin/ 45 | $ echo "export PATH=$PATH:$HOME/.bin" >> ~/.zshrc 46 | ``` 47 | 48 | ## Installation using Makefile 49 | Before installing using this method, you need to know two things: 50 | * The default `PREFIX` path is set to `/usr/local` - you can change it. 51 | * If you changes the `PREFIX`, make sure it's in the `PATH`. 52 | ```bash 53 | $ sudo make install 54 | 55 | or 56 | 57 | $ sudo make install PREFIX=/new/path 58 | ``` 59 | 60 | ## Usage 61 | ``` 62 | USAGE: 63 | 64 | vpsm [OPTIONS] [SUBCOMMANDS] [] 65 | 66 | OPTIONS: 67 | 68 | --color= - Enable/Disable colorized output (default: auto) 69 | --help - (same as: help) 70 | --help-pager - (same as: helppager) 71 | 72 | 73 | GIT SUBCOMMANDS: 74 | 75 | add-changes (ac) - Add work changes in your clone repository. 76 | add-remote-repo (arr) - Add new remote repo in your clone repository. 77 | checkout-branch (co) - Switch branch. 78 | commit-changes (cc) - Commits changes added. 79 | create-branch (cb) - Create a new branch. 80 | delete-branch (delb) - Delete a existing branch. 81 | pull (pp) - Pull commit from . 82 | pull-request (pr) [message] - Create a pull-request [optional message]. 83 | push-commit (pc) - Push commits to . 84 | update-repo (upr) - Pull commits from void-linux official repo. 85 | 86 | 87 | XBPS-SRC SUBCOMMANDS: 88 | 89 | binbootstrap (bb) - Install bootstrap packages from host repositories into . 90 | bootstrap-up (bu) - Updates bootstrap packages. 91 | build-environment - Configure environment to create binary packages. 92 | edit-template (et) - Edit template. 93 | install (i) - Build binary package for and all required dependencies and install. 94 | lint (li) - Scan XBPS template for common mistakes. 95 | list (l) - Lists installed packages in . 96 | pkg - Only build binary package for and all required dependencies. 97 | purge-distfiles (pdistf) - Removes all obsolete distfiles in /sources. 98 | searchbin (sb) - Search in /binpkgs for package by (use xbps-query). 99 | searchsrc (ss) - Search in for package by . 100 | show (sw) - Show information for the specified package. 101 | show-build-deps (bdeps) - Show required build dependencies for . 102 | show-deps (rdeps) - Show required run-time dependencies for . 103 | uninstall (un) - Uninstall and purge distfiles for . 104 | update-bulk (upb) - Rebuilds all packages in the system repositories that are outdated. 105 | update-check (upc) - Check upstream site of for new releases. 106 | update-sys (ups) - Rebuilds packages in system and updates them. 107 | xgsum - Generate SHA256 for template. 108 | xinstall (xi) - Like xbps-install -S , but take cwd repo and sudo/su into account. 109 | ``` 110 | 111 | ## Examples 112 | #### Query some package from `srcpkgs` directory 113 | ```bash 114 | $ vpsm searchsrc chrome 115 | [vpsm] Searching (srcpkgs) -> chrome (search_result chrome): 116 | [-] chrome-gnome-shell - GNOME Shell integration for Chrome 117 | [*] google-chrome - An attempt at creating a safer, faster, and more stable browser 118 | [-] mkchromecast - Cast Linux Audio/Video to Google cast and Sonos devices 119 | [-] python3-chromecast - Python3 library to communicate with Google Chromecast 120 | [-] xf86-video-openchrome - Xorg driver for VIA IGPs 121 | [vpsm] [search_result chrome], return code was: 0 122 | ``` 123 | 124 | #### Update upstream repository 125 | ```bash 126 | $ vpsm update-repo 127 | [vpsm] Pull commits from void-linux official repo->void-linux 128 | Switched to branch 'master' 129 | Your branch is up to date with 'origin/master'. 130 | ... 131 | From https://github.com/void-linux/void-packages 132 | * branch master -> FETCH_HEAD 133 | 485822d38b..d3df1d1680 master -> void-linux/master 134 | Updating 485822d38b..d3df1d1680 135 | Fast-forward 136 | README.md | 2 +- 137 | srcpkgs/GCP-Guest-Environment/template | 10 +++------- 138 | srcpkgs/NetworkManager/template | 4 ++-- 139 | srcpkgs/aisleriot/template | 4 ++-- 140 | srcpkgs/ampache/template | 4 ++-- 141 | ... 142 | srcpkgs/xsoldier/template | 16 ---------------- 143 | 27 files changed, 113 insertions(+), 94 deletions(-) 144 | ... 145 | Current branch master is up to date. 146 | ... 147 | => xbps-src: updating /home/sineto/.void-packages/masterdir ... 148 | [*] Updating `https://alpha.de.repo.voidlinux.org/current/x86_64-repodata' ... 149 | ... 150 | `https://alpha.de.repo.voidlinux.org/current/aarch64/x86_64-repodata': Not Found 151 | ``` 152 | 153 | #### Show required build dependencies 154 | ```bash 155 | $ vpsm show-build-deps vivaldi 156 | [vpsm] Show required build dependencies -> vivaldi (./xbps-src show-build-deps vivaldi): 157 | desktop-file-utils 158 | hicolor-icon-theme 159 | [vpsm] [./xbps-src show-build-deps vivaldi], return code was: 0 160 | ``` 161 | 162 | ## References 163 | * Xbps-src - Void Linux Wiki - https://wiki.voidlinux.eu/Xbps-src 164 | * Void Packages Manual - https://github.com/sinetoami/void-packages/blob/master/Manual.md 165 | * VoidLinux's quick PR guide - https://forum.voidlinux.org/t/voidlinuxs-quick-pr-guide/6333 166 | 167 | ## Special thanks 168 | * [Dave Eddy](https://github.com/bahamas10) - From whom I copied a piece of code from his [vpm][3] 169 | fork and the Makefile file. 170 | * [shizonic](https://github.com/shizonic) - For encouraging me to continue with this small project. 171 | 172 | Thank you guys! Cheers! 173 | 174 | ## Self-Promotion 175 | Do you like this plugin? Come on: 176 | - Star and follow the repository on [GitHub](https://github.com/sinetoami/vpsm). 177 | - Follow me on 178 | - [GitHub](https://github.com/sinetoami) 179 | 180 | ## License 181 | [MIT License](https://raw.githubusercontent.com/sinetoami/vpsm/master/LICENSE) 182 | 183 | 184 | [0]: https://voidlinux.org 185 | [1]: https://github.com/void-linux/void-packages/blob/master/xbps-src 186 | [2]: https://github.com/chneukirchen/xtools 187 | [3]: https://github.com/bahamas10/vpm 188 | [4]: https://github.com/netzverweigerer/vpm 189 | [5]: https://github.com/bahamas10/vsv 190 | [6]: https://github.com/void-linux/void-packages 191 | -------------------------------------------------------------------------------- /doc/print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sineto/vpsm/f82152942adfb18f156bd87c7f98314b03f89007/doc/print.png -------------------------------------------------------------------------------- /man/vpsm.1: -------------------------------------------------------------------------------- 1 | .TH VPSM 1 "OCTUBER 2018" Linux "User Manuals" 2 | .SH NAME 3 | .PP 4 | vpsm \- void\-packages sources management wrapper for xbps\-src. 5 | 6 | .SH SYNOPSIS 7 | .PP 8 | \fBvpsm\fP [\fIOPTIONS\fP] [\fISUBCOMMANDS\fP] [\fI\fP] 9 | 10 | .SH DESCRIPTION 11 | .PP 12 | \fBvpsm\fP was made specifically for Void Linux. Is a simple wrapper for \fBxbps\-src\fP commands that allows handling binary packages sources, query, smooth the workflow of the creation of new packages \- and a little more. Also used to substitute some commands from \fBxtools\fP(1) collection utilities. 13 | 14 | .SH OPTIONS 15 | .PP 16 | \fB\-\-color=\fP\fI\fP 17 | Enable/Disable colorized output (default: auto) 18 | 19 | .PP 20 | \fB\-\-help\fP 21 | (same as: help). 22 | 23 | .PP 24 | \fB\-\-help\-pager\fP 25 | (same as: helppager). 26 | 27 | .SH GIT SUBCOMMANDS 28 | .PP 29 | \fBadd\-changes, ac\fP \fI[file]\fP 30 | Add worked changes to the cloned repository \- more details 31 | \fBgit\-add\fP(1). 32 | 33 | .PP 34 | \fBadd\-remote\-repo, arr\fP \fI \fP 35 | Add new remote repository to the cloned repository. 36 | 37 | .PP 38 | \fBcheckout\-branch, co\fP \fI\fP 39 | Switch branch. 40 | 41 | .PP 42 | \fBcommit\-changes, cc\fP 43 | Commits changes added \- the message will be something like "New 44 | package: my\-package\-name\-0.1\_1". 45 | 46 | .PP 47 | \fBcreate\-branch, cb\fP \fI\fP 48 | Create a new branch. 49 | 50 | .PP 51 | \fBdelete\-branch, delb\fP \fI\fP 52 | Delete a existing branch. 53 | 54 | .PP 55 | \fBlist\-branches, lb\fP 56 | List all branches. 57 | 58 | .PP 59 | \fBlog, lg\fP \fI\fP 60 | Commit log for \fB\fC\fR XBPS template 61 | 62 | .PP 63 | \fBlog\-graph, lgg\fP 64 | Commit graph for all commits and branches 65 | 66 | .PP 67 | \fBpull, pp\fP \fI \fP 68 | Pull commit from \fB\fC \fR\&. 69 | 70 | .PP 71 | \fBpull\-request, pr\fP \fI[message]\fP 72 | Create a pull\-request \- [optional message]. 73 | 74 | .PP 75 | \fBpush\-commit, pc\fP \fI \fP 76 | Push commits to \fB\fC \fR\&. 77 | 78 | .PP 79 | \fBupdate\-repo, upr\fP 80 | Pull commits from Void Linux's void\-packages repository. 81 | 82 | .SH XBPS\-SRC SUBCOMMANDS 83 | .PP 84 | \fBbinbootstrap, bb\fP 85 | Install bootstrap packages from host repositories into \fB\fC\fR\&. 86 | 87 | .PP 88 | \fBbootstrap\-up, bu\fP 89 | Updates bootstrap packages. 90 | 91 | .PP 92 | \fBbuild\-environment\fP 93 | Configure environment to create binary packages. 94 | 95 | .PP 96 | \fBedit\-template, et\fP \fI\fP 97 | Edit \fB\fC\fR template. 98 | 99 | .PP 100 | \fBinstall, i\fP \fI\fP 101 | Build binary package for \fB\fC\fR, all required dependencies and 102 | install. 103 | 104 | .PP 105 | \fBlint, li\fP \fI\fP 106 | Scan XBPS \fB\fC\fR template for common mistakes. 107 | 108 | .PP 109 | \fBlist, l\fP 110 | Lists installed packages in \fB\fC\fR\&. 111 | 112 | .PP 113 | \fBlog, lg\fP \fI\fP 114 | Commit log for \fB\fC\fR XBPS template. 115 | 116 | .PP 117 | \fBmypkgs, mp\fP \fI[email]\fP 118 | List all pkgs maintained by the owner repository. 119 | Pass a [email] to list pkgs maintained by other owner than yourself. 120 | 121 | .PP 122 | \fBnew, n\fP \fI\fP 123 | Create a new \fB\fC\fR package. 124 | 125 | .PP 126 | \fBpkg\fP \fI\fP 127 | Only build binary package for \fB\fC\fR and all required 128 | dependencies. 129 | 130 | .PP 131 | \fBpurge\-distfiles, pdistf\fP 132 | Removes all obsolete distfiles in \fB\fC/sources\fR\&. 133 | 134 | .PP 135 | \fBsearchbin, sb\fP \fI\fP 136 | Search in \fB\fC/binpkgs\fR for package by \fB\fC\fR \- use \fBxbps\-query\fP(1). 137 | 138 | .PP 139 | \fBsearchsrc, ss\fP \fI\fP 140 | Search in \fB\fC\fR for package by \fB\fC\fR\&. 141 | 142 | .PP 143 | \fBshow, sw\fP \fI\fP 144 | Show information for the specified package. 145 | 146 | .PP 147 | \fBshow\-build\-deps, bdeps\fP \fI\fP 148 | Show required build dependencies for \fB\fC\fR\&. 149 | 150 | .PP 151 | \fBshow\-deps, rdeps\fP \fI\fP 152 | Show required run\-time dependencies for \fB\fC\fR\&. 153 | 154 | .PP 155 | \fBuninstall, un\fP \fI\fP 156 | Uninstall and purge distfiles for \fB\fC\fR\&. 157 | 158 | .PP 159 | \fBupdate\-bulk, upb\fP 160 | Rebuilds all packages in the system repositories that are outdated. 161 | 162 | .PP 163 | \fBupdate\-check, upc\fP \fI\fP 164 | Check upstream site of \fB\fC\fR for new releases. 165 | 166 | .PP 167 | \fBupdate\-sys, ups\fP 168 | Rebuilds packages in system and updates them. 169 | 170 | .PP 171 | \fBxgsum\fP \fI\fP 172 | Generate SHA256 for \fB\fC\fR template \- more details \fBxtools\fP(1). 173 | 174 | .PP 175 | \fBxinstall, xi\fP \fI\fP 176 | Like xbps\-install \-S \fB\fC\fR, but take cwd repo and sudo/su into 177 | account. 178 | 179 | .SH ENVIRONMENT 180 | .PP 181 | \fBXBPS\_DISTDIR\fP 182 | The void\-packages repository directory path passed to the \fBvpsm\fP 183 | command. 184 | 185 | .SH BUGS 186 | .PP 187 | All bugs should be reported to 188 | \[la]https://github.com/sinetoami/vpsm\[ra] 189 | 190 | .SH AUTHOR 191 | .PP 192 | \fB\fCSinésio Neto \fR 193 | 194 | .SH SEE ALSO 195 | .PP 196 | \fBxtools\fP(1), \fBgit\-add\fP(1), \fBxbps\-query\fP(1) 197 | 198 | .SH SEE ALSO 199 | .PP 200 | MIT License 201 | -------------------------------------------------------------------------------- /man/vpsm.md: -------------------------------------------------------------------------------- 1 | VPSM 1 "OCTUBER 2018" Linux "User Manuals" 2 | ======================================= 3 | 4 | NAME 5 | ---- 6 | 7 | vpsm - void-packages sources management wrapper for xbps-src. 8 | 9 | SYNOPSIS 10 | -------- 11 | 12 | **vpsm** [*OPTIONS*] [*SUBCOMMANDS*] [**] 13 | 14 | DESCRIPTION 15 | ----------- 16 | 17 | **vpsm** was made specifically for Void Linux. Is a simple wrapper for **xbps-src** commands that allows handling binary packages sources, query, smooth the workflow of the creation of new packages - and a little more. Also used to substitute some commands from **xtools**(1) collection utilities. 18 | 19 | OPTIONS 20 | ------- 21 | 22 | **--color=**** 23 | Enable/Disable colorized output (default: auto) 24 | 25 | **--help** 26 | (same as: help). 27 | 28 | **--help-pager** 29 | (same as: helppager). 30 | 31 | 32 | GIT SUBCOMMANDS 33 | ------- 34 | 35 | **add-changes, ac** *[file]* 36 | Add worked changes to the cloned repository - more details 37 | **git-add**(1). 38 | 39 | **add-remote-repo, arr** * * 40 | Add new remote repository to the cloned repository. 41 | 42 | **checkout-branch, co** ** 43 | Switch branch. 44 | 45 | **commit-changes, cc** 46 | Commits changes added - the message will be something like "New 47 | package: my-package-name-0.1_1". 48 | 49 | **create-branch, cb** ** 50 | Create a new branch. 51 | 52 | **delete-branch, delb** ** 53 | Delete a existing branch. 54 | 55 | **list-branches, lb** 56 | List all branches. 57 | 58 | **log, lg** ** 59 | Commit log for `` XBPS template 60 | 61 | **log-graph, lgg** 62 | Commit graph for all commits and branches 63 | 64 | **pull, pp** * * 65 | Pull commit from ` `. 66 | 67 | **pull-request, pr** *[message]* 68 | Create a pull-request - [optional message]. 69 | 70 | **push-commit, pc** * * 71 | Push commits to ` `. 72 | 73 | **update-repo, upr** 74 | Pull commits from Void Linux's void-packages repository. 75 | 76 | XBPS-SRC SUBCOMMANDS 77 | ------- 78 | 79 | **binbootstrap, bb** 80 | Install bootstrap packages from host repositories into ``. 81 | 82 | **bootstrap-up, bu** 83 | Updates bootstrap packages. 84 | 85 | **build-environment** 86 | Configure environment to create binary packages. 87 | 88 | **edit-template, et** ** 89 | Edit `` template. 90 | 91 | **install, i** ** 92 | Build binary package for ``, all required dependencies and 93 | install. 94 | 95 | **lint, li** ** 96 | Scan XBPS `` template for common mistakes. 97 | 98 | **list, l** 99 | Lists installed packages in ``. 100 | 101 | **log, lg** ** 102 | Commit log for `` XBPS template. 103 | 104 | **mypkgs, mp** *[email]* 105 | List all pkgs maintained by the owner repository. 106 | Pass a [email] to list pkgs maintained by other owner than yourself. 107 | 108 | **new, n** ** 109 | Create a new `` package. 110 | 111 | **pkg** ** 112 | Only build binary package for `` and all required 113 | dependencies. 114 | 115 | **purge-distfiles, pdistf** 116 | Removes all obsolete distfiles in `/sources`. 117 | 118 | **searchbin, sb** ** 119 | Search in `/binpkgs` for package by `` - use **xbps-query**(1). 120 | 121 | **searchsrc, ss** ** 122 | Search in `` for package by ``. 123 | 124 | **show, sw** ** 125 | Show information for the specified package. 126 | 127 | **show-build-deps, bdeps** ** 128 | Show required build dependencies for ``. 129 | 130 | **show-deps, rdeps** ** 131 | Show required run-time dependencies for ``. 132 | 133 | **uninstall, un** ** 134 | Uninstall and purge distfiles for ``. 135 | 136 | **update-bulk, upb** 137 | Rebuilds all packages in the system repositories that are outdated. 138 | 139 | **update-check, upc** ** 140 | Check upstream site of `` for new releases. 141 | 142 | **update-sys, ups** 143 | Rebuilds packages in system and updates them. 144 | 145 | **xgsum** ** 146 | Generate SHA256 for `` template - more details **xtools**(1). 147 | 148 | **xinstall, xi** ** 149 | Like xbps-install -S ``, but take cwd repo and sudo/su into 150 | account. 151 | 152 | ENVIRONMENT 153 | ----- 154 | 155 | **XBPS_DISTDIR** 156 | The void-packages repository directory path passed to the **vpsm** 157 | command. 158 | 159 | BUGS 160 | ---- 161 | 162 | All bugs should be reported to https://github.com/sinetoami/vpsm 163 | 164 | AUTHOR 165 | ------ 166 | 167 | `Sinésio Neto ` 168 | 169 | SEE ALSO 170 | -------- 171 | 172 | **xtools**(1), **git-add**(1), **xbps-query**(1) 173 | 174 | SEE ALSO 175 | -------- 176 | MIT License 177 | -------------------------------------------------------------------------------- /vpsm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | progname=${0##*/} 3 | 4 | numcolorok=2 5 | numcolorfail=1 6 | numcolorlogo=5 7 | numcolorheader=3 8 | numcolortext=4 9 | numcolorgray=2 10 | numcolorpkgcount=8 11 | numcolordarkgray=11 12 | numcolorbrackets=6 13 | 14 | # enable or disable colors based on the argument given, i.e.: 15 | # setcolors on # colors on 16 | # setcolors off # colors off 17 | # setcolors auto # colors on or off depending on environment 18 | declare -A COLORS 19 | setcolors () { 20 | local opt=$1 21 | 22 | # determine if colors should be enabled or not 23 | if [[ $opt == auto ]]; then 24 | # if stdout is a TTY and the TERM looks like it supports color enable colors 25 | if [[ -t 1 && $TERM == *color* ]]; then 26 | opt='on' 27 | else 28 | opt='off' 29 | fi 30 | fi 31 | 32 | case "$opt" in 33 | on) 34 | local i 35 | for i in {1..11}; do 36 | if [[ -n ${COLORS[$i]} ]]; then 37 | continue 38 | fi 39 | COLORS[$i]=$(tput setaf "$i") 40 | done 41 | colorbrackets=${COLORS[$numcolorbrackets]} 42 | colordarkgray=${COLORS[$numcolordarkgray]} 43 | colorfail=${COLORS[$numcolorfail]} 44 | colorgray=${COLORS[$numcolorgray]} 45 | colorheader=${COLORS[$numcolorheader]} 46 | colorlogo=${COLORS[$numcolorlogo]} 47 | colorok=${COLORS[$numcolorok]} 48 | colorpkgcount=${COLORS[$numcolorpkgcount]} 49 | colortext=${COLORS[$numcolortext]} 50 | colorreset=$(tput sgr0) 51 | ;; 52 | off) 53 | colorbrackets= 54 | colordarkgray= 55 | colorfail= 56 | colorgray= 57 | colorheader= 58 | colorlogo= 59 | colorok= 60 | colorpkgcount= 61 | colortext= 62 | colorreset= 63 | unset COLORS 64 | declare -A COLORS 65 | ;; 66 | *) 67 | rmsg 255 "unknown color option: '$opt'" 68 | exit 255 69 | ;; 70 | esac 71 | } 72 | 73 | # print the logo with brackets colorized 74 | getlogo () { 75 | printf '%s[%s%s%s]%s' \ 76 | "$colorbrackets" \ 77 | "$colorlogo" "$progname" \ 78 | "$colorbrackets" \ 79 | "$colorreset" 80 | } 81 | 82 | # prints a message (with vpsm-prefix) 83 | msg () { 84 | local logo=$(getlogo) 85 | local newline=true 86 | 87 | if [[ $1 == '-n' ]]; then 88 | newline=false 89 | shift 90 | fi 91 | 92 | printf '%s %s%s%s' "$logo" "$colortext" "$*" "$colorreset" 93 | $newline && echo 94 | } 95 | 96 | # rmsg - same (but colorized based on return status passed via $1) 97 | rmsg () { 98 | local code=$1 99 | shift 100 | 101 | local logo=$(getlogo) 102 | local statuscolor 103 | 104 | if ((code == 0)); then 105 | statuscolor=$colorok 106 | else 107 | statuscolor=$colorfail 108 | fi 109 | 110 | printf '%s %s%s%s\n' "$logo" "$statuscolor" "$*" "$colorreset" 111 | } 112 | 113 | 114 | # -------------------------------------------------------------------------------------------- 115 | 116 | setcolors on 117 | logo=$(getlogo) 118 | distdir=$(xdistdir 2>&1) 119 | IFS=$'\n' read -rd '' -a xdistdir_msgs <<<"$distdir" 120 | 121 | if [ "$?" == 111 ]; then 122 | for m in "${xdistdir_msgs[@]}" 123 | do 124 | printf '%s %s%s%s\n' "$logo" "$colorfail" "$m" "$colorreset" 125 | done 126 | exit 127 | elif ! [ -d $distdir ]; then 128 | m="No such file or directory: $distdir" 129 | printf '%s %s%s%s\n' "$logo" "$colorfail" "$m" "$colorreset" 130 | 131 | read -p "$colorgray-> Clone void-packages from: $colorreset" void_packages_url 132 | read -e -p "$colorgray-> Target directory: $colorreset" void_packages_dest 133 | 134 | eval target_dir=$void_packages_dest 135 | 136 | msg "Cloning from $void_packages_url -> $target_dir" 137 | git clone "$void_packages_url" "$target_dir" 138 | msg "Cloned!" 139 | 140 | msg "Install xtools utility " 141 | sudo xbps-install xtools 142 | 143 | exit 144 | else 145 | export VOID_PKGS=$XBPS_DISTDIR 146 | export VOID_SRCPKGS=$VOID_PKGS/srcpkgs 147 | export VOID_HOSTDIR=$VOID_PKGS/hostdir 148 | export VOID_BINPKGS=$VOID_HOSTDIR/binpkgs 149 | cd $VOID_PKGS 150 | fi 151 | 152 | # -------------------------------------------------------------------------------------------- 153 | 154 | getversion () { 155 | local fp=$(readlink -f "$0") 156 | (cd "${fp%/*}" && \ 157 | git describe --all --debug --long --tags 2>/dev/null) || echo "UNKNOWN" 158 | } 159 | 160 | version=$(getversion) 161 | verbose=false 162 | 163 | banner () { 164 | echo -n "$colorlogo" 165 | echo ' __ ___ __ ____ __ '; 166 | 167 | printf " \ V / '_ (_-< ' \ " 168 | echo -n "$colorgray" 169 | echo " $progname - void-packages sources management wrapper for XBPS-SRC" 170 | echo -n "$colorlogo" 171 | echo -n ' \_/| .__/__/_|_|_|' 172 | echo -n "$colorgray" 173 | echo ' GitHub: https://github.com/sinetoami/vpsm' 174 | echo -n "$colorlogo" 175 | echo ' |/ ' 176 | echo ' ´ ' 177 | echo -n "$colorreset" 178 | } 179 | 180 | version () { 181 | banner 182 | msg "$progname - Version: $version" 183 | msg "Copyright (c) 2018 Sinésio Neto (GPLv3+)" 184 | msg "XBPS version: $(xbps-query -v --version | sed 's/GIT: UNSET//')" 185 | } 186 | 187 | wrapcommand() { 188 | local cmd ret 189 | cmd=("$@") 190 | 191 | echo "$colortext(${cmd[*]}):$colorreset" 192 | 193 | "${cmd[@]}" 194 | ret=$? 195 | 196 | rmsg "$ret" "[${cmd[*]}], return code was: $ret" 197 | exit "$ret" 198 | } 199 | 200 | usage () { 201 | # echo 202 | version 203 | echo 204 | echo -n "$colorheader" 205 | echo "USAGE: " 206 | echo -n "$colorgray" 207 | echo "$progname [OPTIONS] [SUBCOMMANDS] []" 208 | echo 209 | echo -n "$colorheader" 210 | echo "OPTIONS: " 211 | echo -n "$colorgray" 212 | 213 | echo "--color= - Enable/Disable colorized output (default: auto)" 214 | echo "--help - (same as: help)" 215 | echo "--help-pager - (same as: helppager)" 216 | echo 217 | 218 | echo -n "$colorheader" 219 | echo "GIT SUBCOMMANDS: " 220 | echo -n "$colorgray" 221 | 222 | echo "add-changes (ac) - Add work changes in your clone repository." 223 | echo "add-remote-repo (arr) - Add new remote repo in your clone repository." 224 | echo "checkout-branch (co) - Switch branch." 225 | echo "commit-changes (cc) - Commits changes added." 226 | echo "create-branch (cb) - Create a new branch." 227 | echo "delete-branch (delb) - Delete a existing branch." 228 | echo "list-branches (lb) - List all branches." 229 | echo "log (lg) - Commit log for XBPS template" 230 | echo "log-graph (lgg) - Commit graph log for all commits" 231 | echo "pull (pp) - Pull commit from ." 232 | echo "pull-request (pr) [message] - Create a pull-request [optional message]." 233 | echo "push-commit (pc) - Push commits to ." 234 | echo "update-repo (upr) - Pull commits from void-linux official repo." 235 | echo 236 | 237 | echo -n "$colorheader" 238 | echo "XBPS-SRC SUBCOMMANDS: " 239 | echo -n "$colorgray" 240 | 241 | echo "binbootstrap (bb) - Install bootstrap packages from host repositories into ." 242 | echo "bootstrap-up (bu) - Updates bootstrap packages." 243 | echo "build-environment - Configure environment to create binary packages." 244 | echo "edit-template (et) - Edit template." 245 | echo "install (i) - Build binary package for and all required dependencies and install." 246 | echo "lint (li) - Scan XBPS template for common mistakes." 247 | echo "list (l) - Lists installed packages in ." 248 | echo "mypkgs (mp) [email] - List all pkgs maintained by you or by [optional email]." 249 | echo "new (n) - Create a new package." 250 | echo "pkg - Only build binary package for and all required dependencies." 251 | echo "purge-distfiles (pdistf) - Removes all obsolete distfiles in /sources." 252 | echo "searchbin (sb) - Search in /binpkgs for package by (use xbps-query). " 253 | echo "searchsrc (ss) - Search in for package by ." 254 | echo "show (sw) - Show information for the specified package." 255 | echo "show-build-deps (bdeps) - Show required build dependencies for ." 256 | echo "show-deps (rdeps) - Show required run-time dependencies for ." 257 | echo "uninstall (un) - Uninstall and purge distfiles for ." 258 | echo "update-bulk (upb) - Rebuilds all packages in the system repositories that are outdated." 259 | echo "update-check (upc) - Check upstream site of for new releases." 260 | echo "update-sys (ups) - Rebuilds packages in system and updates them." 261 | echo "xgsum - Generate SHA256 for template." 262 | echo "xinstall (xi) - Like xbps-install -S , but take cwd repo and sudo/su into account." 263 | echo 264 | echo -n "$colorreset" 265 | } 266 | 267 | setcolors auto 268 | case "$1" in 269 | --color=true|--color=yes|--color=on) 270 | setcolors on 271 | shift 272 | ;; 273 | --color=auto) 274 | setcolors auto 275 | shift 276 | ;; 277 | --color=false|--color=off|--color=no) 278 | setcolors off 279 | shift 280 | ;; 281 | --help) 282 | shift 283 | usage 284 | exit 255 285 | ;; 286 | --help-pager) 287 | shift 288 | "$0" --color=off --help | less 289 | ;; 290 | --*) 291 | msg "Unknown option: $1 (try: $progname --help)" 292 | exit 1 293 | ;; 294 | esac 295 | 296 | current_branch=$(git rev-parse --abbrev-ref HEAD) 297 | template_path() { 298 | echo "$VOID_PKGS/srcpkgs/$1/template" 299 | } 300 | 301 | 302 | git_owner_name() { 303 | url="$(git config --get remote.origin.url)" 304 | re="^(https|git)(:\/\/|@)([^\/:]+)[\/:]([^\/:]+)\/(.+).git$" 305 | 306 | if [[ $url =~ $re ]]; then 307 | user=${BASH_REMATCH[4]} 308 | fi 309 | echo "$user" 310 | } 311 | 312 | void_linux_remote() { 313 | git remote -v | rg void-linux/void-packages | awk '{print $1}' | head -1 314 | } 315 | 316 | longest_word () { 317 | declare -a pkgs=$@ 318 | declare -i longest=0 319 | for pkg in ${pkgs[@]} 320 | do 321 | if [ ${#pkg} -gt $longest ]; then 322 | longest=${#pkg} 323 | fi 324 | done 325 | echo $longest 326 | } 327 | 328 | whitespaces() { 329 | i=0 330 | space=" " 331 | qnt_ws=$(($1 - $2)) 332 | 333 | while [[ "$i" != $qnt_ws ]] 334 | do 335 | space+=" " 336 | ((i+=1)) 337 | done 338 | echo "$space" 339 | } 340 | 341 | show_desc () { 342 | ./xbps-src show "$1" | rg short_desc | awk '{$1=""; print $0}' 343 | } 344 | 345 | if_instaled () { 346 | [[ "$1" != '' ]] && flag="[$colorgray*$colorreset]" || flag="[-]" 347 | echo -n "$flag" 348 | } 349 | 350 | lsgrep_binpkgs () { 351 | [ -d "$VOID_BINPKGS" ] && ls $VOID_HOSTDIR/* | rg $1 || echo '' 352 | } 353 | 354 | check_binpkgs () { 355 | check=$(lsgrep_binpkgs "$1") 356 | resul=$(if_instaled $check) 357 | echo -n "$resul" 358 | } 359 | 360 | search_result () { 361 | declare -a res=() 362 | 363 | pkgs=$(ls $VOID_SRCPKGS | rg $1) 364 | lword=$(longest_word ${pkgs[@]}) 365 | 366 | for pkg in ${pkgs[@]} 367 | do 368 | wsnum=$(whitespaces $lword ${#pkg}) 369 | desc=$(show_desc $pkg) 370 | inststr=$(check_binpkgs $pkg) 371 | res+=("$inststr $pkg$wsnum-$desc") 372 | done 373 | 374 | printf '%s\n' "${res[@]}" 375 | } 376 | 377 | xgensum_config() { 378 | template=$(template_path $1) 379 | xgensum -f $template | \ 380 | while read line 381 | do 382 | if [[ "$line" =~ checksum= ]]; then 383 | sed -i "s/^checksum=.*$/$line/g" $template 384 | fi 385 | echo "$line" 386 | done 387 | } 388 | 389 | addrepos() { 390 | check_repos=$(find $VOID_BINPKGS/* -type d) 391 | declare -a repos 392 | for repo in ${check_repos[@]} 393 | do 394 | if ! [[ "$repo" =~ repodata ]];then 395 | repos+="--repository=$repo " 396 | fi 397 | done 398 | 399 | echo "${repos[@]}" 400 | } 401 | 402 | if [[ -z $1 ]]; then 403 | usage 404 | exit 0 405 | fi 406 | 407 | cmd=$1 408 | if [[ $arg =~ --.* ]]; then 409 | cmd=${arg:2} 410 | fi 411 | shift 412 | 413 | case "$cmd" in 414 | # -------------------------------------------------------------------------------------------- 415 | #GIT OPTIONS 416 | add-changes|ac) 417 | msg -n "Add changes $* " 418 | wrapcommand git add "$@" 419 | ;; 420 | 421 | add-remote-repo|arr) 422 | msg -n "Add new remote repo $* " 423 | wrapcommand git remote add "$@" 424 | ;; 425 | 426 | checkout-branch|co) 427 | msg -n "Switch branch -> $* " 428 | wrapcommand git checkout "$@" 429 | ;; 430 | 431 | commit-changes|cc) 432 | msg -n "Commit changes on -> $current_branch " 433 | wrapcommand xbump "$@" 434 | ;; 435 | 436 | create-branch|cb) 437 | msg -n "Create a new branch -> $* " 438 | wrapcommand git branch "$@" 439 | ;; 440 | 441 | delete-branch|delb) 442 | msg -n "Delete branch -> $* " 443 | wrapcommand git branch -d "$@" 444 | ;; 445 | 446 | list-branches|lb) 447 | msg -n "Listing all branchs" 448 | wrapcommand git branch -lv 449 | ;; 450 | 451 | log|lg) 452 | msg -n "Commit log of $* template " 453 | wrapcommand xlg "$@" 454 | ;; 455 | 456 | log-graph|lgg) 457 | git log --all --graph --date=short \ 458 | --pretty=format:'%C(auto)%h%C(auto)%d %s %C(dim white)(%aN, %ar, %cd)' 459 | ;; 460 | 461 | pull|pp) 462 | msg -n "Pull commits from: repo->$1, branch->$2 " 463 | wrapcommand git pull --rebase "$@" 464 | ;; 465 | 466 | pull-request|pr) 467 | ! [ -z "$1" ] && m="$*" || m="$(git log -1 --pretty=%B)" 468 | ownername=$(git_owner_name) 469 | lrepo=$(void_linux_remote) 470 | msg -n "Create a pull-request " 471 | wrapcommand hub pull-request -m "$m" -b "$lrepo:master" -h "$ownername:$current_branch" 472 | ;; 473 | 474 | push-commit|pc) 475 | msg -n "Push commit to: repo->$1, branch->$2 " 476 | wrapcommand git push -u "$@" 477 | ;; 478 | 479 | update-repo|upr) 480 | lrepo=$(void_linux_remote) 481 | msg "Pull commits from Void Linux's void-packages: remote-name -> $lrepo " 482 | git checkout master 483 | git pull --rebase $lrepo master 484 | git push -u origin master 485 | ./xbps-src bootstrap-update 486 | ;; 487 | 488 | # -------------------------------------------------------------------------------------------- 489 | # XBPS-SRC OPTIONS 490 | binbootstrap|bb) 491 | msg -n "Create the bootstrap environment " 492 | echo XBPS_ALLOW_RESTRICTED=yes >> etc/conf 493 | wrapcommand ./xbps-src binary-bootstrap 494 | ;; 495 | 496 | bootstrap-up|bu) 497 | msg -n "Updates bootstrap packages " 498 | wrapcommand ./xbps-src bootstrap-update 499 | ;; 500 | 501 | build-environment) 502 | whoami=$(whoami) 503 | 504 | msg "Setting up XBPS_CHROOT_CMD=uchroot " 505 | echo XBPS_CHROOT_CMD=uchroot >> etc/conf 506 | 507 | cd /usr/bin 508 | msg "chown root:xbuilder xbps-uchroot " 509 | sudo chown root:xbuilder xbps-uchroot 510 | msg "chmod 4750 xbps-uchroot" 511 | sudo chmod 4750 xbps-uchroot 512 | msg "usermod -a -G xbuilder $whoami" 513 | sudo usermod -a -G xbuilder $whoami 514 | 515 | # cd $OLDPWD 516 | # msg "add void-linux/void-packages track repository " 517 | # git remote add void-linux git://github.com/void-linux/void-packages.git 518 | # msg "git pull void-linux master " 519 | # git pull --rebase void-linux master 520 | ;; 521 | 522 | edit-template|et) 523 | template=$(template_path "$@") 524 | exec $EDITOR $template 525 | ;; 526 | 527 | install|i) 528 | if (($# < 1)); then 529 | rmsg 255 "ERROR: install: argument missing, try --help." 530 | exit 1 531 | fi 532 | 533 | msg "Build binary package -> $* " 534 | ./xbps-src pkg "$@" 535 | 536 | msg -n "Installing package -> $* " 537 | wrapcommand xi "$@" 538 | ;; 539 | 540 | lint|li) 541 | template=$(template_path "$@") 542 | msg -n "Scan for common mistakes " 543 | wrapcommand xlint "$template" 544 | ;; 545 | 546 | list|l) 547 | msg -n "Lists installed packages " 548 | wrapcommand ./xbps-src list 549 | ;; 550 | 551 | mypkgs|mp) 552 | ownername=$(git_owner_name) 553 | msg -n "Listing packages of $ownername " 554 | wrapcommand xmypkgs 555 | ;; 556 | 557 | new|n) 558 | msg -n "Creating a new package -> $* " 559 | wrapcommand xnew "$@" 560 | ;; 561 | 562 | pkg) 563 | msg -n "Build binary package -> $* " 564 | wrapcommand ./xbps-src pkg "$@" 565 | ;; 566 | 567 | purge-distfiles|purged) 568 | msg -n "Removes all obsolete distfiles in $VOID_HOSTDIR/sources " 569 | wrapcommand ./xbps-src purge-distfiles 570 | ;; 571 | 572 | searchbin|sb) 573 | repos=$(addrepos) 574 | msg -n "Searching (binpkgs) -> $* " 575 | wrapcommand xbps-query $repos -Rs "$@" 576 | ;; 577 | 578 | searchsrc|ss) 579 | msg -n "Searching (srcpkgs) -> $* " 580 | wrapcommand search_result "$@" 581 | ;; 582 | 583 | show|sw) 584 | msg -n "Show information -> $* " 585 | wrapcommand ./xbps-src show "$@" 586 | ;; 587 | 588 | show-build-deps|bdeps) 589 | msg -n "Show required build dependencies -> $* " 590 | wrapcommand ./xbps-src show-build-deps "$@" 591 | ;; 592 | 593 | show-deps|rdeps) 594 | msg -n "Show required run-time dependencies -> $* " 595 | wrapcommand ./xbps-src show-deps "$@" 596 | ;; 597 | 598 | show-repo-updates|sru) 599 | msg -n "Printing the list of outdated packages " 600 | wrapcommand ./xbps-src show-repo-updates 601 | ;; 602 | 603 | uninstall|un) 604 | shopt -s globstar 605 | 606 | msg "Remove package and purge distfiles -> $* " 607 | sudo xbps-remove -v -R "$@" 608 | rm -rf $VOID_BINPKGS/**/*$@* 609 | 610 | shopt -u globstar 611 | ;; 612 | 613 | update-bulk|upb) 614 | msg -n "Rebuilds all packages outdated (system repositories) " 615 | wrapcommand ./xbps-src update-bulk 616 | ;; 617 | 618 | update-check|upc) 619 | msg -n "Check upstream site new releases -> $* " 620 | wrapcommand ./xbps-src update-check "$@" 621 | ;; 622 | 623 | update-sys|ups) 624 | msg -n "Rebuilds packages and updates them (in system) " 625 | wrapcommand ./xbps-src update-sys 626 | ;; 627 | 628 | xgsum) 629 | msg -n "Generate/Update SHA256 sum -> $@/template " 630 | wrapcommand xgensum_config "$@" 631 | ;; 632 | 633 | xinstall|xi) 634 | if (($# < 1)); then 635 | rmsg 255 "ERROR: install: argument missing, try --help." 636 | exit 1 637 | fi 638 | 639 | msg -n "Install $* package " 640 | wrapcommand xi "$@" 641 | ;; 642 | esac 643 | --------------------------------------------------------------------------------