termux-packages/packages/dpkg/verify-prefix.patch.txt

34 lines
1.4 KiB
Plaintext
Raw Normal View History

Patch to encourage third-parties to compile own packages instead
of using hosted by Termux.
diff -uNr dpkg-1.20.5/src/main.c dpkg-1.20.5.mod/src/main.c
--- dpkg-1.20.5/src/main.c 2020-06-28 00:07:40.000000000 +0300
+++ dpkg-1.20.5.mod/src/main.c 2020-09-28 02:51:27.602517110 +0300
@@ -760,6 +760,26 @@
int main(int argc, const char *const *argv) {
int ret;
+ // Reversed /data/data/com.termux/files/usr. Prevents patching with 'sed'
+ // by using equal-size prefixes.
+ const char termux_prefix_obfs[] = "rsu/selif/xumret.moc/atad/atad/";
+ char termux_prefix[sizeof(termux_prefix_obfs)/sizeof(char)] = {0};
+ int termux_prefix_len = sizeof(termux_prefix_obfs)/sizeof(char) - 1;
+
+ // Decode.
+ for (int i=0; i<termux_prefix_len; i++) {
+ termux_prefix[termux_prefix_len - 1 - i] = termux_prefix_obfs[i];
+ }
+
+ // Stub to verify that we can access @TERMUX_PREFIX@ and it is a directory.
+ // If checks failed, then we probably running in incompatible environment.
+ // In this case warn user and exit with status 1.
+ if (access(termux_prefix, R_OK) != 0) {
+ fprintf(stderr, "Warning: aborting execution because %s is not accessible.\n", termux_prefix);
+ fprintf(stderr, "Please make sure that program is compiled with correct prefix.\n");
+ return 1;
+ }
+
dpkg_locales_init(PACKAGE);
dpkg_program_init("dpkg");
set_force_default(FORCE_ALL);