Last active
June 20, 2020 23:22
-
-
Save jkachmar/64c90267b158e5002a3225559a67bc71 to your computer and use it in GitHub Desktop.
Pi-hole FTL derivation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ fetchFromGitHub, gmp, nettle, sqlite, stdenv }: | |
let | |
rev = "3d7c095cb10a1b692c80dd28f6051dea91d45baa"; | |
version = "5.0"; | |
tag = "v${version}"; | |
in | |
stdenv.mkDerivation { | |
pname = "pihole-ftl"; | |
inherit version; | |
src = fetchFromGitHub { | |
owner = "pi-hole"; | |
repo = "FTL"; | |
rev = "refs/tags/${tag}"; | |
sha256 = "1pz7azqi1mpxwgshnc4n8x07hkipl7h3808zcdpzwg0wrg3yp42s"; | |
}; | |
enableParallelBuilding = true; | |
# XXX: Should we patch the source to depend on libsqlite instead of using a | |
# hardcoded sqlite source (cf. src/database/sqlite) | |
buildInputs = [ gmp nettle sqlite ]; | |
patches = [ ./unvendor-sqlite.patch ]; | |
postPatch = '' | |
# Remove vendored SQLite source | |
# | |
# NOTE: Putting this in the 'unvendor_sqlite.patch' bloats it to >8 MB | |
rm \ | |
src/database/sqlite3.h \ | |
src/database/sqlite3.c | |
# remove a couple of irrelevant usage strings - `service pihole-FTL start` | |
substituteInPlace src/args.c --replace 'printf("Usage:' '//printf("Usage:' | |
substituteInPlace src/args.c --replace 'printf("where ' '//printf("where ' | |
''; | |
makeFlags = [ | |
"GIT_BRANCH=master" | |
"GIT_HASH=${rev}" | |
"GIT_VERSION=${tag}" | |
"GIT_DATE=2020-06-20" | |
"GIT_TAG=${tag}" | |
]; | |
preBuild = '' | |
makeFlagsArray+=(LIBS="-pthread -lrt -lhogweed -lgmp -lnettle -lsqlite3") | |
''; | |
installPhase = '' | |
mkdir -p $out/bin | |
cp pihole-FTL $out/bin | |
''; | |
meta = with stdenv.lib; { | |
description = "Pi-hole FTL DNS engine"; | |
homepage = "https://github.com/pi-hole/FTL"; | |
platforms = platforms.linux; | |
license = licenses.eupl11; # TODO: upstream eupl12 | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Makefile b/Makefile | |
index aff6722..f5ab620 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -141,9 +141,6 @@ $(_FTL_OBJ): $(ODIR)/%.o: $(IDIR)/%.c $(_FTL_DEPS) | $(ODIR) $(DB_OBJ_DIR) $(API | |
$(_DNSMASQ_OBJ): $(DNSMASQ_OBJ_DIR)/%.o: $(IDIR)/dnsmasq/%.c $(_DNSMASQ_DEPS) | $(DNSMASQ_OBJ_DIR) | |
$(CC) -c -o $@ $< -g3 $(CCFLAGS) -DVERSION=\"$(DNSMASQ_VERSION)\" $(DNSMASQ_OPTS) | |
-$(DB_OBJ_DIR)/sqlite3.o: $(IDIR)/database/sqlite3.c | $(DB_OBJ_DIR) | |
- $(CC) -c -o $@ $< -g3 $(CCFLAGS) | |
- | |
$(ODIR): | |
mkdir -p $(ODIR) | |
@@ -156,7 +153,7 @@ $(API_OBJ_DIR): | |
$(DNSMASQ_OBJ_DIR): | |
mkdir -p $(DNSMASQ_OBJ_DIR) | |
-pihole-FTL: $(_FTL_OBJ) $(_DNSMASQ_OBJ) $(DB_OBJ_DIR)/sqlite3.o | |
+pihole-FTL: $(_FTL_OBJ) $(_DNSMASQ_OBJ) | |
$(CC) $(CCFLAGS) -o $@ $^ $(LIBS) | |
.PHONY: clean force install | |
diff --git a/src/database/sqlite3-ext.c b/src/database/sqlite3-ext.c | |
index 30e8bd6..5581b81 100644 | |
--- a/src/database/sqlite3-ext.c | |
+++ b/src/database/sqlite3-ext.c | |
@@ -8,7 +8,7 @@ | |
* This file is copyright under the latest version of the EUPL. | |
* Please see LICENSE file for your rights under this license. */ | |
-#include "database/sqlite3.h" | |
+#include <sqlite3.h> | |
#include "database/sqlite3-ext.h" | |
// inet_pton | |
@@ -151,4 +151,4 @@ int sqlite3_pihole_extensions_init(sqlite3 *db, const char **pzErrMsg, const str | |
} | |
return rc; | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/src/datastructure.h b/src/datastructure.h | |
index 74c78b8..e74f731 100644 | |
--- a/src/datastructure.h | |
+++ b/src/datastructure.h | |
@@ -11,7 +11,7 @@ | |
#define DATASTRUCTURE_H | |
// Definition of sqlite3_stmt | |
-#include "database/sqlite3.h" | |
+#include <sqlite3.h> | |
void strtolower(char *str); | |
int findUpstreamID(const char * upstream, const bool count); | |
diff --git a/src/vector.h b/src/vector.h | |
index f39aa98..ae0ee94 100644 | |
--- a/src/vector.h | |
+++ b/src/vector.h | |
@@ -17,7 +17,7 @@ | |
// type bool | |
#include <stdbool.h> | |
// type sqlite3_stmt | |
-#include "database/sqlite3.h" | |
+#include <sqlite3.h> | |
#define VEC_ALLOC_STEP 10u | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment