Last active 1769902804

riff'd off gist.github.com/bdrewery/9438353

dch's Avatar dch revised this gist 1769902803. Go to revision

2 files changed, 53 insertions

bulk.sh

@@ -1,4 +1,31 @@
1 1 #!/bin/sh
2 + #
3 + # Copyright (c) 2013-2014 Bryan Drewery <bdrewery@FreeBSD.org>
4 + # Copyright (c) 2025 Dave Cottlehuber <dch@FreeBSD.org>
5 +
6 + # All rights reserved.
7 + #
8 + # Redistribution and use in source and binary forms, with or without
9 + # modification, are permitted provided that the following conditions
10 + # are met:
11 + # 1. Redistributions of source code must retain the above copyright
12 + # notice, this list of conditions and the following disclaimer.
13 + # 2. Redistributions in binary form must reproduce the above copyright
14 + # notice, this list of conditions and the following disclaimer in the
15 + # documentation and/or other materials provided with the distribution.
16 + #
17 + # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 + # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 + # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 + # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 + # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 + # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 + # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 + # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 + # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 + # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 + # SUCH DAMAGE.
28 +
2 29 # /usr/local/etc/poudriere.d/hooks/bulk.sh
3 30
4 31 [ -f "${POUDRIERED}/hooks/config" ] && . "${POUDRIERED}/hooks/config"

pkgrepo.sh

@@ -1,4 +1,30 @@
1 1 #!/bin/sh
2 + #
3 + # Copyright (c) 2025 Dave Cottlehuber <dch@FreeBSD.org>
4 +
5 + # All rights reserved.
6 + #
7 + # Redistribution and use in source and binary forms, with or without
8 + # modification, are permitted provided that the following conditions
9 + # are met:
10 + # 1. Redistributions of source code must retain the above copyright
11 + # notice, this list of conditions and the following disclaimer.
12 + # 2. Redistributions in binary form must reproduce the above copyright
13 + # notice, this list of conditions and the following disclaimer in the
14 + # documentation and/or other materials provided with the distribution.
15 + #
16 + # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 + # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 + # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 + # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 + # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 + # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 + # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 + # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 + # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 + # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 + # SUCH DAMAGE.
27 +
2 28 # /usr/local/etc/poudriere.d/hooks/pkgrepo.sh
3 29 # PACKAGES PKG_REPO_SIGNING_KEY PKG_REPO_FROM_HOST PKG_REPO_META_FILE
4 30

dch's Avatar dch revised this gist 1769902670. Go to revision

4 files changed, 89 insertions

bulk.sh(file created)

@@ -0,0 +1,45 @@
1 + #!/bin/sh
2 + # /usr/local/etc/poudriere.d/hooks/bulk.sh
3 +
4 + [ -f "${POUDRIERED}/hooks/config" ] && . "${POUDRIERED}/hooks/config"
5 +
6 + bulk_sync() {
7 +
8 + local arch=$(pkg info -f -F ${PACKAGES}/Latest/pkg.??? |
9 + awk '$1 == "Architecture" {print $3}')
10 +
11 + curl ${NTFY_URL} -d "$(hostname -s) ${arch} built $1 failed $2 ignored $3 skipped $4"
12 +
13 + [ "${SHOULD_SYNC_TO_S3:-0}" -eq 1 ] || return 0
14 +
15 + touch ${PACKAGES}/.commitid
16 + (cd /usr/ports && git rev-parse HEAD > ${PACKAGES}/.commitid)
17 + (cd ${PACKAGES} && s5cmd \
18 + --endpoint-url ${S3_ENDPOINT_URL} \
19 + --credentials-file ${S3_CREDENTIALS_FILE} \
20 + --profile ${S3_PROFILE} \
21 + sync --delete \
22 + --include 'All/*.pkg' \
23 + --include 'All/*.txz' \
24 + --include 'Latest/pkg.*' \
25 + --include .buildname \
26 + --include .commitid \
27 + --include .jailversion \
28 + --include data.pkg \
29 + --include meta.conf \
30 + --include packagesite.pkg \
31 + --no-follow-symlinks \
32 + . \
33 + s3://pkg/${arch}/ )
34 + return 0
35 + }
36 +
37 + status="$1"
38 + shift
39 +
40 + case ${status} in
41 + "done")
42 + test $2 -le 0 && bulk_sync "$@"
43 + ;;
44 + esac
45 + exit 0

config(file created)

@@ -0,0 +1,8 @@
1 + NTFY_URL=https://ntfy.sh/xyz
2 + S3_ENDPOINT_URL=https://....compat.objectstorage.eu-amsterdam-1.oraclecloud.com/
3 + S3_CREDENTIALS_FILE=/root/.config/s5cmd/oci
4 + S3_PROFILE=poudriere
5 + # push packages up on completion
6 + SHOULD_SYNC_TO_S3=1
7 + # pull in custom packages from S3 prior to signing
8 + FETCH_PKG_FROM_S3=1

oci(file created)

@@ -0,0 +1,5 @@
1 + [poudriere]
2 + region = eu-amsterdam-1
3 + aws_access_key_id = ...
4 + aws_secret_access_key = ...
5 + endpoint_url = ....compat.objectstorage.eu-amsterdam-1.oraclecloud.com

pkgrepo.sh(file created)

@@ -0,0 +1,31 @@
1 + #!/bin/sh
2 + # /usr/local/etc/poudriere.d/hooks/pkgrepo.sh
3 + # PACKAGES PKG_REPO_SIGNING_KEY PKG_REPO_FROM_HOST PKG_REPO_META_FILE
4 +
5 + [ -f "${POUDRIERED}/hooks/config" ] && . "${POUDRIERED}/hooks/config"
6 +
7 + fetch_custom_packages() {
8 + [ "${FETCH_PKG_FROM_S3:-0}" -eq 1 ] || return 0
9 +
10 + arch=$(pkg info -f -F ${PACKAGES}/Latest/pkg.pkg |
11 + awk '$1 == "Architecture" {print $3}')
12 +
13 + /usr/local/bin/s5cmd \
14 + --endpoint-url ${S3_ENDPOINT_URL} \
15 + --credentials-file ${S3_CREDENTIALS_FILE} \
16 + --profile ${S3_PROFILE} \
17 + sync s3://pkg/indie/${arch}/\*.pkg ${PACKAGES}/All/
18 + # ignore errors if there are no packages because indie:15:amd64/ "dir" is not present
19 + return 0
20 + }
21 +
22 + status="$1"
23 +
24 + shift
25 +
26 + case ${status} in
27 + "sign")
28 + fetch_custom_packages "$@"
29 + ;;
30 + esac
31 + exit 0
Newer Older