Skip to content

Commit

Permalink
autoconfiscate (#167)
Browse files Browse the repository at this point in the history
Configuration and installation routines. New invariant: nothing generated goes in the repo.

- autoconf to generate a configure script, explicit enumeration of dependencies
- options for building utilities and generating manpages
- updated CI to exercise a variety of installation scenarios
- source distribution target in Makefile that includes generated artifact (configure script, manpages)
  • Loading branch information
mgree authored Jun 16, 2024
1 parent f0744d4 commit 2c000b8
Show file tree
Hide file tree
Showing 41 changed files with 4,726 additions and 99 deletions.
137 changes: 97 additions & 40 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,125 @@ on:
- cron: '17 14 * * *'

jobs:
test:
dist:
strategy:
fail-fast: false
fail-fast: true

runs-on: ubuntu-latest
if: github.event.pull_request.draft == false

steps:
- name: Install dependencies
run: |
sudo apt-get install expect mergerfs attr
sudo apt-get install expect mergerfs attr pandoc
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Build utilities
- name: Check autoscan
run: |
make -C utils all
autoscan | tee autoscan.out
! [ -s autoscan.out ]
- name: Run tests with utilities
- name: Configure and build manpage
run: |
autoconf
./configure
make dist
- name: Upload dist tarball
uses: actions/upload-artifact@v4
with:
name: try-dist.tgz
path: try-*.tgz

test-dist:
needs: dist
strategy:
fail-fast: false

runs-on: ubuntu-latest
if: github.event.pull_request.draft == false

steps:
- name: Install dependencies
run: |
PATH="$PWD/utils:$PATH" scripts/run_tests.sh
sudo apt-get install expect mergerfs attr pandoc
- name: Download dist tarball
uses: actions/download-artifact@v4

- name: Unpack tarball; configure and build utilities
run: |
tar xzf try-dist.tgz/try-*.tgz --strip-components=1
rm -r try-dist.tgz
./configure
make all
- name: Run tests with shell fallbacks
run: |
! which try-summary
! which try-commit
scripts/run_tests.sh
- name: Upload script
uses: actions/upload-artifact@v4
with:
name: try
path: try
- name: Install utilities
run: |
sudo make install
- name: Run tests with utilities
run: |
which try-summary
which try-commit
scripts/run_tests.sh
- name: Check manpage
run: |
man -w try
test-checkout:
strategy:
fail-fast: false

manpage:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false

steps:
- name: Install pandoc
- name: Install dependencies
run: |
sudo apt-get install pandoc
sudo apt-get install expect mergerfs attr pandoc
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Build manpage
run: make -C man
- name: Configure and build utilities
run: |
autoconf
./configure
make all
- name: Upload script
uses: actions/upload-artifact@v4
with:
name: try.1
path: man/try.1
- name: Run tests with shell fallbacks
run: |
! which try-summary
! which try-commit
scripts/run_tests.sh
- name: Install utilities
run: |
sudo make install
- name: Run tests with utilities
run: |
which try-summary
which try-commit
scripts/run_tests.sh
- name: Check manpage
run: |
man -w try
lint:
runs-on: ubuntu-latest
Expand All @@ -85,8 +147,7 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Run check_trycase.sh
run: |
scripts/check_trycase.sh
run: scripts/check_trycase.sh

version-check:
runs-on: ubuntu-latest
Expand All @@ -99,20 +160,13 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Check version consistency (script, manpage, include)
run: |
SCRIPT_VERSION=$(grep 'TRY_VERSION=' try | cut -d'"' -f 2)
MANPAGE_VERSION=$(grep 'TRY(1)' docs/try.1.md | cut -d' ' -f 4)
INCLUDE_VERSION=$(grep '#define TRY_VERSION' utils/version.h | cut -d'"' -f 2)
echo "SCRIPT_VERSION = '$SCRIPT_VERSION'"
echo "MANPAGE_VERSION = '$MANPAGE_VERSION'"
echo "INCLUDE_VERSION = '$INCLUDE_VERSION'"
[ "$SCRIPT_VERSION" = "$MANPAGE_VERSION" ]
[ "$SCRIPT_VERSION" = "$INCLUDE_VERSION" ]
run: scripts/check_version.sh

shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

Expand All @@ -121,11 +175,13 @@ jobs:
with:
ignore_paths: >-
completions
./configure
./install-sh
prerelease:
needs:
- test
- manpage
- test-checkout
- test-dist
- version-check
- lint
- shellcheck
Expand All @@ -137,16 +193,17 @@ jobs:
- name: Download binaries
uses: actions/download-artifact@v4

- name: Collect artifacts
- name: Rename tarball
run: |
mv try.1/try.1 try/try.1
mv try-dist.tgz/try-*.tgz try-latest.tgz
rmdir try-dist.tgz
- name: Deploy 'latest' release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Latest script and manpage"
title: "Latest distribution tarball"
files: |
try/*
try-latest.tgz
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ test/try_workspace/
*~
.vagrant/
.vagrant
autom4te.cache/
config.log
config.status
Makefile
configure.scan
autoscan.log
configure
try-0.2.0.tgz
70 changes: 70 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
datarootdir=@datarootdir@
mandir=@mandir@

CC=@CC@
CFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@
INSTALL=@INSTALL@

.PHONY: all install test dist lint clean

DISTDIR=@PACKAGE_TARNAME@-@PACKAGE_VERSION@
DISTTGZ=$(DISTDIR).tgz

TARGETS=$(if $(findstring yes,@enable_utils@),utils/try-summary utils/try-commit) man/try.1.gz

all: $(TARGETS)

install: $(TARGETS)
$(INSTALL) -d $(bindir)
$(INSTALL) -m 755 try $(bindir)
ifeq (@enable_utils@, yes)
$(INSTALL) -m 755 utils/try-summary $(bindir)
$(INSTALL) -m 755 utils/try-commit $(bindir)
endif
$(INSTALL) -d $(mandir)/man1
$(INSTALL) -m 644 man/try.1.gz $(mandir)/man1

dist: $(DISTTGZ)

$(DISTTGZ): $(DISTDIR)
tar czf $@ $<
rm -rf $(DISTDIR)

$(DISTDIR): man/try.1 man/try.1.gz
mkdir $@
cp configure configure.ac config.guess config.sub install-sh LICENSE Makefile.in README.md STYLE.md try Vagrantfile $@
cp -R completions $@
cp -R docs $@
cp -R man $@
cp -R scripts $@
cp -R test $@
cp -R utils $@

man/try.1.gz: man/try.1
cat $< | gzip >$@

man/try.1: docs/try.1.md
pandoc --standalone --from markdown-smart --to man $< -o $@

utils/try-summary: utils/ignores.o utils/try-summary.o
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -g $^

utils/try-commit: utils/ignores.o utils/try-commit.o
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -g $^

test: try utils/try-summary utils/try-commit
scripts/run_tests.sh

lint:
scripts/lint.sh

clean:
ifeq (@enable_manpage@, yes)
-rm man/try.1 man/try.1.gz
endif
-rm utils/*.o
-rm utils/try-summary utils/try-commit
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ commands that you don't already trust on your system, (i.e. network calls are al

* `util-linux` (for standard Linux utilities, `findmnt`)
* `attr` (for `getfattr`)
* `pandoc` and `autoconf` (if working from a GitHub clone)

In cases where overlayfs doesn't work on nested mounts, you will need either
[mergerfs](https://github.com/trapexit/mergerfs) or [unionfs](https://github.com/rpodgorny/unionfs-fuse). `try` should be able to autodetect them, but you can specify the path to mergerfs or unionfs with -U (e.g. `try -U ~/.local/bin/unionfs`)
Expand All @@ -34,6 +35,7 @@ To run `try`'s test suite (`scripts/run_tests.sh`), you will need:

* `bash`
* `expect`
* `curl`

`try` has been tested on the following distributions:

Expand All @@ -52,13 +54,22 @@ or higher for overlayfs to work in a user namespace.*

### Installing

You only need the [`try` script](https://raw.githubusercontent.com/binpash/try/main/try), which you can download by cloning this repository:
There are three ways to install try:

1. **The quick and janky way: grab the script.** You only need the [`try` script](https://raw.githubusercontent.com/binpash/try/main/try). Put it in your `PATH` and you're ready to go. You won't have documentation or utility support, but it should work as is.
2. **By cloning the repository.** Run the following:
```ShellSession
$ git clone https://github.com/binpash/try.git
$ autoconf && ./configure && make && sudo make install
```
You should now have a fully featured `try`, including the support utilities (which should help `try` run faster) and manpage. Run `make test` to confirm that everything works.
3. **By using a source distribution.** Download `try-XXX.tgz` from [the release page](https://github.com/binpash/try/releases). You can get the latest prerelease by downloading [`try-latest.tgz`](https://github.com/binpash/try/releases/download/latest/try-latest.tgz). You can then install similarly to the above:
```ShellSession
$ git clone https://github.com/binpash/try.git
$ ./configure && make && sudo make install
```

To install the support utilities (which speed up `try` and improve its behavior on tricky filenames), run `make -C utils` and put the `try-commit` and `try-summary` binaries on your `$PATH`.
The repository and source distribution are slightly different: the repository does not include the `configure` script (generated by `autoconf`) or the manpage (generated by `pandoc`), but the source distribution does.

#### Arch Linux

Expand Down
Loading

0 comments on commit 2c000b8

Please sign in to comment.