diff --git a/.dockerignore b/.dockerignore index c18fe769..ee0212aa 100644 --- a/.dockerignore +++ b/.dockerignore @@ -65,3 +65,14 @@ test/test-suite-data/ test/*.trs test/*.txt .version +libfyaml-*/ +libfyaml[_-]*.deb +libfyaml[_-]*.tar.* +libfyaml[_-]*.build +libfyaml[_-]*.dsc +libfyaml[_-]*.changes +libfyaml_*.orig.tar.gz +debian/changelog +debian/control +debian/copyright +artifacts/ diff --git a/.gitignore b/.gitignore index 2e101cd8..05c68bba 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,15 @@ test/test-suite-data/ test/*.trs test/*.txt .version +libfyaml-*/ +libfyaml[_-]*.deb +libfyaml[_-]*.tar.* +libfyaml[_-]*.build +libfyaml[_-]*.dsc +libfyaml[_-]*.changes +libfyaml_*.orig.tar.gz +debian/*.install +debian/changelog +debian/control +debian/copyright +artifacts/ diff --git a/Dockerfile-build-deb b/Dockerfile-build-deb new file mode 100644 index 00000000..079ffbca --- /dev/null +++ b/Dockerfile-build-deb @@ -0,0 +1,21 @@ +ARG IMAGE=ubuntu +FROM ${IMAGE} +# install build dependencies +RUN apt-get update -qq +RUN apt-get install --no-install-recommends --fix-missing -y \ + gcc autoconf automake libtool git make libyaml-dev libltdl-dev \ + pkg-config check python3 python3-pip python3-setuptools \ + devscripts build-essential lintian debhelper dh-buildinfo dh-autoreconf fakeroot \ + gnupg +# install sphinx doc dependencies +RUN pip3 install wheel sphinx git+http://github.com/return42/linuxdoc.git sphinx_rtd_theme sphinx-markdown-builder +# configure argument +ARG CONFIG_ARGS +ENV CONFIG_ARGS=${CONFIG_ARGS} +COPY . /build +WORKDIR /build +# do a maintainer clean if the directory was unclean (it can fail) +RUN make maintainer-clean >/dev/null 2>&1|| true +RUN ./bootstrap.sh 2>&1 +RUN ./configure 2>&1 ${CONFIG_ARGS} +RUN make deb diff --git a/Makefile.am b/Makefile.am index f50bc99b..76aeb03c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,8 @@ dist-hook: EXTRA_DIST=bootstrap.sh \ build-aux/shave.in build-aux/shave-libtool.in \ build-aux/git-version-gen \ - README.md + README.md \ + debian MAINTAINERCLEANFILES = \ Makefile.in src/Makefile.in config.h.in configure \ @@ -25,7 +26,9 @@ MAINTAINERCLEANFILES = \ build-aux/ltmain.sh build-aux/missing build-aux/tap-driver.sh DISTCLEANFILES = \ - .version .tarball-version + .version .tarball-version \ + debian/changelog debian/control debian/copyright \ + debian/libfyaml-dev.install debian/libfyaml-utils.install debian/libfyaml-$(DEBVERSION).install clean-local: @@ -34,8 +37,25 @@ SUBDIRS = src test doc pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libfyaml.pc +if HAVE_DPKG +DEB_ARTIFACTS= \ + $(PACKAGE_NAME)-$(DEBVERSION)_$(DEBVERSION)_$(DPKG_ARCH).deb \ + $(PACKAGE_NAME)-dev_$(DEBVERSION)_$(DPKG_ARCH).deb \ + $(PACKAGE_NAME)-utils_$(DEBVERSION)_$(DPKG_ARCH).deb \ + $(PACKAGE_NAME)_$(DEBVERSION).dsc \ + $(PACKAGE_NAME)_$(DEBVERSION).tar.xz \ + $(PACKAGE_NAME)_$(DEBVERSION)_$(DPKG_ARCH).build \ + $(PACKAGE_NAME)_$(DEBVERSION)_$(DPKG_ARCH).changes +endif + maintainer-clean-local: @rm -rf install sphinx +if HAVE_DPKG + @rm -rf $(DEB_ARTIFACTS) + @rm -rf $(PACKAGE_NAME)_$(DEBVERSION).orig.tar.gz + @rm -rf $(PACKAGE_NAME)-$(VERSION).tar.gz +endif + @rm -rf install artifacts # extra file to put in the distribution EXTRA_DIST += \ @@ -59,3 +79,29 @@ if HAVE_DOCKER docker: Dockerfile @DOCKER@ build -t libfyaml:$(VERSION) $(top_srcdir) endif + +if HAVE_DPKG + +# note the package will not be signed +# deb: dist +# @cp $(PACKAGE_NAME)-$(VERSION).tar.gz $(PACKAGE_NAME)_$(DEBVERSION).orig.tar.gz +# @rm -rf $(PACKAGE_NAME)-$(VERSION) +# @tar zxf $(PACKAGE_NAME)-$(VERSION).tar.gz +# @(cd $(PACKAGE_NAME)-$(VERSION) && debuild -us -uc) + +deb: $(DEB_ARTIFACTS) + @mkdir -p artifacts && mv $(DEB_ARTIFACTS) artifacts/ + @rm -rf $(PACKAGE_NAME)-$(VERSION).tar.gz $(PACKAGE_NAME)-$(VERSION)/ + +$(PACKAGE_NAME)-$(VERSION).tar.gz: dist + +$(PACKAGE_NAME)_$(DEBVERSION).orig.tar.gz: $(PACKAGE_NAME)-$(VERSION).tar.gz + @cp $< $@ + +$(PACKAGE_NAME)-$(VERSION)/: $(PACKAGE_NAME)-$(VERSION).tar.gz + @tar zxf $< + +$(DEB_ARTIFACTS): $(PACKAGE_NAME)-$(VERSION)/ + @(cd $< && debuild -us -uc) + +endif diff --git a/configure.ac b/configure.ac index 025766aa..78885cab 100644 --- a/configure.ac +++ b/configure.ac @@ -11,16 +11,21 @@ AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign 1.8.5 -Wall subdir-objects ]) AM_EXTRA_RECURSIVE_TARGETS([doc-help doc-html doc-latexpdf doc-man doc-clean doc-markdown]) -m4_define(fyaml_major, `echo $VERSION | cut -d. -f1`) -m4_define(fyaml_minor, `echo $VERSION | cut -d. -f2`) +m4_define(fyaml_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`) +m4_define(fyaml_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`) m4_define(fyaml_patch, `echo $VERSION | cut -d. -f3- | cut -d- -f1`) -m4_define(fyaml_extra, `echo $VERSION | cut -d. -f3- | cut -d- -f2-`) +m4_define(fyaml_extra, `echo $VERSION | cut -d- -f2-`) AC_SUBST(MAJOR, fyaml_major) AC_SUBST(MINOR, fyaml_minor) AC_SUBST(PATCH, fyaml_patch) AC_SUBST(EXTRA, fyaml_extra) +m4_define(fyaml_date, `git show -s --format=%ci`) +AC_SUBST(DATE, fyaml_date) + +AC_SUBST(DEBVERSION, "$MAJOR.$MINOR") + AX_CHECK_ENABLE_DEBUG() AC_PROG_MKDIR_P @@ -102,9 +107,43 @@ AC_SUBST(CHECK_LIBS) AC_DEFINE_UNQUOTED([HAVE_CHECK], [$HAVE_CHECK], [Define to 1 if you have check available]) AM_CONDITIONAL([HAVE_CHECK], [ test x$HAVE_CHECK = x1 ]) +HAVE_COMPATIBLE_CHECK=0 +if test "x$HAVE_CHECK" == "x1" ; then + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$LIBS $CHECK_LIBS" + CFLAGS="$CFLAGS $CHECK_CFLAGS" + + # check if libcheck has srunner_set_tap (jessie has outdated libcheck) + AC_CHECK_FUNC([srunner_set_tap], + HAVE_COMPATIBLE_CHECK=1, + HAVE_COMPATIBLE_CHECK=0) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +AC_SUBST(HAVE_COMPATIBLE_CHECK) +AC_DEFINE_UNQUOTED([HAVE_COMPATIBLE_CHECK], [$HAVE_COMPATIBLE_CHECK], [Define to 1 if you have a compatible version of check available]) +AM_CONDITIONAL([HAVE_COMPATIBLE_CHECK], [ test x$HAVE_COMPATIBLE_CHECK = x1 ]) + +dnl enable internet available when checking +AC_ARG_ENABLE([network], + AS_HELP_STRING([--disable-network], + [Disable tests requiring network access])) + +if test "x$enable_network" != "xno" ; then + HAVE_NETWORK=1 +else + HAVE_NETWORK=0 +fi +AC_SUBST(HAVE_NETWORK) +AM_CONDITIONAL([HAVE_NETWORK], + [ test x$HAVE_NETWORK = x1 ]) + # check for sphinx AC_PATH_PROG([SPHINX], [sphinx-build]) -if test "x$SPHINX" != "x" ; then +if test "x$SPHINX" != "x" ; then HAVE_SPHINX=1 else HAVE_SPHINX=0 @@ -114,7 +153,7 @@ AM_CONDITIONAL([HAVE_SPHINX], [ test x$HAVE_SPHINX = x1 ]) # check for git AC_PATH_PROG([GIT], [git]) -if test "x$GIT" != "x" ; then +if test "x$GIT" != "x" ; then HAVE_GIT=1 else HAVE_GIT=0 @@ -137,6 +176,26 @@ else fi AM_CONDITIONAL([HAVE_DOCKER], [ test x$HAVE_DOCKER = x1 ]) +# note that debian does not support cross compilation +# so do not use it to build cross packages + +# check for dpkg +AC_PATH_PROG([DPKG], [dpkg]) +if test "x$DPKG" != "x" ; then + HAVE_DPKG=1 +else + HAVE_DPKG=0 +fi +AC_DEFINE_UNQUOTED([HAVE_DPKG], [$HAVE_DPKG], [Define to 1 if you have dpkg available]) +AM_CONDITIONAL([HAVE_DPKG], [ test x$HAVE_DPKG = x1 ]) + +if test "x$HAVE_DPKG" = "x1" ; then + DPKG_ARCH=`$DPKG --print-architecture` +else + DPKG_ARCH="unknown" +fi +AC_SUBST(DPKG_ARCH, "$DPKG_ARCH") + # Shave by default SHAVE_INIT([build-aux], [enable]) @@ -148,6 +207,12 @@ AC_CONFIG_FILES([ test/Makefile doc/Makefile libfyaml.pc + debian/changelog + debian/control + debian/copyright + debian/$PACKAGE_NAME-$DEBVERSION.install:debian/$PACKAGE_NAME.install.in + debian/$PACKAGE_NAME-dev.install + debian/$PACKAGE_NAME-utils.install ]) AC_REQUIRE_AUX_FILE([tap-driver.sh]) @@ -157,20 +222,24 @@ AC_OUTPUT echo " ---{ $PACKAGE_NAME $VERSION }--- - VERSION: ${VERSION} - MAJOR.MINOR: ${MAJOR}.${MINOR} - PATCH: ${PATCH} - EXTRA: ${EXTRA} - prefix: ${prefix} - C compiler: ${CC} - CFLAGS: ${CFLAGS} - Linker: ${LD} - LDFLAGS: ${LDFLAGS} - LIBS: ${LIBS} - CHECK: ${HAVE_CHECK} - SPHINX: $SPHINX - GIT: $GIT - DOCKER: $DOCKER - TESTSUITEURL: $TESTSUITEURL + VERSION: ${VERSION} + MAJOR.MINOR: ${MAJOR}.${MINOR} + PATCH: ${PATCH} + EXTRA: ${EXTRA} + prefix: ${prefix} + C compiler: ${CC} + CFLAGS: ${CFLAGS} + Linker: ${LD} + LDFLAGS: ${LDFLAGS} + LIBS: ${LIBS} + HAVE_CHECK: ${HAVE_CHECK} + HAVE_COMPATIBLE_CHECK: ${HAVE_COMPATIBLE_CHECK} + HAVE_NETWORK: ${HAVE_NETWORK} + SPHINX: $SPHINX + GIT: $GIT + DOCKER: $DOCKER + HAVE_DPKG: $HAVE_DPKG + DPKG_ARCH: $DPKG_ARCH + TESTSUITEURL: $TESTSUITEURL " diff --git a/debian/changelog.in b/debian/changelog.in new file mode 100644 index 00000000..b537f436 --- /dev/null +++ b/debian/changelog.in @@ -0,0 +1,22 @@ +libfyaml (0.2) unstable; urgency=medium + + * debian compatibility #1 + * Add a distcheck command in the Dockerfile + * gh action badge + * run apt using sudo + * github actions ci + * Make distcheck target work + * Update README.md with fy-tool documentation + * Cleanup and update fy-tool usage banner + * Add argument to fy_emit_document_start of root node + * Merge pull request #1 from ohporter/typos + * README: fix typos + * Point to API in github pages + + -- Pantelis Antoniou Thu, 19 Sep 2019 17:04:27 +0300 + +libfyaml (0.1) unstable; urgency=medium + + * Initial release + + -- Pantelis Antoniou Mon, 16 Sep 2019 14:25:04 +0300 diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control.in b/debian/control.in new file mode 100644 index 00000000..92893e09 --- /dev/null +++ b/debian/control.in @@ -0,0 +1,50 @@ +Source: libfyaml +Priority: optional +Maintainer: Pantelis Antoniou +Build-Depends: debhelper (>=9),autotools-dev, + dh-buildinfo (>= 0.9+nmu1~), + dh-autoreconf,pkg-config,libltdl-dev +Standards-Version: 3.9.7 +Section: libs +Homepage: https://github.com/pantoniou/libfyaml +Vcs-Git: https://github.com/pantoniou/libfyaml.git + +Package: libfyaml-dev +Section: libdevel +Architecture: any +Multi-Arch: same +Depends: ${misc:Depends}, libfyaml-@DEBVERSION@ (= ${binary:Version}) +Description: Fully feature complete YAML parser and emitter. + Fully feature complete YAML parser and emitter, supporting the latest YAML + spec and passing the full YAML testsuite. + . + It is designed to be very efficient, avoiding copies of data, and has no + artificial limits like the 1024 character limit for implicit keys. + . + This package contains development headers and static libraries. + +Package: libfyaml-utils +Section: devel +Architecture: any +Multi-Arch: same +Depends: ${misc:Depends}, libfyaml-@DEBVERSION@ (= ${binary:Version}) +Description: Fully feature complete YAML parser and emitter. + Fully feature complete YAML parser and emitter, supporting the latest YAML + spec and passing the full YAML testsuite. + . + It is designed to be very efficient, avoiding copies of data, and has no + artificial limits like the 1024 character limit for implicit keys. + . + This package contains utilities manipulating YAML files. + +Package: libfyaml-@DEBVERSION@ +Architecture: any +Multi-Arch: same +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Fully feature complete YAML parser and emitter. + Fully feature complete YAML parser and emitter, supporting the latest YAML + spec and passing the full YAML testsuite. + . + It is designed to be very efficient, avoiding copies of data, and has no + artificial limits like the 1024 character limit for implicit keys. + diff --git a/debian/copyright.in b/debian/copyright.in new file mode 100644 index 00000000..7ee501ca --- /dev/null +++ b/debian/copyright.in @@ -0,0 +1,31 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: libfyaml +Source: https://github.com/pantoniou/libfyaml + +Files: * +Copyright: 2019 Pantelis Antoniou +License: MIT + +Files: debian/* +Copyright: 2019 Pantelis Antoniou +License: MIT + +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/debian/libfyaml-dev.install.in b/debian/libfyaml-dev.install.in new file mode 100644 index 00000000..b0e6bc4f --- /dev/null +++ b/debian/libfyaml-dev.install.in @@ -0,0 +1,4 @@ +usr/include/* +usr/lib/*/*.a +usr/lib/*/*.so +usr/lib/*/pkgconfig/* diff --git a/debian/libfyaml-utils.install.in b/debian/libfyaml-utils.install.in new file mode 100644 index 00000000..1df36c61 --- /dev/null +++ b/debian/libfyaml-utils.install.in @@ -0,0 +1 @@ +usr/bin/* diff --git a/debian/libfyaml.install.in b/debian/libfyaml.install.in new file mode 100644 index 00000000..3de3b10a --- /dev/null +++ b/debian/libfyaml.install.in @@ -0,0 +1 @@ +usr/lib/*/*.so.* diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..16b05af9 --- /dev/null +++ b/debian/rules @@ -0,0 +1,24 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +# debian builds do not like testsuites to download stuff +%: + dh $@ --with autotools_dev + + +# dh_make generated override targets +override_dh_auto_configure: + dh_auto_configure -- --disable-network + diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..89ae9db8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/scripts/get-gpg-key-id-by-email.sh b/scripts/get-gpg-key-id-by-email.sh new file mode 100755 index 00000000..300b4791 --- /dev/null +++ b/scripts/get-gpg-key-id-by-email.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# either use the supplied email address, or the current git user's email +if [ "x$1" != "x" ] ; then + email="$1" +else + email=`git config user.email` +fi +last="" +id="" +gpg --list-secret-keys | \ + while read line; do + if [[ $line =~ ^uid\ .* ]] ; then + temail=`echo $line | cut -d'<' -f2 | cut -d'>' -f1` + if [[ "$email" == "$temail" && $last =~ ^sec\ .* ]]; then + echo $last | cut -d/ -f 2 | cut -d' ' -f1 + fi + fi + last="$line" + done diff --git a/test/Makefile.am b/test/Makefile.am index 5b482723..43463fd6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -23,7 +23,7 @@ TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/build-aux/tap-d TESTS = -if HAVE_CHECK +if HAVE_COMPATIBLE_CHECK check_PROGRAMS = libfyaml-test libfyaml_test_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src/valgrind/ \ @@ -41,6 +41,7 @@ TESTS += libfyaml.test endif +if HAVE_NETWORK if HAVE_GIT TESTS += testsuite.test @@ -56,6 +57,7 @@ distclean-local: @rm -rf test-suite-data endif +endif TESTS += testerrors.test