Skip to content

Commit e60ad7c

Browse files
committed
open-pr: support update scripts to set pkgver
Some packages like bash and openssl need a little more attention than our generic sed invocation. This fixes #1 Signed-off-by: Matthias Aßhauer <[email protected]>
1 parent 0fff3ff commit e60ad7c

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

.github/workflows/open-pr.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,16 @@ jobs:
141141
shell: bash
142142
run: |
143143
cd "/usr/src/$REPO/$PACKAGE_TO_UPGRADE" &&
144-
sed -i \
145-
-e "s/^\\(pkgver=\\).*/\\1$UPGRADE_TO_VERSION/" \
146-
-e 's/^pkgrel=.*/pkgrel=1/' \
147-
PKGBUILD &&
144+
update_script="$GITHUB_WORKSPACE/version/checksums/$PACKAGE_TO_UPGRADE"
145+
if test -f "$update_script"
146+
then
147+
$update_script "$UPGRADE_TO_VERSION"
148+
else
149+
sed -i \
150+
-e "s/^\\(pkgver=\\).*/\\1$UPGRADE_TO_VERSION/" \
151+
-e 's/^pkgrel=.*/pkgrel=1/' \
152+
PKGBUILD
153+
fi &&
148154
git update-index -q --refresh &&
149155
if git diff-files --exit-code
150156
then

update-scripts/version/bash

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env node
2+
3+
// The `PKGBUILD` file of `bash` is sligtly different from most other packages
4+
// as it sets pkgver through a _basever part and a _patchlevel part.
5+
6+
// Therefore we need to be a bit more careful when updating than just replacing
7+
// the value of pkgver.
8+
9+
(async () => {
10+
const version = process.argv[2]
11+
12+
let [ , basever, patchlevel ] = version.match(/^(\d+\.\d+)\.(\d+)/)
13+
let match
14+
15+
const fs = require('fs')
16+
const lines = fs.readFileSync('PKGBUILD').toString('utf-8').split(/\r?\n/)
17+
lines.forEach((line, i) => {
18+
if ((match = line.match(/^(\s*_basever=)\S+/))) {
19+
lines[i] = `${match[1]}${basever}`
20+
} else if ((match = line.match(/^(\s*_patchlevel=)\S+\s(.*)/))) {
21+
lines[i] = `${match[1]}${patchlevel.toString().padStart(3, "0")} ${match[2]}`
22+
} else if ((match = line.match(/^(\s*pkgrel=)\S+/))) {
23+
lines[i] = `${match[1]}${1}`
24+
}
25+
})
26+
fs.writeFileSync('PKGBUILD', lines.join('\n'))
27+
})().catch(console.log)

0 commit comments

Comments
 (0)