From bb25f70192a3276f2cca2913e9012d2c56393bd6 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Wed, 30 Aug 2023 11:31:40 +0900 Subject: Add md4c bug 107 References: https://github.com/mity/md4c/issues/107 --- .reuse/dep5 | 10 ++++++- cppcheck.nix | 74 ------------------------------------------------ cppcheck/default.nix | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ grep.nix | 45 ----------------------------- grep/default.nix | 44 ++++++++++++++++++++++++++++ md4c/107.md | 1 + md4c/default.nix | 67 +++++++++++++++++++++++++++++++++++++++++++ md4c/fix-pkgconfig.patch | 14 +++++++++ shell.nix | 16 +++++++++-- 9 files changed, 223 insertions(+), 122 deletions(-) delete mode 100644 cppcheck.nix create mode 100644 cppcheck/default.nix delete mode 100644 grep.nix create mode 100644 grep/default.nix create mode 100644 md4c/107.md create mode 100644 md4c/default.nix create mode 100644 md4c/fix-pkgconfig.patch diff --git a/.reuse/dep5 b/.reuse/dep5 index ea56b84..63ea501 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -1,7 +1,15 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Source: https://trong.loang.org/~cnx/bux Upstream-Name: bux -Upstream-Contact: Nguyễn Gia Phong +Upstream-Contact: Nguyễn Gia Phong + +Files: md4c/107.md +Copyright: 2020 Martin Mitáš +License: MIT + +Files: md4c/fix-pkgconfig.patch +Copyright: 2023 Nguyễn Gia Phong +License: AGPL-3.0-or-later Files: README.md Copyright: N/A diff --git a/cppcheck.nix b/cppcheck.nix deleted file mode 100644 index 60991a7..0000000 --- a/cppcheck.nix +++ /dev/null @@ -1,74 +0,0 @@ -# Recipe for building cppcheck at specific revision -# -# SPDX-FileCopyrightText: 2012, 2014, 2016 Peter Simons -# SPDX-FileCopyrightText: 2013 Bjørn Forsman -# SPDX-FileCopyrightText: 2014 Linquize -# SPDX-FileCopyrightText: 2014 Moritz Ulrich -# SPDX-FileCopyrightText: 2014 Pascal Wittmann -# SPDX-FileCopyrightText: 2014 Peter Simons -# SPDX-FileCopyrightText: 2015-2017 Joachim Fasting -# SPDX-FileCopyrightText: 2015 koral -# SPDX-FileCopyrightText: 2016 Nikolay Amiantov -# SPDX-FileCopyrightText: 2017 Guillaume Maudoux -# SPDX-FileCopyrightText: 2018 Ignat Loskutov -# SPDX-License-Identifier: MIT -# -# SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong -# SPDX-License-Identifier: AGPL-3.0-or-later - -{ lib, stdenv, fetchFromGitHub, fetchpatch, version, commit, hash, binRenameHook -, docbook_xsl, docbook_xml_dtd_45, libxslt, python3, which, pcre }: - -stdenv.mkDerivation rec { - pname = "cppcheck"; - inherit version; - - src = fetchFromGitHub { - owner = "danmar"; - repo = pname; - rev = commit; - inherit hash; - }; - - patches = [ - (fetchpatch { - name = "glibc-2.34-compat.patch"; - url = "https://github.com/danmar/cppcheck/commit/8869ee3554f19ce63892891a697378d8b745414b.patch"; - hash = "sha256-K9+/2VIb5OFz+es8ZrprCBx8nkKZZycagw6ripWavPw="; - }) - ]; - - # strictDeps = true; - nativeBuildInputs = [ - binRenameHook docbook_xsl docbook_xml_dtd_45 libxslt python3 which - ]; - buildInputs = [ pcre ]; - - makeFlags = [ - "PREFIX=$(out)" - "MATCHCOMPILER=yes" - "FILESDIR=$(out)/cfg" - "HAVE_RULES=yes" - ]; - - enableParallelBuilding = true; - - outputs = [ "out" "man" ]; - - postInstall = '' - make DB2MAN=${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl man - mkdir -p $man/share/man/man1 - cp cppcheck.1 $man/share/man/man1/cppcheck.1 - ''; - - meta = with lib; { - description = "A static analysis tool for C/C++ code"; - longDescription = '' - Check C/C++ code for memory leaks, mismatching allocation-deallocation, - buffer overruns and more. - ''; - homepage = "https://cppcheck.sourceforge.net"; - license = licenses.gpl3Plus; - platforms = platforms.unix; - }; -} diff --git a/cppcheck/default.nix b/cppcheck/default.nix new file mode 100644 index 0000000..60991a7 --- /dev/null +++ b/cppcheck/default.nix @@ -0,0 +1,74 @@ +# Recipe for building cppcheck at specific revision +# +# SPDX-FileCopyrightText: 2012, 2014, 2016 Peter Simons +# SPDX-FileCopyrightText: 2013 Bjørn Forsman +# SPDX-FileCopyrightText: 2014 Linquize +# SPDX-FileCopyrightText: 2014 Moritz Ulrich +# SPDX-FileCopyrightText: 2014 Pascal Wittmann +# SPDX-FileCopyrightText: 2014 Peter Simons +# SPDX-FileCopyrightText: 2015-2017 Joachim Fasting +# SPDX-FileCopyrightText: 2015 koral +# SPDX-FileCopyrightText: 2016 Nikolay Amiantov +# SPDX-FileCopyrightText: 2017 Guillaume Maudoux +# SPDX-FileCopyrightText: 2018 Ignat Loskutov +# SPDX-License-Identifier: MIT +# +# SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ lib, stdenv, fetchFromGitHub, fetchpatch, version, commit, hash, binRenameHook +, docbook_xsl, docbook_xml_dtd_45, libxslt, python3, which, pcre }: + +stdenv.mkDerivation rec { + pname = "cppcheck"; + inherit version; + + src = fetchFromGitHub { + owner = "danmar"; + repo = pname; + rev = commit; + inherit hash; + }; + + patches = [ + (fetchpatch { + name = "glibc-2.34-compat.patch"; + url = "https://github.com/danmar/cppcheck/commit/8869ee3554f19ce63892891a697378d8b745414b.patch"; + hash = "sha256-K9+/2VIb5OFz+es8ZrprCBx8nkKZZycagw6ripWavPw="; + }) + ]; + + # strictDeps = true; + nativeBuildInputs = [ + binRenameHook docbook_xsl docbook_xml_dtd_45 libxslt python3 which + ]; + buildInputs = [ pcre ]; + + makeFlags = [ + "PREFIX=$(out)" + "MATCHCOMPILER=yes" + "FILESDIR=$(out)/cfg" + "HAVE_RULES=yes" + ]; + + enableParallelBuilding = true; + + outputs = [ "out" "man" ]; + + postInstall = '' + make DB2MAN=${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl man + mkdir -p $man/share/man/man1 + cp cppcheck.1 $man/share/man/man1/cppcheck.1 + ''; + + meta = with lib; { + description = "A static analysis tool for C/C++ code"; + longDescription = '' + Check C/C++ code for memory leaks, mismatching allocation-deallocation, + buffer overruns and more. + ''; + homepage = "https://cppcheck.sourceforge.net"; + license = licenses.gpl3Plus; + platforms = platforms.unix; + }; +} diff --git a/grep.nix b/grep.nix deleted file mode 100644 index b430b50..0000000 --- a/grep.nix +++ /dev/null @@ -1,45 +0,0 @@ -# Recipe for building GNU grep at specific snapshot -# -# SPDX-FileCopyrightText: 2003-2012 Eelco Dolstra -# SPDX-FileCopyrightText: 2009-2011 Ludovic Courtès -# SPDX-FileCopyrightText: 2009-2010 Rob Vermaas -# SPDX-FileCopyrightText: 2010 Lluís Batlle i Rossell -# SPDX-License-Identifier: MIT -# -# SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong -# SPDX-License-Identifier: AGPL-3.0-or-later - -{ lib, stdenv, version, base, snapshot, binRenameHook, pcre, libiconv }: -stdenv.mkDerivation rec { - pname = "grep"; - inherit version; - - nativeBuildInputs = [ binRenameHook ]; - buildInputs = [ pcre libiconv ]; - hardeningDisable = [ "all" ]; - - src = base; # bootstrap files - postPatch = '' - tar xf ${snapshot} --strip-components=1 - ''; - - # On macOS, force use of mkdir -p, since grep's fallback - # (./install-sh) is broken. - preConfigure = '' - export MKDIR_P="mkdir -p" - ''; - doCheck = false; - - meta = with lib; { - homepage = "https://www.gnu.org/software/grep"; - description = "GNU implementation of the Unix grep command"; - longDescription = '' - The grep command searches one or more input files for lines - containing a match to a specified pattern. By default, grep - prints the matching lines. - ''; - license = licenses.gpl3Plus; - platforms = platforms.all; - mainProgram = "grep"; - }; -} diff --git a/grep/default.nix b/grep/default.nix new file mode 100644 index 0000000..ae1e9d3 --- /dev/null +++ b/grep/default.nix @@ -0,0 +1,44 @@ +# Recipe for building GNU grep at specific snapshot +# +# SPDX-FileCopyrightText: 2003-2012 Eelco Dolstra +# SPDX-FileCopyrightText: 2009-2011 Ludovic Courtès +# SPDX-FileCopyrightText: 2009-2010 Rob Vermaas +# SPDX-FileCopyrightText: 2010 Lluís Batlle i Rossell +# SPDX-License-Identifier: MIT +# +# SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ lib, stdenv, version, base, snapshot, binRenameHook, pcre, libiconv }: +stdenv.mkDerivation rec { + pname = "grep"; + inherit version; + + nativeBuildInputs = [ binRenameHook ]; + buildInputs = [ pcre libiconv ]; + hardeningDisable = [ "all" ]; + + src = base; # bootstrap files + postPatch = '' + tar xf ${snapshot} --strip-components=1 + ''; + + # On macOS, force use of mkdir -p, since grep's fallback + # (./install-sh) is broken. + preConfigure = '' + export MKDIR_P="mkdir -p" + ''; + doCheck = false; + + meta = with lib; { + homepage = "https://www.gnu.org/software/grep"; + description = "GNU implementation of the Unix grep command"; + longDescription = '' + The grep command searches one or more input files for lines + containing a match to a specified pattern. By default, grep + prints the matching lines. + ''; + license = licenses.gpl3Plus; + platforms = platforms.all; + }; +} diff --git a/md4c/107.md b/md4c/107.md new file mode 100644 index 0000000..7096fb8 --- /dev/null +++ b/md4c/107.md @@ -0,0 +1 @@ +***foo *bar baz*** diff --git a/md4c/default.nix b/md4c/default.nix new file mode 100644 index 0000000..d5fb39e --- /dev/null +++ b/md4c/default.nix @@ -0,0 +1,67 @@ +# Recipe for building md4c at specific snapshot +# +# SPDX-FileCopyrightText: 2021 Anderson Torres +# SPDX-FileCopyrightText: 2021 Thomas Gerbet +# SPDX-FileCopyrightText: 2021 Leif Middelschulte +# SPDX-License-Identifier: MIT +# +# SPDX-FileCopyrightText: 2023 Nguyễn Gia Phong +# SPDX-License-Identifier: AGPL-3.0-or-later + +{ lib, stdenv, version, fetchFromGitHub, commit, hash +, binRenameHook, cmake, pkg-config }: + +stdenv.mkDerivation rec { + pname = "md4c"; + inherit version; + + src = fetchFromGitHub { + owner = "mity"; + repo = pname; + rev = commit; + inherit hash; + }; + + patches = [ + # We set CMAKE_INSTALL_LIBDIR to the absolute path in $out, so + # prefix and exec_prefix cannot be $out, too + # Use CMake's _FULL_ variables instead of `prefix` concatenation. + ./fix-pkgconfig.patch + ]; + + nativeBuildInputs = [ binRenameHook cmake pkg-config ]; + + meta = with lib; { + description = "Markdown parser made in C"; + longDescription = '' + MD4C is Markdown parser implementation in C, with the following features: + + - Compliance: Generally, MD4C aims to be compliant to the latest version + of CommonMark specification. Currently, we are fully compliant to + CommonMark 0.29. + - Extensions: MD4C supports some commonly requested and accepted + extensions. See below. + - Performance: MD4C is very fast. + - Compactness: MD4C parser is implemented in one source file and one + header file. There are no dependencies other than standard C library. + - Embedding: MD4C parser is easy to reuse in other projects, its API is + very straightforward: There is actually just one function, md_parse(). + - Push model: MD4C parses the complete document and calls few callback + functions provided by the application to inform it about a start/end of + every block, a start/end of every span, and with any textual contents. + - Portability: MD4C builds and works on Windows and POSIX-compliant + OSes. (It should be simple to make it run also on most other platforms, + at least as long as the platform provides C standard library, including + a heap memory management.) + - Encoding: MD4C by default expects UTF-8 encoding of the input + document. But it can be compiled to recognize ASCII-only control + characters (i.e. to disable all Unicode-specific code), or (on Windows) + to expect UTF-16 (i.e. what is on Windows commonly called just + "Unicode"). See more details below. + - Permissive license: MD4C is available under the MIT license. + ''; + homepage = "https://github.com/mity/md4c"; + license = licenses.mit; + platforms = platforms.all; + }; +} diff --git a/md4c/fix-pkgconfig.patch b/md4c/fix-pkgconfig.patch new file mode 100644 index 0000000..cf3c264 --- /dev/null +++ b/md4c/fix-pkgconfig.patch @@ -0,0 +1,14 @@ +diff --git a/md4c/md4c.pc.in b/md4c/md4c.pc.in +index 61c78d890249..72943b52d050 100644 +--- a/md4c/md4c.pc.in ++++ b/md4c/md4c.pc.in +@@ -1,7 +1,7 @@ + prefix=@CMAKE_INSTALL_PREFIX@ + exec_prefix=@CMAKE_INSTALL_PREFIX@ +-libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ ++libdir=@CMAKE_INSTALL_LIBDIR@ ++includedir=@CMAKE_INSTALL_INCLUDEDIR@ + + Name: @PROJECT_NAME@ + Description: @PROJECT_DESCRIPTION@ diff --git a/shell.nix b/shell.nix index 52541b8..8ec7eb8 100644 --- a/shell.nix +++ b/shell.nix @@ -19,7 +19,7 @@ let executable = true; destination = "/nix-support/setup-hook"; }; - cppcheck = version: commit: hash: callPackage ./cppcheck.nix { + cppcheck = version: commit: hash: callPackage ./cppcheck { inherit version; inherit commit; inherit hash; @@ -33,7 +33,7 @@ let url = "mirror://gnu/grep/grep-2.12.tar.xz"; hash = "sha256-Tc4KT7g93QEg31HgC1L6dg8u2GddTUwLCuZCumkurWQ="; }; - grep = version: base: commit: hash: callPackage ./grep.nix { + grep = version: base: commit: hash: callPackage ./grep { inherit version; inherit base; snapshot = fetchurl { @@ -42,6 +42,12 @@ let }; binRenameHook = binRenameHook version; }; + md4c = version: commit: hash: callPackage ./md4c { + inherit version; + inherit commit; + inherit hash; + binRenameHook = binRenameHook version; + }; in mkShell { packages = [ (cppcheck "9261.buggy" @@ -62,5 +68,11 @@ in mkShell { (grep "55cf7b6a" grep-2_12 "55cf7b6a1905320c36702a476b09ebb29a2934d3" "sha256-uUHEG4bDDNFiVgj/1mIkttp1B7tlZ1HOWJGPEfbCErU=") + (md4c "107.buggy" + "e278609ee06ad7f9efcb06da48188a4b837ed11b" + "sha256-UoqBSOnlfDsTHz/uLGIUEgmTSiU408iUcwAJTLdbEPM=") + (md4c "107.fixed" + "5d7c35973e5d06b46ca21b5b6e292c56dba7ca23" + "sha256-N/vIRhXuU948z0O4NXKMSKOZGAEE6UjGDT5oqrGpUy8=") ]; } -- cgit 1.4.1