Last active 1769902804

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

Revision 1b3e203d1c235c574da34953cf036151145d0dec

bulk.sh Raw
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
29# /usr/local/etc/poudriere.d/hooks/bulk.sh
30
31[ -f "${POUDRIERED}/hooks/config" ] && . "${POUDRIERED}/hooks/config"
32
33bulk_sync() {
34
35 local arch=$(pkg info -f -F ${PACKAGES}/Latest/pkg.??? |
36 awk '$1 == "Architecture" {print $3}')
37
38 curl ${NTFY_URL} -d "$(hostname -s) ${arch} built $1 failed $2 ignored $3 skipped $4"
39
40 [ "${SHOULD_SYNC_TO_S3:-0}" -eq 1 ] || return 0
41
42 touch ${PACKAGES}/.commitid
43 (cd /usr/ports && git rev-parse HEAD > ${PACKAGES}/.commitid)
44 (cd ${PACKAGES} && s5cmd \
45 --endpoint-url ${S3_ENDPOINT_URL} \
46 --credentials-file ${S3_CREDENTIALS_FILE} \
47 --profile ${S3_PROFILE} \
48 sync --delete \
49 --include 'All/*.pkg' \
50 --include 'All/*.txz' \
51 --include 'Latest/pkg.*' \
52 --include .buildname \
53 --include .commitid \
54 --include .jailversion \
55 --include data.pkg \
56 --include meta.conf \
57 --include packagesite.pkg \
58 --no-follow-symlinks \
59 . \
60 s3://pkg/${arch}/ )
61 return 0
62}
63
64status="$1"
65shift
66
67case ${status} in
68 "done")
69 test $2 -le 0 && bulk_sync "$@"
70 ;;
71esac
72exit 0
config Raw
1NTFY_URL=https://ntfy.sh/xyz
2S3_ENDPOINT_URL=https://....compat.objectstorage.eu-amsterdam-1.oraclecloud.com/
3S3_CREDENTIALS_FILE=/root/.config/s5cmd/oci
4S3_PROFILE=poudriere
5# push packages up on completion
6SHOULD_SYNC_TO_S3=1
7# pull in custom packages from S3 prior to signing
8FETCH_PKG_FROM_S3=1
oci Raw
1[poudriere]
2region = eu-amsterdam-1
3aws_access_key_id = ...
4aws_secret_access_key = ...
5endpoint_url = ....compat.objectstorage.eu-amsterdam-1.oraclecloud.com
6
pkgrepo.sh Raw
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
28# /usr/local/etc/poudriere.d/hooks/pkgrepo.sh
29# PACKAGES PKG_REPO_SIGNING_KEY PKG_REPO_FROM_HOST PKG_REPO_META_FILE
30
31[ -f "${POUDRIERED}/hooks/config" ] && . "${POUDRIERED}/hooks/config"
32
33fetch_custom_packages() {
34 [ "${FETCH_PKG_FROM_S3:-0}" -eq 1 ] || return 0
35
36 arch=$(pkg info -f -F ${PACKAGES}/Latest/pkg.pkg |
37 awk '$1 == "Architecture" {print $3}')
38
39 /usr/local/bin/s5cmd \
40 --endpoint-url ${S3_ENDPOINT_URL} \
41 --credentials-file ${S3_CREDENTIALS_FILE} \
42 --profile ${S3_PROFILE} \
43 sync s3://pkg/indie/${arch}/\*.pkg ${PACKAGES}/All/
44 # ignore errors if there are no packages because indie:15:amd64/ "dir" is not present
45 return 0
46}
47
48status="$1"
49
50shift
51
52case ${status} in
53 "sign")
54 fetch_custom_packages "$@"
55 ;;
56esac
57exit 0