Browse Source

Adds support for queueing installs

Fixes segfault when no task packages are available
tags/debian_version_1_0-8
Randolph Chung 22 years ago
parent
commit
50ea1ba28c
2 changed files with 59 additions and 21 deletions
  1. +7
    -0
      debian/changelog
  2. +52
    -21
      tasksel.c

+ 7
- 0
debian/changelog View File

@@ -1,3 +1,10 @@
tasksel (1.0-5) frozen unstable; urgency=low

* Adds option to queue installs instead of running them immediately (-q)
* Fixed a segfault that occurs when no task packages are found on the system

-- Randolph Chung <tausq@debian.org> Sun, 16 Jan 2000 00:27:30 -0700

tasksel (1.0-4) frozen unstable; urgency=low

* More changes from Joey Hess; adds buttons to clear up main screen;


+ 52
- 21
tasksel.c View File

@@ -1,6 +1,7 @@
/* $Id: tasksel.c,v 1.3 1999/11/23 05:12:43 tausq Exp $ */
/* $Id: tasksel.c,v 1.4 2000/01/16 07:33:08 tausq Exp $ */
#include "tasksel.h"

#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <libintl.h>
@@ -26,17 +27,19 @@ static void signalhandler(int sig)

void help(void)
{
fprintf(stderr, "tasksel [-t]\n\t");
fprintf(stderr, "%s\n\n", _("-t -- test mode; don't actually run apt-get on exit"));
fprintf(stderr, "tasksel [-t]\n");
fprintf(stderr, "\t%s\n", _("-t -- test mode; don't actually run apt-get on exit"));
fprintf(stderr, "\t%s\n\n", _("-q -- queue installs; do not install packages with apt-get;\n\t\tjust queue them in dpkg"));
exit(0);
}

int main(int argc, char * const argv[])
{
int i, c, r, testmode = 0;
int i, c, r, testmode = 0, queueinstalls = 0;
struct packages_t taskpkgs, packages;
struct package_t **pkglist;
char buf[2048];
FILE *todpkg;
signal(SIGWINCH, signalhandler);
@@ -45,16 +48,23 @@ int main(int argc, char * const argv[])
textdomain(PACKAGE);
while (1) {
c = getopt(argc, argv, "t");
c = getopt(argc, argv, "tq");
if (c == -1) break;

switch (c) {
case 't': testmode = 1; break;
case 'q': queueinstalls = 1; break;
default: help();
}
}
packages_readlist(&taskpkgs, &packages);

if (taskpkgs.count == 0) {
fprintf(stderr, _("No task packages found on this system.\nDid you update your available file?"));
return 255;
}
ui_init(argc, argv, &taskpkgs, &packages);
ui_drawscreen();
r = ui_eventloop();
@@ -62,26 +72,47 @@ int main(int argc, char * const argv[])

pkglist = packages_enumerate(&taskpkgs);

c = 0;
if (r == 0) {
sprintf(buf, "apt-get install ");
c = 0;
for (i = 0; i < taskpkgs.count; i++) {
if (pkglist[i]->selected > 0) {
/* TODO check buffer overflow; not likely, but still... */
strcat(buf, pkglist[i]->name);
strcat(buf, " ");
c++;
if (queueinstalls) {
if (testmode)
todpkg = stdout;
else
todpkg = popen("dpkg", "w");
if (!todpkg) PERROR("Cannot send output to dpkg");
for (i = 0; i < taskpkgs.count; i++) {
if (pkglist[i]->selected > 0) {
fprintf(todpkg, "%s install\n", pkglist[i]->name);
c++;
}
}
}
if (!testmode) pclose(todpkg);

if (c > 0) {
if (testmode == 1)
printf("%s\n", buf);
else
system(buf);
if (c == 0) {
fprintf(stderr, "No packages selected\n");
r = 1;
}
} else {
fprintf(stderr, "No packages selected\n");
r = 1;
sprintf(buf, "apt-get install ");
for (i = 0; i < taskpkgs.count; i++) {
if (pkglist[i]->selected > 0) {
/* TODO check buffer overflow; not likely, but still... */
strcat(buf, pkglist[i]->name);
strcat(buf, " ");
c++;
}
}

if (c > 0) {
if (testmode == 1)
printf("%s\n", buf);
else
system(buf);
} else {
fprintf(stderr, "No packages selected\n");
r = 1;
}
}
}


Loading…
Cancel
Save