Skip to content

Commit d8e3bc1

Browse files
committed
chore: remove copyleft files and add fork tooling
Remove GPL/AGPL-licensed files from the tree: - test/test-stdio/test-printf.c - test/test-stdio/test-printf-testcases.h - scripts/GeneratePicolibcCrossFile.sh - COPYING.GPL2 Add fork infrastructure: - COPYLEFT_EXCLUSIONS: manifest of removed files - scripts/import-upstream.sh: cherry-pick upstream commits with filtering - .github/workflows/license-check.yml: scancode CI for copyleft detection - .github/workflows/update-upstream.yml: manual upstream import workflow - .github/workflows/tag-release.yml: auto-tag on PR merge - license-policy.yml: scancode policy for forbidden licenses - README.md: fork documentation, upstream README preserved as README.upstream.md
1 parent 97db7b5 commit d8e3bc1

11 files changed

Lines changed: 1996 additions & 3212 deletions
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: License Check
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
scancode:
11+
name: Scancode License Scan
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v6
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v6
19+
with:
20+
python-version: "3.12"
21+
22+
- name: Install scancode-toolkit
23+
run: pip install 'scancode-toolkit==32.3.0'
24+
25+
- name: Scan licenses
26+
run: |
27+
scancode \
28+
--license \
29+
--license-policy license-policy.yml \
30+
--only-findings \
31+
--processes "$(nproc)" \
32+
--json-pp scancode-results.json \
33+
--ignore ".git/*" \
34+
--ignore ".github/*" \
35+
--ignore "scripts/import-upstream.sh" \
36+
--ignore "COPYLEFT_EXCLUSIONS" \
37+
--ignore "COPYING.picolibc" \
38+
--ignore "find-copyright" \
39+
--ignore "license-policy.yml" \
40+
--ignore "README.md" \
41+
--ignore "README.upstream.md" \
42+
.
43+
44+
- name: Check for unapproved licenses
45+
run: |
46+
jq -r '
47+
[.files[]
48+
| select(.license_detections | length > 0)
49+
| select(.license_policy | length == 0)]
50+
| if length > 0 then
51+
"Unapproved licenses found:",
52+
(.[] | " \(.path): \(.detected_license_expression_spdx)"),
53+
halt_error(1)
54+
else
55+
"All detected licenses are approved."
56+
end
57+
' scancode-results.json
58+
59+
- name: Upload scancode results
60+
if: always()
61+
uses: actions/upload-artifact@v7
62+
with:
63+
name: scancode-results
64+
path: scancode-results.json
65+
66+
exclusions-check:
67+
name: COPYLEFT_EXCLUSIONS Consistency
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Checkout
71+
uses: actions/checkout@v6
72+
73+
- name: Verify excluded paths do not exist
74+
run: |
75+
awk '!/^#/ && NF { if (system("test ! -e " $0)) { print "ERROR: Excluded file found: " $0; exit 1 } }' COPYLEFT_EXCLUSIONS
76+
echo "All excluded paths are absent from the tree."

.github/workflows/tag-release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Tag Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
tag:
13+
name: Create version tag
14+
if: github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'update-upstream-')
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
20+
- name: Create tag
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: |
24+
version="${GITHUB_HEAD_REF#update-upstream-}"
25+
tag="${version}-bsd"
26+
echo "Creating tag: $tag"
27+
gh release create "$tag" --title "picolibc ${version} (BSD)" --notes "Based on upstream picolibc ${version}"
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Update from Upstream
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
to_ref:
7+
description: "Upstream version tag to import up to, e.g., 1.9.0"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
update:
17+
name: Import Upstream Commits
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v6
22+
with:
23+
fetch-depth: 0
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Configure git
27+
run: |
28+
git config user.name "github-actions[bot]"
29+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
30+
31+
- name: Import upstream commits
32+
id: import
33+
run: |
34+
# Auto-detect from_ref: find latest *-bsd tag, strip suffix to get upstream ref
35+
from=$(git tag -l '*-bsd' --sort=-v:refname | head -1 | sed 's/-bsd$//')
36+
if [ -z "$from" ]; then
37+
echo "No *-bsd tags found. Tag the initial import first (e.g., git tag 1.8.11-bsd)." >&2
38+
exit 1
39+
fi
40+
target="${{ inputs.to_ref }}"
41+
42+
branch="update-upstream-${target}"
43+
git branch -D "$branch" 2>/dev/null || true
44+
git push origin --delete "$branch" 2>/dev/null || true
45+
git checkout -b "$branch"
46+
47+
scripts/import-upstream.sh "$from" "$target" 2>&1 | tee import-log.txt
48+
49+
imported=$(grep -oP 'Imported: \K[0-9]+' import-log.txt || echo "0")
50+
echo "imported=$imported" >> "$GITHUB_OUTPUT"
51+
echo "branch=$branch" >> "$GITHUB_OUTPUT"
52+
echo "from=$from" >> "$GITHUB_OUTPUT"
53+
54+
- name: Create or update PR
55+
if: steps.import.outputs.imported != '0'
56+
env:
57+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
TARGET: ${{ inputs.to_ref }}
59+
BRANCH: ${{ steps.import.outputs.branch }}
60+
FROM: ${{ steps.import.outputs.from }}
61+
run: |
62+
git push origin "$BRANCH"
63+
64+
# Generate PR body
65+
cat > pr-body.md <<EOF
66+
## Upstream Update: picolibc ${TARGET}
67+
68+
**Upstream compare**: [${FROM:0:12}...${TARGET}](https://github.com/picolibc/picolibc/compare/${FROM:0:12}...${TARGET})
69+
70+
### Imported commits
71+
$(git log --oneline main..HEAD | head -50)
72+
73+
### Checklist
74+
- [ ] Review imported commits
75+
- [ ] Verify license scan passes
76+
- [ ] Update version table in README.md
77+
- [ ] Merge with **rebase** to preserve commit history
78+
- [ ] After merge, tag will be created automatically
79+
EOF
80+
81+
existing_pr=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null || true)
82+
if [[ -n "$existing_pr" ]]; then
83+
gh pr edit "$existing_pr" --title "Update from upstream picolibc ${TARGET}" --body-file pr-body.md
84+
else
85+
gh pr create --base main --head "$BRANCH" --title "Update from upstream picolibc ${TARGET}" --body-file pr-body.md
86+
fi

COPYLEFT_EXCLUSIONS

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyleft Exclusions
2+
#
3+
# Files excluded from this fork because they are under copyleft licenses.
4+
# Used by scripts/import-upstream.sh and CI license checks.
5+
# One path per line. Lines starting with # are comments.
6+
7+
# GPL-2.0-or-later: Printf test suite by Bart Massey
8+
test/test-stdio/test-printf.c
9+
test/test-stdio/test-printf-testcases.h
10+
11+
# AGPL-3.0-or-later: Meson cross-file generator script
12+
scripts/GeneratePicolibcCrossFile.sh
13+
14+
# GPL-2.0-only: GPL license text file
15+
COPYING.GPL2

0 commit comments

Comments
 (0)