Skip to content

Commit

Permalink
Merge pull request #36 from cedricduriau/refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricduriau authored Feb 17, 2024
2 parents 67afb2f + 1623270 commit 04f14e6
Show file tree
Hide file tree
Showing 46 changed files with 1,193 additions and 1,196 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/packagerbuddy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.6]
python-version: [3.8, 3.11]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -15,10 +15,7 @@ jobs:

- name: Install
run: |
pip install -e .[dev]
make install-dev
- name: Lint
run: |
./runcheck
- name: Test
run: |
./runtests
make check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# files
*.pyc
.coverage
.DS_Store

# directories
.vscode/
__pycache__/
build/
dist/
*.egg-info/
.env/
.ruff_cache/
92 changes: 92 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
.PHONY: install install-dev clean check format test

## Install for production
install:
@echo ">> Installing dependencies"
python -m pip install --upgrade pip
python -m pip install -e .

## Install for development
install-dev: install
python -m pip install -e ".[dev]"

## Delete all temporary files
clean:
rm -rf .pytest_cache
rm -rf **/.pytest_cache
rm -rf __pycache__
rm -rf **/__pycache__
rm -rf build
rm -rf dist

## Run checks
check:
ruff check .
black --check .

## Format files using black
format:
ruff . --fix
black .

test:
pytest -vv --disable-warnings --no-header --cov=packagerbuddy --cov-branch --cov-report=term-missing ./tests

#################################################################################
# Self Documenting Commands #
#################################################################################

.DEFAULT_GOAL := help

# Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
# sed script explained:
# /^##/:
# * save line in hold space
# * purge line
# * Loop:
# * append newline + line to hold space
# * go to next line
# * if line starts with doc comment, strip comment character off and loop
# * remove target prerequisites
# * append hold space (+ newline) to line
# * replace newline plus comments by `---`
# * print line
# Separate expressions are necessary because labels cannot be delimited by
# semicolon; see <http://stackoverflow.com/a/11799865/1968>
.PHONY: help
help:
@echo "$$(tput bold)Available commands:$$(tput sgr0)"
@sed -n -e "/^## / { \
h; \
s/.*//; \
:doc" \
-e "H; \
n; \
s/^## //; \
t doc" \
-e "s/:.*//; \
G; \
s/\\n## /---/; \
s/\\n/ /g; \
p; \
}" ${MAKEFILE_LIST} \
| awk -F '---' \
-v ncol=$$(tput cols) \
-v indent=19 \
-v col_on="$$(tput setaf 6)" \
-v col_off="$$(tput sgr0)" \
'{ \
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
n = split($$2, words, " "); \
line_length = ncol - indent; \
for (i = 1; i <= n; i++) { \
line_length -= length(words[i]) + 1; \
if (line_length <= 0) { \
line_length = ncol - indent - length(words[i]) - 1; \
printf "\n%*s ", -indent, " "; \
} \
printf "%s ", words[i]; \
} \
printf "\n"; \
}' \
| more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')
81 changes: 40 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# PackagerBuddy

![](https://github.com/cedricduriau/packagerbuddy/workflows/Build/badge.svg?branch=master)
[![Platform](https://img.shields.io/badge/Platform-linux--64-lightgrey.svg)](https://img.shields.io/badge/Platform-linux--64-lightgrey.svg)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Python](https://img.shields.io/badge/Python-2.7%20|%203.6-blue.svg)](https://img.shields.io/badge/Python-2.7%20|%203.6-blue.svg)
[![platform](https://img.shields.io/badge/platform-linux--x64-lightgrey.svg)](https://img.shields.io/badge/platform-linux--x64-lightgrey.svg)
[![platform](https://img.shields.io/badge/platform-darwin--arm64-lightgrey.svg)](https://img.shields.io/badge/platform-darwin--arm64-lightgrey.svg)
[![license: GPL v3](https://img.shields.io/badge/license-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![python](https://img.shields.io/badge/python-3.8+-blue.svg)](https://img.shields.io/badge/Python-3.8+-blue.svg)
[![coverage](https://img.shields.io/badge/coverage-90%25-brightgreen.svg)](https://img.shields.io/badge/coverage-90%25-brightgreen)

## Overview

PackagerBuddy is a JSON config based software packager written entirely in Python for Linux.
PackagerBuddy is a JSON config based software packager written entirely in Python.

Use Cases

Expand All @@ -20,76 +20,78 @@ of itself.

If you wish to install the current master, use the following command:

`pip install git+git://github.com/cedricduriau/packagerbuddy.git`
```sh
# latest master
pip install git+git://github.com/cedricduriau/packagerbuddy.git

Or a specific release version:
# specific version
pip install git+git://github.com/cedricduriau/packagerbuddy.git@{RELEASE}
```

`pip install git+git://github.com/cedricduriau/packagerbuddy.git@{RELEASE}`
## Usage

### Setup

This will create all default directories and copy the default configuration file that ships with the repository. (see [Configure](#Configure))
The setup command will create all directories required to function. By default these are installed in the user home directory. To change the default location, see see [Configure](#Configure).

## Usage
```sh
packagerbuddy setup
```

### Add software
The add command requires two arguments. The `software` argument used as alias to interact with, and the `url` argument which needs to be an url containing a version placeholder.

```
packagerbuddy add --software codium --url https://github.com/VSCodium/vscodium/releases/download/{version}/VSCodium-linux-x64-{version}.tar.gz
```sh
packagerbuddy add --software codium --url https://github.com/VSCodium/vscodium/releases/download/{version}/VSCodium-darwin-arm64-{version}.zip
```

### Remove software

The remove command requires a single argument, the `software` argument, which needs to match an already added software. To list the available software packages, see `avail` command below.

```
```sh
packagerbuddy remove --software codium
```

### Install software
The `install` command requires two arguments. The `software` argument which needs to match an alias in the software config and the `version` argument which needs to form an existing download url. If the requested software version has already been installed, the install will stop. If you wish to force an install
again, the `force` flag covers this feature.
### List available software to install
The `avail` command prints all software names that are present in the config, supported by PackgerBuddy.

```sh
packagerbuddy avail
```
packagerbuddy install --software codium --version 1.44.0
packagerbuddy install --software codium --version 1.44.0 --force

### Install software
The `install` command requires two arguments. The `software` argument which needs to match an alias in the software config and the `version` argument which needs to form an existing download url. If the requested software version has already been installed, the install will stop.

```sh
packagerbuddy install --software codium --version 1.85.2.2401
```

Installing consists of five steps:

1. Download the software from the url in the configs to the designated download directory.
2. Unpack the downloaded content.
3. Install/move the unpacked content to the designated install directory.
4. Create a package file inside the installed directory.
5. Run the post install script from the designated scripts directory.
4. Run the post install script from the designated scripts directory.

### List installed software
The `list` command prints all installed software. PackagerBuddy knows the difference between ordinary directories and software it installed thanks to a package file which is written out at install time.
```
packagerbuddy list
```

### List software available to install
The `avail` command prints all software names that are present in the config, supported by PackgerBuddy.
```
packagerbuddy avail
```sh
packagerbuddy list
```

### Uninstalling
The `uninstall` command, well, does exactly that. It checks if the given software is installed at all and if so, proceeds to remove the file system contents in the designated install location.

The `version` argument is optional. If it is passed, only given version will be removed. If it is not passed, **all** versions will be uninstalled of given software. Beware of this feature.

If you're the kind of person that prepares a batch of commands before running them and then feed those to a terminal, there is also a `--dry-run` flag for you to enjoy.
```
```sh
# uninstall all versions
packagerbuddy uninstall --software codium

# uninstall specific version
packagerbuddy uninstall --software codium --version 1.44.0
# dry run, execute without removing
packagerbuddy uninstall --software codium --dry-run
packagerbuddy uninstall --software codium --version 1.85.2.2401
```

## Configure
Expand All @@ -99,19 +101,16 @@ packagerbuddy uninstall --software codium --dry-run
* `PB_CONFIG` : Path of the software config.
* default: custom file in the user home. (`~/.packagerbuddy/config/software.json`)
* `PB_DOWNLOAD` : Directory the software will be downloaded to.
* default: custom directory in the user home. (`~/.packagerbuddy/source`)
* default: custom directory in the user home. (`~/.packagerbuddy/downloaded`)
* `PB_INSTALL`: Directory the software will be installed in.
* default: custom directory in the user home. (`~/.packagerbuddy/installed`)
* `PB_SCRIPTS`: Directory of the post install scripts.
* default: custom directory in the user home. (`~/.packagerbuddy/scripts`)


### Examples

If you want to try out the example shipping with the repository, run following commands from the root of this repo:

* `cp -R ./examples/* ~/.packagerbuddy/`

This will allow you to install three software packages. One of them is `code` (Visual Studio Code), which has a post install script.
Check out the `code` post install script for its inner working.
Check out the [vscode release notes](https://code.visualstudio.com/updates) for a valid version number to install.
```sh
cp -R ./darwin-arm64/examples/* ~/.packagerbuddy/
```
Loading

0 comments on commit 04f14e6

Please sign in to comment.