From 1d8eba4368aa53ad5e534b68873d24b3ee69cc51 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Thu, 15 Dec 2011 19:04:55 +1030 Subject: Automate package releases with build-packages.sh build-packages.sh has several advantages: - Automatically bumps version numbers - Builds HTML documentation on the fly --- .gitattributes | 2 ++ Makefile | 7 ------ build-packages.sh | 46 +++++++++++++++++++++++++++++++++++++ lua-cjson-1.0.4-1.rockspec | 53 ------------------------------------------- lua-cjson-1.0devel-1.rockspec | 53 +++++++++++++++++++++++++++++++++++++++++++ lua-cjson.spec | 4 ++-- lua_cjson.c | 2 +- manual.txt | 9 ++++---- runtests.sh | 37 ++++++++++++++++++++---------- 9 files changed, 133 insertions(+), 80 deletions(-) create mode 100644 .gitattributes create mode 100755 build-packages.sh delete mode 100644 lua-cjson-1.0.4-1.rockspec create mode 100644 lua-cjson-1.0devel-1.rockspec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..07f243a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.gitattributes export-ignore +build-packages.sh export-ignore diff --git a/Makefile b/Makefile index 3e179e8..9b1b649 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ -CJSON_VERSION = 1.0.4 LUA_VERSION = 5.1 ## Available Lua CJSON specific workarounds @@ -69,9 +68,3 @@ manual.html: manual.txt clean: rm -f *.o *.so - -package: - git archive --prefix="lua-cjson-$(CJSON_VERSION)/" master | \ - gzip -9 > "lua-cjson-$(CJSON_VERSION).tar.gz" - git archive --prefix="lua-cjson-$(CJSON_VERSION)/" \ - -o "lua-cjson-$(CJSON_VERSION).zip" master diff --git a/build-packages.sh b/build-packages.sh new file mode 100755 index 0000000..858ad0d --- /dev/null +++ b/build-packages.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# build-packages.sh [ VERSION [ BRANCH ] ] + +# No args: Build current 1.0devel packages +# 1 args: Build release package for VERSION (>= 1.0.5) +# 2 args: Build release package for VERSION from BRANCH + +# Files requiring a version bump +VERSION_FILES="lua-cjson-1.0devel-1.rockspec lua-cjson.spec lua_cjson.c manual.txt runtests.sh" + +if [ "$1" ] +then + VERSION="$1" + BRANCH="cjson-$VERSION" + VER_BUMP=1 +else + VERSION=1.0devel + BRANCH=master +fi + +[ "$2" ] && BRANCH="$2" + +PREFIX="lua-cjson-$VERSION" + +set -x +set -e + +DESTDIR="`pwd`/packages" +mkdir -p "$DESTDIR" +BUILDROOT="`mktemp -d`" +trap "rm -rf '$BUILDROOT'" 0 + +git archive --prefix="$PREFIX/" "$BRANCH" | tar xf - -C "$BUILDROOT" +cd "$BUILDROOT" + +if [ "$VER_BUMP" ]; then + ( cd "$PREFIX" + rename 1.0devel "$VERSION" $VERSION_FILES + perl -pi -e "s/\\b1.0devel\\b/$VERSION/g" ${VERSION_FILES/1.0devel/$VERSION}; ) +fi +make -C "$PREFIX" doc +tar cf - "$PREFIX" | gzip -9 > "$DESTDIR/$PREFIX.tar.gz" +zip -9rq "$DESTDIR/$PREFIX.zip" "$PREFIX" + +# vi:ai et sw=4 ts=4: diff --git a/lua-cjson-1.0.4-1.rockspec b/lua-cjson-1.0.4-1.rockspec deleted file mode 100644 index ee287b5..0000000 --- a/lua-cjson-1.0.4-1.rockspec +++ /dev/null @@ -1,53 +0,0 @@ -package = "lua-cjson" -version = "1.0.4-1" - -source = { - url = "http://www.kyne.com.au/~mark/software/lua-cjson-1.0.4.zip", -} - -description = { - summary = "Fast JSON encoding/parsing support for Lua", - detailed = [[ - Lua CJSON provides fast UTF-8 JSON parsing/encoding support for Lua, - and has no external dependencies. - ]], - homepage = "http://www.kyne.com.au/~mark/software/lua-cjson.php", - license = "MIT" -} - -dependencies = { - "lua >= 5.1" -} - -build = { - type = "builtin", - modules = { - cjson = { - sources = { "lua_cjson.c", "strbuf.c" }, --- Optional workarounds: --- USE_POSIX_USELOCALE: Linux, OSX. Thread safe. Recommended. --- USE_POSIX_SETLOCALE: Works on all ANSI C platforms. May be used when --- thread-safety isn't required. --- USE_INTERNAL_ISINF: Provide internal isinf() implementation. Required --- on some Solaris platforms. - defines = { - "USE_POSIX_SETLOCALE", --- LuaRocks does not support platform specific configuration for Solaris. --- Uncomment the line below on Solaris platforms. --- "USE_INTERNAL_ISINF" - } - } - }, - -- Override default build options (per platform) - platforms = { - linux = { modules = { cjson = { defines = { - [1] = "USE_POSIX_USELOCALE" - } } } }, - macosx = { modules = { cjson = { defines = { - [1] = "USE_POSIX_USELOCALE" - } } } } - }, - copy_directories = { "tests" } -} - --- vi:ai et sw=4 ts=4: diff --git a/lua-cjson-1.0devel-1.rockspec b/lua-cjson-1.0devel-1.rockspec new file mode 100644 index 0000000..8df0658 --- /dev/null +++ b/lua-cjson-1.0devel-1.rockspec @@ -0,0 +1,53 @@ +package = "lua-cjson" +version = "1.0devel-1" + +source = { + url = "http://www.kyne.com.au/~mark/software/lua-cjson-1.0devel.zip", +} + +description = { + summary = "Fast JSON encoding/parsing support for Lua", + detailed = [[ + Lua CJSON provides fast UTF-8 JSON parsing/encoding support for Lua, + and has no external dependencies. + ]], + homepage = "http://www.kyne.com.au/~mark/software/lua-cjson.php", + license = "MIT" +} + +dependencies = { + "lua >= 5.1" +} + +build = { + type = "builtin", + modules = { + cjson = { + sources = { "lua_cjson.c", "strbuf.c" }, +-- Optional workarounds: +-- USE_POSIX_USELOCALE: Linux, OSX. Thread safe. Recommended. +-- USE_POSIX_SETLOCALE: Works on all ANSI C platforms. May be used when +-- thread-safety isn't required. +-- USE_INTERNAL_ISINF: Provide internal isinf() implementation. Required +-- on some Solaris platforms. + defines = { + "USE_POSIX_SETLOCALE", +-- LuaRocks does not support platform specific configuration for Solaris. +-- Uncomment the line below on Solaris platforms. +-- "USE_INTERNAL_ISINF" + } + } + }, + -- Override default build options (per platform) + platforms = { + linux = { modules = { cjson = { defines = { + [1] = "USE_POSIX_USELOCALE" + } } } }, + macosx = { modules = { cjson = { defines = { + [1] = "USE_POSIX_USELOCALE" + } } } } + }, + copy_directories = { "tests" } +} + +-- vi:ai et sw=4 ts=4: diff --git a/lua-cjson.spec b/lua-cjson.spec index c446bfb..0f7fe9a 100644 --- a/lua-cjson.spec +++ b/lua-cjson.spec @@ -2,7 +2,7 @@ %define lualibdir %{_libdir}/lua/%{luaver} Name: lua-cjson -Version: 1.0.4 +Version: 1.0devel Release: 1%{?dist} Summary: JSON support for the Lua language @@ -39,7 +39,7 @@ rm -rf "$RPM_BUILD_ROOT" %files %defattr(-,root,root,-) -%doc LICENSE NEWS performance.txt manual.txt rfc4627.txt tests THANKS TODO +%doc LICENSE NEWS performance.txt manual.html manual.txt rfc4627.txt tests THANKS TODO %{lualibdir}/* diff --git a/lua_cjson.c b/lua_cjson.c index 24fb13d..b3c816d 100644 --- a/lua_cjson.c +++ b/lua_cjson.c @@ -45,7 +45,7 @@ #include "strbuf.h" #ifndef CJSON_VERSION -#define CJSON_VERSION "1.0.4" +#define CJSON_VERSION "1.0devel" #endif /* Support to reset locale to POSIX for strtod() / sprintf(). diff --git a/manual.txt b/manual.txt index ab08377..4229b51 100644 --- a/manual.txt +++ b/manual.txt @@ -1,7 +1,6 @@ -Lua CJSON Manual -================ += Lua CJSON 1.0devel Manual = Mark Pulford -v1.0.4, November 30 2011 +:revdate: 30th November 2011 Overview -------- @@ -96,7 +95,7 @@ similar) then: [source,sh] ----------- -rpmbuild -tb lua-cjson-1.0.4.tar.gz +rpmbuild -tb lua-cjson-1.0devel.tar.gz rpm -Uvh $newly_built_lua_cjson_rpm ----------- @@ -111,7 +110,7 @@ Extract the Lua CJSON source package into a directory and run: [source,sh] ----------- -cd lua-cjson-1.0.4 +cd lua-cjson-1.0devel luarocks make ----------- diff --git a/runtests.sh b/runtests.sh index c520be0..d313db3 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,13 +1,14 @@ #!/bin/sh PLATFORM="`uname -s`" +[ "$1" ] && VERSION="$1" || VERSION="1.0devel" set -e # Portable "ggrep -A" replacement # contextgrep PATTERN POST_MATCH_LINES contextgrep() { - awk "/$1/ { count = ($2 + 1) } count { count--; print }" + awk "/$1/ { count = ($2 + 1) } count { count--; print }" } do_tests() { @@ -33,11 +34,11 @@ echo "===== Verifying cjson.so is not installed =====" cd tests if lua -e 'require "cjson"' 2>/dev/null then - cat < "$LOG" + RPM="`awk '/^Wrote: / && ! /debuginfo/ { print $2}' < "$LOG"`" + sudo -- rpm -Uvh \"$RPM\" + do_tests + sudo -- rpm -e lua-cjson + rm -f "$LOG" + else + echo "==> skipping, $TGZ not found" + fi fi + +# vi:ai et sw=4 ts=4: -- cgit v1.2.3-55-g6feb