Merge branch 'main' into pantry.core

This commit is contained in:
Max Howell 2023-03-15 09:09:36 -04:00 committed by GitHub
commit 6f7651f69e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
268 changed files with 10368 additions and 2 deletions

View file

@ -75,6 +75,9 @@ jobs:
bottle-standalone:
runs-on: ubuntu-latest
needs: [cd]
permissions:
contents: read
actions: write
if: ${{ needs.cd.outputs.has-artifacts == 'false' }}
steps:
- uses: actions/checkout@v3
@ -92,5 +95,5 @@ jobs:
- run: gh workflow run new-version.yml -f "projects=$PROJECTS"
if: ${{ steps.diff.outputs.diff != '' }}
env:
GITHUB_TOKEN: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
GH_TOKEN: ${{ github.token }}
PROJECTS: ${{ steps.diff.outputs.diff }}

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
/srcs
/builds
/testbeds
.DS_Store
#TODO commit after v1
/deno.lock

View file

@ -1,3 +1,97 @@
![tea](https://tea.xyz/banner.png)
➡➡➡ https://github.com/teaxyz/pantry
# What is a Pantry?
Pantries provide consistent metadata about open source packages. This
metadata shouldnt require manual collection, but at this current state in
open source it does.
It is collected and duplicated thousands of times. A huge waste of effort.
tea aims to eradicate this wasted effort, though unfortunately, the journey
there will require—to some extent—doing that duplication one more time.
## Doing it a Little Better This Time
Our format is YAML, which is at least non-proprietary and could be used by
other tools without an independent parser. And were pulling in data from
other sources as much as possible, eg. versions are taken from the
“source” whenever possible.
 
# Contributing
Assuming you have tea (/w magic) installed:
```sh
$ git clone https://github.com/teaxyz/pantry
$ cd pantry
# all the following commands operate in `./tea.out`
# your tea installation remains untouched
$ pkg init
# ^^ creates a “wip” package.yml
# ^^ if you already know the name, you can pass it as an argument
$ pkg edit
# ^^ opens the new package.yml in your EDITOR
$ pkg build
# ^^ needs a zero permissions GITHUB_TOKEN to use the GitHub API
# either set `GITHUB_TOKEN` or run `gh auth login`
$ pkg test
# ^^ you need to write a test that verifies the package works
$ gh repo fork
$ git branch -m my-new-package
$ git push origin my-new-package
$ gh pr create
```
> * `pkg` can be run without magic via `tea -E pkg` (this dev-env provides `+tea.xyz/brewkit`).
> * `gh` can be run without magic via `tea gh`.
> * `git` can be run without magic via `tea git`.
> * `pkg build` and `pkg test` take a `-L` flag to run in a Linux Docker container
> * All commands take an optional pkg-spec eg. `pkg build zlib.net^1.1`
While inside a pantry dev-env you can run commands from any built packages
provided you specified their `provides:` key.
## Packaging Guide
Packaging can be cumbersome.
Our [wiki] is our packaging knowledge base.
For other assistance, start a [discussion].
## After Your Contribution
We build “bottles” (tard binaries) and upload them to both our centralized
bottle storage and decentralized [IPFS].
tea automatically builds new releases of packages *as soon as they are
released* (usually starting the builds within seconds). There is no need to
submit PRs for updates.
## Working on Other Peoples Pull Requests
Packaging can be fiddly so we all pitch in. If you want to help someone else
with their pull request then you can use GitHubs CLI:
```
$ gh pr checkout 123
# or you can copy paste the URL:
$ gh pr checkout https://github.com/teaxyz/pantry/pull/123
# then open for editing:
$ pkg edit
```
[wiki]: https://github.com/teaxyz/pantry/wiki
[discussion]: https://github.com/orgs/teaxyz/discussions
[IPFS]: https://ipfs.tech

View file

@ -0,0 +1 @@
localhost ansible_connection=local

View file

@ -0,0 +1,74 @@
distributable:
url: https://github.com/ansible/ansible/archive/v{{version}}.tar.gz
strip-components: 1
versions:
github: ansible/ansible/tags # reads github *tags*
strip: /^v/
dependencies:
python.org: '>=3.7'
build:
script: |
python-venv.sh {{prefix}}/bin/ansible
# manually register all the ansible-* executables with tea
#FIXME dirty hack, replace with a proper solution
for _EXEC in {{prefix}}/venv/bin/ansible-*; do
CMD_NAME="${_EXEC##*/}" # get text after the last slash (the command name)
TRG_BIN_NAME="{{prefix}}/bin/$CMD_NAME"
cp -v {{prefix}}/bin/ansible $TRG_BIN_NAME # copy the tea-configured executable with the correct name
# replace the original 'ansible' with the correct $CMD_NAME
sed -i.bak -e \
"s|/bin/ansible|/bin/$CMD_NAME|" \
$TRG_BIN_NAME
done
# install paramiko, a python ssh library sometimes used with ansible
{{prefix}}/venv/bin/pip install paramiko #FIXME should we pin a version?
rm -v {{prefix}}/bin/ansible-*.bak
test:
script: |
ansible --version
ansible-playbook playbook.yml -i hosts.ini
#FIXME below is a test from the brew formula, but I'm not sure what it's testing
# ^ especially considering that 'requests' is not a part of ansible's dependencies
# Ensure requests[security] is activated
# py_script="import requests as r; r.get('https://mozilla-modern.badssl.com')"
# {{prefix}}/venv/bin/python -c "$py_script"
# Ensure ansible-vault can encrypt/decrypt files.
echo $SECRET_MESSAGE > vault-test-file.txt
echo $VAULT_PASSWORD > vault-password.txt
ansible-vault encrypt --vault-password-file vault-password.txt vault-test-file.txt
test "$(cat vault-test-file.txt)" != "$SECRET_MESSAGE" # encrypted
ansible-vault decrypt --vault-password-file vault-password.txt vault-test-file.txt
test "$(cat vault-test-file.txt)" = "$SECRET_MESSAGE" # decrypted
# ensure paramiko is installed
{{prefix}}/venv/bin/python -c "import paramiko"
env:
VAULT_PASSWORD: "123456789"
SECRET_MESSAGE: "Hello world!"
provides:
- bin/ansible
- bin/ansible-config
- bin/ansible-connection
- bin/ansible-console
- bin/ansible-doc
- bin/ansible-galaxy
- bin/ansible-inventory
- bin/ansible-playbook
- bin/ansible-pull
- bin/ansible-test
- bin/ansible-vault

View file

@ -0,0 +1,6 @@
---
- hosts: all
gather_facts: False
tasks:
- name: ping
ping:

View file

@ -0,0 +1,34 @@
distributable:
url: https://aomedia.googlesource.com/aom/+archive/v{{version}}.tar.gz
versions:
- 3.5.0
build:
dependencies:
x86-64:
nasm.us: 2
tea.xyz/gx/cc: c99
cmake.org: ^3
tea.xyz/gx/make: '*'
working-directory:
out
script: |
cmake .. $ARGS
make
make install
env:
ARGS:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX="{{prefix}}"
linux:
CFLAGS: -fPIC
CXXFLAGS: -fPIC
LDFLAGS: -pie
test: |
aomenc --help
aomdec --help
provides:
- bin/aomenc
- bin/aomdec

View file

@ -0,0 +1,38 @@
distributable:
url: https://github.com/aria2/aria2/releases/download/release-{{ version }}/aria2-{{ version }}.tar.xz
strip-components: 1
versions:
github: aria2/aria2
strip: /^aria2 /
provides:
- bin/aria2c
dependencies:
zlib.net: ^1
openssl.org: ^1
libexpat.github.io: '*'
sqlite.org: ^3
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
gnupg.org/libgcrypt: ^1
gnupg.org/libgpg-error: ^1
freedesktop.org/pkg-config: '*'
script: |
./configure $ARGS
make --jobs {{hw.concurrency}}
make install
env:
ARGS:
- --prefix="{{prefix}}"
- --with-openssl
- --with-libgcrypt
test: |
aria2c -v
aria2c https://tea.xyz
aria2c --seed-time=0 "magnet:?xt=urn:btih:d984f67af9917b214cd8b6048ab5624c7df6a07a&tr=https%3A%2F%2Facademictorrents.com%2Fannounce.php&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce"

View file

@ -0,0 +1,32 @@
distributable:
url: https://github.com/aws/aws-cli/archive/{{version}}.tar.gz
strip-components: 1
versions:
github: aws/aws-cli/tags
dependencies:
python.org: ">=3.7"
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: "*"
rust-lang.org: ">=1.48.0" # needed for cryptography
rust-lang.org/cargo: "*"
script: |
python-venv.sh {{prefix}}/bin/aws
env:
# python includes are subdirectoried under the version
# frankly, python's versioning system causes a lot of
# issues for us despite its similarities to our own,
# due to versioning at the end of the path tree,
# instead of the beginning.
CPATH: $CPATH:{{deps.python.org.prefix}}/include/python{{deps.python.org.version.marketing}}
test: |
# Pretty much anything else appears to require AWS credentials
aws --version
provides:
- bin/aws

View file

@ -0,0 +1,24 @@
distributable:
url: https://beyondgrep.com/ack-v{{version}}
versions:
github: beyondgrep/ack3/tags
provides:
- bin/ack
dependencies:
perl.org: '*'
build: |
mkdir -p "{{prefix}}/bin"
mv beyondgrep.com-{{version}}* ack
install -m755 ./ack "{{prefix}}/bin"
#TODO generate man page
# ^^ above is weird as our cache system adds a `.[0-9]` extension because the
# download is a text file without extension but the URL itself ends with the
# version number
# 3 ways to fix this, 1. magic file detection, 2. mime-types, 3. explicit yaml
test: |
ack --version

View file

@ -0,0 +1,43 @@
distributable:
url: https://bitcoincore.org/bin/bitcoin-core-{{version}}/bitcoin-{{version}}.tar.gz
strip-components: 1
versions:
github: bitcoin/bitcoin
strip: /^Bitcoin Core /
dependencies:
oracle.com/berkeley-db: ^18
boost.org: ^1
libevent.org: ^2
zeromq.org: ^4
sqlite.org: ^3
build:
dependencies:
gnu.org/autoconf: ^2
gnu.org/automake: ^1
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
freedesktop.org/pkg-config: ^0.29
gnu.org/libtool: ^2
script: |
./autogen.sh
./configure $ARGS
make --jobs {{ hw.concurrency }} install
env:
ARGS:
- --prefix={{prefix}}
- --disable-debug
- --disable-tests # needs: `hexedit`
- --disable-bench # fails: linux/aarch64/v24.0.1
provides:
- bin/bitcoin-cli
- bin/bitcoin-tx
- bin/bitcoin-util
- bin/bitcoin-wallet
- bin/bitcoind
test:
bitcoind -version

View file

@ -0,0 +1,25 @@
distributable:
url: https://boostorg.jfrog.io/artifactory/main/release/{{ version }}/source/boost_{{version.major}}_{{version.minor}}_{{version.patch}}.tar.gz
strip-components: 1
versions:
github: boostorg/boost
strip: /^boost-/
dependencies:
facebook.com/zstd: ^1
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: |
./bootstrap.sh --prefix={{ prefix }}
./b2 install --prefix={{ prefix }}
test:
dependencies:
tea.xyz/gx/cc: c99
script: |
c++ test.cpp -std=c++14 -lboost_iostreams -lzstd
./a.out

View file

@ -0,0 +1,39 @@
#include <boost/algorithm/string.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filter/zstd.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/stream.hpp>
#include <string>
#include <iostream>
#include <vector>
#include <assert.h>
using namespace boost::algorithm;
using namespace boost::iostreams;
using namespace std;
int main() {
string str("a,b");
vector<string> strVec;
split(strVec, str, is_any_of(","));
assert(strVec.size()==2);
assert(strVec[0]=="a");
assert(strVec[1]=="b");
// Test boost::iostreams::zstd_compressor() linking
std::vector<char> v;
back_insert_device<std::vector<char>> snk{v};
filtering_ostream os;
os.push(zstd_compressor());
os.push(snk);
os << "Boost" << std::flush;
os.pop();
array_source src{v.data(), v.size()};
filtering_istream is;
is.push(zstd_decompressor());
is.push(src);
std::string s;
is >> s;
assert(s == "Boost");
return 0;
}

View file

@ -0,0 +1,47 @@
distributable:
url: https://github.com/oven-sh/bun/archive/refs/tags/bun-v{{version}}.tar.gz
warnings:
- vendored
versions:
github: oven-sh/bun
strip: /^Bun /
#FIXME proper system for re-using pre-built binaries
# we must require the vendor to provide signatures against a published public
# key. If they dont then really we should build ourselves or warn the user
# about the fact.
# The thing is, we trust the sources implicitly currently because signing is
# so rare. The only way wide spread signing will occur is via our protocol.
build:
dependencies:
curl.se: '*'
info-zip.org/unzip: '*'
working-directory: ${{prefix}}
script: |
curl -Lfo bun.zip "https://github.com/oven-sh/bun/releases/download/bun-v{{version}}/bun-$PLATFORM.zip"
unzip bun.zip
mv bun-$PLATFORM bin
rm bun.zip
cd bin
ln -s bun bunx
env:
darwin/aarch64: {PLATFORM: darwin-aarch64}
darwin/x86-64: {PLATFORM: darwin-x64}
linux/aarch64: {PLATFORM: linux-aarch64}
linux/x86-64: {PLATFORM: linux-x64}
test: |
if test "{{hw.platform}}+{{hw.arch}}" != "darwin+x86-64"; then
# bun hangs in CI/CD for this platform (BUT WORKS LOCALLY LOL)
bun --help
fi
# bunx shx ls
# ^^ tries to run `node` for some reason
#TODO a reasonable test for `bunx` that works ffs
provides:
- bin/bun
- bin/bunx

View file

@ -0,0 +1,42 @@
distributable:
url: https://cairographics.org/releases/cairo-{{ version }}.tar.xz
strip-components: 1
versions:
- 1.16.0
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
libpng.org: 1
pixman.org: ^0.40.0
freetype.org: 2
gnome.org/glib: 2
freedesktop.org/fontconfig: 2
sourceware.org/bzip2: 1
build:
dependencies:
freedesktop.org/pkg-config: ^0.29
#FIXME or fontconfig detection fails
#FIXME build looks for 2.4.9 even when it has 2.5.0
libexpat.github.io: =2.4.9
gnome.org/gobject-introspection: 1
gnu.org/libtool: ^2
script: |
./configure --prefix={{ prefix }} --disable-dependency-tracking
make --jobs {{ hw.concurrency }}
make install
rm -rf {{prefix}}/share # docs are online
test:
dependencies:
tea.xyz/gx/cc: c99
script: |
cc test.c -I{{prefix}}/include/cairo -lcairo
./a.out
#FIXME env should add that include path via pkg-config look up
provides:
- bin/cairo-trace

View file

@ -0,0 +1,7 @@
#include <cairo.h>
int main(int argc, char *argv[]) {
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 600, 400);
cairo_t *context = cairo_create(surface);
return 0;
}

View file

@ -0,0 +1,50 @@
distributable:
url: https://github.com/capstone-engine/capstone/archive/{{ version }}.tar.gz
strip-components: 1
versions:
github: capstone-engine/capstone/releases/tags
strip: /^v/
provides:
- bin/cstool
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: |
./make.sh
make install PREFIX={{ prefix }}
test:
dependencies:
tea.xyz/gx/cc: c99
script: |
mv $FIXTURE test.c
gcc test.c -lcapstone -o test
test "$(./test)" = "0x1000:\tpop\t\trsp\n0x1001:\tjs\t\t0x1038\n0x1003:\txor\t\teax, 0x3834785c\n0x1008:\tpop\t\trsp\n0x1009:\tjs\t\t0x1043\n"
fixture: |
#include <stdio.h>
#include <inttypes.h>
#include <capstone/capstone.h>
#define CODE "\\x55\\x48\\x8b\\x05\\xb8\\x13\\x00\\x00"
int main()
{
csh handle;
cs_insn *insn;
size_t count;
if (cs_open(CS_ARCH_X86, CS_MODE_64, &handle) != CS_ERR_OK)
return -1;
count = cs_disasm(handle, CODE, sizeof(CODE)-1, 0x1000, 0, &insn);
if (count > 0) {
size_t j;
for (j = 0; j < count; j++) {
printf("0x%"PRIx64":\\t%s\\t\\t%s\\n", insn[j].address, insn[j].mnemonic,insn[j].op_str);
}
cs_free(insn, count);
} else
printf("ERROR: Failed to disassemble given code!\\n");
cs_close(&handle);
return 0;
}

View file

@ -0,0 +1,27 @@
distributable:
url: http://www.catb.org/~esr/wumpus/wumpus-1.7.tar.gz
strip-components: 1
# When https://gitlab.com/esr/wumpus/-/merge_requests/3 is merged, then switch to
# https://gitlab.com/esr/wumpus/-/archive/{{ version.raw }}/wumpus-{{ version.raw }}.tar.gz
versions:
- 1.7
# TODO: Is there a gitlab version provider?
provides:
- bin/wumpus
- bin/superhack
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: |
make
make prefix={{prefix}} install
test:
script: echo no way to test this

View file

@ -0,0 +1,32 @@
distributable:
url: https://github.com/charmbracelet/glow/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: charmbracelet/glow
provides:
- bin/glow
build:
script: |
go mod download
go build -v -ldflags="$LDFLAGS"
mkdir -p "{{ prefix }}"/bin
mv glow "{{ prefix }}"/bin
dependencies:
go.dev: ^1.18
#FIXME should be this but we didnt build 1.17 yet
# go.dev: ~1.17
env:
GO111MODULE: on
LDFLAGS:
[-s, -w, "-X=main.Version={{version}}"]
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test:
glow --version

View file

@ -0,0 +1,31 @@
distributable:
url: https://github.com/charmbracelet/gum/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: charmbracelet/gum
provides:
- bin/gum
build:
script: |
go mod download
go build -v -ldflags="$LDFLAGS"
mkdir -p "{{ prefix }}"/bin
mv gum "{{ prefix }}"/bin
dependencies:
go.dev: ^1.18
#FIXME should be this but we didnt build 1.17 yet
# go.dev: ~1.17
env:
GO111MODULE: on
LDFLAGS:
[-s, -w, "-X=main.Version={{version}}"]
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test:
gum --version

View file

@ -0,0 +1,32 @@
distributable:
url: https://github.com/charmbracelet/melt/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: charmbracelet/melt
provides:
- bin/melt
build:
script: |
go mod download
go build -v -ldflags="$LDFLAGS" ./cmd/melt
mkdir -p "{{ prefix }}"/bin
mv melt "{{ prefix }}"/bin
dependencies:
go.dev: ^1.18
#FIXME should be this but we didnt build 1.17 yet
# go.dev: ~1.17
env:
GO111MODULE: on
LDFLAGS:
[-s, -w, "-X=main.Version={{version}}"]
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test:
melt --help

View file

@ -0,0 +1,38 @@
distributable:
url: https://github.com/charmbracelet/vhs/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: charmbracelet/vhs
provides:
- bin/vhs
interprets:
extensions: tape
args: vhs
dependencies:
ffmpeg.org: '>=5' # note might work with older versions
tsl0922.github.io/ttyd: ^1.7.2
build:
dependencies:
go.dev: ^1.18
script: |
go mod download
go build -v -ldflags="$LDFLAGS"
mkdir -p "{{ prefix }}"/bin
mv vhs "{{ prefix }}"/bin
env:
LDFLAGS:
[-s, -w, "-X=main.Version={{version}}"]
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
#TODO better
test:
vhs --version

View file

@ -0,0 +1,41 @@
distributable:
url: https://github.com/twpayne/chezmoi/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
versions:
github: twpayne/chezmoi/tags
strip: /v/
provides:
- bin/chezmoi
build:
script: |
go build -v -ldflags="$LDFLAGS"
mkdir -p "{{ prefix }}"/bin
mv chezmoi "{{ prefix }}"/bin
dependencies:
go.dev: ^1.18
linux:
gnu.org/gcc: "*"
gnu.org/binutils: "*" # for `as`
env:
LDFLAGS:
- -s
- -w
- -X main.version={{ version }}
- -X main.revision=tea
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test:
script: |
export HOME=$(pwd)
touch .bashrc
chezmoi -S .chezmoi init
chezmoi -S .chezmoi add .bashrc
ls -la .chezmoi
test -f .chezmoi/empty_dot_bashrc

View file

@ -0,0 +1,29 @@
distributable:
url: https://github.com/CircleCI-Public/circleci-cli/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: CircleCI-Public/circleci-cli/tags
strip: /^v/
build:
dependencies:
tea.xyz/gx/make: '*'
go.dev: '*'
script: |
go build -ldflags="$LDFLAGS" -o {{prefix}}/bin/circleci
env:
LDFLAGS:
- -s
- -w
- -X github.com/CircleCI-Public/circleci-cli/version.packageManager=tea
- -X github.com/CircleCI-Public/circleci-cli/version.Version={{version}}
provides:
- bin/circleci
test:
script: |
circleci version
echo "{version: 2.1}" > .circleci.yml
circleci config pack .circleci.yml

View file

@ -0,0 +1,37 @@
distributable:
url: https://github.com/cli/cli/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: cli/cli/tags
ignore: /-pre\./
provides:
- bin/gh
build:
script: |
make bin/gh
mkdir -p "{{prefix}}"/bin
mv bin/gh "{{prefix}}"/bin
# cleanup - gocache for some reason is not writeable
chmod -R u+w "$GOPATH" "$GOCACHE"
rm -rf "$GOPATH" "$GOCACHE"
dependencies:
go.dev: ^1.18
tea.xyz/gx/make: '*'
tea.xyz/gx/cc: c99 # for cgo
env:
GOPATH: ${{prefix}}/gopath
GOCACHE: ${{prefix}}/gocache
GH_VERSION: ${{version}}
GO_LDFLAGS:
- -s -w
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
GO_LDFLAGS:
- -buildmode=pie
test:
gh --version

View file

@ -0,0 +1,30 @@
distributable:
url: https://code.videolan.org/rist/librist/-/archive/v{{version}}/librist-v{{version}}.tar.gz
strip-components: 1
versions:
- 0.2.7
build:
dependencies:
tea.xyz/gx/cc: c99
mesonbuild.com: ^0.47
ninja-build.org: 1
working-directory:
build
script: |
meson .. --prefix={{prefix}} --libdir={{prefix}}/lib --buildtype=release
ninja -v
ninja install
env:
CC: clang
test:
script: |
ristsrppasswd test test
provides:
- bin/rist2rist
- bin/ristreceiver
- bin/ristsender
- bin/ristsrppasswd

View file

@ -0,0 +1,34 @@
distributable:
url: https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/App-cpanminus-{{version.raw}}.tar.gz
strip-components: 1
versions:
github: miyagawa/cpanminus/tags
ignore:
- /^1.9/ # invalid versions in the tags for some reason
- /^1.79/ # ^^
- /^1.71/ # ^^ like wtf?
dependencies:
perl.org: '*'
companions:
tea.xyz/gx/make: '*'
provides:
- bin/cpanm
build:
dependencies:
tea.xyz/gx/make: '*'
script: |
perl Makefile.PL INSTALL_BASE={{prefix}}
make install
fix-shebangs.ts {{prefix}}/bin/cpanm
test:
dependencies:
tea.xyz/gx/make: '*'
script:
cpanm --verbose --local-lib=./out Test::More

View file

@ -0,0 +1,27 @@
distributable:
url: https://github.com/sharkdp/bat/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
provides:
- bin/bat
versions:
github: sharkdp/bat/tags
strip: /v/
dependencies:
zlib.net: ^1
build:
dependencies:
rust-lang.org: '>=1.60'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
script: |
mv $FIXTURE $FIXTURE.js
bat $FIXTURE.js
fixture: |
console.log("Hello, World!");

View file

@ -0,0 +1,25 @@
distributable:
url: https://codeload.github.com/ClementTsang/bottom/tar.gz/refs/tags/{{version}}
strip-components: 1
provides:
- bin/btm
versions:
github: ClementTsang/bottom/tags
strip: /v/
dependencies:
zlib.net: ^1
build:
dependencies:
rust-lang.org: '>=1.60'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
script: |
test "$(btm --version)"="bottom {{version}}"

View file

@ -0,0 +1,24 @@
# cargo install bpb does not work because cargo does not require correct
# semantic versioning and allows yanking so the dependency graph has begun to
# fail
distributable:
url: https://github.com/withoutboats/bpb/tarball/b1ef5ca1d2dea0e2ec0b1616f087f110ea17adfa
# repo has no tags, presumably we can get the tags from crates.io, but not
# sure how to do that at this time
strip-components: 1
provides:
- bin/bpb
versions:
- 1.1.0
build:
dependencies:
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
bpb --help

View file

@ -0,0 +1,24 @@
distributable:
url: https://github.com/Canop/broot/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
provides:
- bin/broot
versions:
github: Canop/broot/tags
strip: /v/
dependencies:
zlib.net: ^1
build:
dependencies:
rust-lang.org: '>=1.56'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
#FIXME? how does one test a curses app well?
broot --help

View file

@ -0,0 +1,27 @@
distributable:
url: https://github.com/Byron/dua-cli/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
provides:
- bin/dua
versions:
github: Byron/dua-cli/tags
strip: /v/
dependencies:
zlib.net: ^1
build:
dependencies:
rust-lang.org: '>=1.60'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
script: |
for x in foo bar baz bat; do
echo $x > $x
done
dua

View file

@ -0,0 +1,25 @@
distributable:
url: https://github.com/ogham/exa/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
provides:
- bin/exa
versions:
github: ogham/exa/tags
strip: /^v/
dependencies:
darwin:
zlib.net: ^1
build:
dependencies:
rust-lang.org: '>=1.60'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
script: |
exa --version

View file

@ -0,0 +1,24 @@
distributable:
url: https://github.com/sharkdp/fd/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
provides:
- bin/fd
versions:
github: sharkdp/fd/tags
build:
dependencies:
tea.xyz/gx/make: '*'
rust-lang.org: '>=1.60'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
script: |
mv $FIXTURE test.cpp
fd -e cpp test
fixture: |
hello, world

View file

@ -0,0 +1,19 @@
distributable:
url: https://github.com/sharkdp/hyperfine/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
provides:
- bin/hyperfine
versions:
github: sharkdp/hyperfine/tags
strip: /v/
build:
dependencies:
rust-lang.org: '>=1.60'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test: hyperfine --runs 5 'sleep 0.3'

View file

@ -0,0 +1,23 @@
distributable:
url: https://github.com/raftario/licensor/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
provides:
- bin/licensor
versions:
github: raftario/licensor/tags
strip: /v/
dependencies:
zlib.net: ^1
build:
dependencies:
rust-lang.org: '>=1.31'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
licensor MIT | grep 'AS IS'

View file

@ -0,0 +1,21 @@
distributable:
url: https://github.com/swsnr/mdcat/archive/refs/tags/mdcat-{{ version }}.tar.gz
strip-components: 1
provides:
- bin/mdcat
versions:
github: swsnr/mdcat/tags
strip: /mdcat-/
build:
dependencies:
rust-lang.org: '>=1.56'
rust-lang.org/cargo: '*'
freedesktop.org/pkg-config: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
mdcat --version

View file

@ -0,0 +1,22 @@
distributable:
url: https://github.com/BurntSushi/ripgrep/archive/refs/tags/{{version}}.tar.gz
strip-components: 1
provides:
- bin/rg
versions:
github: BurntSushi/ripgrep/tags
build:
dependencies:
rust-lang.org: '>=1.34'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
script: |
rg hello $FIXTURE
fixture: |
hello, world

View file

@ -0,0 +1,464 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h> /* gai_strerror() */
#include <io.h> /* write() */
#include <fcntl.h> /* O_BINARY */
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/uio.h>
#endif
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
/* rustls.h is autogenerated in the Makefile using cbindgen. */
#include "rustls.h"
#include "common.h"
/*
* Connect to the given hostname on the given port and return the file
* descriptor of the socket. On error, print the error and return 1. Caller is
* responsible for closing socket.
*/
int
make_conn(const char *hostname, const char *port)
{
int sockfd = 0;
enum crustls_demo_result result = 0;
struct addrinfo *getaddrinfo_output = NULL, hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM; /* looking for TCP */
fprintf(stderr, "connecting to %s:%s\n", hostname, port);
int getaddrinfo_result =
getaddrinfo(hostname, port, &hints, &getaddrinfo_output);
if(getaddrinfo_result != 0) {
fprintf(stderr, "client: getaddrinfo: %s\n", gai_strerror(getaddrinfo_result));
goto cleanup;
}
sockfd = socket(getaddrinfo_output->ai_family,
getaddrinfo_output->ai_socktype,
getaddrinfo_output->ai_protocol);
if(sockfd < 0) {
perror("making socket");
goto cleanup;
}
int connect_result = connect(
sockfd, getaddrinfo_output->ai_addr, getaddrinfo_output->ai_addrlen);
if(connect_result < 0) {
perror("connecting");
goto cleanup;
}
result = nonblock(sockfd);
if(result != CRUSTLS_DEMO_OK) {
return 1;
}
freeaddrinfo(getaddrinfo_output);
return sockfd;
cleanup:
if(getaddrinfo_output != NULL) {
freeaddrinfo(getaddrinfo_output);
}
if(sockfd > 0) {
close(sockfd);
}
return -1;
}
/*
* Do one read from the socket, and process all resulting bytes into the
* rustls_connection, then copy all plaintext bytes from the session to stdout.
* Returns:
* - CRUSTLS_DEMO_OK for success
* - CRUSTLS_DEMO_AGAIN if we got an EAGAIN or EWOULDBLOCK reading from the
* socket
* - CRUSTLS_DEMO_EOF if we got EOF
* - CRUSTLS_DEMO_ERROR for other errors.
*/
enum crustls_demo_result
do_read(struct conndata *conn, struct rustls_connection *rconn)
{
int err = 1;
int result = 1;
size_t n = 0;
ssize_t signed_n = 0;
char buf[1];
err = rustls_connection_read_tls(rconn, read_cb, conn, &n);
if(err == EAGAIN || err == EWOULDBLOCK) {
fprintf(stderr,
"client: reading from socket: EAGAIN or EWOULDBLOCK: %s\n",
strerror(errno));
return CRUSTLS_DEMO_AGAIN;
}
else if(err != 0) {
fprintf(stderr, "client: reading from socket: errno %d\n", err);
return CRUSTLS_DEMO_ERROR;
}
result = rustls_connection_process_new_packets(rconn);
if(result != RUSTLS_RESULT_OK) {
print_error("server", "in process_new_packets", result);
return CRUSTLS_DEMO_ERROR;
}
result = copy_plaintext_to_buffer(conn);
if(result != CRUSTLS_DEMO_EOF) {
return result;
}
/* If we got an EOF on the plaintext stream (peer closed connection cleanly),
* verify that the sender then closed the TCP connection. */
signed_n = read(conn->fd, buf, sizeof(buf));
if(signed_n > 0) {
fprintf(stderr,
"client: error: read returned %zu bytes after receiving close_notify\n",
n);
return CRUSTLS_DEMO_ERROR;
}
else if (signed_n < 0 && errno != EWOULDBLOCK) {
fprintf(stderr,
"client: error: read returned incorrect error after receiving close_notify: %s\n",
strerror(errno));
return CRUSTLS_DEMO_ERROR;
}
return CRUSTLS_DEMO_EOF;
}
static const char *CONTENT_LENGTH = "Content-Length";
/*
* Given an established TCP connection, and a rustls_connection, send an
* HTTP request and read the response. On success, return 0. On error, print
* the message and return 1.
*/
int
send_request_and_read_response(struct conndata *conn,
struct rustls_connection *rconn,
const char *hostname, const char *path)
{
int sockfd = conn->fd;
int ret = 1;
int err = 1;
int result = 1;
char buf[2048];
fd_set read_fds;
fd_set write_fds;
size_t n = 0;
const char *body;
const char *content_length_str;
const char *content_length_end;
unsigned long content_length = 0;
size_t headers_len = 0;
struct rustls_str version;
version = rustls_version();
bzero(buf, sizeof(buf));
snprintf(buf,
sizeof(buf),
"GET %s HTTP/1.1\r\n"
"Host: %s\r\n"
"User-Agent: %.*s\r\n"
"Accept: carcinization/inevitable, text/html\r\n"
"Connection: close\r\n"
"\r\n",
path,
hostname,
(int)version.len,
version.data);
/* First we write the plaintext - the data that we want rustls to encrypt for
* us- to the rustls connection. */
result = rustls_connection_write(rconn, (uint8_t *)buf, strlen(buf), &n);
if(result != RUSTLS_RESULT_OK) {
fprintf(stderr, "client: error writing plaintext bytes to rustls_connection\n");
goto cleanup;
}
if(n != strlen(buf)) {
fprintf(stderr,
"client: short write writing plaintext bytes to rustls_connection\n");
goto cleanup;
}
for(;;) {
FD_ZERO(&read_fds);
/* These two calls just inspect the state of the connection - if it's time
for us to write more, or to read more. */
if(rustls_connection_wants_read(rconn)) {
FD_SET(sockfd, &read_fds);
}
FD_ZERO(&write_fds);
if(rustls_connection_wants_write(rconn)) {
FD_SET(sockfd, &write_fds);
}
if(!rustls_connection_wants_read(rconn) && !rustls_connection_wants_write(rconn)) {
fprintf(stderr, "client: rustls wants neither read nor write. draining plaintext and exiting.\n");
goto drain_plaintext;
}
result = select(sockfd + 1, &read_fds, &write_fds, NULL, NULL);
if(result == -1) {
perror("select");
goto cleanup;
}
if(FD_ISSET(sockfd, &read_fds)) {
/* Read all bytes until we get EAGAIN. Then loop again to wind up in
select awaiting the next bit of data. */
for(;;) {
result = do_read(conn, rconn);
if(result == CRUSTLS_DEMO_AGAIN) {
break;
}
else if(result == CRUSTLS_DEMO_EOF) {
goto drain_plaintext;
}
else if(result != CRUSTLS_DEMO_OK) {
goto cleanup;
}
if(headers_len == 0) {
body = body_beginning(&conn->data);
if(body != NULL) {
headers_len = body - conn->data.data;
fprintf(stderr, "client: body began at %zu\n", headers_len);
content_length_str = get_first_header_value(conn->data.data,
headers_len,
CONTENT_LENGTH,
strlen(CONTENT_LENGTH),
&n);
if(content_length_str == NULL) {
fprintf(stderr, "client: content length header not found\n");
goto cleanup;
}
content_length =
strtoul(content_length_str, (char **)&content_length_end, 10);
if(content_length_end == content_length_str) {
fprintf(stderr,
"client: invalid Content-Length '%.*s'\n",
(int)n,
content_length_str);
goto cleanup;
}
fprintf(stderr, "client: content length %lu\n", content_length);
}
}
if(headers_len != 0 &&
conn->data.len >= headers_len + content_length) {
goto drain_plaintext;
}
}
}
if(FD_ISSET(sockfd, &write_fds)) {
for(;;) {
/* This invokes rustls_connection_write_tls. We pass a callback to
* that function. Rustls will pass a buffer to that callback with
* encrypted bytes, that we will write to `conn`. */
err = write_tls(rconn, conn, &n);
if(err != 0) {
fprintf(
stderr, "client: error in rustls_connection_write_tls: errno %d\n", err);
goto cleanup;
}
if(result == CRUSTLS_DEMO_AGAIN) {
break;
}
else if(n == 0) {
fprintf(stderr, "client: write returned 0 from rustls_connection_write_tls\n");
break;
}
}
}
}
fprintf(stderr, "client: send_request_and_read_response: loop fell through");
drain_plaintext:
result = copy_plaintext_to_buffer(conn);
if(result != CRUSTLS_DEMO_OK && result != CRUSTLS_DEMO_EOF) {
goto cleanup;
}
fprintf(stderr, "client: writing %zu bytes to stdout\n", conn->data.len);
if(write(STDOUT_FILENO, conn->data.data, conn->data.len) < 0) {
fprintf(stderr, "error writing to stderr\n");
goto cleanup;
}
ret = 0;
cleanup:
if(sockfd > 0) {
close(sockfd);
}
return ret;
}
int
do_request(const struct rustls_client_config *client_config,
const char *hostname, const char *port, const char *path)
{
struct rustls_connection *rconn = NULL;
struct conndata *conn = NULL;
int ret = 1;
int sockfd = make_conn(hostname, port);
if(sockfd < 0) {
// No perror because make_conn printed error already.
goto cleanup;
}
rustls_result result =
rustls_client_connection_new(client_config, hostname, &rconn);
if(result != RUSTLS_RESULT_OK) {
print_error("server", "client_connection_new", result);
goto cleanup;
}
conn = calloc(1, sizeof(struct conndata));
if(conn == NULL) {
goto cleanup;
}
conn->rconn = rconn;
conn->fd = sockfd;
conn->verify_arg = "verify_arg";
conn->program_name = "client";
rustls_connection_set_userdata(rconn, conn);
rustls_connection_set_log_callback(rconn, log_cb);
ret = send_request_and_read_response(conn, rconn, hostname, path);
if(ret != RUSTLS_RESULT_OK) {
goto cleanup;
}
ret = 0;
cleanup:
rustls_connection_free(rconn);
if(sockfd > 0) {
close(sockfd);
}
if(conn != NULL) {
if(conn->data.data != NULL) {
free(conn->data.data);
}
free(conn);
}
return ret;
}
enum rustls_result
verify(void *userdata, const rustls_verify_server_cert_params *params)
{
size_t i = 0;
const rustls_slice_slice_bytes *intermediates =
params->intermediate_certs_der;
struct rustls_slice_bytes bytes;
const size_t intermediates_len = rustls_slice_slice_bytes_len(intermediates);
struct conndata *conn = (struct conndata *)userdata;
fprintf(stderr,
"client: custom certificate verifier called for %.*s\n",
(int)params->dns_name.len,
params->dns_name.data);
fprintf(stderr, "client: end entity len: %zu\n", params->end_entity_cert_der.len);
fprintf(stderr, "client: intermediates:\n");
for(i = 0; i < intermediates_len; i++) {
bytes = rustls_slice_slice_bytes_get(intermediates, i);
if(bytes.data != NULL) {
fprintf(stderr, "client: intermediate, len = %zu\n", bytes.len);
}
}
fprintf(stderr, "client: ocsp response len: %zu\n", params->ocsp_response.len);
if(0 != strcmp(conn->verify_arg, "verify_arg")) {
fprintf(stderr, "client: invalid argument to verify: %p\n", userdata);
return RUSTLS_RESULT_GENERAL;
}
return RUSTLS_RESULT_OK;
}
int
main(int argc, const char **argv)
{
int ret = 1;
int result = 1;
if(argc <= 2) {
fprintf(stderr,
"usage: %s hostname port path\n\n"
"Connect to a host via HTTPS on the provided port, make a request "
"for the\n"
"given path, and emit response to stdout (three times).\n",
argv[0]);
return 1;
}
const char *hostname = argv[1];
const char *port = argv[2];
const char *path = argv[3];
struct rustls_client_config_builder *config_builder =
rustls_client_config_builder_new();
const struct rustls_client_config *client_config = NULL;
struct rustls_slice_bytes alpn_http11;
alpn_http11.data = (unsigned char*)"http/1.1";
alpn_http11.len = 8;
#ifdef _WIN32
WSADATA wsa;
WSAStartup(MAKEWORD(1, 1), &wsa);
setmode(STDOUT_FILENO, O_BINARY);
#endif
if(getenv("CA_FILE")) {
result = rustls_client_config_builder_load_roots_from_file(
config_builder, getenv("CA_FILE"));
if(result != RUSTLS_RESULT_OK) {
print_error("server", "loading trusted certificates", result);
goto cleanup;
}
} else if(getenv("NO_CHECK_CERTIFICATE")) {
rustls_client_config_builder_dangerous_set_certificate_verifier(
config_builder, verify);
} else {
fprintf(stderr, "client: must set either CA_FILE or NO_CHECK_CERTIFICATE env var\n");
goto cleanup;
}
rustls_client_config_builder_set_alpn_protocols(config_builder, &alpn_http11, 1);
client_config = rustls_client_config_builder_build(config_builder);
int i;
for(i = 0; i < 3; i++) {
result = do_request(client_config, hostname, port, path);
if(result != 0) {
goto cleanup;
}
}
// Success!
ret = 0;
cleanup:
rustls_client_config_free(client_config);
#ifdef _WIN32
WSACleanup();
#endif
return ret;
}

View file

@ -0,0 +1,355 @@
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h> /* gai_strerror() */
#include <io.h> /* write() */
#include <fcntl.h> /* O_BINARY */
#define strncasecmp _strnicmp
#else
#include <sys/socket.h>
#include <sys/uio.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#endif
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "rustls.h"
#include "common.h"
void
print_error(const char *program_name, const char *prefix, rustls_result result)
{
char buf[256];
size_t n;
rustls_error(result, buf, sizeof(buf), &n);
fprintf(stderr, "%s: %s: %.*s\n", program_name, prefix, (int)n, buf);
}
#ifdef _WIN32
const char *
ws_strerror(int err)
{
static char ws_err[50];
if(err >= WSABASEERR) {
snprintf(ws_err, sizeof(ws_err), "Winsock err: %d", err);
return ws_err;
}
/* Assume a CRT error */
return (strerror)(err);
}
#endif
/*
* Write n bytes from buf to the provided fd (on Windows, this must be
* stdout/stderr or a file, not a socket), retrying short writes until
* we finish or hit an error. Assumes fd is blocking and therefore doesn't
* handle EAGAIN. Returns 0 for success or 1 for error.
*/
int
write_all(int fd, const char *buf, int n)
{
int m = 0;
while(n > 0) {
m = write(fd, buf, n);
if(m < 0) {
perror("write_all");
return 1;
}
n -= m;
}
return 0;
}
/*
* Set a socket to be nonblocking.
*
* Returns CRUSTLS_DEMO_OK on success, CRUSTLS_DEMO_ERROR on error.
*/
enum crustls_demo_result
nonblock(int sockfd)
{
#ifdef _WIN32
u_long nonblock = 1UL;
if(ioctlsocket(sockfd, FIONBIO, &nonblock) != 0) {
perror("Error setting socket nonblocking");
return CRUSTLS_DEMO_ERROR;
}
#else
int flags;
flags = fcntl(sockfd, F_GETFL, 0);
if(flags < 0) {
perror("getting socket flags");
return CRUSTLS_DEMO_ERROR;
}
flags = fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
if(flags < 0) {
perror("setting socket nonblocking");
return CRUSTLS_DEMO_ERROR;
}
#endif
return CRUSTLS_DEMO_OK;
}
int
read_cb(void *userdata, unsigned char *buf, size_t len, size_t *out_n)
{
ssize_t n = 0;
struct conndata *conn = (struct conndata *)userdata;
n = recv(conn->fd, buf, len, 0);
if(n < 0) {
return errno;
}
if(out_n != NULL) {
*out_n = n;
}
return 0;
}
int
write_cb(void *userdata, const unsigned char *buf, size_t len, size_t *out_n)
{
ssize_t n = 0;
struct conndata *conn = (struct conndata *)userdata;
n = send(conn->fd, buf, len, 0);
if(n < 0) {
return errno;
}
if(out_n != NULL) {
*out_n = n;
}
return 0;
}
rustls_io_result
write_tls(struct rustls_connection *rconn, struct conndata *conn, size_t *n)
{
#ifdef _WIN32
return rustls_connection_write_tls(rconn, write_cb, conn, n);
#else
if(getenv("VECTORED_IO")) {
return rustls_connection_write_tls_vectored(rconn, write_vectored_cb, conn, n);
} else {
return rustls_connection_write_tls(rconn, write_cb, conn, n);
}
#endif /* _WIN32 */
}
#ifndef _WIN32
rustls_io_result write_vectored_cb(
void *userdata, const struct rustls_iovec *iov, size_t count, size_t *out_n)
{
ssize_t n = 0;
struct conndata *conn = (struct conndata *)userdata;
n = writev(conn->fd, (const struct iovec *)iov, count);
if(n < 0) {
return errno;
}
*out_n = n;
return 0;
}
#endif /* _WIN32 */
size_t
bytevec_available(struct bytevec *vec)
{
return vec->capacity - vec->len;
}
char *
bytevec_writeable(struct bytevec *vec)
{
return vec->data + vec->len;
}
void
bytevec_consume(struct bytevec *vec, size_t n)
{
vec->len += n;
}
// Ensure there are at least n bytes available between vec->len and
// vec->capacity. If this requires reallocating, this may return
// CRUSTLS_DEMO_ERROR.
enum crustls_demo_result
bytevec_ensure_available(struct bytevec *vec, size_t n)
{
size_t available = vec->capacity - vec->len;
size_t newsize;
void *newdata;
if(available < n) {
newsize = vec->len + n;
if(newsize < vec->capacity * 2) {
newsize = vec->capacity * 2;
}
newdata = realloc(vec->data, newsize);
if(newdata == NULL) {
fprintf(stderr, "out of memory trying to get %zu bytes\n", newsize);
return CRUSTLS_DEMO_ERROR;
}
vec->data = newdata;
vec->capacity = newsize;
}
return CRUSTLS_DEMO_OK;
}
/**
* Copy all available plaintext from rustls into our own buffer, growing
* our buffer as much as needed.
*/
int
copy_plaintext_to_buffer(struct conndata *conn)
{
int result;
size_t n;
struct rustls_connection *rconn = conn->rconn;
if(bytevec_ensure_available(&conn->data, 1024) != CRUSTLS_DEMO_OK) {
return CRUSTLS_DEMO_ERROR;
}
for(;;) {
char *buf = bytevec_writeable(&conn->data);
size_t avail = bytevec_available(&conn->data);
result = rustls_connection_read(rconn, (uint8_t *)buf, avail, &n);
if(result == RUSTLS_RESULT_PLAINTEXT_EMPTY) {
/* This is expected. It just means "no more bytes for now." */
return CRUSTLS_DEMO_OK;
}
if(result != RUSTLS_RESULT_OK) {
print_error(conn->program_name, "Error in rustls_connection_read", result);
return CRUSTLS_DEMO_ERROR;
}
if(n == 0) {
fprintf(stderr, "got 0-byte read, cleanly ending connection\n");
return CRUSTLS_DEMO_EOF;
}
bytevec_consume(&conn->data, n);
if(bytevec_ensure_available(&conn->data, 1024) != CRUSTLS_DEMO_OK) {
return CRUSTLS_DEMO_ERROR;
}
}
return CRUSTLS_DEMO_ERROR;
}
/**
* Since memmem is not cross-platform compatible, we bring our own.
* Copied from https://www.capitalware.com/rl_blog/?p=5847.
*
* Function Name
* memmem
*
* Description
* Like strstr(), but for non-text buffers that are not NULL delimited.
*
* public domain by Bob Stout
*
* Input parameters
* haystack - pointer to the buffer to be searched
* haystacklen - length of the haystack buffer
* needle - pointer to a buffer that will be searched for
* needlelen - length of the needle buffer
*
* Return Value
* pointer to the memory address of the match or NULL.
*/
void *
memmem(const void *haystack, size_t haystacklen, const void *needle,
size_t needlelen)
{
const char *bf = haystack;
const char *pt = needle;
const char *p = bf;
while(needlelen <= (haystacklen - (p - bf))) {
if(NULL != (p = memchr(p, (int)(*pt), haystacklen - (p - bf)))) {
if(0 == memcmp(p, needle, needlelen)) {
return (void *)p;
}
else {
++p;
}
}
else {
break;
}
}
return NULL;
}
char *
body_beginning(struct bytevec *vec)
{
const void *result = memmem(vec->data, vec->len, "\r\n\r\n", 4);
if(result == NULL) {
return NULL;
}
else {
return (char *)result + 4;
}
}
const char *
get_first_header_value(const char *headers, size_t headers_len,
const char *name, size_t name_len, size_t *n)
{
const void *result;
const char *current = headers;
size_t len = headers_len;
size_t skipped;
// We use + 3 because there needs to be room for `:` and `\r\n` after the
// header name
while(len > name_len + 3) {
result = memmem(current, len, "\r\n", 2);
if(result == NULL) {
return NULL;
}
skipped = (char *)result - current + 2;
len -= skipped;
current += skipped;
/* Make sure there's enough room to conceivably contain the header name,
* a colon (:), and something after that.
*/
if(len < name_len + 2) {
return NULL;
}
if(strncasecmp(name, current, name_len) == 0 && current[name_len] == ':') {
/* Found it! */
len -= name_len + 1;
current += name_len + 1;
result = memmem(current, len, "\r\n", 2);
if(result == NULL) {
*n = len;
return current;
}
*n = (char *)result - current;
return current;
}
}
return NULL;
}
void
log_cb(void *userdata, const struct rustls_log_params *params)
{
struct conndata *conn = (struct conndata*)userdata;
struct rustls_str level_str = rustls_log_level_str(params->level);
fprintf(stderr, "%s[fd %d][%.*s]: %.*s\n", conn->program_name, conn->fd,
(int)level_str.len, level_str.data, (int)params->message.len, params->message.data);
}

View file

@ -0,0 +1,128 @@
#ifndef COMMON_H
#define COMMON_H
#ifdef _WIN32
#define sleep(s) Sleep(1000 * (s))
#define read(s, buf, n) recv(s, buf, n, 0)
#define close(s) closesocket(s)
#define bzero(buf, n) memset(buf, '\0', n)
/* Hacks for 'errno' stuff
*/
#undef EAGAIN
#define EAGAIN WSAEWOULDBLOCK
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#undef errno
#define errno WSAGetLastError()
#define perror(str) fprintf(stderr, str ": %d.\n", WSAGetLastError())
const char * ws_strerror(int err);
#define strerror(e) ws_strerror(e)
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1 /* MinGW has this */
#endif /* !STDOUT_FILENO */
#endif /* _WIN32 */
enum crustls_demo_result
{
CRUSTLS_DEMO_OK,
CRUSTLS_DEMO_ERROR,
CRUSTLS_DEMO_AGAIN,
CRUSTLS_DEMO_EOF,
};
/* A growable vector of bytes. */
struct bytevec {
char *data;
size_t len;
size_t capacity;
};
struct conndata {
int fd;
const char *verify_arg;
const char *program_name;
struct bytevec data;
struct rustls_connection *rconn;
};
void
print_error(const char *program_name, const char *prefix, rustls_result result);
int
write_all(int fd, const char *buf, int n);
/* Make a socket nonblocking. */
enum crustls_demo_result
nonblock(int sockfd);
/* A callback that reads bytes from the network. */
int
read_cb(void *userdata, uint8_t *buf, uintptr_t len, uintptr_t *out_n);
/* Invoke rustls_connection_write_tls with either a vectored or unvectored
callback, depending on environment variable. */
rustls_io_result
write_tls(struct rustls_connection *rconn, struct conndata *conn, size_t *n);
/* A callback that writes bytes to the network. */
int
write_cb(void *userdata, const uint8_t *buf, uintptr_t len, uintptr_t *out_n);
#ifndef _WIN32
rustls_io_result write_vectored_cb(
void *userdata, const struct rustls_iovec *iov, size_t count, size_t *out_n);
#endif /* _WIN32 */
/* Number of bytes available for writing. */
size_t
bytevec_available(struct bytevec *vec);
/* Pointer to the writeable region. */
char *
bytevec_writeable(struct bytevec *vec);
/* Indicate that n bytes have been written, increasing len. */
void
bytevec_consume(struct bytevec *vec, size_t n);
/* Ensure there are at least n bytes available between vec->len and
* vec->capacity. If this requires reallocating, this may return
* CRUSTLS_DEMO_ERROR. */
enum crustls_demo_result
bytevec_ensure_available(struct bytevec *vec, size_t n);
/* Read all available bytes from the rustls_connection until EOF.
* Note that EOF here indicates "no more bytes until
* process_new_packets", not "stream is closed".
*
* Returns CRUSTLS_DEMO_OK for success,
* CRUSTLS_DEMO_ERROR for error,
* CRUSTLS_DEMO_EOF for "connection cleanly terminated by peer"
*/
int
copy_plaintext_to_buffer(struct conndata *conn);
/* Polyfill */
void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen);
/* If headers are done (received \r\n\r\n), return a pointer to the beginning
* of the body. Otherwise return NULL.
*/
char *
body_beginning(struct bytevec *vec);
/* If any header matching the provided name (NUL-terminated) exists, return
* a pointer to the beginning of the value for the first such occurrence
* and store the length of the header in n.
* If no such header exists, return NULL and don't modify n.
* The returned pointer will be borrowed from `headers`.
*/
const char *
get_first_header_value(const char *headers, size_t headers_len,
const char *name, size_t name_len, size_t *n);
void
log_cb(void *userdata, const struct rustls_log_params *params);
#endif /* COMMON_H */

View file

@ -0,0 +1,42 @@
distributable:
url: https://codeload.github.com/rustls/rustls-ffi/tar.gz/refs/tags/v{{version}}
strip-components: 1
versions:
github: rustls/rustls-ffi/tags
strip: /v/
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
rust-lang.org/cargo: '*'
script: |
cargo install cbindgen
make DESTDIR={{prefix}}
make DESTDIR={{prefix}} install
test:
dependencies:
tea.xyz/gx/cc: c99
openssl.org: '*' # needed for SSL_CERT_FILE
env:
LIBS:
- -lrustls
- -lc
linux:
LIBS:
- -lgcc_s
- -lutil
- -lrt
- -lpthread
- -lm
- -ldl
darwin:
LIBS:
- -framework Security
- -liconv
- -lSystem
script: |
cc client.c common.c -o client $LIBS
CA_FILE=$SSL_CERT_FILE ./client tea.xyz 443 /

View file

@ -0,0 +1,33 @@
distributable:
url: https://github.com/jhheider/sanitize/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
provides:
- bin/sanitize
versions:
github: jhheider/sanitize/tags
strip: /v/
build:
dependencies:
rust-lang.org: '>=1.56'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
script: |
mkdir -p foo/foo
touch foo/bar foo/bat foo/foo/bat foo/foo/bar
sanitize foo -f $FIXTURE -y
test "$(find foo | sort)" = "$OUT"
env:
OUT: |
foo
foo/bar
foo/foo
foo/foo/bat
fixture: |
/bar
/foo/bat

View file

@ -0,0 +1,38 @@
distributable:
url: https://github.com/jhheider/semverator/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
provides:
- bin/semverator
versions:
github: jhheider/semverator
strip: /v/
build:
dependencies:
rust-lang.org: '>=1.56'
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
script: |
# Passes
semverator validate 1.2.3
semverator eq 1.2.3 1.2.3
semverator neq 1.2.3 1.2.4
semverator gt 1.2.3 1.2.2
semverator lt 1.2.3 1.2.4
# Fails
semverator validate 1.2.three || rv1=$?
test $rv1 -ne 0
semverator eq 1.2.3 1.2.4 || rv2=$?
test $rv2 -ne 0
semverator neq 1.2.3 1.2.3 || rv3=$?
test $rv3 -ne 0
semverator gt 1.2.3 1.2.4 || rv4=$?
test $rv4 -ne 0
semverator lt 1.2.3 1.2.2 || rv5=$?
test $rv5 -ne 0

View file

@ -0,0 +1,19 @@
distributable:
url: https://github.com/ajeetdsouza/zoxide/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
provides:
- bin/zoxide
versions:
github: ajeetdsouza/zoxide
strip: /v/
build:
dependencies:
rust-lang.org/cargo: '*'
script:
cargo install --locked --path . --root {{prefix}}
test:
zoxide --help

View file

@ -0,0 +1,3 @@
package tea
project: "cuelang.org"

View file

@ -0,0 +1,32 @@
distributable:
url: https://github.com/cue-lang/cue/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: cue-lang/cue/tags
ignore: /-beta\./
provides:
- bin/cue
build:
script: |
go mod download
go build -v -ldflags="$LDFLAGS" -o "{{ prefix }}"/bin/cue ./cmd/cue
dependencies:
go.dev: ^1.18
env:
LDFLAGS:
- -s
- -w
- -X cuelang.org/go/cmd/cue/cmd.version=v{{ version }}
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test:
script: |
out=$(cue export data.cue --out yaml)
test "$out" = "project: cuelang.org"

View file

@ -0,0 +1,52 @@
distributable:
url: https://github.com/dagger/dagger/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
versions:
github: dagger/dagger
strip: /v/
provides:
- bin/dagger
build:
script: |
go build -v -ldflags="$LDFLAGS" ./cmd/dagger
mkdir -p "{{ prefix }}"/bin
mv dagger "{{ prefix }}"/bin
dependencies:
go.dev: ^1.18
env:
CGO_ENABLED: 0
LDFLAGS:
- -s
- -w
- -X go.dagger.io/dagger/version.Version={{ version }}
- -X go.dagger.io/dagger/version.Revision=tea
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test: |
dagger version
# This is a better test, but we might mask failures using || true
# think more about this.
#out=$(dagger query <<EOF 2>&1 || true
# {
# container {
# from(address:"alpine:latest") {
# withExec(args:["uname", "-nrio"]) {
# stdout
# }
# }
# }
# }
#EOF
#)
#if command -v docker; then
# test ! -z "$out"
#else
# test "$out" = 'Error: failed to run container: : exec: "docker": executable file not found in $PATH'
#fi

View file

@ -0,0 +1,17 @@
distributable:
url: https://github.com/denilsonsa/prettyping/archive/refs/tags/v{{ version }}/prettyping-{{ version }}.tar.gz
strip-components: 1
versions:
github: denilsonsa/prettyping/tags
provides:
- bin/prettyping
build:
script: |
mkdir {{ prefix }}/bin
mv prettyping {{ prefix }}/bin
test: |
prettyping -c 3 127.0.0.1

View file

@ -0,0 +1,11 @@
#include <jansson.h>
#include <assert.h>
int main()
{
json_t *json;
json_error_t error;
json = json_loads("\"foo\"", JSON_DECODE_ANY, &error);
assert(json && json_is_string(json));
json_decref(json);
return 0;
}

View file

@ -0,0 +1,25 @@
distributable:
url: https://github.com/akheron/jansson/releases/download/v{{ version.raw }}/jansson-{{ version.raw }}.tar.gz
strip-components: 1
versions:
github: akheron/jansson/tags
strip: /^v/
build:
dependencies:
linux:
gnu.org/gcc: '*'
darwin:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: |
./configure --prefix="{{prefix}}"
make --jobs {{ hw.concurrency }} install
test:
dependencies:
tea.xyz/gx/cc: c99
script: |
cc fixture.c -ljansson
./a.out

View file

@ -0,0 +1,25 @@
distributable:
url: https://downloads.sourceforge.net/project/docutils/docutils/{{version.marketing}}/docutils-{{version.marketing}}.tar.gz
strip-components: 1
versions:
- 0.19.0
dependencies:
python.org: 3.11
build:
script: |
python-venv.sh {{prefix}}/bin/docutils
provides:
- bin/docutils
test:
fixture: |
- This is a bullet list.
- Bullets can be "*", "+", or "-".
script: |
docutils $FIXTURE test.html

View file

@ -0,0 +1,56 @@
distributable:
url: https://gitlab.com/libeigen/eigen/-/archive/{{version}}/eigen-{{version}}.tar.gz
strip-components: 1
versions:
- 3.4.0
build:
working-directory: build
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
cmake.org: '^3'
script: |
cmake .. -DCMAKE_INSTALL_PREFIX={{prefix}}
make install
# stuff expects `Eigen` to be in `include` rather than namespaced
cd "{{prefix}}"
mv include/eigen3/* include
cd include
rmdir eigen3
# but work for stuff that expects the namespace too
ln -s eigen3 .
test:
make test
test:
dependencies:
tea.xyz/gx/cc: c99
freedesktop.org/pkg-config: ^0.29
env:
cxxflags: $(pkg-config --cflags eigen3)
fixture: |
#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
std::cout << m << std::endl;
}
script: |
mv $FIXTURE test.cpp
g++ test.cpp ${cxxflags} -o test
./test > output.txt
out=$(./test)
if test "$out" = $' 3 -1\n2.5 1.5'; then
echo "PASS"
else
echo "FAIL"
fi

View file

@ -0,0 +1,92 @@
distributable:
url: https://github.com/erlang/otp/releases/download/OTP-{{ version.raw }}/otp_src_{{ version.raw }}.tar.gz
strip-components: 1
provides:
- bin/ct_run
- bin/dialyzer
- bin/epmd
- bin/erl
- bin/erlc
- bin/escript
- bin/run_erl
- bin/to_erl
- bin/typer
interprets:
extensions: erl
args: escript
versions:
github: erlang/otp
strip: /^OTP /
dependencies:
openssl.org: '*'
invisible-island.net/ncurses: '*'
runtime:
env:
ERL_ROOTDIR: ${{prefix}}/lib/erlang
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
perl.org: '>=5'
script: |
export ERL_TOP=$(pwd)
./configure $ARGS
make -j {{hw.concurrency}}
make install
env:
CC: cc
CXX: c++
LD: ld
ARGS:
- --disable-debug
- --disable-silent-rules
- --prefix={{prefix}}
- --enable-dynamic-ssl-lib
- --enable-hipe
- --enable-smp-support
- --enable-threads
- --enable-pie
- --with-ssl={{deps.openssl.org.prefix}}
- --without-javac
darwin:
ARGS:
- --enable-darwin-64bit
- --enable-kernel-poll
- --with-dynamic-trace=dtrace
test:
script: |
epmd -kill || true
epmd -daemon -address 127.0.0.1 -relaxed_command_check
test "$(escript $FIXTURE 10)" = "factorial 10 = 3628800"
epmd -kill || true
env:
ERL_DIST_PORT: 8001
fixture: |
#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
main([String]) ->
try
N = list_to_integer(String),
F = fac(N),
io:format("factorial ~w = ~w\n", [N,F])
catch
_:_ ->
usage()
end;
main(_) ->
usage().
usage() ->
io:format("usage: factorial integer\n").
fac(0) -> 1;
fac(N) -> N * fac(N-1).

View file

@ -0,0 +1,52 @@
distributable:
url: https://github.com/facebook/zstd/archive/v{{version}}.tar.gz
strip-components: 1
versions:
github: facebook/zstd/releases/tags
dependencies:
lz4.org: ^1
tukaani.org/xz: ^5
zlib.net: ^1
provides:
- bin/pzstd
- bin/unzstd
- bin/zstd
- bin/zstdcat
- bin/zstdgrep
- bin/zstdless
- bin/zstdmt
build:
dependencies:
tea.xyz/gx/cc: c99
cmake.org: ^3
ninja-build.org: ^1
working-directory: build/out
script: |
cmake ../cmake $ARGS
cmake --build .
cmake --install .
env:
ARGS:
- -GNinja
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX="{{prefix}}"
- -DZSTD_PROGRAMS_LINK_SHARED=ON # link `zstd` to `libzstd`
- -DZSTD_BUILD_CONTRIB=ON
- -DZSTD_LEGACY_SUPPORT=ON
- -DZSTD_ZLIB_SUPPORT=ON
- -DZSTD_LZMA_SUPPORT=ON
- -DZSTD_LZ4_SUPPORT=ON
darwin:
ARGS:
# Otherwise we get errors from clang
- -DCMAKE_CXX_FLAGS="-std=c++11"
test: |
export fixture="asdf123%!*"
for x in zstd pzstd xz lz4 gzip; do
test $(echo "$fixture" | $x | zstd -d) = "$fixture"
done

View file

@ -0,0 +1,5 @@
#!/bin/sh
export GEM_HOME="$(cd $(dirname $0)/.. && pwd)"
export GEM_PATH="$GEM_HOME"
export PATH="$GEM_HOME/gems/bin:$PATH"
exec "$GEM_HOME"/gems/bin/fastlane "$@"

View file

@ -0,0 +1,45 @@
distributable:
url: https://github.com/fastlane/fastlane/archive/{{version}}.tar.gz
strip-components: 1
versions:
github: fastlane/fastlane/releases/tags
dependencies:
ruby-lang.org: ^3.1
rubygems.org: '*'
build:
dependencies:
rubygems.org: '*'
tea.xyz/gx/make: '*'
tea.xyz/gx/cc: '*'
env:
GEM_HOME: ${{prefix}}
GEM_PATH: ${{prefix}}
script: |
gem build fastlane.gemspec
gem install \
--no-user-install \
--bindir={{prefix}}/gems/bin \
--no-document \
fastlane-{{version}}.gem
mkdir "{{prefix}}"/bin
mv props/fastlane "{{prefix}}"/bin
# fails to code sign and non-essential
rm -rf "{{prefix}}"/gems/terminal-notifier-*
provides:
- bin/fastlane
test:
env:
# or writes a bunch of warnings to stdout
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
script: |
out="$(fastlane --version 2>/dev/null | tail -n1)"
test "$out" = "fastlane {{version}}"

View file

@ -0,0 +1,29 @@
distributable:
url: https://ffmpeg.org/releases/ffmpeg-{{version}}.tar.xz
sig: ${{url}}.asc
strip-components: 1
# docs: https://trac.ffmpeg.org/wiki/CompilationGuide
versions:
- 5.1.2
# TODO they have their own git repo we can grab tags from
provides:
- bin/ffmpeg
- bin/ffprobe
build:
dependencies:
x86-64:
nasm.us: 2
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: |
./configure --prefix="{{prefix}}"
make --jobs {{hw.concurrency}}
make install
test: |
ffmpeg -filter_complex testsrc=rate=1:duration=1 out.mp4
test -f out.mp4

View file

@ -0,0 +1,68 @@
diff --git a/doc_src/language.rst b/doc_src/language.rst
index 16558cc8899..f3767415f8e 100644
--- a/doc_src/language.rst
+++ b/doc_src/language.rst
@@ -1718,7 +1718,7 @@ In order:
- If the kernel knows how to run the file (e.g. via a ``#!`` line - ``#!/bin/sh`` or ``#!/usr/bin/python``), it does it.
- If the kernel reports that it couldn't run it because of a missing interpreter, and the file passes a rudimentary check, fish tells ``/bin/sh`` to run it.
-If none of these work, fish runs the function :doc:`fish_command_not_found <cmds/fish_command_not_found>` and sets :envvar:`status` to 127.
+If none of these work, fish runs the function :doc:`fish_command_not_found <cmds/fish_command_not_found>`.
You can use :doc:`type <cmds/type>` to see how fish resolved something::
diff --git a/share/functions/fish_command_not_found.fish b/share/functions/fish_command_not_found.fish
index 36ca2190553..77b3a78f7b9 100644
--- a/share/functions/fish_command_not_found.fish
+++ b/share/functions/fish_command_not_found.fish
@@ -13,6 +13,7 @@ end
function __fish_default_command_not_found_handler
printf (_ "fish: Unknown command: %s\n") (string escape -- $argv[1]) >&2
+ return 127
end
# If an old handler already exists, defer to that.
diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp
index 1050095116d..01b74398da1 100644
--- a/src/parse_execution.cpp
+++ b/src/parse_execution.cpp
@@ -723,7 +723,8 @@ parse_execution_context_t::ast_args_list_t parse_execution_context_t::get_argume
end_execution_reason_t parse_execution_context_t::handle_command_not_found(
const wcstring &cmd_str, const ast::decorated_statement_t &statement, int err_code) {
// We couldn't find the specified command. This is a non-fatal error. We want to set the exit
- // status to 127, which is the standard number used by other shells like bash and zsh.
+ // status to 127, which is the standard number used by other shells like bash and zsh,
+ // unless there is an explicit command handler, then we can use its exit code.
const wchar_t *const cmd = cmd_str.c_str();
if (err_code != ENOENT) {
@@ -770,7 +771,6 @@ end_execution_reason_t parse_execution_context_t::handle_command_not_found(
// Redirect to stderr
auto io = io_chain_t{};
- io.append_from_specs({redirection_spec_t{STDOUT_FILENO, redirection_mode_t::fd, L"2"}}, L"");
if (function_exists(L"fish_command_not_found", *parser)) {
buffer = L"fish_command_not_found";
@@ -778,15 +778,18 @@ end_execution_reason_t parse_execution_context_t::handle_command_not_found(
buffer.push_back(L' ');
buffer.append(escape_string(arg));
}
- auto prev_statuses = parser->get_last_statuses();
event_t event(event_type_t::generic);
event.desc.str_param1 = L"fish_command_not_found";
block_t *b = parser->push_block(block_t::event_block(event));
parser->eval(buffer, io);
parser->pop_block(b);
- parser->set_last_statuses(std::move(prev_statuses));
+
+ return end_execution_reason_t::cancelled;
} else {
+ // Redirect to stderr _if there's no handler_
+ io.append_from_specs({redirection_spec_t{STDOUT_FILENO, redirection_mode_t::fd, L"2"}},
+ L"");
// If we have no handler, just print it as a normal error.
error = _(L"Unknown command:");
if (!event_args.empty()) {

View file

@ -0,0 +1,63 @@
distributable:
url: https://github.com/fish-shell/fish-shell/archive/refs/tags/{{version}}.tar.gz
strip-components: 1
versions:
github: fish-shell/fish-shell/tags
dependencies:
gnu.org/gettext: '*'
invisible-island.net/ncurses: '>=6.0'
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
cmake.org: '>=3.5'
freedesktop.org/pkg-config: '*'
git-scm.org: '*'
script: |
# By default, fish's fish_command_not_found handler will redirect to stderr,
# return an exit code of 127. Always. This patch fixes it. Hopefully, it will
# be merged upstream soon. https://github.com/fish-shell/fish-shell/pull/9517
git apply props/command_not_found_handler.diff
echo {{version}} >version
mkdir build
cd build
cmake .. $ARGS
make install
cd {{prefix}}/share/fish
sed -i.bak -e "s| $TEA_PREFIX/| (tea --prefix)/|g" __fish_build_paths.fish
rm __fish_build_paths.fish.bak
env:
ARGS:
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX="{{prefix}}"
- -DCURSES_INCLUDE_PATH="{{deps.invisible-island.net/ncurses.prefix}}/include/ncursesw"
test:
script:
fish $FIXTURE | grep "variable1variable2variable3variable4variable5variable6variable7variable8variable9variable10go version go"
fixture: |
#!/usr/bin/env fish
set -lx V variable
for x in (seq 1 10)
echo -n $V$x
end
begin
set -lx SHELL fish
tea --magic | source
go version
end
provides:
- bin/fish
- bin/fish_indent
- bin/fish_key_reader

View file

@ -0,0 +1,32 @@
distributable:
url: https://libbsd.freedesktop.org/releases/libbsd-{{version}}.tar.xz
strip-components: 1
versions:
github: freedesktop/libbsd/tags
provides:
- bin/column
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
hadrons.org/libmd: '*'
script: |
if test "{{hw.platform}}" != "linux"; then
echo "libbsd is only supported on Linux"
touch {{prefix}}/linux-only
exit 0
fi
./configure --prefix={{prefix}}
make --jobs {{hw.concurrency}} install
test:
dependencies:
gnu.org/binutils: '*'
script: |
if test "{{hw.platform}}" = "linux"; then
nm {{prefix}}/lib/libbsd.so.{{version.major}} | grep strtonum
fi

View file

@ -0,0 +1,29 @@
distributable:
url: https://github.com/p11-glue/p11-kit/releases/download/{{ version }}/p11-kit-{{ version }}.tar.xz
strip-components: 1
versions:
github: p11-glue/p11-kit
strip: / \(stable\)$/
provides:
- bin/p11-kit
- bin/trust
dependencies:
sourceware.org/libffi: ^3
curl.se/ca-certs: '*'
gnu.org/gettext: '*'
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
gnu.org/libtasn1: ^4
freedesktop.org/pkg-config: '*'
script: |-
./configure --prefix={{prefix}} --with-trust-paths={{deps.curl.se/ca-certs}}/ssl
make -j {{ hw.concurrency }} install
test:
script: p11-kit list-modules

View file

@ -0,0 +1,52 @@
distributable:
url: https://gitlab.freedesktop.org/slirp/libslirp/-/archive/v{{ version }}/libslirp-v{{ version }}.tar.gz
strip-components: 1
versions:
- 4.7.0
dependencies:
gnome.org/glib: ^2
build:
dependencies:
mesonbuild.com: ^0.63
ninja-build.org: 1
freedesktop.org/pkg-config: ^0.29
tea.xyz/gx/cc: c99
script: |
meson build $ARGS
ninja -C build install all
cd "{{ prefix }}/lib"
mv pkgconfig/* .
rmdir pkgconfig
ln -s . slirp
env:
ARGS:
- -Ddefault_library=both
- --prefix={{ prefix }}
- --libdir={{ prefix }}/lib
- --buildtype=release
- --wrap-mode=nofallback
test:
dependencies:
tea.xyz/gx/cc: c99
script: |
mv $FIXTURE test.c
gcc test.c -lslirp -o test
./test
fixture: |
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <slirp/libslirp.h>
int main() {
SlirpConfig cfg;
memset(&cfg, 0, sizeof(cfg));
cfg.version = 1;
cfg.in_enabled = true;
cfg.vhostname = "testServer";
Slirp* ctx = slirp_new(&cfg, NULL, NULL);
return 0;
}

View file

@ -0,0 +1,40 @@
distributable:
url: https://github.com/fukuchi/libqrencode/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: fukuchi/libqrencode/tags
strip: /v/
provides:
- bin/qrencode
dependencies:
libpng.org: '*'
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
gnu.org/autoconf: '*'
gnu.org/automake: '*'
gnu.org/coreutils: '*'
gnu.org/libtool: '*'
freedesktop.org/pkg-config: '*'
script: |
./autogen.sh
./configure $ARGS
echo '#define VERSION "{{version}}"' >> config.h
make install
env:
ARGS:
- --prefix={{prefix}}
CFLAGS: $(pkg-config --cflags libpng)
LDFLAGS: $(pkg-config --libs libpng)
test:
dependencies:
imagemagick.org: '*'
script: |
qrencode 123456789 -o test.png
test "$(identify test.png | rev | cut -d ' ' -f3-| rev)" = "test.png PNG 87x87 87x87+0+0 8-bit sRGB 293B"

View file

@ -0,0 +1,55 @@
distributable:
url: https://github.com/gflags/gflags/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: gflags/gflags/tags
strip: /^v/
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
cmake.org: '*'
working-directory: buildroot
script: |
cmake $ARGS ..
make --jobs {{ hw.concurrency }}
make install
env:
ARGS:
- -DCMAKE_INSTALL_PREFIX={{prefix}}
- -DBUILD_SHARED_LIBS=ON
- -DBUILD_STATIC_LIBS=ON
- -DCMAKE_POSITION_INDEPENDENT_CODE=ON
test:
dependencies:
tea.xyz/gx/cc: c99
fixture: |
#include <iostream>
#include "gflags/gflags.h"
DEFINE_bool(verbose, false, "Display program name before message");
DEFINE_string(message, "Hello world!", "Message to print");
static bool IsNonEmptyMessage(const char *flagname, const std::string &value)
{
return value[0] != '\0';
}
DEFINE_validator(message, &IsNonEmptyMessage);
int main(int argc, char *argv[])
{
gflags::SetUsageMessage("some usage message");
gflags::SetVersionString("1.0.0");
gflags::ParseCommandLineFlags(&argc, &argv, true);
if (FLAGS_verbose) std::cout << gflags::ProgramInvocationShortName() << ": ";
std::cout << FLAGS_message;
gflags::ShutDownCommandLineFlags();
return 0;
}
script: |
mv $FIXTURE test.cpp
g++ test.cpp -lgflags -o test
./test

View file

@ -0,0 +1,108 @@
--- Makefile.orig 2019-06-26 12:08:33.000000000 +1000
+++ Makefile 2019-06-26 12:48:05.000000000 +1000
@@ -37,6 +37,8 @@
UHEADERS = getarg.h
UOBJECTS = $(USOURCES:.c=.o)
+UNAME:=$(shell uname)
+
# Some utilities are installed
INSTALLABLE = \
gif2rgb \
@@ -61,27 +63,53 @@
LDLIBS=libgif.a -lm
-all: libgif.so libgif.a libutil.so libutil.a $(UTILS)
+SOEXTENION = so
+LIBGIFSO = libgif.$(SOEXTENSION)
+LIBGIFSOMAJOR = libgif.$(SOEXTENSION).$(LIBMAJOR)
+LIBGIFSOVER = libgif.$(SOEXTENSION).$(LIBVER)
+LIBUTILSO = libutil.$(SOEXTENSION)
+LIBUTILSOMAJOR = libutil.$(SOEXTENSION).$(LIBMAJOR)
+ifeq ($(UNAME), Darwin)
+SOEXTENSION = dylib
+LIBGIFSO = libgif.$(SOEXTENSION)
+LIBGIFSOMAJOR = libgif.$(LIBMAJOR).$(SOEXTENSION)
+LIBGIFSOVER = libgif.$(LIBVER).$(SOEXTENSION)
+LIBUTILSO = libutil.$(SOEXTENSION)
+LIBUTILSOMAJOR = libutil.$(LIBMAJOR).$(SOEXTENSION)
+endif
+
+all: $(LIBGIFSO) libgif.a $(LIBUTILSO) libutil.a $(UTILS)
+ifeq ($(UNAME), Darwin)
+else
$(MAKE) -C doc
+endif
$(UTILS):: libgif.a libutil.a
-libgif.so: $(OBJECTS) $(HEADERS)
- $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libgif.so.$(LIBMAJOR) -o libgif.so $(OBJECTS)
+$(LIBGIFSO): $(OBJECTS) $(HEADERS)
+ifeq ($(UNAME), Darwin)
+ $(CC) $(CFLAGS) -dynamiclib -current_version $(LIBVER) $(OBJECTS) -o $(LIBGIFSO)
+else
+ $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,$(LIBGIFSOMAJOR) -o $(LIBGIFSO) $(OBJECTS)
+endif
libgif.a: $(OBJECTS) $(HEADERS)
$(AR) rcs libgif.a $(OBJECTS)
-libutil.so: $(UOBJECTS) $(UHEADERS)
- $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,libutil.so.$(LIBMAJOR) -o libutil.so $(UOBJECTS)
+$(LIBUTILSO): $(UOBJECTS) $(UHEADERS)
+ifeq ($(UNAME), Darwin)
+ $(CC) $(CFLAGS) -dynamiclib -current_version $(LIBVER) $(OBJECTS) -o $(LIBUTILSO)
+else
+ $(CC) $(CFLAGS) -shared $(LDFLAGS) -Wl,-soname -Wl,$(LIBUTILMAJOR) -o $(LIBUTILSO) $(UOBJECTS)
+endif
libutil.a: $(UOBJECTS) $(UHEADERS)
$(AR) rcs libutil.a $(UOBJECTS)
clean:
- rm -f $(UTILS) $(TARGET) libgetarg.a libgif.a libgif.so libutil.a libutil.so *.o
- rm -f libgif.so.$(LIBMAJOR).$(LIBMINOR).$(LIBPOINT)
- rm -f libgif.so.$(LIBMAJOR)
+ rm -f $(UTILS) $(TARGET) libgetarg.a libgif.a $(LIBGIFSO) libutil.a $(LIBUTILSO) *.o
+ rm -f $(LIBGIFSOVER)
+ rm -f $(LIBGIFSOMAJOR)
rm -fr doc/*.1 *.html doc/staging
check: all
@@ -89,7 +117,12 @@
# Installation/uninstallation
+ifeq ($(UNAME), Darwin)
+install: all install-bin install-include install-lib
+else
install: all install-bin install-include install-lib install-man
+endif
+
install-bin: $(INSTALLABLE)
$(INSTALL) -d "$(DESTDIR)$(BINDIR)"
$(INSTALL) $^ "$(DESTDIR)$(BINDIR)"
@@ -99,9 +132,9 @@
install-lib:
$(INSTALL) -d "$(DESTDIR)$(LIBDIR)"
$(INSTALL) -m 644 libgif.a "$(DESTDIR)$(LIBDIR)/libgif.a"
- $(INSTALL) -m 755 libgif.so "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBVER)"
- ln -sf libgif.so.$(LIBVER) "$(DESTDIR)$(LIBDIR)/libgif.so.$(LIBMAJOR)"
- ln -sf libgif.so.$(LIBMAJOR) "$(DESTDIR)$(LIBDIR)/libgif.so"
+ $(INSTALL) -m 755 $(LIBGIFSO) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSOVER)"
+ ln -sf $(LIBGIFSOVER) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSOMAJOR)"
+ ln -sf $(LIBGIFSOMAJOR) "$(DESTDIR)$(LIBDIR)/$(LIBGIFSO)"
install-man:
$(INSTALL) -d "$(DESTDIR)$(MANDIR)/man1"
$(INSTALL) -m 644 doc/*.1 "$(DESTDIR)$(MANDIR)/man1"
@@ -112,7 +145,7 @@
rm -f "$(DESTDIR)$(INCDIR)/gif_lib.h"
uninstall-lib:
cd "$(DESTDIR)$(LIBDIR)" && \
- rm -f libgif.a libgif.so libgif.so.$(LIBMAJOR) libgif.so.$(LIBVER)
+ rm -f libgif.a $(LIBGIFSO) $(LIBGIFSOMAJOR) $(LIBGIFSOVER)
uninstall-man:
cd "$(DESTDIR)$(MANDIR)/man1" && rm -f $(shell cd doc >/dev/null && echo *.1)

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 B

View file

@ -0,0 +1,31 @@
distributable:
url: https://downloads.sourceforge.net/project/giflib/giflib-{{version}}.tar.gz
strip-components: 1
versions:
- 5.2.1
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
gnu.org/patch: '*'
script: |
if test {{ hw.platform }} = "darwin"; then
# needed to work on macOS
patch -p0 < props/Makefile.patch
fi
make --jobs {{ hw.concurrency }} all
make install PREFIX="{{ prefix }}"
test:
giftext fixture.gif
provides:
- bin/gif2rgb
- bin/gifbuild
- bin/gifclrmp
- bin/giffix
- bin/giftext
- bin/giftool

View file

@ -0,0 +1,28 @@
distributable:
url: https://github.com/arzzen/git-quick-stats/archive/refs/tags/{{ version }}.tar.gz
strip-components: 1
versions:
github: arzzen/git-quick-stats
strip: /^Version /
provides:
- bin/git-quick-stats
dependencies:
git-scm.org: '*'
gnu.org/bash: '*'
linux:
# bin/column
github.com/util-linux/util-linux: '*'
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: make PREFIX={{prefix}} install
test: make test
test: |
git clone https://github.com/teaxyz/cli
git -C cli quick-stats -T

View file

@ -0,0 +1,58 @@
#include "avif/avif.h"
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char * argv[])
{
if (argc != 2) {
fprintf(stderr, "avif_example_decode_file [filename.avif]\n");
return 1;
}
const char * inputFilename = argv[1];
int returnCode = 1;
avifRGBImage rgb;
memset(&rgb, 0, sizeof(rgb));
avifDecoder * decoder = avifDecoderCreate();
avifResult result = avifDecoderSetIOFile(decoder, inputFilename);
if (result != AVIF_RESULT_OK) {
fprintf(stderr, "Cannot open file for read: %s\n", inputFilename);
goto cleanup;
}
result = avifDecoderParse(decoder);
if (result != AVIF_RESULT_OK) {
fprintf(stderr, "Failed to decode image: %s\n", avifResultToString(result));
goto cleanup;
}
printf("Parsed AVIF: %ux%u (%ubpc)\n", decoder->image->width, decoder->image->height, decoder->image->depth);
while (avifDecoderNextImage(decoder) == AVIF_RESULT_OK) {
avifRGBImageSetDefaults(&rgb, decoder->image);
avifRGBImageAllocatePixels(&rgb);
if (avifImageYUVToRGB(decoder->image, &rgb) != AVIF_RESULT_OK) {
fprintf(stderr, "Conversion from YUV failed: %s\n", inputFilename);
goto cleanup;
}
if (rgb.depth > 8) {
uint16_t * firstPixel = (uint16_t *)rgb.pixels;
printf(" * First pixel: RGBA(%u,%u,%u,%u)\n", firstPixel[0], firstPixel[1], firstPixel[2], firstPixel[3]);
} else {
uint8_t * firstPixel = rgb.pixels;
printf(" * First pixel: RGBA(%u,%u,%u,%u)\n", firstPixel[0], firstPixel[1], firstPixel[2], firstPixel[3]);
}
}
returnCode = 0;
cleanup:
avifRGBImageFreePixels(&rgb);
avifDecoderDestroy(decoder);
return returnCode;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

View file

@ -0,0 +1,43 @@
distributable:
url: https://github.com/AOMediaCodec/libavif/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: AOMediaCodec/libavif
dependencies:
aomedia.googlesource.com/aom: ^3
libpng.org: ^1
libjpeg-turbo.org: ^2
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
cmake.org: ^3
working-directory: build
script: |
cmake .. $ARGS
make --jobs {{ hw.concurrency }} install
env:
ARGS:
- -DCMAKE_INSTALL_PREFIX={{prefix}}
- -DCMAKE_BUILD_TYPE=Release
- -DAVIF_CODEC_AOM=ON
- -DAVIF_BUILD_APPS=ON
- -DAVIF_BUILD_EXAMPLES=OFF
- -DAVIF_BUILD_TESTS=OFF
provides:
- bin/avifenc
- bin/avifdec
test: |
avifenc fixture.png test.avif
test -f test.avif
avifdec test.avif test.jpg
test -f test.jpg
cc example.c -lavif
./a.out test.avif

View file

@ -0,0 +1,27 @@
distributable:
url: https://github.com/boyter/scc/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: boyter/scc
strip: /v/
provides:
- bin/scc
build:
dependencies:
go.dev: ^1.14
env:
LDFLAGS:
- -X=main.version={{version}}
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
script: |
GOBIN={{prefix}}/bin go install -ldflags="$LDFLAGS" .
test: |
scc .

View file

@ -0,0 +1,25 @@
distributable:
url: https://github.com/BurntSushi/xsv/archive/refs/tags/{{ version }}.tar.gz
strip-components: 1
versions:
github: BurntSushi/xsv/tags
provides:
- bin/xsv
build:
dependencies:
rust-lang.org: ">=1.60"
rust-lang.org/cargo: "*"
script: cargo install --locked --path . --root {{prefix}}
test:
script: |
out=$(xsv count $FIXTURE)
test "$out" = "2"
fixture: |
foo,bar
1,2
3,42

View file

@ -0,0 +1,32 @@
distributable:
url: https://github.com/charliermarsh/ruff/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: charliermarsh/ruff
strip: /^v /
build:
dependencies:
rust-lang.org: '>=1.60'
rust-lang.org/cargo: '*'
crates.io/semverator: '*'
tea.xyz/gx/make: '*' #build.rs uses make since 0.0.246
script: |
if semverator lt {{version}} 0.0.242; then
CRATE=ruff_cli
else
CRATE=crates/ruff_cli
fi
cargo install --locked --path $CRATE --root {{prefix}}
provides:
- bin/ruff
test:
script: |
ruff -e $FIXTURE | grep "\`os\` imported but unused"
ruff --fix $FIXTURE
test ! -s $FIXTURE
fixture: |
import os

View file

@ -0,0 +1,36 @@
distributable:
url: https://github.com/clever/microplane/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: clever/microplane/tags
dependencies:
git-scm.org: ^2
provides:
- bin/mp
build:
script: |
go mod download
go build -v -ldflags="$LDFLAGS" -o "{{ prefix }}"/bin/mp
dependencies:
go.dev: ^1.18
env:
LDFLAGS:
- -s
- -w
- -X main.version=v{{ version }}
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test: |
echo "teaxyz/pantry" > repos.txt
mp init -f repos.txt
# mp clone
# ^^ FIXME fails with exit code 128
mp status

View file

@ -0,0 +1,23 @@
distributable:
url: https://github.com/cpuguy83/go-md2man/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: cpuguy83/go-md2man/releases/tags
strip: /^v/
provides:
- bin/go-md2man
build:
dependencies:
go.dev: ^1.19
script: |
go build -ldflags="-s -w" -o bin/go-md2man
mkdir -p "{{ prefix }}"/bin
mv bin/go-md2man "{{ prefix }}"/bin
test: |
echo '# manpage\nand a half\n' > input.md
go-md2man -in input.md -out output.man
grep ".TH manpage" output.man

View file

@ -0,0 +1,33 @@
distributable:
url: https://github.com/create-dmg/create-dmg/archive/v{{version}}.tar.gz
strip-components: 1
versions:
github: create-dmg/create-dmg/tags
strip: /^v/
provides:
- bin/create-dmg
dependencies:
tea.xyz/gx/cc: c99
build:
dependencies:
tea.xyz/gx/make: '*'
script: |
if test "{{hw.platform}}" != "darwin"; then
mkdir -p {{prefix}}
echo "create-dmg is only supported on mac" >> {{prefix}}/mac-only
exit 0
fi
make prefix={{prefix}} install
test: |
if test "{{hw.platform}}" = "darwin"; then
create-dmg --version
touch Brew-Eula.txt
echo "Eula" >> Brew-Eula.txt
mkdir -p Test-Source
mkdir -p Test-Source/Brew.app
create-dmg --sandbox-safe --eula Brew-Eula.txt Brew-Test.dmg Test-Source
fi

View file

@ -0,0 +1,36 @@
distributable:
url: https://github.com/dduan/tre/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
provides:
- bin/tre
versions:
github: dduan/tre/tags
strip: /v/
dependencies:
zlib.net: ^1
build:
dependencies:
rust-lang.org: '>=1.60'
rust-lang.org/cargo: '*'
script: |
cargo install --locked --path . --root {{prefix}}
test:
script: |
# prepare for tests
mkdir -p foo/bar
mkdir -p foo/buzz
touch foo/buzz/lupus.txt
# run tests
test "$(tre --version)"='tre-command {{version}}'
out="$(tre . --all)"
echo $out | grep lupus.txt # test for files found
echo $out | grep bar # test for level 2 dirs found
echo $out | grep buzz # ^
tre --all

View file

@ -0,0 +1,42 @@
distributable:
url: https://github.com/evilmartians/lefthook/archive/refs/tags/v{{version}}.tar.gz
versions:
github: evilmartians/lefthook/tags
strip: /^v/
build:
dependencies:
curl.se: '*'
working-directory: ${{prefix}}
script: |
if test "{{hw.platform}}+{{hw.arch}}" == "darwin+x86-64"; then
curl -sSfL --output lefthook.gz "${DOWNLOAD_BASE}/v{{version}}/lefthook_{{version}}_MacOS_x86_64.gz"
elif test "{{hw.platform}}+{{hw.arch}}" == "darwin+aarch64"; then
curl -sSfL --output lefthook.gz "${DOWNLOAD_BASE}/v{{version}}/lefthook_{{version}}_MacOS_arm64.gz"
elif test "{{hw.platform}}+{{hw.arch}}" == "linux+x86-64"; then
curl -sSfL --output lefthook.gz "${DOWNLOAD_BASE}/v{{version}}/lefthook_{{version}}_Linux_x86_64.gz"
elif test "{{hw.platform}}+{{hw.arch}}" == "linux+aarch64"; then
curl -sSfL --output lefthook.gz "${DOWNLOAD_BASE}/v{{version}}/lefthook_{{version}}_Linux_arm64.gz"
elif test "{{hw.platform}}+{{hw.arch}}" == "windows+x86-64"; then
curl -sSfL --output lefthook.gz "${DOWNLOAD_BASE}/v{{version}}/lefthook_{{version}}_Windows_x86_64.gz"
elif test "{{hw.platform}}+{{hw.arch}}" == "windows+aarch64"; then
curl -sSfL --output lefthook.gz "${DOWNLOAD_BASE}/v{{version}}/lefthook_{{version}}_Windows_arm64.gz"
fi
gunzip --force lefthook.gz
mkdir -p {{ prefix }}/bin
chmod +x lefthook
if test "{{hw.platform}}" == "windows"; then
mv lefthook bin/lefthook.exe
else
mv lefthook bin/
fi
env:
DOWNLOAD_BASE: https://github.com/evilmartians/lefthook/releases/download
provides:
- bin/lefthook
test: |
lefthook completion zsh

View file

@ -0,0 +1,37 @@
distributable:
url: https://github.com/gofireflyio/aiac/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: gofireflyio/aiac
strip: /^v /
dependencies:
# __DEP__: __DEP_VERSION__
build:
dependencies:
go.dev: ^1.18
# __DEP__: __DEP_VERSION__
script: |
go build -v -ldflags="$LDFLAGS"
mkdir -p "{{ prefix }}"/bin
mv aiac "{{ prefix }}"/bin
env:
LDFLAGS:
[-s, -w, "-X=main.Version={{version}}"]
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
provides:
- bin/aiac
# FIXME: not much to test without an API key
test: |
aiac --help
if test ! -z $OPENAPI_KEY; then
aiac --api-key $OPENAPI_KEY get bash api wrapper
fi

View file

@ -0,0 +1,28 @@
distributable:
url: https://github.com/google/brotli/archive/v{{version}}.tar.gz
strip-components: 1
versions:
github: google/brotli
build:
dependencies:
cmake.org: '*'
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
working-directory: build.d
script: |
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX={{prefix}}
make --jobs={{ hw.concurrency }}
make install
provides:
- bin/brotli
test:
fixture:
Hello, World!
script: |
brotli $FIXTURE $FIXTURE.br
brotli $FIXTURE.br --output=out.txt --decompress
test "$(cat $FIXTURE)" = "$(cat out.txt)"

View file

@ -0,0 +1,32 @@
distributable:
# url: https://github.com/jart/blink/archive/refs/tags/{{version}}.tar.gz currently no tags/releases
url: https://github.com/jart/blink/archive/13df12124d69aba8a7f74803715af36ed629b349.tar.gz
strip-components: 1
provides:
- bin/blink
- bin/blinkenlights
versions:
# github: jart/blink/tags FIXME once they start tagging/releasing
- 0.0.0
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
script: |
make -j {{hw.concurrency}}
mkdir {{prefix}}/bin
cp o/blink/blink{,enlights} {{prefix}}/bin
test: |
make check
make check2
make emulates
test:
dependencies:
curl.se: '*'
script: |
curl -O https://raw.githubusercontent.com/jart/blink/13df12124d69aba8a7f74803715af36ed629b349/third_party/cosmo/tinyhello.elf
blink tinyhello.elf

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

View file

@ -0,0 +1,34 @@
distributable:
url: https://github.com/jasper-software/jasper/releases/download/version-{{version}}/jasper-{{version}}.tar.gz
strip-components: 1
versions:
github: jasper-software/jasper/releases/tags
strip: /^version-/
dependencies:
libjpeg-turbo.org: ^2
provides:
- bin/jasper
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
cmake.org: ^3
working-directory: tmp_cmake
script: |
cmake .. $ARGS
make --jobs {{ hw.concurrency }} install
env:
ARGS:
- -DJAS_ENABLE_DOC=OFF
- -DJAS_ENABLE_AUTOMATIC_DEPENDENCIES=false
- -DJAS_ENABLE_SHARED=ON
- -DCMAKE_INSTALL_PREFIX={{prefix}}
- -DCMAKE_BUILD_TYPE=Release
test: |
jasper --input fixture.jpeg --output test.bmp
test -f test.bmp

View file

@ -0,0 +1,27 @@
distributable:
url: https://github.com/jesseduffield/lazydocker/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: jesseduffield/lazydocker
strip: /v/
provides:
- bin/lazydocker
build:
dependencies:
go.dev: ^1.18
env:
LDFLAGS:
- -X=main.version={{version}}
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
script: |
GOBIN={{prefix}}/bin go install -ldflags="$LDFLAGS" .
test: |
lazydocker --config

View file

@ -0,0 +1,27 @@
distributable:
url: https://github.com/jesseduffield/lazygit/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: jesseduffield/lazygit
strip: /v/
provides:
- bin/lazygit
build:
dependencies:
go.dev: ^1.18
env:
LDFLAGS:
- -X=main.version={{version}}
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
script: |
GOBIN={{prefix}}/bin go install -ldflags="$LDFLAGS" .
test: |
lazygit --config

View file

@ -0,0 +1,9 @@
#include <stdio.h>
#include <json-c/json.h>
int main() {
json_object *obj = json_object_new_object();
json_object *value = json_object_new_string("value");
json_object_object_add(obj, "key", value);
printf("%s\n", json_object_to_json_string(obj));
return 0;
}

View file

@ -0,0 +1,26 @@
distributable:
url: https://s3.amazonaws.com/json-c_releases/releases/json-c-{{ version.raw }}.tar.gz
strip-components: 1
versions:
github: json-c/json-c/tags
strip:
- /^json-c-/
- /-\d{8}/ # calver
build:
dependencies:
cmake.org: 3
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
working-directory: build
script: |
cmake .. -DCMAKE_INSTALL_PREFIX="{{prefix}}" -DCMAKE_BUILD_TYPE=Release
make --jobs {{ hw.concurrency }} install
test:
dependencies:
tea.xyz/gx/cc: c99
script: |
cc fixture.c -ljson-c
./a.out

View file

@ -0,0 +1,2 @@
hello
world

View file

@ -0,0 +1,33 @@
distributable:
url: https://github.com/junegunn/fzf/archive/refs/tags/{{version}}.tar.gz
strip-components: 1
versions:
github: junegunn/fzf
provides:
- bin/fzf
build:
script: |
go build -v -ldflags="$LDFLAGS"
mkdir -p "{{ prefix }}"/bin
mv fzf "{{ prefix }}"/bin
dependencies:
go.dev: ^1.18
env:
LDFLAGS:
- -s
- -w
- -X main.version={{ version }}
- -X main.revision=tea
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test:
script: |
out=$(cat data.txt | fzf -f wld)
test "$out" = "world"

View file

@ -0,0 +1,39 @@
distributable:
url: https://github.com/kevinburke/go-bindata/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: kevinburke/go-bindata
provides:
- bin/go-bindata
build:
dependencies:
go.dev: ^1.18
gnu.org/patch: '*'
script: |
patch -p1 <props/patch-go-modules.diff
mkdir -p "{{ prefix }}"/bin
go build -v -ldflags="$LDFLAGS" -o "{{ prefix }}"/bin/go-bindata ./go-bindata
env:
LDFLAGS:
[-s, -w, "-X=main.Version={{version}}"]
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test:
script: |
output=$(go-bindata -version)
case $output in
*{{ version }}*)
echo "Version match"
;;
*)
echo "Version mismatch"
;;
esac

View file

@ -0,0 +1,10 @@
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..ce4eba8
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module github.com/kevinburke/go-bindata
+
+go 1.19

View file

@ -0,0 +1,18 @@
distributable:
url: https://github.com/lra/mackup/archive/refs/tags/{{version}}.tar.gz
strip-components: 1
versions:
github: lra/mackup/releases/tags
dependencies:
python.org: ^3
build:
python-venv.sh {{prefix}}/bin/mackup
provides:
- bin/mackup
test:
mackup --help

View file

@ -0,0 +1,54 @@
# You may notice that this bottle named "mamba-org" refers to conda-forge github repo
# This is intentional and not an error
# cask: https://github.com/Homebrew/homebrew-cask/blob/c6e8fd99bdfd5ec217ff3b53505f42214f5cba58/Casks/mambaforge.rb
distributable:
url: https://github.com/conda-forge/miniforge/archive/refs/tags/22.11.1-4.tar.gz #FIXME UGLY HACK, NEED TO MOVE '-4' TO versions.anytext
strip-components: 1
versions:
- "22.11.1.4"
build:
dependencies:
aria2.github.io: '1.36' #FIXME aria2 has heavier dependencies than curl,
# ^ when this package is more stable and we no longer need fast local iteration,
# ^ look into swapping it for curl
script: |
#FIXME mamba provides sha256 signatures, should we check against them before building?
# ^ https://github.com/conda-forge/miniforge/releases
# download mamba installation script
aria2c -c -o mamba.sh "https://github.com/conda-forge/miniforge/releases/download/22.11.1-4/Mambaforge-22.11.1-4-$PLATFORM.sh"
# install mamba
chmod +x mamba.sh
./mamba.sh $ARGS
fix-shebangs.ts {{prefix}}/bin/*
#FIXME: add caveats
# Please run the following to setup your shell:
# mamba init "$(basename "${SHELL}")" # updates your .zshrc or .bashrc to make mamba & conda usable
env:
# env-dependent vars
darwin/aarch64: {PLATFORM: MacOSX-arm64}
darwin/x86-64: {PLATFORM: MacOSX-x86_64}
linux/aarch64: {PLATFORM: Linux-aarch64}
linux/x86-64: {PLATFORM: Linux-x86_64}
# mamba install args
ARGS:
- -b # skip interactive - accept all licence agreements
- -s # skip running pre/post-link/install scripts
- -u # update if already installed
- -p {{prefix}} # prefix - where to install
test: |
mamba --version
conda --version
provides:
- condabin/conda
- bin/mamba

View file

@ -0,0 +1,31 @@
distributable:
url: https://github.com/mikefarah/yq/archive/refs/tags/v{{ version }}.tar.gz
strip-components: 1
versions:
github: mikefarah/yq/releases/tags
build:
script: |
go build -v -ldflags="$LDFLAGS"
./scripts/generate-man-page-md.sh
./scripts/generate-man-page.sh
mkdir -p "{{ prefix }}"/bin
mv yq "{{ prefix }}"/bin
mkdir -p "{{ prefix }}"/share/man/man1
mv yq.1 "{{ prefix }}"/share/man/man1
dependencies:
go.dev: ^1.18
pandoc.org: '*'
env:
LDFLAGS:
- -s -w
linux:
LDFLAGS:
- -buildmode=pie
test:
yq --version
provides:
- bin/yq

View file

@ -0,0 +1,34 @@
distributable:
url: https://github.com/mtoyoda/sl/archive/{{version.raw}}.tar.gz
strip-components: 1
versions:
github: mtoyoda/sl/releases/tags
provides:
- bin/sl
dependencies:
invisible-island.net/ncurses: 6
build:
dependencies:
tea.xyz/gx/cc: c99
tea.xyz/gx/make: '*'
gnu.org/patch: '*'
script: |
# Add -v to allow testing resultant binary
patch -p1 < props/version.patch
make
mkdir "{{prefix}}"/bin
mv sl "{{prefix}}"/bin
env:
CPATH: ${{ deps.invisible-island.net/ncurses.prefix }}/include/ncursesw:$CPATH
TEA_VERSION: ${{ version }}
test:
# FIXME: best tested with Expect, if possible.
# dependencies:
# tcl-lang.org/expect: '*'
# script: expect -d ./script.exp
test "$(sl -v)" = "sl version {{version}}"

View file

@ -0,0 +1,49 @@
#!/usr/bin/env -S expect -f
#
# This Expect script was generated by autoexpect on Sun Jan 15 01:33:05 2023
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
#
# 2) differing output - Some programs produce different output each time
# they run. The "date" command is an obvious example. Another is
# ftp, if it produces throughput statistics at the end of a file
# transfer. If this causes a problem, delete these patterns or replace
# them with wildcards. An alternative is to use the -p flag (for
# "prompt") which makes Expect only look for the last line of output
# (i.e., the prompt). The -P flag allows you to define a character to
# toggle this mode off and on.
#
# Read the man page for more info.
#
# -Don
set timeout -1
set send_slow {1 .1}
spawn sl -c
match_max 100000
expect eof

View file

@ -0,0 +1,49 @@
diff --color -u a/Makefile b/Makefile
--- a/Makefile 2014-06-16 03:27:59
+++ b/Makefile 2023-01-15 03:32:37
@@ -8,6 +8,9 @@
CC=gcc
CFLAGS=-O
+TEA_VERSION?= "0.0.0-dev"
sl: sl.c sl.h
+ sed -i.bak -e "s/#define TEA_VERSION \".*\"/#define TEA_VERSION \"$(TEA_VERSION)\"/" sl.h
+ rm sl.h.bak
$(CC) $(CFLAGS) -o sl sl.c -lncurses
Common subdirectories: a/props and b/props
diff --color -u a/sl.c b/sl.c
--- a/sl.c 2014-06-16 03:27:59
+++ b/sl.c 2023-01-15 03:27:18
@@ -39,6 +39,8 @@
#include <curses.h>
#include <signal.h>
#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
#include "sl.h"
void add_smoke(int y, int x);
@@ -73,6 +75,10 @@
case 'F': FLY = 1; break;
case 'l': LOGO = 1; break;
case 'c': C51 = 1; break;
+ case 'v':
+ printf("sl version %s", TEA_VERSION);
+ exit(0);
+ break;
default: break;
}
}
diff --color -u a/sl.h b/sl.h
--- a/sl.h 2014-06-16 03:27:59
+++ b/sl.h 2023-01-15 03:33:08
@@ -12,6 +12,8 @@
#define D51LENGTH 83
#define D51PATTERNS 6
+#define TEA_VERSION "UNSET"
+
#define D51STR1 " ==== ________ ___________ "
#define D51STR2 " _D _| |_______/ \\__I_I_____===__|_________| "

View file

@ -0,0 +1,31 @@
distributable:
url: https://github.com/muesli/duf/archive/refs/tags/v{{version}}.tar.gz
strip-components: 1
versions:
github: muesli/duf/tags
provides:
- bin/duf
build:
script: |
go mod download
go build -v -ldflags="$LDFLAGS"
mkdir -p "{{ prefix }}"/bin
mv duf "{{ prefix }}"/bin
dependencies:
go.dev: ^1.18
env:
GO111MODULE: on
LDFLAGS:
[-s, -w, "-X=main.Version={{version}}"]
linux:
# or segmentation fault
# fix found here https://github.com/docker-library/golang/issues/402#issuecomment-982204575
LDFLAGS:
- -buildmode=pie
test:
script: |
test "$(duf -version)" = "duf {{version}}"

Some files were not shown because too many files have changed in this diff Show more