Skip to content

Commit 023447c

Browse files
committed
Update scripts for new release format (#17)
1 parent aec9656 commit 023447c

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

rekeyvacuum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
** Change 2: Remove local variable 'int nRes'
99
** Change 3: Remove initialization 'nRes = sqlite3BtreeGetOptimalReserve(pMain)'
1010
**
11-
** This code is generated by script/rekeyvacuum.sh from SQLite version 3.27.1.
11+
** Code generated by script/rekeyvacuum.sh from SQLite v3.27.1 amalgamation.
1212
*/
1313
SQLITE_PRIVATE int sqlite3RekeyVacuum(
1414
char **pzErrMsg, /* Write error message here */

script/amalgamate.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/sh
2+
# Generate amalgamation by replacing '#include "..."' lines with file contents.
23
# Usage: ./script/amalgamate.sh <sqleet.c >amalgamation.c
34
while IFS='' read -r ln; do
45
if echo "$ln" | grep -q '^#include "[^"]\+"$'; then

script/rekeyvacuum.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/sh
2-
# Generate rekeyvacuum.c from SQLite3 amalgamation and print it to stdout.
2+
# Generate rekeyvacuum.c from an SQLite3 amalgamation and write it to stdout.
3+
# Usage: ./script/rekeyvacuum.sh sqlite3.c >rekeyvacuum.c
34

4-
if [ "$#" -ne 1 ] || ! [ "$1" = "-" -o -f "$1" ]; then
5+
INPUT="$([ "$#" -eq 1 ] && echo "$1" || echo "sqlite3.c")"
6+
if ! [ -f "$INPUT" ]; then
57
echo "Usage: $0 <SQLITE3_AMALGAMATION>" >&2
68
echo " e.g.: $0 sqlite3.c" >&2
79
exit 1
@@ -12,8 +14,8 @@ die() {
1214
exit 2
1315
}
1416

15-
VERSION="$(sed -n 's/^#define SQLITE_VERSION[^"]*"\([0-9]\+\.[0-9]\+\.[0-9]\+\)"$/\1/p' sqlite3.h)"
16-
[ -z "$VERSION" ] && die "Cannot find SQLite3 version"
17+
VERSION="$(sed -n 's/^#define SQLITE_VERSION[^"]*"\([0-9]\+\.[0-9]\+\.[0-9]\+\)"$/\1/p' "$INPUT")"
18+
[ -z "$VERSION" ] && die "cannot find SQLite3 version (is '$INPUT' a valid amalgamation?)"
1719

1820
cat <<EOF
1921
/*
@@ -26,10 +28,10 @@ cat <<EOF
2628
** Change 2: Remove local variable 'int nRes'
2729
** Change 3: Remove initialization 'nRes = sqlite3BtreeGetOptimalReserve(pMain)'
2830
**
29-
** This code is generated by script/rekeyvacuum.sh from SQLite version $VERSION.
31+
** Code generated by script/rekeyvacuum.sh from SQLite v$VERSION amalgamation.
3032
*/
3133
EOF
32-
sed -n '/^SQLITE_PRIVATE int sqlite3RunVacuum([^;]*$/,/^}$/p' "$1" \
34+
sed -n '/^SQLITE_PRIVATE int sqlite3RunVacuum([^;]*$/,/^}$/p' "$INPUT" \
3335
| sed 's/sqlite3RunVacuum/sqlite3RekeyVacuum/' \
3436
| sed 's/^\([^ )][^)]*\)\?){$/\1, int nRes){/' \
3537
| grep -v "int nRes;\|nRes = " \

script/release.sh

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/sh
2-
# Prepare sqleet.c sqleet.h amalgamation for a release.
2+
# Prepare release archives.
33

44
set -e
55

66
die() {
7-
rm -f tmp-rekeyvacuum.c tmp-sqleet.c tmp-sqleet.h
7+
[ ! -z "$RELEASE" ] && rm -rf "$RELEASE_DIR" "$RELEASE.zip" "$RELEASE.tar.gz"
88
[ "$#" -ne 0 ] && echo "[-] Error:" "$@" >&2
99
exit 1
1010
}
@@ -14,32 +14,33 @@ cd "$(git rev-parse --show-toplevel)"
1414
git status --short | grep -vq '^[!?]' && die "dirty working tree (commit or stash your changes)"
1515
VERSION="$(sed -n 's/^#define SQLITE_VERSION[^"]*"\([0-9]\+\.[0-9]\+\.[0-9]\+\)"$/\1/p' sqlite3.h)"
1616
[ -z "$VERSION" ] && die "cannot find SQLite3 version"
17+
SQLEET_VERSION="$(echo "$VERSION" | sed 's/^3/0/')"
18+
RELEASE="sqleet-v$SQLEET_VERSION"
19+
RELEASE_DIR="$RELEASE"
1720

1821
echo "[+] SQLite version $VERSION" >&2
1922

20-
echo "[+] Generating rekeyvacuum.c" >&2
21-
./script/rekeyvacuum.sh sqlite3.c >tmp-rekeyvacuum.c || die "generating rekeyvacuum.c failed"
23+
echo "[+] Checking rekeyvacuum.c" >&2
24+
./script/rekeyvacuum.sh sqlite3.c | cmp -s - rekeyvacuum.c || die "rekeyvacuum.c outdated"
25+
26+
echo "[+] Creating release directory $RELEASE_DIR" >&2
27+
mkdir -p "$RELEASE_DIR"
28+
cp README.md "$RELEASE_DIR"
2229

2330
echo "[+] Generating sqleet.c amalgamation" >&2
24-
./script/amalgamate.sh <sqleet.c >tmp-sqleet.c || die "sqleet.c amalgamation failed"
31+
./script/amalgamate.sh <sqleet.c >"$RELEASE_DIR/sqleet.c" || die "sqleet.c amalgamation failed"
2532

2633
echo "[+] Generating sqleet.h amalgamation" >&2
27-
./script/amalgamate.sh <sqleet.h >tmp-sqleet.h || die "sqleet.h amalgamation failed"
34+
./script/amalgamate.sh <sqleet.h >"$RELEASE_DIR/sqleet.h" || die "sqleet.h amalgamation failed"
2835

2936
echo '[+] Updating shell.c #include "sqlite3.h" -> "sqleet.h"' >&2
30-
sed -i 's/^#include "sqlite3.h"$/#include "sqleet.h"/' shell.c
31-
grep -Fq '#include "sqleet.h"' shell.c || die "failed to update shell.c include"
37+
sed 's/^#include "sqlite3.h"$/#include "sqleet.h"/' shell.c >"$RELEASE_DIR/shell.c"
38+
grep -Fq '#include "sqleet.h"' "$RELEASE_DIR/shell.c" || die "failed to update shell.c include"
3239

33-
echo "[+] Moving files around a bit" >&2
34-
mv tmp-sqleet.h sqleet.h
35-
mv tmp-sqleet.c sqleet.c
36-
mv tmp-rekeyvacuum.c rekeyvacuum.c
37-
git add sqleet.c sqleet.h shell.c
38-
git ls-files | grep ".[ch]$\|^script/" | grep -v "sqleet.[ch]\|shell.c" | xargs git rm -fq
40+
echo "[+] Creating release archives" >&2
41+
zip -qr "$RELEASE-amalgamation.zip" "$RELEASE_DIR" || die "failed to create $RELEASE-amalgamation.zip"
42+
tar -czf "$RELEASE-amalgamation.tar.gz" --owner=0 --group=0 "$RELEASE_DIR" || die "failed to create $RELEASE-amalgamation.tar.gz"
3943

4044
sync
41-
SQLEET_VERSION="$(echo "$VERSION" | sed 's/^3/0/')"
4245
echo "[+] Success!" >&2
43-
echo "git checkout -b v$SQLEET_VERSION"
44-
echo "git commit -m \"Release v$SQLEET_VERSION\""
45-
echo "git push -u origin v$SQLEET_VERSION"
46+
echo "git tag v$SQLEET_VERSION && git push origin v$SQLEET_VERSION"

0 commit comments

Comments
 (0)