--- a/lib/dpkg/doubao-prefix.h 2026-10-14 12:41:34.579902172 +0800 +++ b/lib/dpkg/doubao-prefix.h 2026-10-14 12:41:34.580926465 +0800 @@ -0,0 +1,52 @@ +/* + * doubao-prefix.h - resolve the installation prefix at runtime + * + * Copyright (C) 2026 doubao-clone + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef DOUBAO_PREFIX_H +#define DOUBAO_PREFIX_H + +#include + +DPKG_BEGIN_DECLS + +/** + * Return the prefix this dpkg was installed under. + * + * The prefix is derived from the path of the running executable, because + * Android hands every application its own private data directory and the + * same binary has to work under any of them. Falls back to the compile-time + * DOUBAO_DEFAULT_PREFIX when the executable path cannot be determined. + */ +const char *doubao_prefix(void); + +/** + * Return the configuration directory ($prefix/etc/dpkg). + */ +const char *doubao_config_dir(void); + +/** + * Prepend our own bin directories to PATH and point LD_LIBRARY_PATH at our + * own lib directory. + * + * Needed because apt sanitises the environment before it execs dpkg, and the + * PATH it hands over names the *other* application's prefix; dpkg would then + * fail its own sanity check with "expected programs not found in PATH". + */ +void doubao_fix_environment(void); + +/** + * Rewrite a maintainer script's interpreter line so it points at this + * installation instead of the application it was built for. + */ +void doubao_fix_script_shebang(const char *path); + +DPKG_END_DECLS + +#endif /* DOUBAO_PREFIX_H */