mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-21 12:59:04 +02:00
minimal-bootstrap.gnupatch: init at 2.5.9
This commit is contained in:
parent
343af2758e
commit
575171d619
|
@ -21,4 +21,7 @@ lib.makeScope
|
|||
|
||||
tinycc-bootstrappable = callPackage ./tinycc/bootstrappable.nix { };
|
||||
tinycc-mes = callPackage ./tinycc/mes.nix { };
|
||||
|
||||
gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; };
|
||||
|
||||
})
|
||||
|
|
107
pkgs/os-specific/linux/minimal-bootstrap/gnupatch/default.nix
Normal file
107
pkgs/os-specific/linux/minimal-bootstrap/gnupatch/default.nix
Normal file
|
@ -0,0 +1,107 @@
|
|||
{ lib
|
||||
, runCommand
|
||||
, fetchurl
|
||||
, tinycc
|
||||
}:
|
||||
let
|
||||
pname = "gnupatch";
|
||||
# 2.6.x and later use features not implemented in mes-libc (eg. quotearg.h)
|
||||
version = "2.5.9";
|
||||
|
||||
src = fetchurl {
|
||||
url = "mirror://gnu/patch/patch-${version}.tar.gz";
|
||||
sha256 = "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc";
|
||||
};
|
||||
|
||||
# Thanks to the live-bootstrap project!
|
||||
# https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/patch-2.5.9/mk/main.mk
|
||||
CFLAGS = [
|
||||
"-I."
|
||||
"-DHAVE_DECL_GETENV"
|
||||
"-DHAVE_DECL_MALLOC"
|
||||
"-DHAVE_DIRENT_H"
|
||||
"-DHAVE_LIMITS_H"
|
||||
"-DHAVE_GETEUID"
|
||||
"-DHAVE_MKTEMP"
|
||||
"-DPACKAGE_BUGREPORT="
|
||||
"-Ded_PROGRAM=\\\"/nullop\\\""
|
||||
"-Dmbstate_t=int" # When HAVE_MBRTOWC is not enabled uses of mbstate_t are always a no-op
|
||||
"-DRETSIGTYPE=int"
|
||||
"-DHAVE_MKDIR"
|
||||
"-DHAVE_RMDIR"
|
||||
"-DHAVE_FCNTL_H"
|
||||
"-DPACKAGE_NAME=\\\"patch\\\""
|
||||
"-DPACKAGE_VERSION=\\\"${version}\\\""
|
||||
"-DHAVE_MALLOC"
|
||||
"-DHAVE_REALLOC"
|
||||
"-DSTDC_HEADERS"
|
||||
"-DHAVE_STRING_H"
|
||||
"-DHAVE_STDLIB_H"
|
||||
];
|
||||
|
||||
# Maintenance note: List of sources from Makefile.in
|
||||
SRCS = [
|
||||
"addext.c"
|
||||
"argmatch.c"
|
||||
"backupfile.c"
|
||||
"basename.c"
|
||||
"dirname.c"
|
||||
"getopt.c"
|
||||
"getopt1.c"
|
||||
"inp.c"
|
||||
"maketime.c"
|
||||
"partime.c"
|
||||
"patch.c"
|
||||
"pch.c"
|
||||
"quote.c"
|
||||
"quotearg.c"
|
||||
"quotesys.c"
|
||||
"util.c"
|
||||
"version.c"
|
||||
"xmalloc.c"
|
||||
];
|
||||
sources = SRCS ++ [
|
||||
# mes-libc doesn't implement `error()`
|
||||
"error.c"
|
||||
];
|
||||
|
||||
objects = map (x: lib.replaceStrings [".c"] [".o"] (builtins.baseNameOf x)) sources;
|
||||
in
|
||||
runCommand "${pname}-${version}" {
|
||||
inherit pname version;
|
||||
|
||||
nativeBuildInputs = [ tinycc ];
|
||||
|
||||
meta = with lib; {
|
||||
description = "GNU Patch, a program to apply differences to files";
|
||||
homepage = "https://www.gnu.org/software/patch";
|
||||
license = licenses.gpl3Plus;
|
||||
maintainers = with maintainers; [ emilytrau ];
|
||||
mainProgram = "patch";
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
} ''
|
||||
# Unpack
|
||||
ungz --file ${src} --output patch.tar
|
||||
untar --file patch.tar
|
||||
rm patch.tar
|
||||
cd patch-${version}
|
||||
|
||||
# Configure
|
||||
catm config.h
|
||||
|
||||
# Build
|
||||
alias CC="tcc ${lib.concatStringsSep " " CFLAGS}"
|
||||
${lib.concatMapStringsSep "\n" (f: "CC -c ${f}") sources}
|
||||
|
||||
# Link
|
||||
CC -static -o patch ${lib.concatStringsSep " " objects}
|
||||
|
||||
# Check
|
||||
./patch --version
|
||||
|
||||
# Install
|
||||
mkdir -p ''${out}/bin
|
||||
cp ./patch ''${out}/bin
|
||||
chmod 555 ''${out}/bin/patch
|
||||
''
|
Loading…
Reference in a new issue