about summary refs log tree commit diff
path: root/pkgs/build-support/deb-package/default.nix
blob: 78bdeb07d187219abe2c851a3682f10f35295ff2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
args : with args;	
	let 
       	localDefs = with (builderDefs.meta.function {src="";});
	let 
	  checkFlag = flag : lib.getAttr [flag] false args;
	in
	  builderDefs.meta.function ({
		inherit src;
		inherit checkFlag;
		buildInputs = [];
		configureFlags = [];
		makeFlags = if (checkFlag "omitConfigure") 
		then [" PREFIX=$out "]
		else [];
		patch = null;
		meta = {};
		doInstall = if args ? Install then 
		(FullDepEntry 
		  args.Install 
		  (["doMake"] 
		  ++ (lib.getAttr ["extraInstallDeps"] [] args))
		)
		else FullDepEntry "" ["doMakeInstall"];

		debPatch = FullDepEntry ((if args ? patch then ''
		  gunzip < ${args.patch} | patch -Np1
		'' else "")
		+''
		  sed -e 's/-o root//' -i Makefile Makefile.in Makefile.new || true;
		  sed -e 's/-g root//' -i Makefile Makefile.in Makefile.new || true;
		''
		+(if (checkFlag "omitFilePatches") then "" else 
		''
		  if test -d debian/patches; then 
		    for i in debian/patches/*; do 
		      patch -Np0 -i $i; 
		    done;
		  fi;
		'')
		+ (if args ? extraReplacements then 
		  args.extraReplacements 
		else ""))["minInit" "doUnpack"];
	}  // args);
	in with localDefs;
stdenv.mkDerivation rec {
	name = localDefs.name + "deb";
	builder = writeScript (name + "-builder")
		(textClosure localDefs ([debPatch] ++ 
		(lib.optional (! (checkFlag "omitConfigure")) "doConfigure")
		++ [doInstall doForceShare]));
	inherit meta;
	inherit src;
}