Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git_xy/git@github.com:icyfork/pacapt branch ng path lib/ #14

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*~
.*.swp
pacapt.dev
pacapt-*
tests/tmp/*
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sudo: required
language:
- bash
services:
- docker
script:
# lib{json,uri}-perl is required for `make shellcheck`
- sudo apt-get install libjson-perl liburi-perl
- make shellcheck
- make tests

notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/228a31b6140b028bcf79
on_success: change # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: never # options: [always|never|change] default: always
142 changes: 142 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
## v2.4.3

* `lib/homebrew`: Support `cask` (fix #117)
* `tests/dpkg`: Support new distros, drop support for old distro

## v2.4.2

* Update README.md
* Support sysget-style sub commands (`pacapt install`, `pacapt upgrade`,...)
* `lib/homebrew/Rs`: Improvements (#124, @Mnkai)
* `lib/dpkg`: Use `dist-upgrade` for `Suy` and `Su` operations

## v2.4.0

* `lib/tlmgr`: Add TeXLive support (Antony Lee)
* `lib/conda`: Conda support (Antony Lee)

For developers:

* Ability to support non-system package manager (`npm`, `gem`, ...)
* Reduce shellcheck warning/error reports

## v2.3.15

* A warm up release with very minor updates.

## v2.3.14

* `lib/homebrew`: `brew upgrade` is equivalant to `brew upgrade --all`.
See #90 and #101.
* Support `Clear Linux`. See #94.

For developers:

* Add Travis support
* Add and update test cases for Ubuntu 16.04, Ubuntu 14.04

## v2.3.13

* `lib/dpkg`: Fix `-Qs` for old `dpkg`.

For developers:

* Test scripts can now be automated thanks to `tests/*`;
* `tests/slitz40`: Add;
* `tests/dpkg`: Update.

## v2.3.12

* `lib/dpkg`: Fix #84 (incorrect implementation of `-Qs`.)

For developers:

* `bin/gen_tests.rb`: Add;
* `lib/dpkg`: Add and update test cases;
* `CONTRIBUTING`: Add new section `Writting test cases`.

## v2.3.11

* `lib/tazpkg`: Improve `-U`.

## v2.3.10

* `lib/tazpkg`: Support `-Scc`.

## v2.3.9

* `lib/tazpkg`: Support `SliTaz` distribution.

For developers:

* `contrib/*`: Add instructions to build packages on some distributions (Credit: `Pival81`).

## v2.3.8

* `lib/alpine`: Support `Alpine` distirubtion (Credit: `Carl X. Su`, `Cuong Manh Le`);
* `lib/dnf`: Support new package manager on `Fedora` system (Credit: `Huy Ngô`);
* `lib/termux`: Support `termux` on Android (Credit: `Jiawei Zhou`);
* `lib/zypper`: New option `-Sw` (Forgot to merge #72);
* `lib/yum`: New option `-Qs` (Credit: `Siôn Le Roux`);

For developers:

* Improve translation method `_translate_all`;

## v2.2.7

* `lib/zypper`: Complete query/removal options (Credit: `Janne Heß`);
* `lib/cave`: Fix an issue with `-R` option;
* New option `--noconfirm` to help non-interactive scripts (Cf. #43).
Currently available for `pkgng`, `yum`, `dpkg` and `zypper`.

For developers:

* `lib/{00_core,zz_main}`: Refactor to support future option translation;
* Refactor code supports `-w` (download only) and `-v` (debug) options;
* Improve coding quality thanks to `shellcheck`;
* Move `compile.sh` to `bin/compile.sh`;
* Use `lib/00_core#_translate_all` to add future option translation;
* `bin/check`: Add script to inspect coding style issues (Cf. #54).

## v2.1.6

* `lib/sun_tools`: `SunOS` support (Credit: `Daniel YC Lin`);
* Fix a minor bug related to argument parsing (4287ff16e869a0960ea54233);
* Improve documentation;
* `lib/dnf`: Add some initial support;
* Adding `GREP` and `AWK` environments to future non-`Linux` systems;
* `compile.sh` will exit if it can't detect version information;
* `README` has a table of supported operations generated by `compile.sh`;
* In debug mode, `pacapt` will print body of function it would execute.

## v2.0.5

* `lib/zz_main`: Improve secondary option parsing;
* `lib/pkg_tools`: Remove `Rns` support.

## v2.0.4

* `openbsd/pkg_tools`: Add (Credit: `Somasis`);
* `homebrew/Su*`: Use `--all` flag when upgrading;
* `homebrew/*`: Some typo fixes;
* `compile.sh`: `git` becomes optional (useful for `docker` tester.);
* `compile.sh`: Get list of authors from `README.md`;
* `Makefile`: Various improvements;
* `lib/00_core`: Add `_removing_is_dangerous` method;
* `lib/00_core`: `_not_implemented` now returns `1`;
* `lib/help.txt`: Remove list of authors from help message;
* `CHANGELOG.md`: Add.

## v2.0.3

* `homebrew/Qs`: Add;
* `homebrew/*`: Fix minor bugs.

## v2.0.2

* `lib/zz_main`: Fix quoting issue (Credit: `Cuong Manh Le`).

## v2.0.1

* `git log v2.0.1`.
70 changes: 70 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## Table of contents

1. [Future development](#future-development)
1. [Coding style](#coding-style)
1. [Testing. Writting test cases](#testing-writting-test-cases)
1. [Generating pacapt script](#generating-pacapt-script)
1. [Branches](#branches)
1. [Closed branches](#closed-branches)

## Future development

See also [README.md](README.md#read-me-first)

## Coding style

1. Don't use tab or smart tab;
1. Use `2-space` instead of a tab;
1. Contribute to library file under `./lib/` directory;
1. We try to follow the convention from:
https://github.com/icy/bash-coding-style.

## Testing. Writting test cases

See also `tests/README.md` and https://travis-ci.org/icy/pacapt.

1. Use `make shellcheck` if you have a network connection,
and enough `Perl` packages (`JSON`, `URI::Escape`) on your system;
1. Use `PACAPT_DEBUG=foo` where `foo` is a package manager
(`dpkg`, `pacman`, `zypper`, ...) to print what `pacapt` will do.
Use `PACAPT_DEBUG=auto` for auto-detection;
1. You can use `docker` for testing, by mounting the `pacapt.dev` script
to the container. See also `docker.i` section in `Makefile`. Example:

````
$ make pacapt.dev
$ docker run --rm -ti \
-v $PWD/pacapt.dev:/usr/bin/pacman \
debian:stable /bin/bash
# you are in container now
````

## Generating `pacapt` script

1. The `pacapt` script is generated from the latest stable branch,
it is there to make installation process simple;
1. Please **do not** use `make pacapt` to update `pacapt`,
and/or modify it manually;
1. For your development, use `make pacapt.dev`;

## Branches

1. `ng`:
The current development branch.
Some pull requests are merged on to this branch,
but the work may not be ready for production.
1. `v2.0`:
The current stable branch.
All future `v2.x` releases come from this branch.

1. `your feature branch`:
For new feature or bug fix, please work on your own branch
and create pull request.
Do not put different ideas on a same branch
because that makes future tracking harder.

## Closed branches

1. `master`:
The old stable code of the `pacapt`.
This branch is closed on May 4th, 2014.
31 changes: 31 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env groovy

// Author : Ky-Anh Huynh
// Date : 2018 July 08
// License: MIT

@Library("icy@master")

def icyUtils = new org.icy.Utils()

try {
node {
checkOut("clean")

buildInfo()

stage("tests") {
sh '''
make tests
'''
}
}
}
catch (exc) {
currentBuild.result = currentBuild.result ?: "FAILED"
echo "Caught: ${exc}"
throw exc
}
finally {
echo "Finally."
}
115 changes: 95 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,107 @@
BINDIR=/usr/local/bin
BINDIR=/usr/local/bin/
DISTRO=debian:stable

default:
@echo "make README : build the README file from script's contents"
@echo "make install : install pacapt script into $(BINDIR)/"
@echo "make clean : remove git-ignored files"

README: Makefile pacapt
@cat pacapt \
| awk > $(@) \
' \
BEGIN { EOF = 0 } \
{ \
if ( $$0 ~ /EOF/ ) { EOF += 1 } \
else if ( EOF == 1 ) { print $$0 } \
} \
'
@echo "This is an experimental Makefile. Use it at your own risk."
@echo ""
@echo " pacapt.dev : Generate development script."
@echo ' install.dev : Install development script into $$BINDIR.'
@echo " pacapt : Generate stable script."
@echo ' install : Install stable script into $$BINDIR.'
@echo " clean : (Experimental) Remove git-ignored files."
@echo " shellcheck : Syntax and style checking. Use http://shellcheck.net/."
@echo " docker.i : Launch interactive Docker container which mounts."
@echo ' your local 'pacapt.dev' script to $$BINDIR/pacman.'
@echo ' Please use DISTRO= to specify Docker image'
@echo " tests : Run all tests. Please read tests/README.md first."
@echo " Use TESTS= to specify a package. Docker is required."
@echo " stats : Generate table of implemented operations in development branch."
@echo " update_stats: Update README.md using results from 'stats' section."
@echo ""
@echo "Environments:"
@echo ""
@echo " VERSION : Version information. Default: git commit hash."
@echo " BINDIR : Destination directory. Default: /usr/local/bin."
@echo " DISTRO : Container image. Default: debian:stable."

# Build and install development script

pacapt.dev: ./lib/*.sh ./lib/*.txt bin/compile.sh
@./bin/compile.sh > $(@) || { rm -fv $(@); exit 1; }
@bash -n $(@)
@chmod 755 $(@)
@echo 1>&2 "The output file is '$(@)' (unstable version)"

.PHONY: install.dev
install.dev: pacapt.dev
@if [ -e $(@) ] && ! file $(@) | grep -q 'script'; then \
echo >&2 "Makefile Will not overwrite non-script $(@)"; \
exit 1; \
else \
install -vm755 pacapt.dev $(BINDIR)/pacapt; \
fi

# Build and install stable script

.PHONY: pacapt.check

pacapt.check:
@test -n "${VERSION}" || { echo ":: Please specify VERSION, i.e., make pacapt VERSION=1.2.3"; exit 1; }

pacapt: pacapt.check ./lib/*.sh ./lib/*.txt bin/compile.sh
@./bin/compile.sh > $(@).tmp || { rm -fv $(@).tmp; exit 1; }
@mv -fv $(@).tmp $(@)
@bash -n $(@)
@chmod 755 $(@)
@echo 1>&2 "The output file is '$(@)' (stable version)"

.PHONY: install
install: $(BINDIR)/pacapt

$(BINDIR)/pacman:
@if [ ! -e $(@) ]; then \
ln -vs $(BINDIR)/pacapt $(@); \
fi

$(BINDIR)/pacapt: pacapt
@if [ -e $(@) ] && ! file $(@) | grep -q 'shell script'; then \
echo "will not overwrite non-script $(@)" >&2; exit 1; \
@if [ -e $(@) ] && ! file $(@) | grep -q 'script'; then \
echo >&2 "Makefile Will not overwrite non-script $(@)"; \
exit 1; \
else \
install $(<) $(@); \
install -vm755 pacapt $(BINDIR)/pacapt; \
fi

.PHONY: docker.i
docker.i:
@docker run --rm -ti \
-v $(PWD)/pacapt.dev:$(BINDIR)/pacman \
$(DISTRO) /bin/bash

.PHONY: update_stats
update_stats:
@./bin/update_stats.sh

.PHONY: stats
stats:
@./bin/gen_stats.sh

.PHONY: clean
clean:
@if git clean -nX | grep -q .; then \
git clean -nX; echo -n "Remove these files? [y/N] "; read ANS; \
case "$$ANS" in [yY]*) git clean -fX ;; *) exit 1;; esac ; \
git clean -nX; \
echo -n "Remove these files? [y/N] "; \
read ANS; \
case "$$ANS" in \
[yY]*) git clean -fX ;; \
*) exit 1;; \
esac ; \
fi
@cd tests/ && make -s clean

.PHONY: shellcheck
shellcheck:
@./bin/check.sh _check_files bin/*.sh lib/*.sh

.PHONY: tests
tests:
@cd tests/ && make all
Loading