new package: synaptic (#732)

This commit is contained in:
Yisus7u7 2022-04-06 22:13:56 -05:00 committed by Yaksh Bariya
parent a30a6e73c5
commit 10a2e564a7
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
3 changed files with 461 additions and 0 deletions

View File

@ -0,0 +1,20 @@
TERMUX_PKG_HOMEPAGE=https://www.nongnu.org/synaptic/
TERMUX_PKG_DESCRIPTION="Synaptic is a graphical package management tool based on GTK+ and APT."
TERMUX_PKG_LICENSE="GPL-2.0"
TERMUX_PKG_MAINTAINER="Yisus7u7 <dev.yisus@hotmail.com>"
TERMUX_PKG_VERSION=0.90.1
_COMMIT=a85c743e10e39a43737d5f8a0f0cc4ea755eb545
TERMUX_PKG_SRCURL=https://github.com/mvo5/synaptic/archive/${_COMMIT}.zip
TERMUX_PKG_SHA256=a500cfeea6c4ec4463b42495cba224b9548acbd557e9da695730acf7e49e0798
TERMUX_PKG_DEPENDS="apt, dpkg, gtk3, atk, libvte, hicolor-icon-theme"
TERMUX_PKG_RECOMMENDS="netsurf"
TERMUX_PKG_BUILD_IN_SRC=true
termux_step_pre_configure(){
NOCONFIGURE=1 ./autogen.sh
}
termux_step_post_make_install(){
install -Dm700 -t ${TERMUX_PREFIX}/bin ./gtk/synaptic
}

View File

@ -0,0 +1,38 @@
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index ed83daa..6100cf9 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -23,7 +23,6 @@ synaptic_LDADD = \
@GTK_LIBS@ \
@VTE_LIBS@ @LP_LIBS@\
-lutil \
- -lpthread \
$(LIBEPT_LIBS)
synaptic_SOURCES= \
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4888444..b382f7a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,7 +8,7 @@ LDADD = \
${top_builddir}/common/libsynaptic.a\
-lapt-pkg -lX11 @RPM_LIBS@ @DEB_LIBS@ \
@GTK_LIBS@ @VTE_LIBS@ @LP_LIBS@\
- -lpthread $(LIBEPT_LIBS)
+ $(LIBEPT_LIBS)
test_rpackage_SOURCES= test_rpackage.cc
diff --git a/wings/Makefile.am b/wings/Makefile.am
index f59034f..76592bf 100644
--- a/wings/Makefile.am
+++ b/wings/Makefile.am
@@ -7,7 +7,7 @@ sbin_PROGRAMS=wsynaptic
wsynaptic_LDADD =-lExtraWINGs @WINGS_LIBS@ \
${top_builddir}/common/libsynaptic.a\
-lapt-pkg @RPM_LIBS@ @DEB_LIBS@\
- -lpthread -L/usr/X11R6/lib $(LIBTAGCOLL_LIBS)
+ -L/usr/X11R6/lib $(LIBTAGCOLL_LIBS)

View File

@ -0,0 +1,403 @@
diff --git a/common/rconfiguration.cc b/common/rconfiguration.cc
index 2603588..5cb8958 100644
--- a/common/rconfiguration.cc
+++ b/common/rconfiguration.cc
@@ -86,24 +86,22 @@ bool RWriteConfigFile(Configuration &Conf)
// store option 'consider recommended packages as dependencies'
// to config of apt if we run as root
- if (getuid() == 0) {
- string aptConfPath = _config->FindDir("Dir::Etc::parts", "/etc/apt/apt.conf.d/")
- + "99synaptic";
-
- int old_umask = umask(0022);
- ofstream aptfile(aptConfPath.c_str(), ios::out);
- if (!aptfile != 0) {
- cerr << "cannot open " << aptConfPath.c_str() <<
- " to write APT::Install-Recommends" << endl;
- } else {
- if (_config->FindB("APT::Install-Recommends", false))
- aptfile << "APT::Install-Recommends \"true\";" << endl;
- else
- aptfile << "APT::Install-Recommends \"false\";" << endl;
+ string aptConfPath = _config->FindDir("Dir::Etc::parts", "@TERMUX_PREFIX@/etc/apt/apt.conf.d/")
+ + "99synaptic";
+
+ int old_umask = umask(0022);
+ ofstream aptfile(aptConfPath.c_str(), ios::out);
+ if (!aptfile != 0) {
+ cerr << "cannot open " << aptConfPath.c_str() <<
+ " to write APT::Install-Recommends" << endl;
+ } else {
+ if (_config->FindB("APT::Install-Recommends", false))
+ aptfile << "APT::Install-Recommends \"true\";" << endl;
+ else
+ aptfile << "APT::Install-Recommends \"false\";" << endl;
aptfile.close();
- }
- umask(old_umask);
}
+ umask(old_umask);
// and backup Install-Recommends to config of synaptic
_config->Set("Synaptic::Install-Recommends",
_config->FindB("APT::Install-Recommends",
@@ -135,14 +133,14 @@ static bool checkConfigDir(string &path)
struct stat stbuf;
struct passwd *pwd;
- pwd = getpwuid(getuid());
+ /* pwd = getpwuid(getuid());
if (!pwd) {
return _error->Errno("getpwuid",
_
("ERROR: Could not get password entry for superuser"));
}
- path = string(pwd->pw_dir) + "/.synaptic";
- //path = "/etc/synaptic";
+ path = string(pwd->pw_dir) + "/.synaptic";*/
+ path = "@TERMUX_PREFIX@/etc/synaptic";
if (stat(path.c_str(), &stbuf) < 0) {
if (mkdir(path.c_str(), 0700) < 0) {
@@ -185,7 +183,7 @@ string RStateDir()
string RTmpDir()
{
struct stat stbuf;
- static string tmpDir = RConfDir() + string("/tmp/");
+ static string tmpDir = RConfDir() + string("@TERMUX_PREFIX@/tmp/");
if (stat(tmpDir.c_str(), &stbuf) < 0) {
if (mkdir(tmpDir.c_str(), 0700) < 0) {
_error->Errno("mkdir",
@@ -241,17 +239,10 @@ bool RInitConfiguration(string confFileName)
// read Install-Recommends, preferably from APT:: if we run as root
// or from Synaptic:: otherwise
- if(getuid() == 0) {
- _config->Set("APT::Install-Recommends",
- _config->FindB("APT::Install-Recommends",
- _config->FindB("Synaptic::Install-Recommends",
- false)));
- } else {
- _config->Set("APT::Install-Recommends",
- _config->FindB("Synaptic::Install-Recommends",
- _config->FindB("APT::Install-Recommends",
- false)));
- }
+ _config->Set("APT::Install-Recommends",
+ _config->FindB("APT::Install-Recommends",
+ _config->FindB("Synaptic::Install-Recommends",
+ false)));
return true;
}
diff --git a/common/rpackage.cc b/common/rpackage.cc
index 834b199..ad34aad 100644
--- a/common/rpackage.cc
+++ b/common/rpackage.cc
@@ -233,10 +233,10 @@ const char *RPackage::installedFiles()
filelist.erase(filelist.begin(), filelist.end());
// try normal file first
- string f = "/var/lib/dpkg/info/" + string(name()) + ".list";
+ string f = "@TERMUX_PREFIX@/var/lib/dpkg/info/" + string(name()) + ".list";
// try multiarch name next
if (!FileExists(f))
- f = "/var/lib/dpkg/info/" + string(name()) + ":" + arch() + ".list";
+ f = "@TERMUX_PREFIX@/var/lib/dpkg/info/" + string(name()) + ":" + arch() + ".list";
if (FileExists(f)) {
ifstream in(f.c_str());
if (!in != 0)
diff --git a/common/rpackagelister.cc b/common/rpackagelister.cc
index 084e7ae..628b274 100644
--- a/common/rpackagelister.cc
+++ b/common/rpackagelister.cc
@@ -309,8 +309,6 @@ bool RPackageLister::openCache()
// only lock if we run as root
bool lock = true;
- if(getuid() != 0)
- lock = false;
if (!_cache->open(_progMeter,lock)) {
_progMeter->Done();
diff --git a/data/synaptic.desktop.in b/data/synaptic.desktop.in
index 28025a8..6c5ee22 100644
--- a/data/synaptic.desktop.in
+++ b/data/synaptic.desktop.in
@@ -2,7 +2,7 @@
_Name=Synaptic Package Manager
_GenericName=Package Manager
_Comment=Install, remove and upgrade software packages
-Exec=synaptic-pkexec
+Exec=synaptic
Icon=synaptic
Terminal=false
Type=Application
diff --git a/gtk/gsynaptic.cc b/gtk/gsynaptic.cc
index a6d5834..602a519 100644
--- a/gtk/gsynaptic.cc
+++ b/gtk/gsynaptic.cc
@@ -185,12 +185,12 @@ void update_check(RGMainWindow *mainWindow, RPackageLister *lister)
vector<string> filenames = lister->getPolicyArchives(true);
for (int i=0;i<filenames.size();i++) {
stat(filenames[i].c_str(), &st);
- if(filenames[i] != "/var/lib/dpkg/status")
+ if(filenames[i] != "@TERMUX_PREFIX@/var/lib/dpkg/status")
lastUpdate = max(lastUpdate, (int)st.st_mtime);
}
// new apt uses this
- string update_stamp = _config->FindDir("Dir::State","var/lib/apt");
+ string update_stamp = _config->FindDir("Dir::State","@TERMUX_PREFIX@/var/lib/apt");
update_stamp += "update-stamp";
if(FileExists(update_stamp)) {
stat(update_stamp.c_str(), &st);
@@ -309,9 +309,6 @@ pid_t TestLock(string File)
// *) if not, show message and fail
void check_and_aquire_lock()
{
- if (getuid() != 0)
- return;
-
GtkWidget *dia;
gchar *msg = NULL;
pid_t LockedApp, runsNonInteractive;
@@ -429,17 +426,6 @@ int main(int argc, char **argv)
if (_config->FindB("help") == true)
ShowHelp(CmdL);
- if (getuid() != 0) {
- RGUserDialog userDialog;
- userDialog.warning(g_strdup_printf("<b><big>%s</big></b>\n\n%s",
- _("Starting \"Synaptic Package Manager\" without "
- "administrative privileges"),
- _("You will not be able to apply "
- "any changes, but you can still "
- "export the marked changes or "
- "create a download script "
- "for them.")));
- }
if (!RInitConfiguration("synaptic.conf")) {
RGUserDialog userDialog;
diff --git a/gtk/rgdebinstallprogress.cc b/gtk/rgdebinstallprogress.cc
index 9a8e2eb..db46575 100644
--- a/gtk/rgdebinstallprogress.cc
+++ b/gtk/rgdebinstallprogress.cc
@@ -142,7 +142,7 @@ read_fd(int fd, void *ptr, size_t nbytes, int *recvfd)
}
/* end read_fd */
-#define UNIXSTR_PATH "/var/run/synaptic.socket"
+#define UNIXSTR_PATH "@TERMUX_PREFIX@/var/run/synaptic.socket"
int ipc_send_fd(int fd)
{
@@ -259,7 +259,7 @@ void RGDebInstallProgress::conffile(gchar *conffile, gchar *status)
// read diff
string diff;
char buf[512];
- char *cmd = g_strdup_printf("/usr/bin/diff -u %s %s", orig_file.c_str(), new_file.c_str());
+ char *cmd = g_strdup_printf("@TERMUX_PREFIX@/bin/diff -u %s %s", orig_file.c_str(), new_file.c_str());
FILE *f = popen(cmd,"r");
while(fgets(buf,sizeof(buf),f) != NULL) {
diff += utf8(buf);
diff --git a/gtk/rgmainwindow.cc b/gtk/rgmainwindow.cc
index 3f2d563..a19e817 100644
--- a/gtk/rgmainwindow.cc
+++ b/gtk/rgmainwindow.cc
@@ -405,10 +405,8 @@ void RGMainWindow::updatePackageInfo(RPackage *pkg)
gtk_widget_set_sensitive(_detailsM, TRUE);
gtk_widget_set_sensitive(_propertiesB, TRUE);
// activate for root only
- if(getuid() == 0) {
- gtk_widget_set_sensitive(_pinM, TRUE);
- gtk_widget_set_sensitive(_autoM, TRUE);
- }
+ gtk_widget_set_sensitive(_pinM, TRUE);
+ gtk_widget_set_sensitive(_autoM, TRUE);
// set info
gtk_widget_set_sensitive(pkginfo, true);
@@ -872,19 +870,16 @@ gboolean RGMainWindow::xapianDoIndexUpdate(void *data)
}
// do not run if we don't have it
- if(!FileExists("/usr/sbin/update-apt-xapian-index"))
- return false;
- // no permission
- if (getuid() != 0)
+ if(!FileExists("@TERMUX_PREFIX@/bin/update-apt-xapian-index"))
return false;
// if we make it to this point, we need a xapian update
if(_config->FindB("Debug::Synaptic::Xapian",false))
std::cerr << "running update-apt-xapian-index" << std::endl;
GPid pid;
- const char *argp[] = {"/usr/bin/nice",
- "/usr/bin/ionice","-c3",
- "/usr/sbin/update-apt-xapian-index",
+ const char *argp[] = {"@TERMUX_PREFIX@/bin/nice",
+ "@TERMUX_PREFIX@/bin/ionice","-c3",
+ "@TERMUX_PREFIX@/bin/update-apt-xapian-index",
"--update", "-q",
NULL};
if(g_spawn_async(NULL, const_cast<char **>(argp), NULL,
@@ -1580,29 +1575,6 @@ void RGMainWindow::buildInterface()
gtk_box_set_center_widget(GTK_BOX(
gtk_builder_get_object(_builder, "hbox_button_toolbar")), NULL);
#endif
- // stuff for the non-root mode
- if(getuid() != 0) {
- GtkWidget *menu;
- gtk_widget_set_sensitive(_proceedB, false);
- gtk_widget_set_sensitive(_proceedM, false);
- button = GTK_WIDGET(gtk_builder_get_object(_builder, "button_update"));
- gtk_widget_set_sensitive(button, false);
- menu = GTK_WIDGET(gtk_builder_get_object
- (_builder, "menu_add_downloadedfiles"));
- gtk_widget_set_sensitive(menu, false);
- menu = GTK_WIDGET(gtk_builder_get_object(_builder, "menu_repositories"));
- gtk_widget_set_sensitive(menu, false);
- menu = GTK_WIDGET(gtk_builder_get_object(_builder, "view_commit_log"));
- gtk_widget_set_sensitive(menu, false);
- menu = GTK_WIDGET(gtk_builder_get_object
- (_builder, "menu_update_packages"));
- gtk_widget_set_sensitive(menu, false);
- menu = GTK_WIDGET(gtk_builder_get_object(_builder, "add_cdrom"));
- gtk_widget_set_sensitive(menu, false);
- menu = GTK_WIDGET(gtk_builder_get_object(_builder, "menu_hold"));
- gtk_widget_set_sensitive(menu, false);
- }
-
}
@@ -1690,10 +1662,8 @@ void RGMainWindow::setStatusText(char *text)
gtk_widget_set_sensitive(_upgradeB, _lister->upgradable());
gtk_widget_set_sensitive(_upgradeM, _lister->upgradable());
- if (getuid() == 0) {
- gtk_widget_set_sensitive(_proceedB, (toInstall + toRemove) != 0);
- gtk_widget_set_sensitive(_proceedM, (toInstall + toRemove) != 0);
- }
+ gtk_widget_set_sensitive(_proceedB, (toInstall + toRemove) != 0);
+ gtk_widget_set_sensitive(_proceedM, (toInstall + toRemove) != 0);
_unsavedChanges = ((toInstall + toRemove) != 0);
gtk_widget_queue_draw(_statusL);
diff --git a/gtk/rgutils.cc b/gtk/rgutils.cc
index f5ebdc3..e0506eb 100644
--- a/gtk/rgutils.cc
+++ b/gtk/rgutils.cc
@@ -114,17 +114,17 @@ std::string SizeToStr(double Size)
std::vector<const gchar*> GetBrowserCommand(const gchar *link)
{
std::vector<const gchar*> cmd;
- if (FileExists("/usr/bin/xdg-open")) {
- cmd.push_back("/usr/bin/xdg-open");
+ if (FileExists("@TERMUX_PREFIX@/bin/xdg-open")) {
+ cmd.push_back("@TERMUX_PREFIX@/bin/xdg-open");
cmd.push_back(link);
- } else if (FileExists("/usr/bin/firefox")) {
- cmd.push_back("/usr/bin/firefox");
+ } else if (FileExists("@TERMUX_PREFIX@/bin/netsurf-gtk3")) {
+ cmd.push_back("@TERMUX_PREFIX@/bin/netsurf-gtk3");
cmd.push_back(link);
- } else if (FileExists("/usr/bin/iceweasel")) {
- cmd.push_back("/usr/bin/iceweasel");
+ } else if (FileExists("@TERMUX_PREFIX@/bin/iceweasel")) {
+ cmd.push_back("@TERMUX_PREFIX@/bin/iceweasel");
cmd.push_back(link);
- } else if (FileExists("/usr/bin/konqueror")) {
- cmd.push_back("/usr/bin/konqueror");
+ } else if (FileExists("@TERMUX_PREFIX@/bin/konqueror")) {
+ cmd.push_back("@TERMUX_PREFIX@/bin/konqueror");
cmd.push_back(link);
}
return cmd;
@@ -139,46 +139,10 @@ bool RunAsSudoUserCommand(std::vector<const gchar*> cmd)
std::cerr << "Empty command for RunAsSudoUserCommand" << std::endl;
return true;
}
- bool getuidbyname = false;
- // try pkexec first, then sudo
- sudo_user = getenv("PKEXEC_UID");
- if (sudo_user == NULL) {
- sudo_user = getenv("SUDO_UID");
- }
- if (sudo_user == NULL) {
- sudo_user = getenv("USER");
- getuidbyname = true;
- }
- if (sudo_user == NULL) {
- return false;
- }
- if(strncmp("root", sudo_user, strlen("root")) == 0){
- return false;
- }
- if(!getuidbyname){
- pwd = getpwuid(atoi(sudo_user));
- }
- else{
- pwd = getpwnam(sudo_user);
- }
- sudo_user = pwd->pw_name;
#if 0 // does not work for some reason
- if(FileExists("/usr/bin/pkexec") && sudo_user != NULL)
- {
- prefix.push_back("/usr/bin/pkexec");
- prefix.push_back("--user");
- prefix.push_back(sudo_user);
- }
#endif
- if(FileExists("/usr/bin/sudo") && sudo_user != NULL)
- {
- prefix.push_back("/usr/bin/sudo");
- prefix.push_back("-u");
- prefix.push_back(sudo_user);
- }
- // insert the prefix string
- cmd.insert(cmd.begin(), prefix.begin(), prefix.end());
+
#if 0
for(std::vector<const gchar*>::iterator it = cmd.begin();
@@ -228,7 +192,7 @@ char *gtk_get_string_from_color(GdkRGBA * colp)
g_free(_str);
if (colp == NULL) {
- _str = g_strdup("");
+ _str = g_strdup("USER");
return _str;
}
_str = gdk_rgba_to_string(colp);
diff --git a/wings/synaptic.cc b/wings/synaptic.cc
index 3a84ed2..48cc5b5 100644
--- a/wings/synaptic.cc
+++ b/wings/synaptic.cc
@@ -61,7 +61,7 @@ int main(int argc, char **argv)
{
setlocale(LC_ALL, "");
-// bindtextdomain(PACKAGE, "/usr/local/share/locale");
+// bindtextdomain(PACKAGE, "@TERMUX_PREFIX@/share/locale");
textdomain(PACKAGE);
WMInitializeApplication("synaptic", &argc, argv);
@@ -75,12 +75,12 @@ int main(int argc, char **argv)
//XSynchronize(dpy, 1);
scr = WMCreateScreen(dpy, DefaultScreen(dpy));
- if (getuid() != 0) {
+ /* if (getuid() != 0) {
WMRunAlertPanel(scr, NULL, _("Error"),
_("You must run this program as the root user."),
_("OK"), NULL, NULL);
exit(1);
- }
+ }*/
if (!RInitConfiguration("synaptic.conf")) {