auto-apt-0.3.23ubuntu0.14.04.1/0000775000000000000000000000000012330411273012344 5ustar auto-apt-0.3.23ubuntu0.14.04.1/README0000664000000000000000000000325507206514177013246 0ustar $Id: README,v 1.9 2000/11/21 15:45:03 ukai Exp $ auto-apt -- on demand package installation tool Copyright (c) 2000 Fumitoshi UKAI This is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. * Setup In case that a file is not installed and found in db, auto-apt will automatically run "sudo apt-get install ". So you need to setup sudo in order to get root privs without password (visudo(1), adduser sudo) For example, in /etc/sudoers: ALL=(root) NOPASSWD: /usr/bin/apt-get -y install [!-]* Create your pkgcontents.db (available file info) and pkgfiles.db (installed file info) # auto-apt update -- create pkgcontents.db (from /etc/apt/sources.list info) # auto-apt update-local -- create pkgfiles.db Note that these operation is not so fast. * Usage % auto-apt run -- enter auto-apt environment % auto-apt status -- show "auto-apt mode" or "normal mode" # auto-apt update -- recreate /var/cache/auto-apt/pkgcontents.db % auto-apt check /bin/ls fileutils -- Check which package provides the file. % auto-apt search keyword -- Search by keyword * detect file access % auto-apt run -L $HOME/detect.lists -s -- enter auto-apt environments, and save file access information to $HOME/detect.lists (by -L option) No automatic apt-get install (by -s option) You can exit auto-apt mode by simply exiting from the shell. detect.lists is plain text. Another example, # auto-apt update-local -- generate installed file information % auto-apt debuild -- debuild with checking build-depends auto-apt-0.3.23ubuntu0.14.04.1/auto-apt.es.10000664000000000000000000001263510460540107014576 0ustar .\" Hey, EMACS: -*- nroff -*- .\" (c) 2003 Software in the Public Interest .\" Esta traducción ha sido realizada por Rubén Porras Campo .\" Está basada en la página de manual original: .\" versión 1.2 del CVS de .\" /cvs/debian-doc/manpages/english/auto-apt/auto-apt.1 .TH auto-apt 1 "29 de Junio de 2000" .SH NOMBRE auto-apt \- herramienta de instalación de paquetes por demanda .SH SINOPSIS .B auto-apt .RI [ opciones ] " " [ orden ] " " [ args... ] .SH DESCRIPCIÓN Esta página del manual describe brevemente las órdenes de .B auto-apt . .PP \fBauto-apt\fP es un programa que comprueba los accesos a ficheros de los programas ejecutándose dentro de un entorno \fBauto-apt\fP. Si un programa accede a un fichero de un paquete que no está instalado, \fBauto-apt\fP instalará el paquete que contiene ese fichero usando apt-get. .SH OPCIONES A continuación se incluye un resumen de la opciones. .TP .B "-h" Muestra el modo de uso. .TP .B "-s" No realiza ninguna acción, realiza una simulación. .TP .B "-y" Asume respuestas afirmativas. .TP .B "-q" Modo silencioso. .TP .B "-i" No realiza la instalación en segundo plano. .TP .B "-x" Deshabilita la interfaz X. .TP .B "-X" Habilita la interfaz X. Ejecuta apt-get en otro \fBx-terminal-emulator\fP si se ejecuta en un entorno X. .TP .BI "-a [" dist [, dist... ]] Selecciona la distribución instalable de entre .BR main , contrib , non-free , non-US o .B none. Si usa "-a none", es igual que si usase la opción "-s". .TP .BI "-p [" enganche [, enganche... ]] Selecciona las funciones de enganche de entre .BR exec , open , access , stat o .B none Si usa "-p none", es igual que si usase la opción "-s". .TP .BI "-D [" ficherodb ] Usa \fIficherodb\fP en vez del predeterminado .B /var/cache/auto-apt/pkgcontents.db .TP .BI "-F [" ficherodb ] Usa \fIficherodb\fP en vez del predeterminado .B /var/cache/auto-apt/pkgfiles.db, generado por la orden \fBauto-apt update-local\fP. Es usado como \fIficherodb\fP predeterminado por órdenes con el sufijo \fB-local\fP. En muchos casos se usa junto con la opción .B -L para detectar accesos de ficheros. .TP .BI "-L [" registro.lists ] Añade los datos de acceso a los ficheros al fichero \fIregistro.lists\fP. .SH ÓRDENES A continuación se incluye un resumen de las órdenes. .TP .BI "run [" orden ] Ejecuta orden de forma controlada por \fPauto-apt\fP. Si \fIorden\fP no se especifica, se usará el shell de usuario. .TP .B "update [" -a ] Regenerar \fIficherodb\fP desde la información de sources.list. El \fIficherodb\fP puede especificarse con la opción \fB-D\fP. Con la opción \fB-a\fP, todos los ficheros se guardan en \fIficherodb\fP. Dese cuenta de que el \fIficherodb\fP se vuelve muy grande con la opción \fB-a\fP. .TP .B "update-local [" -a ] Genera \fIficherodb\fP con la información de los paquetes instalados. \fficherodb\fP puede especificarse con la opción \fB-F\fP. Con la opción \fB-a\fP, todos los ficheros se guardan en \fIficherodb\fP. Dese cuenta de que el \fIficherodb\fP se vuelve muy grande con la opción \fB-a\fP. .TP .B "merge [" -a ] Combina la información de paquetes y ficheros en \fIficherodb\fP, que puede especificarse con la opción \fB-D\fP. Con la opción \fB-a\fP, todos los ficheros se guardan en \fIficherodb\fP. Dese cuenta de que el \fIficherodb\fP se vuelve muy grande con la opción \fB-a\fP. .TP .BI del " paquete " Borra la información del \fIpaquete\fP de la base de datos del \fIficherodb\fP. .TP .BI check " " "[-v] [-f] " fichero Comprueba que paquete proporciona \fIfichero\fP, usando la base de datos de \fIficherodb\fP. Opciones: \fB-v\fP mensajes explicativos. \fB-f\fP usa el fichero Contents-*.gz en vez de la base de datos \fIficherodb\fP. .TP .BI install " " "[-s] [-d] [-u] [-y] [-v] " fichero Intenta instalar el paquete que proporciona el \fIfichero\fP usando apt-get. Necesita permisos de superusuario para ejecutar apt-get install. .TP .B list [-v] [-f] Lista la información de la base de datos \fIficherodb\fP. Opciones: \fB-v\fP mensajes explicativos. \fB-f\fP usa el fichero Contents-*.gz en vez de la base de datos \fIficherodb\fP. .TP .BI search " " "[-v] [-f] " patrón Busca información en el fichero usando .BR grep (1) \fIpatrón\fP en la base de datos \fIficherodb\fP. Opciones: \fB-v\fP mensajes explicativos. \fB-f\fP usa el fichero Contents-*.gz en vez de la base de datos \fIficherodb\fP. .TP .BI "debuild [" debuildopciones ] Ejecuta .BR debuild (1) en entornos auto-apt, y muestra una estimación de \fBBuild-Depends:\fP. Se recomienda el uso de la opción \fB-s\fP de auto-apt. .TP .B status Muestra si el entorno actual es un entorno \fBauto-apt\fP o no. .\" .SH VÉASE ADEMÁS .\" .BR auto-apt-pkgcdb (8) .br .SH FICHEROS .IP o /etc/auto-apt/paths\&.list ruta de las listas. .IP o /var/cache/auto-apt directorio de caché/base de datos. .IP o /etc/auto-apt/sources.list sources.list para auto-apt. si no existe, se enlazará al sources.list de apt-get. .\" .IP .\" .IP o .\" /etc/auto-apt/commands\&.list .\" configuración de la orden (aún no implementado) .SH ENTORNOS .IP o AUTO_APT_CACHEDIR modifica el directorio de caché/base de datos por omisión. .SH FALLOS Para los fallos conocidos, vea .B /usr/share/doc/auto-apt/BUGS. y/o http://bugs.debian.org/auto-apt .SH AUTOR Este programa fue escrito por Fumitoshi UKAI , inspirado por la idea/comentarios de Debian Guru (debian.gr.jp) y miembros de Project Dice. .SH TRADUCTOR Traducción de Rubén Porras Campo auto-apt-0.3.23ubuntu0.14.04.1/auto-apt.c0000664000000000000000000007236711367443332014273 0ustar /* * auto-apt.so * on demand package installation tool * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ static char auto_apt_rcsid[] __attribute__ ((unused)) = "$Id: auto-apt.c,v 1.28 2000/12/04 14:27:47 ukai Exp $"; #define LARGEFILE_SOURCE #define LARGEFILE64_SOURCE #define __USE_LARGEFILE64 1 #define __USE_FILE_OFFSET64 1 #include #include #include #include #include #include #include #include #include #include #include #include #define PKGCDB_AUTOAPT 1 #include "pkgcdb/debug.h" #include "pkgcdb/pkgcdb2.h" #include "pkgcdb/mempool.c" #include "pkgcdb/strtab.c" #include "pkgcdb/pkgtab.c" #include "pkgcdb/pathnode.c" #include "pkgcdb/pkgcdb2.c" #define APT_HOOK_EXEC 0 #define APT_HOOK_OPEN 1 #define APT_HOOK_ACCESS 2 #define APT_HOOK_STAT 3 #define NUM_APT_HOOK 4 static int apt_hook[NUM_APT_HOOK]; static char *pkgcdb_file = PKGCDB_FILE; static PathNodeTree pkgcdb_tree = NULL; static char *filedb_file = NULL; static PathNodeTree filedb_tree = NULL; #ifdef __alpha__ #define LIBCPATH "/lib/libc.so.6.1" #else #define LIBCPATH "/lib/libc.so.6" #endif typedef int (*funcptr)(); static struct realfunctab { char *name; funcptr fptr; } rftab[] = { {"execve", NULL}, /* execve(2) */ /* XXX: execl(3), execle(3) */ /* execlp(3)->execvp(3) */ /* execvp(3)->execv(3) */ {"execv", NULL}, {"open", NULL}, {"open64", NULL}, #if 1 {"__libc_open", NULL}, {"__libc_open64", NULL}, #endif {"access", NULL}, {"euidaccess", NULL}, {"__xstat", NULL}, {"__xstat64", NULL}, {"__lxstat", NULL}, {"__lxstat64", NULL}, {NULL, NULL} }; static struct path_node *filename2package(PathNodeTree pnt, const char *filename, char **detect); static int command_line_name(char *buf, size_t siz); static funcptr load_library_symbol(char *name) { void *handle; const char *error; struct realfunctab *ft; char *libcpath = NULL; for (ft = rftab; ft->name; ft++) { if (strcmp(name, ft->name) == 0) { if (ft->fptr != NULL) { return ft->fptr; } break; } } if (ft->name == NULL) { DPRINT(("func:%s not found\n", name)); return NULL; } if ((libcpath = getenv("LIBC_PATH")) == NULL) libcpath = LIBCPATH; handle = dlopen (libcpath, RTLD_LAZY); if (!handle) { DPRINT((dlerror())); return NULL; } ft->fptr = dlsym(handle, ft->name); if ((error = dlerror()) != NULL) { DPRINT(("dysym(%s)=%s\n", ft->name, error)); ft->fptr = NULL; } dlclose(handle); return ft->fptr; } static int open_internal(const char *filename, int flag, int mode) { funcptr __open = load_library_symbol("__libc_open64"); if (__open == NULL) __open = load_library_symbol("__libc_open"); if (__open == NULL) __open = load_library_symbol("open64"); if (__open == NULL) __open = load_library_symbol("open"); if (__open == NULL) return -1; return __open(filename, flag, mode); } static char * auto_apt_conf_var(char *name, char *def) { char *p = getenv(name); if (p == NULL) return def; if (*p == '\0') return def; return p; } static int auto_apt_conf_switch(char *name) { char *p = auto_apt_conf_var(name, NULL); if (p == NULL) return 0; if (strcasecmp(p, "no") == 0 || strcasecmp(p, "off") == 0) return 0; return 1; } #ifdef USE_DETECT static char *detectdb_file = NULL; static char *detectdb_lockfile = NULL; /* detectdb will access from multiple process, need lock */ static int detectdb_lock() { struct flock fl; if (detectdb_lock != NULL) { int fd = open_internal(detectdb_lockfile, O_RDWR|O_CREAT|O_TRUNC, 0660); if (fd == -1) { abort(); return -1; } again: fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 1; if (fcntl(fd, F_SETLK, &fl) == -1) { if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EACCES) goto again; close(fd); abort(); return -1; } return fd; } abort(); return -1; } static void detectdb_unlock(int fd) { struct flock fl; if (detectdb_lock != NULL) { if (fd >= 0) { fl.l_type = F_UNLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 1; if (fcntl(fd, F_SETLK, &fl) == -1) { /* cannot happen? */ } close(fd); } unlink(detectdb_lockfile); } } static int detect_package(const char *filename, char *func) { int e = 0; struct path_node *pn; char *file = NULL; char *p = NULL; char pkg[PATH_MAX]; int lockfd; if (detectdb_file == NULL) return -1; if (filedb_tree == NULL) return -1; DPRINT(("detect: %s\n", filename)); /* ignore db files */ if (strcmp(filename, pkgcdb_file) == 0) { return 0; } else if (strcmp(filename, detectdb_file) == 0) { return 0; } else if (detectdb_lockfile && strcmp(filename, detectdb_lockfile) == 0) { return 0; } else if (filedb_file && strcmp(filename, filedb_file) == 0) { return 0; } DPRINT(("check by filedb: %s\n", filename)); pn = filename2package(filedb_tree, filename, &file); if (pn == NULL) { DPRINT(("no package file, ignore\n")); return -1; } p = pathnode_packagename(filedb_tree, pn); if (p == NULL || *p == '!' || *p == '@') { DPRINT(("dummy package, ignore\n")); return -1; } strncpy(pkg, p, PATH_MAX-1); DPRINT(("put it to detect file: %s => %s %s\n", filename, file, pkg)); if (file == NULL) file = (char *)filename; /* XXX: need lock */ lockfd = detectdb_lock(); if (lockfd < 0) goto done; { char cmd[PATH_MAX]; int fd = open_internal(detectdb_file, O_WRONLY|O_APPEND|O_CREAT, 0644); if (fd < 0) { abort(); goto done; } /* () */ write(fd, file, strlen(file)); write(fd, "\t", 1); write(fd, pkg, strlen(pkg)); write(fd, "\t", 1); write(fd, func, strlen(func)); write(fd, "(", 1); write(fd, filename, strlen(filename)); write(fd, ")\t", 2); command_line_name(cmd, PATH_MAX-1); write(fd, cmd, strlen(cmd)); write(fd, "\n", 1); close(fd); } done: /* XXX: need unlock */ detectdb_unlock(lockfd); return e; } #else #define detect_package(filename,func) #endif /* _init() ? */ static void auto_apt_setup() { static int inited = 0; if (!inited) { char *p; int i; inited = 1; mempool_init(); pkgtab_init(); for (i = 0; i < NUM_APT_HOOK; i++) { apt_hook[i] = 0; } p = auto_apt_conf_var("AUTO_APT_HOOK", "none"); if (p != NULL) { apt_hook[APT_HOOK_EXEC] = (strstr(p, "exec") != NULL); apt_hook[APT_HOOK_OPEN] = (strstr(p, "open") != NULL); apt_hook[APT_HOOK_ACCESS] = (strstr(p, "access") != NULL); apt_hook[APT_HOOK_STAT] = (strstr(p, "stat") != NULL); if (strcmp(p, "all") == 0) { for (i = 0; i < NUM_APT_HOOK; i++) { apt_hook[i] = 1; } } if (strstr(p, "none") != NULL) { for (i = 0; i < NUM_APT_HOOK; i++) { apt_hook[i] = 0; } } } if (auto_apt_conf_switch("AUTO_APT_DEBUG")) { debug = 1; } if (auto_apt_conf_switch("AUTO_APT_QUIET")) { quiet = 1; } if (auto_apt_conf_switch("AUTO_APT_VERBOSE")) { verbose = 1; } p = auto_apt_conf_var("AUTO_APT_DB", PKGCDB_FILE); if (p != NULL && *p == '/') { pkgcdb_file = strdup(p); pkgcdb_tree = pkgcdb_load(pkgcdb_file, 0, 0); if (pkgcdb_tree == NULL) { VMSG(("auto-apt %s load failed, auto-apt off\n", pkgcdb_file)); unsetenv("LD_PRELOAD"); free(pkgcdb_file); pkgcdb_file = NULL; /* should exit() here ?*/ } } #ifdef USE_DETECT p = auto_apt_conf_var("AUTO_APT_DETECT", NULL); if (p != NULL) { detectdb_file = strdup(p); DPRINT(("detectdb_file=%s\n", detectdb_file)); detectdb_lockfile = malloc(strlen(detectdb_file) + 5); if (detectdb_lockfile != NULL) { sprintf(detectdb_lockfile, "%s.lck", detectdb_file); DPRINT(("lockfile=%s\n", detectdb_lockfile)); } } if (detectdb_file != NULL) { p = auto_apt_conf_var("AUTO_APT_FILEDB", FILEDB_FILE); if (p != NULL) { filedb_file = strdup(p); DPRINT(("filedb: %s\n", filedb_file)); filedb_tree = pkgcdb_load(filedb_file, 0, 0); if (filedb_tree == NULL) { VMSG(("auto-apt filedb %s not loaded, use %s\n", filedb_file, pkgcdb_file)); free(filedb_file); filedb_file = NULL; } else { VMSG(("auto-apt filedb: %s\n", filedb_file)); } } } #endif } return; } static struct path_node * filename2package(PathNodeTree pnt, const char *filename, char **detected_file) { funcptr __stat = NULL; char *fname = strdup(filename); struct path_node *pn = NULL; #ifdef __USE_LARGEFILE64 struct stat64 st; #else struct stat st; #endif int n = 0; again: if (++n >= 16) /* too much */ goto done; if (fname == NULL) goto done; DPRINT(("fname:%s\n", fname)); /* XXX: normalize fname? */ if (strstr(fname, "/../")) { goto done; } if (fname[0] != '/') { goto done; } if (detected_file == NULL) { #ifdef __USE_LARGEFILE64 __stat = load_library_symbol("__xstat64"); #endif if (__stat == NULL) __stat = load_library_symbol("__xstat"); if (__stat == NULL) __stat = stat; if (__stat == NULL) goto no_file; if (__stat(_STAT_VER, fname, &st) == 0) { DPRINT(("stat(%s) ok: %0x\n", fname, st.st_mode)); if (S_ISREG(st.st_mode)) { char magic[4096]; /* filename found */ int len; int fd = open_internal(fname, O_RDONLY, 0); if (fd < 0) { DPRINT(("fname:%s open fail\n", fname)); goto no_file; } if ((len = read(fd, magic, sizeof magic -1)) > 0) { magic[len] = '\0'; if (len > 2 && magic[0] == '#' && magic[1] == '!') { char *p, *q; // DPRINT(("magic[%d]=[%s]\n", len, magic)); p = &magic[2]; q = strchr(p, ' '); if (q == NULL) { q = strchr(p, '\n'); if (q == NULL) { close(fd); goto done; } } *q = '\0'; DPRINT(("magic#! found:%s\n", p)); free(fname); fname = strdup(p); close(fd); goto again; } } DPRINT(("magic check done\n")); close(fd); } } } no_file: { char *mfile = NULL; pn = pkgcdb_get(pnt, fname, &mfile, NULL); if (pn && mfile) { DPRINT(("matched: file=%s\n", mfile)); if (detected_file) { *detected_file = mfile; } else { char list[PATH_MAX]; if (__stat && __stat(_STAT_VER, mfile, &st) == 0) { /* already exists */ DPRINT(("package:%s seems already installed, ignored\n", pathnode_packagename(pnt, pn))); pn = NULL; goto done; } /* * check /var/lib/dpkg/info/.list whether * this package is already installed */ snprintf(list, sizeof(list)-1, "/var/lib/dpkg/info/%s.list", pathnode_packagename(pnt, pn)); if (__stat && __stat(_STAT_VER, list, &st) == 0) { /* exists */ int len; int fd = open_internal(list, O_RDONLY, 0); if (fd < 0) { /* ??? */ goto done; } if ((len = read(fd, list, sizeof(list)-1)) > 0) { if (strncmp(list, "/.\n", 3) == 0) { /* installed! */ close(fd); return NULL; } } close(fd); } } } } DPRINT(("done; package=%s\n", pn ? pathnode_packagename(pnt, pn) : "(null)")); done: if (fname) free(fname); return pn; } static int command_line_name(char *buf, size_t siz) { int len; int pfd; memset(buf, 0, siz); pfd = open_internal("/proc/self/cmdline", O_RDONLY, 0); if (pfd < 0) { return -1; } if ((len = read(pfd, buf, siz-1)) > 0) { int i; char *p; for (i = 0; i < len; i++) { if (buf[i] == '\0') buf[i] = ' '; /* XXX */ } buf[len] = '\0'; /* remove tail spaces */ for (p = &buf[len-1]; p > &buf[0]; --p) { if (*p == ' ') *p = '\0'; else break; } } close(pfd); return 0; } #define DPKG_LOCKFILE "/var/lib/dpkg/lock" static int check_dpkglock() { int fd; struct flock fl; if (getuid()) { /* not running root */ return 0; } fd = open_internal(DPKG_LOCKFILE, O_RDWR|O_CREAT|O_TRUNC, 0660); if (fd == -1) return 0; fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 1; if (fcntl(fd, F_SETLK, &fl) == -1) { close(fd); if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EACCES) return 1; /* unexpected error? */ return 1; } fl.l_type = F_UNLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 1; if (fcntl(fd, F_SETLK, &fl) == -1) { /* cannot hannen? */ } close(fd); return 0; } static int apt_get_install_for_file(const char *filename) { int status; pid_t pid; struct path_node *pn; char *package; int ok = 0; if (pkgcdb_tree == NULL) return -1; pn = filename2package(pkgcdb_tree, filename, NULL); if (pn != NULL) { char pkg[PATH_MAX]; char *path, *opath; char *logfile = getenv("AUTO_APT_LOG"); int simulate = auto_apt_conf_switch("AUTO_APT_SIMULATE"); int auto_apt_nobg = auto_apt_conf_switch("AUTO_APT_NOBG"); char cmdname[PATH_MAX]; int logfd = -1; char *accept = getenv("AUTO_APT_ACCEPT"); #if 0 int auto_apt_x = auto_apt_conf_switch("AUTO_APT_X"); #endif if (accept && strcmp(accept, "none") == 0) { simulate = 1; } if (logfile) { logfd = open_internal(logfile, O_WRONLY|O_APPEND|O_CREAT, 0644); } opath = getenv("PATH"); path = malloc(strlen("PATH=/usr/sbin:/sbin:") + strlen(opath) + 2); if (path) sprintf(path, "PATH=/usr/sbin:/sbin:%s", opath); package = pathnode_packagename(pkgcdb_tree, pn); strncpy(pkg, package, PATH_MAX-1); command_line_name(cmdname, sizeof(cmdname)); DPRINT(("install: %s by %s\n", pkg, cmdname)); switch (pkg[0]) { case '!': case '*': case ' ': /* ignore! */ goto done; } #if 0 /* check done in auto-apt-installer */ for (pkg = package; *pkg; pkg++) { if (*pkg != '/') continue; *pkg++ = '\0'; if (accept) { if (strstr(accept, "non-US") == NULL && strcmp(package, "non-US") == 0) { if (logfd >= 0) { write(logfd, "Ignore[non-US]:", 15); write(logfd, pkg, strlen(pkg)); write(logfd, "\tfile:", 6); write(logfd, filename, strlen(filename)); write(logfd, "\tby:", 4); write(logfd, cmdname, strlen(cmdname)); write(logfd, "\n", 1); } goto done; } if (strstr(accept, "non-free") == NULL && strcmp(package, "non-free") == 0) { if (logfd >= 0) { write(logfd, "Ignore[non-free]", 17); write(logfd, pkg, strlen(pkg)); write(logfd, "\tfile:", 6); write(logfd, filename, strlen(filename)); write(logfd, "\tby:", 4); write(logfd, cmdname, strlen(cmdname)); write(logfd, "\n", 1); } goto done; } if (strstr(accept, "contrib") == NULL && strcmp(package, "contrib") == 0) { if (logfd >= 0) { write(logfd, "Ignore[contrib]:", 16); write(logfd, pkg, strlen(pkg)); write(logfd, "\tfile:", 6); write(logfd, filename, strlen(filename)); write(logfd, "\tby:", 4); write(logfd, cmdname, strlen(cmdname)); write(logfd, "\n", 1); } goto done; } } package = pkg; } #endif /* do_install: */ if (check_dpkglock()) { if (logfd >= 0) { write(logfd, "Install:", 8); write(logfd, package, strlen(package)); write(logfd, "\tfile:", 6); write(logfd, filename, strlen(filename)); write(logfd, "\tby:", 4); write(logfd, cmdname, strlen(cmdname)); write(logfd, "\n", 1); write(logfd, " - ignored, dpkg is running\n", 29); } goto done; } if (logfd >= 0) { write(logfd, "Install:", 8); write(logfd, package, strlen(package)); write(logfd, "\tfile:", 6); write(logfd, filename, strlen(filename)); write(logfd, "\tby:", 4); write(logfd, cmdname, strlen(cmdname)); write(logfd, "\n", 1); } if (logfd >= 0) { close(logfd); logfd = -1; } if (simulate) { if (quiet || !isatty(1)) { /* do nothing */; } else { printf("Install:%s\tfile:%s\tby:%s\n", package, filename, cmdname); fflush(stdout); } } else { if (auto_apt_nobg && !isatty(1)) { goto done; } pid = fork(); if (pid == 0) { #if 1 const char *progpath = "/usr/lib/auto-apt/auto-apt-installer"; char *argv[5]; argv[0] = "auto-apt-installer"; argv[1] = cmdname; argv[2] = (char *)filename; argv[3] = package; argv[4] = NULL; unsetenv("LD_PRELOAD"); if (path) putenv(path); execv(progpath, argv); exit(-1); #else /* old internal apt-get */ const char *argv0; const char *x_argv0 = "/usr/bin/x-terminal-emulator"; const char *tty_argv0 = "/usr/bin/sudo"; char *const *argv; char *const x_argv[8] = { "x-terminal-emulator", "-e", "sudo", "apt-get", "install", package, NULL }; char *const tty_argv[] = { "sudo", "apt-get", "-y", "install", package, NULL }; unsetenv("LD_PRELOAD"); if (path) putenv(path); argv0 = tty_argv0; argv = tty_argv; if (auto_apt_x) { argv0 = x_argv0; argv = x_argv; } else if (quiet || !isatty(1)) { int fd = open_internal("/dev/null", O_RDWR, 0); /* redirect /dev/null */ dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); } else { printf("Install:%s\tfile:%s\tby:%s\n", package, filename, cmdname); fflush(stdout); if (auto_apt_conf_switch("AUTO_APT_YES") == 0) { char inbuf[64]; printf("Do you want to install %s now? [Y/n] ", package); fflush(stdout); while (fgets(inbuf, sizeof(inbuf)-1, stdin) != NULL) { if (inbuf[0] == 'n' || inbuf[0] == 'N' || inbuf[0] == '\003') { exit(-1); } if (inbuf[0] == 'y' || inbuf[0] == 'Y' || inbuf[0] == '\n' || inbuf[0] == '\r') { break; } } } } if (logfd >= 0) { close(logfd); logfd = -1; } execv(argv0, argv); exit(-1); #endif } /* check wchan is read_chan to catch whether package waits * user interaction (?) */ waitpid(pid, &status, 0); /* need timeout? */ ok = (status == 0); } done: if (logfd >= 0) { close(logfd); logfd = -1; } if (path) free(path); return ok; } return 0; } int execl(const char *path, const char *arg, ...) { size_t argv_max = 1024; const char **argv = alloca(argv_max * sizeof(const char *)); unsigned int i; va_list args; auto_apt_setup(); argv[0] = arg; va_start(args, arg); i = 0; while (argv[i++] != NULL) { if (i == argv_max) { const char **nptr = alloca ((argv_max *= 2) * sizeof(const char *)); argv = (const char **)memmove(nptr, argv, i); argv_max += i; } argv[i] = va_arg(args, const char *); } va_end(args); return execv(path, (char *const *)argv); } int execle(const char *path, const char *arg, ...) { size_t argv_max = 1024; const char **argv = alloca(argv_max * sizeof(const char *)); const char *const *envp; unsigned int i; va_list args; argv[0] = arg; auto_apt_setup(); va_start(args, arg); i = 0; while (argv[i++] != NULL) { if (i == argv_max) { const char **nptr = alloca((argv_max *= 2) * sizeof(const char *)); argv = (const char **)memmove(nptr, argv, i); argv_max += i; } argv[i] = va_arg (args, const char *); } envp = va_arg (args, const char *const *); va_end (args); return execve(path, (char *const *)argv, (char *const *)envp); } int execve(const char *filename, char *const argv [], char *const envp[]) { int e; int apt = 0; funcptr __execve; auto_apt_setup(); again: DPRINT(("execve: filename=%s \n", filename)); if (!apt && detectdb_file) { detect_package(filename, __FUNCTION__); } __execve = load_library_symbol("execve"); if (__execve == NULL) { errno = EINVAL; return -1; } DPRINT(("execve = %p\n", __execve)); e = __execve(filename, argv, envp); DPRINT(("execve: filename=%s, e=%d\n", filename, e)); if (apt_hook[APT_HOOK_EXEC] && e < 0) { switch (errno) { case ENOENT: DPRINT(("execve: filename=%s not found\n", filename)); if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } break; default: break; } } return e; } int execv(const char *filename, char *const argv []) { int e; int apt = 0; funcptr __execv; auto_apt_setup(); again: DPRINT(("execv: filename=%s \n", filename)); if (!apt && detectdb_file) { detect_package(filename, __FUNCTION__); } __execv = load_library_symbol("execv"); if (__execv == NULL) { errno = EINVAL; return -1; } DPRINT(("execv = %p :filename=%s %d,%s\n", __execv, filename, apt, detectdb_file)); e = __execv(filename, argv); DPRINT(("execvp: filename=%s, e=%d\n", filename, e)); if (apt_hook[APT_HOOK_EXEC] && e < 0) { switch (errno) { case ENOENT: DPRINT(("execv: filename=%s not found\n", filename)); if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } break; default: break; } } return e; } #undef open int open(const char *filename, int flags, ...) { int apt = 0; int e; funcptr __open; mode_t mode; va_list ap; static int o = 0; /* XXX: guard for open() in detect_pacage? */ auto_apt_setup(); again: DPRINT(("open: filename=%s \n", filename)); if (!apt && detectdb_file && !o) { o = 1; detect_package(filename, __FUNCTION__); o = 0; } __open = load_library_symbol("open"); if (__open == NULL) { errno = ENOENT; return -1; } DPRINT(("open = %p\n", __open)); va_start(ap, flags); mode = va_arg(ap, mode_t); va_end(ap); e = __open(filename, flags, mode); DPRINT(("open: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_OPEN] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } #if 1 #undef __libc_open int __libc_open(const char *filename, int flags, ...) { int apt = 0; int e; funcptr __open; mode_t mode; va_list ap; static int o = 0; /* XXX */ auto_apt_setup(); again: DPRINT(("__libc_open: filename=%s \n", filename)); if (!apt && detectdb_file && !o) { o = 1; detect_package(filename, __FUNCTION__); o = 0; } __open = load_library_symbol("__libc_open"); if (__open == NULL) { errno = ENOENT; return -1; } DPRINT(("__libc_open = %p\n", __open)); va_start(ap, flags); mode = va_arg(ap, mode_t); va_end(ap); e = __open(filename, flags, mode); DPRINT(("__libc_open: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_OPEN] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } #endif #undef open64 int open64(const char *filename, int flags, ...) { int apt = 0; int e; funcptr __open; mode_t mode; va_list ap; static int o = 0; /* XXX */ auto_apt_setup(); again: DPRINT(("open64: filename=%s \n", filename)); if (!apt && detectdb_file && !o) { o = 1; detect_package(filename, __FUNCTION__); o = 0; } __open = load_library_symbol("open64"); if (__open == NULL) { errno = ENOENT; return -1; } DPRINT(("open64 = %p\n", __open)); va_start(ap, flags); mode = va_arg(ap, mode_t); va_end(ap); e = __open(filename, flags, mode); DPRINT(("open64: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_OPEN] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } #if 1 #undef __libc_open64 int __libc_open64(const char *filename, int flags, ...) { int apt = 0; int e; funcptr __open; mode_t mode; va_list ap; static int o = 0; /* XXX */ auto_apt_setup(); again: DPRINT(("__libc_open64: filename=%s \n", filename)); if (!apt && detectdb_file && !o) { o = 1; detect_package(filename, __FUNCTION__); o = 0; } __open = load_library_symbol("__libc_open64"); if (__open == NULL) { errno = ENOENT; return -1; } DPRINT(("__libc_open64 = %p\n", __open)); va_start(ap, flags); mode = va_arg(ap, mode_t); va_end(ap); e = __open(filename, flags, mode); DPRINT(("__libc_open64: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_OPEN] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } #endif int access(const char *filename, int type) { int apt = 0; int e; funcptr __access; auto_apt_setup(); again: DPRINT(("access: filename=%s \n", filename)); if (!apt && detectdb_file) detect_package(filename, __FUNCTION__); __access = load_library_symbol("access"); if (__access == NULL) { errno = ENOENT; return -1; } DPRINT(("access = %p\n", __access)); e = __access(filename, type); DPRINT(("access: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_ACCESS] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } int euidaccess(const char *filename, int type) { int apt = 0; int e; funcptr __euidaccess; auto_apt_setup(); again: DPRINT(("euidaccess: filename=%s \n", filename)); if (!apt && detectdb_file) detect_package(filename, __FUNCTION__); __euidaccess = load_library_symbol("euidaccess"); if (__euidaccess == NULL) { errno = ENOENT; return -1; } DPRINT(("euidaccess = %p\n", __euidaccess)); e = __euidaccess(filename, type); DPRINT(("euidaccess: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_ACCESS] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } #undef __xstat int __xstat(int ver, const char *filename, struct stat *buf) { int apt = 0; int e; funcptr __stat; auto_apt_setup(); again: DPRINT(("stat: filename=%s \n", filename)); if (!apt && detectdb_file) detect_package(filename, __FUNCTION__); __stat = load_library_symbol("__xstat"); if (__stat == NULL) { errno = ENOENT; return -1; } DPRINT(("stat = %p\n", __stat)); e = __stat(ver, filename, buf); DPRINT(("stat: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_STAT] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } #undef __xstat64 struct stat64; /* XXX */ int __xstat64(int ver, const char *filename, struct stat64 *buf) { int apt = 0; int e; funcptr __stat; auto_apt_setup(); again: DPRINT(("stat64: filename=%s \n", filename)); if (!apt && detectdb_file) detect_package(filename, __FUNCTION__); __stat = load_library_symbol("__xstat64"); if (__stat == NULL) { errno = ENOENT; return -1; } DPRINT(("stat64 = %p\n", __stat)); e = __stat(ver, filename, buf); DPRINT(("stat64: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_STAT] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } #undef __lxstat int __lxstat(int ver, const char *filename, struct stat *buf) { int apt = 0; int e; funcptr __stat; auto_apt_setup(); again: DPRINT(("lstat: filename=%s \n", filename)); if (!apt && detectdb_file) detect_package(filename, __FUNCTION__); __stat = load_library_symbol("__lxstat"); if (__stat == NULL) { errno = ENOENT; return -1; } DPRINT(("lstat = %p\n", __stat)); e = __stat(ver, filename, buf); DPRINT(("lstat: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_STAT] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } #undef __lxstat64 int __lxstat64(int ver, const char *filename, struct stat64 *buf) { int apt = 0; int e; funcptr __stat; auto_apt_setup(); again: DPRINT(("lstat64: filename=%s \n", filename)); if (!apt && detectdb_file) detect_package(filename, __FUNCTION__); __stat = load_library_symbol("__lxstat64"); if (__stat == NULL) { errno = ENOENT; return -1; } DPRINT(("lstat64 = %p\n", __stat)); e = __stat(ver, filename, buf); DPRINT(("lstat64: filename=%s e=%d\n", filename, e)); if (apt_hook[APT_HOOK_STAT] && e < 0) { switch (errno) { case ENOENT: if (*filename == '/') { if (!apt && apt_get_install_for_file(filename)) { apt = 1; goto again; } } break; default: break; } } return e; } auto-apt-0.3.23ubuntu0.14.04.1/481658.mbox0000664000000000000000000000720411346203333014017 0ustar From unknown Thu Mar 11 15:06:03 2010 X-Loop: owner@bugs.debian.org Subject: Bug#481658: auto-apt: uses conflicting wget options: cannot specify -N if -O is given Reply-To: Krzysztof Burghardt , 481658@bugs.debian.org Resent-From: Krzysztof Burghardt Resent-To: debian-bugs-dist@lists.debian.org Resent-CC: krzysztof@burghardt.pl, Fumitoshi UKAI Resent-Date: Sat, 17 May 2008 18:57:01 +0000 Resent-Message-ID: Resent-Sender: owner@bugs.debian.org X-Debian-PR-Message: report 481658 X-Debian-PR-Package: auto-apt X-Debian-PR-Keywords: patch X-Debian-PR-Source: auto-apt Received: via spool by submit@bugs.debian.org id=B.121105058726742 (code B ref -1); Sat, 17 May 2008 18:57:01 +0000 Received: (at submit) by bugs.debian.org; 17 May 2008 18:56:27 +0000 X-Spam-Checker-Version: SpamAssassin 3.1.4-bugs.debian.org_2005_01_02 (2006-07-26) on rietz.debian.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=4.0 tests=BAYES_00,FORGED_RCVD_HELO, FOURLA,HAS_PACKAGE,MURPHY_DRUGS_REL8,X_DEBBUGS_CC autolearn=no version=3.1.4-bugs.debian.org_2005_01_02 Received: from chello089077162166.chello.pl ([89.77.162.166] helo=techie.lan.burghardt.pl) by rietz.debian.org with esmtp (Exim 4.63) (envelope-from ) id 1JxRZz-0006wx-3g for submit@bugs.debian.org; Sat, 17 May 2008 18:56:27 +0000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Krzysztof Burghardt To: Debian Bug Tracking System Message-ID: <20080517185621.19642.97650.reportbug@techie.lan.burghardt.pl> X-Mailer: reportbug 3.39-0.1 Date: Sat, 17 May 2008 20:56:21 +0200 Delivered-To: submit@bugs.debian.org Package: auto-apt Version: 0.3.21+nmu1 Severity: important Tags: patch I'm using wget version 1.11.2-1. Auto-apt is unable to fetch Contents-*.gz files because it invoke wget with --timestamping option and -O. This two options seems to incomaptibile. Removing --timestamping from wget options seems to fix this. I'm not sure if it can causes any side effects. diff -Naur auto-apt-0.3.21+nmu1.orig/auto-apt.sh auto-apt-0.3.21+nmu1/auto-apt.sh --- auto-apt-0.3.21+nmu1.orig/auto-apt.sh 2006-07-23 00:13:13.000000000 +0000 +++ auto-apt-0.3.21+nmu1/auto-apt.sh 2008-05-17 18:48:58.879019682 +0000 @@ -164,7 +164,7 @@ fi fi # other options - wgetopt="--timestamping --continue --progress=bar:force" + wgetopt="--continue --progress=bar:force" if test "$method" = "ftp"; then passive_ftp="true" eval `apt-config shell passive_ftp Acquire::ftp::Passive` -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (900, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 2.6.25-2-amd64 (SMP w/1 CPU core) Locale: LANG=pl_PL.UTF-8, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages auto-apt depends on: ii libc6 2.7-11 GNU C Library: Shared libraries Versions of packages auto-apt recommends: ii apt 0.7.13 Advanced front-end for dpkg ii devscripts 2.10.27 scripts to make the life of a Debi ii dpkg-dev 1.14.19 package building tools for Debian ii perl 5.10.0-10 Larry Wall's Practical Extraction ii sudo 1.6.9p15-2 Provide limited super user privile ii wget 1.11.2-1 retrieves files from the web -- no debconf information auto-apt-0.3.23ubuntu0.14.04.1/auto-apt-installer.pl0000664000000000000000000002015407313665277016454 0ustar #!/usr/bin/perl -- # -*- perl -*- # # auto-apt backend installer # Copyright (c) 2000 Fumitoshi UKAI # GPL # # cmdname trigger command # filename trigger filename # package 1st selected package? (override by pkgcdb output) $rcsid = q$Id: auto-apt-installer.pl,v 1.10 2001/06/19 15:07:43 ukai Exp $; # $ENV{'AUTO_APT_ACCEPT'} # $ENV{'AUTO_APT_QUIET'} # $ENV{'AUTO_APT_ACCEPT'} # $ENV{'AUTO_APT_LOG'} # $ENV{'AUTO_APT_SIMULATE'} # $ENV{'AUTO_APT_NOBG'} # $ENV{'AUTO_APT_X'} @aptinstall = qw(sudo apt-get -y install); $PKGCDB = '/usr/lib/auto-apt/auto-apt-pkgcdb'; $ENV{'PATH'} = '/usr/sbin:/sbin:' . $ENV{'PATH'}; $gtk = 0; eval "use Gtk; use Gtk::Atoms;"; if ($@ eq "") { $gtk = 1; } elsif ($ENV{'AUTO_APT_INSTALL'} ne 'yes') { my ($gtkpm); # install Gtk.pm if (open(L, "$PKGCDB list|")) { while () { chomp; if (/Gtk.pm/) { s/\s+.*//; $gtkpm = $_; last; } } close(L); } if ($gtkpm) { # install now $ENV{'AUTO_APT_INSTALL'} = 'yes'; system($0, $0, $gtkpm, "libgtk-perl"); undef $ENV{'AUTO_APT_INSTALL'}; } eval "use Gtk; use Gtk::Atoms;"; if ($@ eq "") { $gtk = 1; } } sub conf_var { my ($s) = @_; return $ENV{$s}; } sub conf_switch { my ($s) = @_; my ($v) = $ENV{$s}; if ($v eq "no" || $v eq "off") { undef $v; } return $v; } sub check_accept { my ($p) = @_; my (@a) = split(',', &conf_var('AUTO_APT_ACCEPT')); foreach (@a) { return undef if (/none/); return $p if (/main/ && $p !~ m:^(non-US|contrib|non-free)/:); return $p if (/non-US/ && $p =~ m:^non-US/:); return $p if (/contrib/ && $p =~ m:^contrib/:); return $p if (/non-free/ && $p =~ m:^non-free/:); } return undef; } if ($#ARGV < 2) { print STDERR <; chomp; @package = split(/,/, $_); close(PACKAGE); } @package = grep {&check_accept($_)} @package; $package = $package[0]; if ($package eq "") { exit; } if (&conf_switch('AUTO_APT_X') && $gtk) { if ($#package > 0 || ! &conf_switch('AUTO_APT_YES')) { eval "&run_gtk"; if ($@ eq "") { $ENV{'AUTO_APT_YES'} = "yes"; } } } if ($package eq "") { exit; } if (&conf_switch('AUTO_APT_QUIET') || !-t STDOUT) { open(NULL, "+>/dev/null"); close(STDIN); open(STDIN, "<&NULL"); close(STDOUT); open(STDOUT, ">&NULL"); close(STDERR); open(STDERR, ">&NULL"); } else { select(STDOUT); system('tput', 'smcup'); $| = 1; if (! &conf_switch('AUTO_APT_YES')) { print "Install:@package\tfile:$filename\tby:$cmdname\n"; } if ($#package > 0) { print "File $filename may be provided by the following packages\n"; for ($n = 0; $n <= $#package; $n++) { print " $n) $package[$n]\n"; } $n = $#package; print "Which package do you want to install? [0-${n}n] "; while () { if (/n/i) { exit; } elsif ($_ >= 0 && $_ <= $n) { $n = $_; last; } print "Which package do you want to install? [0-${n}n] "; } $package = $package[$n]; } else { if (! &conf_switch('AUTO_APT_YES')) { $yes = 0; print "Do you want to install $package now? [Y/n] "; while () { chomp; exit if (/n/i); if (/y/i || /^\s*$/ || (length($_) == 0)) { $yes = 1; last; } print "\nDo you want to install $package now? [Y/n] "; } } } system('tput', 'rmcup'); } $package =~ s:.*/::; if (&conf_switch('AUTO_APT_X') && ! -x '/usr/bin/x-terminal-emulator' && $ENV{'AUTO_APT_INSTALL'} ne 'yes') { # xterm provides x-terminal-emulator, so install it $ENV{'AUTO_APT_INSTALL'} = 'yes'; system($0, $0, '/usr/X11R6/bin/xterm', 'x11/xterm'); undef $ENV{'AUTO_APT_INSTALL'}; } if (&conf_switch('AUTO_APT_X') && -x "/usr/bin/x-terminal-emulator") { exec {'/usr/bin/x-terminal-emulator'} "x-terminal-emulator", "-title", "auto-apt Install:$package file:$filename by:$cmdname", "-geometry", "+20+30", "-e", "sh", "-c", qq#@aptinstall $package || (echo -n 'Failed [Z - exec shell to fix this situation]'; read yn; case \$yn in Z) echo "Type 'exit' when you're done"; \${SHELL:-/bin/sh};; esac)#; } else { system('tput', 'smcup'); system {'/usr/bin/sudo'} @aptinstall, $package; if ($? != 0) { print "Failed [Z - exec shell to fix this situation]"; my ($yn) = ; if ($yn =~ /Z/) { print "Type 'exit' when you're done\n"; system ($ENV{'SHELL'} || '/bin/sh'); } } system('tput', 'rmcup'); } %pbutton = (); %pinfo = (); sub package_selected { my ($widget, $p) = @_; if ($pbutton{$p}->active) { $package = $p; @package = ($package); foreach (keys %pbutton) { if ($_ ne $p && $pbutton{$_}->active) { $pbutton{$_}->set_active(0); } } } } sub package_info { my ($widget, $p) = @_; my ($window) = new Gtk::Window('toplevel'); $window->set_title("auto-apt: $p"); $window->set_name("info: $p"); $window->signal_connect("destroy", sub { $window->hide(); }); $window->signal_connect("delete_event", sub { $window->hide(); }); $window->set_usize(320, 300); realize $window; my ($text) = new Gtk::Text(undef, undef); $text->show(); $window->add($text); $text->freeze(); $text->realize(); $p =~ s:.*/::; foreach (split(/\n/, $pinfo{$p})) { $text->insert(undef,$text->style->black,undef, "$_\n"); } $text->thaw(); $window->show(); } sub package_description { my ($p) = @_; my ($d); $p =~ s:.*/::; if (open(A, "apt-cache show $p|")) { while () { $pinfo{$p} .= $_; if (s/^Description:\s+//) { $d = $_; } } close(A); } return $d; } sub run_gtk { Gtk->init_check() || die "Gtk init error"; set_locale Gtk; init Gtk; my ($window) = new Gtk::Window('toplevel'); $window->set_title("auto-apt: Debian automatic installation tool"); $window->set_name("main window"); $window->set_uposition(20,20); # $window->set_usize(500,500); $window->signal_connect("destroy" => \&Gtk::main_quit); $window->signal_connect("delete_event" => \&Gtk::false); realize $window; my ($tooltips) = new Gtk::Tooltips; $window->{tooltips} = $tooltips; my ($vbox) = new Gtk::VBox(0,0); $window->add($vbox); $vbox->show(); my ($proglabel) = new Gtk::Label("Program: $cmdname"); $proglabel->set_alignment(0, 0.5); $proglabel->show(); $vbox->pack_start($proglabel, 0, 0, 0); my ($filelabel) = new Gtk::Label("requires file: $filename"); $filelabel->set_alignment(0, 0.5); $filelabel->show(); $vbox->pack_start($filelabel, 0, 0, 0); my ($infolabel) = new Gtk::Label("This file is provided by:"); $infolabel->set_alignment(0, 0.5); $infolabel->show(); $vbox->pack_start($infolabel, 0, 0, 0); my ($hsep0) = new Gtk::HSeparator; $hsep0->show(); $vbox->pack_start($hsep0, 0, 0, 0); my ($p); foreach $p (@package) { my ($pbox) = new Gtk::HBox(0,1); $vbox->pack_start($pbox, 0, 0, 5); $pbox->show(); $pbutton{$p} = new Gtk::CheckButton($p); $pbutton{$p}->signal_connect("clicked", \&package_selected, $p); $pbox->pack_start($pbutton{$p}, 0, 0, 5); $tooltips->set_tip($pbutton{$p}, &package_description($p), "Package/$p"); $pbutton{$p}->show(); $pibutton{$p} = new Gtk::Button("info"); $pibutton{$p}->signal_connect("clicked", \&package_info, $p); $pbox->pack_end($pibutton{$p}, 0, 0, 5); $pibutton{$p}->show(); } my ($buttbox) = new Gtk::HBox(0,1); $vbox->pack_start($buttbox, 0, 0, 5); $buttbox->show(); my ($hsep1) = new Gtk::HSeparator; $hsep1->show(); $vbox->pack_start($hsep1, 0, 0, 0); my (@butts) = (new Gtk::Button("Install"), new Gtk::Button("Cancel")); foreach (@butts) { $buttbox->pack_start($_, 0, 0, 5); $_->show(); } $butts[0]->signal_connect("clicked", \&Gtk::main_quit); $butts[1]->signal_connect("clicked", sub { undef $package; &Gtk::main_quit} ); $window->show(); $package = $package[0]; $pbutton{$package}->set_active(1); Gtk->gc; Gtk->main; } auto-apt-0.3.23ubuntu0.14.04.1/debian/0000775000000000000000000000000012343627122013574 5ustar auto-apt-0.3.23ubuntu0.14.04.1/debian/copyright0000664000000000000000000000070307643612153015534 0ustar This package was debianized by Fumitoshi UKAI on Tue, 27 Jun 2000 15:20:46 +0900. Upstream Author: Fumitoshi UKAI http://alioth.debian.org/projects/auto-apt Copyright (c) 2000 Fumitoshi UKAI This is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. See also /usr/share/common-licenses/GPL auto-apt-0.3.23ubuntu0.14.04.1/debian/rules0000775000000000000000000000003512144402214014642 0ustar #!/usr/bin/make -f %: dh $@ auto-apt-0.3.23ubuntu0.14.04.1/debian/manpages0000664000000000000000000000004712144412562015312 0ustar auto-apt.1 auto-apt.fr.1 auto-apt.es.1 auto-apt-0.3.23ubuntu0.14.04.1/debian/source/0000775000000000000000000000000011367436526015107 5ustar auto-apt-0.3.23ubuntu0.14.04.1/debian/source/format0000664000000000000000000000001511367436526016316 0ustar 3.0 (native) auto-apt-0.3.23ubuntu0.14.04.1/debian/substvars0000664000000000000000000000006410460540336015552 0ustar perl:Depends=perl shlibs:Depends=libc6 (>= 2.3.6-6) auto-apt-0.3.23ubuntu0.14.04.1/debian/docs0000664000000000000000000000002107126610027014437 0ustar README BUGS TODO auto-apt-0.3.23ubuntu0.14.04.1/debian/README.source0000664000000000000000000000030311346205641015747 0ustar Sources for Debian ------------------ This package uses quilt. See more information at /usr/share/doc/quilt/README.source -- Jari Aalto , Thu, 11 Mar 2010 17:26:25 +0200 auto-apt-0.3.23ubuntu0.14.04.1/debian/dirs0000664000000000000000000000007507132644550014466 0ustar lib etc/auto-apt usr/bin usr/lib/auto-apt var/cache/auto-apt auto-apt-0.3.23ubuntu0.14.04.1/debian/changelog0000664000000000000000000003500012343627122015444 0ustar auto-apt (0.3.23ubuntu0.14.04.1) trusty; urgency=medium * No change rebuild from Debian auto-apt 0.3.24, which fixes only these bugs: - Patches supplied by Bruno Nova, with thanks. - Plug a memory leak caused by not freeing lines read from stdin. (LP: #1300987) - Use dpkg --print-architecture instead of deprecated dpkg --print-installation-architecture (the latter causes a warning). (LP: #1300991) - Accept no leading spaces at the start of a line in sources.list. (LP: #1300991) -- Robie Basak Tue, 03 Jun 2014 13:32:35 +0000 auto-apt (0.3.23) unstable; urgency=low * QA upload. * Replace PATH_MAX to build on GNU/Hurd. (Closes: #659025). - Thanks to Tanguy Le Carrour for the patch. * Allow spaces in sources.list. (Closes: #667052). - Thanks to Mateusz Poszwa for the patch. * Change debian/rules to utilize dh 7. * Add debian/manpages file. * Bump Standards Version to 3.9.4. -- Barry deFreese Mon, 13 May 2013 18:31:46 -0400 auto-apt (0.3.22) unstable; urgency=low * QA upload. - ACK NMU. - Move to packaging format "3.0 (native)". * debian/compat - Update to 7. * debian/control - (Maintainer): Set to Debian QA Group. Package orphaned in Bug#541016. - (Build-Depends): update to debhelper 7.1. Add quilt. - (Depends): add ${misc:Depends}. - (Standards-Version): update to 3.8.4 * debian/patches - (Number 10): Fix FTBFS(hurd-i386): PATH_MAX undeclared (Closes: #257087). - (Number 20): Fix conflicting wget(1) options (Closes: #481658). Patch thanks to Krzysztof Burghardt * debian/README.source - New file. * debian/rules - Install quilt. - (install): use dh_prep. Adjust Makefile call. * debian/source/format - New file. -- Jari Aalto Thu, 01 Apr 2010 07:25:46 +0300 auto-apt (0.3.21+nmu1) unstable; urgency=low * Non-maintainer upload. * Move devscripts from Build-Depends to Recommends. It's not used in the build process but in the program itself. (Closes: #475259) -- Thijs Kinkhorst Sat, 03 May 2008 18:04:57 +0200 auto-apt (0.3.21) unstable; urgency=low * debian/postrm; remove cache file when purged. closes: Bug#275579 * auto-apt.sh: remove XSI:ism closes: Bug#259289, Bug#375931 * auto-apt.1: fix typos closes: Bug#307025, Bug#275278 * apply patch to auto-apt.es.1 closes: Bug#257829 * add auto-apt.fr.1 closes: Bug#277535 * debian/control: fix typo in description closes: Bug#243994 * debian/{compat,rules}: debhelper compat level to 4 -- Fumitoshi UKAI Sun, 23 Jul 2006 09:20:01 +0900 auto-apt (0.3.20) unstable; urgency=low * auto-apt.sh: add install command * paths.list: add /usr/lib/pkgconfig/ * auto-apt.es.1: added. spanish manpage closes: Bug#206202 * auto-apt.sh: see /etc/auto-apt/sources.list instead /etc/apt/sources.list. if not found, this file is symlinked to /etc/apt/sources.list. if you want to have different sources.list for auto-apt than apt-get, you can create /etc/auto-apt/sources.list. closes: Bug#202979 -- Fumitoshi UKAI Sat, 20 Mar 2004 02:50:29 +0900 auto-apt (0.3.19) unstable; urgency=low * fix FTBFS with gcc-3.3. closes: Bug#195085 - auto-apt-pkg.c (usage): don't use multiline string literals - auto-apt-pkg.c: include for time() - pkgcdb/mempool.c (mempool_restore): fix warnings: concatenation of string literals with __FUNCTION__ is deprecated -- Fumitoshi UKAI Mon, 2 Jun 2003 01:28:46 +0900 auto-apt (0.3.18) unstable; urgency=low * use --timestamping --continue option for wget closes: Bug#187658 -- Fumitoshi UKAI Sun, 6 Apr 2003 02:29:39 +0900 auto-apt (0.3.17) unstable; urgency=low * show progress bar while downloading Contents.gz by wget closes: Bug#146178, Bug#162068 -- Fumitoshi UKAI Thu, 26 Sep 2002 01:40:38 +0900 auto-apt (0.3.16) unstable; urgency=low * fix RE bug reading sources.list, closes: Bug#160662 * fix obscur message for a search command when db is not initialised closes: Bug#146177 -- Fumitoshi UKAI Wed, 25 Sep 2002 00:28:08 +0900 auto-apt (0.3.15) unstable; urgency=low * The "Sympathy For The Devil" release * add support rsh|ssh method, closes: Bug#94105 * fix typo in examples/auto-apt-get-menu.sh, closes: Bug#127536 -- Fumitoshi UKAI Sun, 6 Jan 2002 03:41:37 +0900 auto-apt (0.3.14) unstable; urgency=low * remove apt, sudo and perl dependency from Depends: move these to Recommends:. This is because these are only required when user uses auto-apt as automatic installation tool. For users who want to search package by file, these packages are not requires. See also Bug#125386: ITP: apt-file -- Fumitoshi UKAI Thu, 20 Dec 2001 01:51:37 +0900 auto-apt (0.3.13) unstable; urgency=low * use $(CC) instead of $(LD) closes: Bug#105593 -- Fumitoshi UKAI Wed, 18 Jul 2001 00:13:07 +0900 auto-apt (0.3.12) unstable; urgency=low * The "Ballad of Fallen Angels" release * fix requirepkg() that auto-apt debuild want to apt-get 'build-essential' even if installed closes: Bug#101120 * update paths.list -- Fumitoshi UKAI Tue, 19 Jun 2001 23:19:24 +0900 auto-apt (0.3.11) unstable; urgency=low * The "Gateway Shuffle" release * adapt apt-config change in apt 0.5 fix apt sources.list:etc/apt//SOURCES_LIST not found (thanks ) -- Fumitoshi UKAI Tue, 27 Feb 2001 20:27:52 +0900 auto-apt (0.3.10) unstable; urgency=low * The "Honky Tonk Women" release * fix perl dependency, closes: Bug#80689 -- Fumitoshi UKAI Thu, 25 Jan 2001 13:00:34 +0900 auto-apt (0.3.9) unstable; urgency=low * The "Stray Dog Strut" release * apt is using ftp passive mode by default so auto-apt do the same. closes: Bug#78245 (thanks Gerfried Fuchs ) * install build-essential if necessary -- Fumitoshi UKAI Wed, 6 Dec 2000 00:35:44 +0900 auto-apt (0.3.8) unstable; urgency=low * The "Asteroid Blues" release * check libc.so path, closes: Bug#78685 * check apt.conf and add --passive-ftp if necessary, closes: Bug#78254 * set proxy configuration using apt.conf -- Fumitoshi UKAI Mon, 4 Dec 2000 23:18:22 +0900 auto-apt (0.3.7) unstable; urgency=low * give a chance of shell when apt-get install failed in auto-apt-installer -- Fumitoshi UKAI Mon, 20 Nov 2000 23:51:05 +0900 auto-apt (0.3.6) unstable; urgency=low * fix auto-apt search -f * remove bashism from /usr/bin/auto-apt, closes: Bug#77074 -- Fumitoshi UKAI Fri, 17 Nov 2000 02:03:40 +0900 auto-apt (0.3.5) unstable; urgency=low * Add -f option to auto-apt check, list, search to search Contents-*.gz itself instead of auto-apt's package db -- Fumitoshi UKAI Fri, 3 Nov 2000 04:21:00 +0900 auto-apt (0.3.4) unstable; urgency=low * segfault againt invalid Contents data. fix this by checking valid chars for package name/filename -- Fumitoshi UKAI Mon, 23 Oct 2000 16:51:23 +0900 auto-apt (0.3.3) unstable; urgency=low * fix bus error on sparc * "auto-apt debuild": surpress garbage output -- Fumitoshi UKAI Thu, 19 Oct 2000 19:13:04 +0900 auto-apt (0.3.2) unstable; urgency=low * remove bashism from /usr/bin/auto-apt, closes: Bug#69491 -- Fumitoshi UKAI Mon, 28 Aug 2000 22:52:15 +0900 auto-apt (0.3.1) unstable; urgency=low * don't print "auto-apt pkgcontents.bin load failed, auto-apt off" because it cause some trouble if no pkgcontents.bin * add examples/auto-apt-get-menu.sh -- Fumitoshi UKAI Fri, 21 Jul 2000 02:05:47 +0900 auto-apt (0.3) unstable; urgency=low * Initial Release to Debian - new contents database, speedup to create db - separate installer backend with X support -- Fumitoshi UKAI Mon, 17 Jul 2000 00:27:13 +0900 auto-apt (0.2.99.8) unstable; urgency=low * (auto-apt-installer.pl) fix libgtk-perl installation * (auto-apt-installer.pl) use tput smcup,rmcup * (auto-apt.c) fix no auto-installation with -L option * (auto-apt.sh) fix regex for sources.list * (debian/control) add perl dependency -- Fumitoshi UKAI Fri, 14 Jul 2000 17:39:19 +0900 auto-apt (0.2.99.7.1) unstable; urgency=low * [fix critical bug] check auto-apt-installer loop -- Fumitoshi UKAI Fri, 14 Jul 2000 01:51:57 +0900 auto-apt (0.2.99.7) unstable; urgency=low * X interface enabled by default * automatic install: libgtk-perl and xterm -- Fumitoshi UKAI Fri, 14 Jul 2000 01:28:35 +0900 auto-apt (0.2.99.6) unstable; urgency=low * select package in auto-apt-installer * add support Gtk package selection -- Fumitoshi UKAI Thu, 13 Jul 2000 22:12:54 +0900 auto-apt (0.2.99.5) unstable; urgency=low * [add] auto-apt-installer apt-get install helper program -- Fumitoshi UKAI Thu, 13 Jul 2000 18:34:51 +0900 auto-apt (0.2.99.4) unstable; urgency=low * use -X instead of -x (like ssh) * more verbose auto-apt status -- Fumitoshi UKAI Thu, 13 Jul 2000 13:44:57 +0900 auto-apt (0.2.99.3) unstable; urgency=low * Support X window system. change -x option old -x hooks => -p hooks -- Fumitoshi UKAI Thu, 13 Jul 2000 11:36:54 +0900 auto-apt (0.2.99.2) unstable; urgency=low * don't link with libdb. * documentation cleanup. -- Fumitoshi UKAI Wed, 12 Jul 2000 12:46:07 +0900 auto-apt (0.2.99.1) unstable; urgency=low * /etc/auto-apt/paths.list as conffiles -- Fumitoshi UKAI Wed, 12 Jul 2000 10:52:43 +0900 auto-apt (0.2.99.0) experimental; urgency=low * new package contents database support -- Fumitoshi UKAI Tue, 11 Jul 2000 01:57:46 +0900 auto-apt (0.2.12) unstable; urgency=low * add "requirepkg /usr/bin/debuild devscripts" for auto-apt debuild -- Fumitoshi UKAI Mon, 10 Jul 2000 23:05:57 +0900 auto-apt (0.2.11) unstable; urgency=low * use "dpkg --print-installation-architecture", instead of dpkg-architecture, because dpkg-architecture depends on gcc * check dpkg lock to fix issues dpkg and re-entrancy, reported by Joey Hess * change message "Exit the command to leave auto-apt mode." as Joey Hess suggested. * change description as Peter S Galbraith suggested. -- Fumitoshi UKAI Sun, 9 Jul 2000 02:56:14 +0900 auto-apt (0.2.10) unstable; urgency=low * [fix] typo in auto-apt update * [fix] typo in usage * add new feature: (pkgcdb) -a - no aggregation -- Fumitoshi UKAI Fri, 7 Jul 2000 01:00:40 +0900 auto-apt (0.2.9) unstable; urgency=low * [fix] command check in "auto-apt run" * [fix] use getopts, instead of getopt(1) no more need "--" to separate auto-apt arg and command arg * [fix] can't handle filename containing space chars. by Shuzo Hatta's advices. * modify "auto-apt debuild" follow option rules -- Fumitoshi UKAI Tue, 4 Jul 2000 23:59:44 +0900 auto-apt (0.2.8) unstable; urgency=low * unified option parsing in /usr/bin/auto-apt. major change: -C => -D -- Fumitoshi UKAI Tue, 4 Jul 2000 12:06:54 +0900 auto-apt (0.2.7) unstable; urgency=low * [fix] auto_apt_setup() - eg. coudn't catch execv() in /usr/bin/man * usage: pkgcdb del -- Fumitoshi UKAI Tue, 4 Jul 2000 00:52:28 +0900 auto-apt (0.2.6) unstable; urgency=low * add new features - auto-apt -x [hook] (AUTO_APT_HOOK) * save extra data in detect database -- Fumitoshi UKAI Sun, 2 Jul 2000 22:12:18 +0900 auto-apt (0.2.5) unstable; urgency=low * add new features - auto-apt debuild (from example gen-build-depends) -- Fumitoshi UKAI Sun, 2 Jul 2000 00:36:56 +0900 auto-apt (0.2.4) unstable; urgency=low * [important fix/auto-apt] - support execl(3),execle(3),execlp(3),execvp(3),execv(3) * fix examples * [fix] auto-apt run -q option -- Fumitoshi UKAI Sat, 1 Jul 2000 10:46:27 +0900 auto-apt (0.2.3) unstable; urgency=low * "pkgcdb put" handle -/+ prefix * add new features - AUTO_APT_FILEDB= it is used for detect package list accessed. * auto-apt update-local * [fix] don't register essential directory (eg. /usr/include) for some package dir -- Fumitoshi UKAI Fri, 30 Jun 2000 18:30:09 +0900 auto-apt (0.2.2) unstable; urgency=low * add new features - AUTO_APT_DB= select file db other than /var/cache/auto-apt/pkgcontent.db * create simple auto-apt.1 * [fix] #! magic fixed -- Fumitoshi UKAI Fri, 30 Jun 2000 12:03:39 +0900 auto-apt (0.2.1) unstable; urgency=low * add new features pkgcdb del package * add new features - AUTO_APT_YES=? auto-apt run -y * add new features pkgcdb list * add new features - AUTO_APT_DETECT= file access detect db * [pkgcdb] add "usr/etc/" to fname_dist * check URL method in auto-apt update * auto install package required in auto-apt update * add new features - AUTO_APT_LOG= print out logfile - AUTO_APT_ACCEPT={main,contrib,non-free,non-US} select acceptable dist - AUTO_APT_SIMULATE=? simulate? * performace tune for pkgcdb * [fix] minor bug to expand filename * [fix] not to put verbose entries in pkgcontents.db * import to CVS -- Fumitoshi UKAI Thu, 29 Jun 2000 18:03:38 +0900 auto-apt (0.2) unstable; urgency=low * new package contents database: pkgcdb * new frontend auto-apt.sh -- Fumitoshi UKAI Thu, 29 Jun 2000 01:39:33 +0900 auto-apt (0.1) unstable; urgency=low * set /sbin and /usr/sbin to PATH for "sudo apt-get" * if stdout isn't tty, redirect: apt-get install < /dev/null > /dev/null * change: auto-apt-makedb, auto-apt-fetchdb -- Fumitoshi UKAI Tue, 27 Jun 2000 18:24:27 +0900 auto-apt (0.0-1) unstable; urgency=low * Initial Release. -- Fumitoshi UKAI Tue, 27 Jun 2000 15:20:46 +0900 auto-apt-0.3.23ubuntu0.14.04.1/debian/postrm0000664000000000000000000000171610460536631015052 0ustar #!/bin/sh # postrm script for auto-apt # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `remove' # * `purge' # * `upgrade' # * `failed-upgrade' # * `abort-install' # * `abort-install' # * `abort-upgrade' # * `disappear' overwrit>r> # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in purge) rm -rf /var/cache/auto-apt ;; remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) ;; *) echo "postrm called with unknown argument \`$1'" >&2 exit 1 esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0 auto-apt-0.3.23ubuntu0.14.04.1/debian/control0000664000000000000000000000146212144271740015202 0ustar Source: auto-apt Section: admin Priority: optional Maintainer: Debian QA Group Standards-Version: 3.9.4 Build-Depends: binutils, cpio, debhelper (>= 7.1), quilt Package: auto-apt Architecture: any Depends: ${misc:Depends}, ${shlibs:Depends} Recommends: ${perl:Depends}, apt, sudo, wget, dpkg-dev, devscripts Suggests: x-terminal-emulator, libgtk-perl, build-essential Description: package search by file and on-demand package installation tool auto-apt checks the file access of programs running within its environments, and if a program tries to access a file known to belong in an uninstalled package, auto-apt will install that package using apt-get. This feature requires apt and sudo to work. . It also provides simple database to search which package contains a requested file. auto-apt-0.3.23ubuntu0.14.04.1/debian/patches/0000775000000000000000000000000011346203644015224 5ustar auto-apt-0.3.23ubuntu0.14.04.1/debian/patches/20-wget-options.patch0000664000000000000000000000161011346203637021123 0ustar From 31c17f29ad02f16675665a47e97f9f83ff9759c3 Mon Sep 17 00:00:00 2001 From: Jari Aalto Date: Thu, 11 Mar 2010 17:09:15 +0200 Subject: [PATCH] auto-apt.sh: (update): remove --timestamping from wgetopt (Patch by Krzysztof Burghardt ) Signed-off-by: Jari Aalto --- auto-apt.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) mode change 100644 => 100755 auto-apt.sh diff --git a/auto-apt.sh b/auto-apt.sh old mode 100644 new mode 100755 index 65b3efc..82d967c --- a/auto-apt.sh +++ b/auto-apt.sh @@ -164,7 +164,7 @@ update() { fi fi # other options - wgetopt="--timestamping --continue --progress=bar:force" + wgetopt="--continue --progress=bar:force" if test "$method" = "ftp"; then passive_ftp="true" eval `apt-config shell passive_ftp Acquire::ftp::Passive` -- 1.7.0 auto-apt-0.3.23ubuntu0.14.04.1/debian/patches/10-hurd-path-max.patch0000664000000000000000000000247111346202767021153 0ustar From 2ac160827d17f210dcc0d03470047ea6260c510f Mon Sep 17 00:00:00 2001 From: Jari Aalto Date: Thu, 11 Mar 2010 17:01:58 +0200 Subject: [PATCH] Fix FTBFS(hurd-i386): PATH_MAX undeclared Signed-off-by: Jari Aalto --- auto-apt.c | 5 +++++ pkgcdb/pkgcdb2.c | 6 ++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/auto-apt.c b/auto-apt.c index 1895440..5b1ddfe 100644 --- a/auto-apt.c +++ b/auto-apt.c @@ -23,8 +23,13 @@ static char auto_apt_rcsid[] __attribute__ ((unused)) = "$Id: auto-apt.c,v 1.28 #include #include #include + #include +#ifndef PATH_MAX +#define PATH_MAX 10000 /* Hurd does not define PATH_MAX in limits.h */ +#endif + #define PKGCDB_AUTOAPT 1 #include "pkgcdb/debug.h" #include "pkgcdb/pkgcdb2.h" diff --git a/pkgcdb/pkgcdb2.c b/pkgcdb/pkgcdb2.c index 9c3915d..5209caf 100644 --- a/pkgcdb/pkgcdb2.c +++ b/pkgcdb/pkgcdb2.c @@ -19,7 +19,13 @@ static char pkgcdb2_rcsid[] __attribute__((unused)) = "$Id: pkgcdb2.c,v 1.4 2000 #include #include #include + #include + +#ifndef PATH_MAX +#define PATH_MAX 50000 /* Hurd does not define PATH_MAX in limits.h */ +#endif + #include #include #include -- 1.7.0 auto-apt-0.3.23ubuntu0.14.04.1/debian/patches/series0000664000000000000000000000005511346203644016441 0ustar 10-hurd-path-max.patch 20-wget-options.patch auto-apt-0.3.23ubuntu0.14.04.1/debian/compat0000664000000000000000000000000211346203730014767 0ustar 7 auto-apt-0.3.23ubuntu0.14.04.1/debian/examples0000664000000000000000000000003607135631010015326 0ustar examples/auto-apt-get-menu.sh auto-apt-0.3.23ubuntu0.14.04.1/BUGS0000664000000000000000000000303007313665277013047 0ustar $Id: BUGS,v 1.17 2001/06/19 15:07:43 ukai Exp $ Bugs, but I'd like to say it's a feature:) if you put the directory in PATH, which doesn't exists and is provided by some uninstalled package, then the package will be installed unintentionally if non exists program is called. So, don't put non-exist dir in your PATH suid root process can't be traced by auto-apt. (because of LD_PRELOAD security problems) files created by maintainer scripts, that is, files not listed in Contents-i386.gz, may be considered as in different package. (for examples, files under /usr/share/emacs20/site-lisp/) aggregated file are not hit by search (because it weren't recorded in db) shell usually has own hash table, so usually uninstalled command will be "command not found" instead auto apt-get? (zsh try to correct cmd name?) can't trace libc internal calls? Bugs to be fixed: Bug#94105: support ssh method if package which has interactive maintainer script are installed with no tty, it probably won't work. => Workaround, if it runs in X environment, apt-get run in x-terminal-emulator otherwise, if no tty, auto-apt will invoke like: apt-get install pkg /dev/null 2>&1 detect wrong packages in (in auto-apt debuild) usr/lib/perl5/5.6/* usr/lib/perl5/File/* usr/lib/perl5/IO/* usr/share/perl5/File/* usr/share/perl5/IO/* usr/share/locale/* (in LANG=ja_JP.eucJP) missing complete manual page auto-apt debuild with fakeroot can't create file with owner root? auto-apt-0.3.23ubuntu0.14.04.1/auto-apt-pkgcdb.c0000664000000000000000000002120312330411273015470 0ustar /*- * auto-apt-db.c * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ #include "pkgcdb/debug.h" #include "pkgcdb/mempool.h" #include "pkgcdb/pkgtab.h" #include "pkgcdb/strtab.h" #include "pkgcdb/pathnode.h" #include "pkgcdb/pkgcdb2.h" #include #include #include #include #include #include #include #include static int profile = 0; static char *prog; static void delete_pathnode_entry(PathNodeTree pnt, char *path, struct path_node *pn, void *arg) { struct path_node *npn; for (npn = pn; npn != NULL; npn = pathnode_next(pnt, npn)) { pkg_id pid = pathnode_package(pnt, npn); if (pkg_cmp(&pid, (pkg_id *)arg) == 0) { MSG(("%s%s\t%s\n", path, pathnode_pathname(pnt, pn), pathnode_packagename(pnt, npn))); pathnode_delete(pnt, npn); } } } static void print_pathnode_entry(PathNodeTree pnt, char *path, struct path_node *pn, void *arg) { struct path_node *npn; printf("%s%s\t", path, pathnode_pathname(pnt, pn)); for (npn = pn; npn != NULL; npn = pathnode_next(pnt, npn)) { if (npn != pn) { printf(","); } printf("%s", pathnode_packagename(pnt, npn)); } printf("\n"); } static void usage() { fprintf(stderr, "usage: %s [option] [command ...]\n" "command:\n" " put\n" " get filename\n" " list\n" " del package\n" "option:\n" " -v verbose\n" " -q quiet\n" " -p profile\n" " -d debug\n" " -f dbfile\n" " -P paths.list\n" , prog); exit(0); } static int timer_start(struct timeval *tvp) { struct timezone tz; return gettimeofday(tvp, &tz); } static double timer_stop(struct timeval *tvp) { struct timeval tv1; struct timezone tz; double t; gettimeofday(&tv1, &tz); if (tvp->tv_usec > tv1.tv_usec) { tv1.tv_sec--; tv1.tv_usec += 1000000; } tv1.tv_sec -= tvp->tv_sec; tv1.tv_usec -= tvp->tv_usec; return t = tv1.tv_sec + (double)tv1.tv_usec/1000000.0; } static int validchartab[256] = { /* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */ 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /* 0x30 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, /* 0x40 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, /* 0x60 */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, /* 0x80-*/ 0, }; static int is_validchar(int c) { return validchartab[(c & 0x0FF)]; } static unsigned char * get_line(FILE *f) { unsigned char *buf = NULL; char *new_buf = NULL; size_t buf_size = 0; size_t last = 0; while (!feof(f)) { buf_size = buf_size ? buf_size * 2 : BUFSIZ; new_buf = realloc(buf, buf_size); if (new_buf == NULL) { free(buf); return NULL; } buf = new_buf; if (fgets(buf + last, buf_size - last, f) == NULL) { free(buf); return NULL; } last = strlen(buf); if (buf[last - 1] == '\n') return buf; } return buf; } int main(int argc, char **argv) { unsigned char *buf = NULL; char *cmd; char *dbfile = PKGCDB_FILE; char *pathlist = PKGCDB_PATH_LIST; int ret = 0; extern char *optarg; extern int optind, opterr, optopt; int c; char *p; PathNodeTree pnt; struct timeval tv; prog = argv[0]; p = getenv("AUTO_APT_DB"); if (p != NULL && *p == '/') { dbfile = strdup(p); } while ((c = getopt(argc, argv, "dvpqf:P:")) != EOF) { switch (c) { case 'v': verbose++; break; case 'p': profile++; break; case 'q': quiet++; break; case 'd': debug++; break; case 'f': dbfile = strdup(optarg); break; case 'P': pathlist = strdup(optarg); break; default: usage(); } } if (argc < optind + 1) { usage(); } cmd = argv[optind]; mempool_init(); pkgtab_init(); if (strcmp(cmd, "put") == 0) { int n = 0, nent = 0; int op = '+'; time_t t0, t1, t; double tt, ta, min_t, max_t; char *max_file; t1 = t0 = t = time(NULL); t0--; if (profile) timer_start(&tv); pnt = pkgcdb_load(dbfile, 0, 0); if (pnt == NULL) { pnt = pkgcdb_alloc(); if (pnt == NULL) { PERROR(("pkgcdb_init")); exit(1); } } if (profile) MSG(("db load: %f sec\n", timer_stop(&tv))); if (profile) timer_start(&tv); pkgcdb_path_list_init(pnt, pathlist); pathnode_ignore_package(pnt, DEFAULT_PATH_PACKAGE); if (profile) MSG(("path init: %f sec\n", timer_stop(&tv))); ta = 0.0; min_t = 9999.9; max_t = 0.0; max_file = NULL; while (!feof(stdin)) { unsigned char *fname, *pkg; unsigned char *p; int nslash = 0; buf = get_line(stdin); if (buf == NULL) break; if (profile) timer_start(&tv); if (buf[strlen(buf)-1] == '\n') { buf[strlen(buf)-1] = '\0'; } DPRINT((">%s<\n", buf)); fname = buf; switch (fname[0]) { case ' ': goto next_line; break; case '-': op = fname[0]; fname++; break; case '+': op = fname[0]; fname++; break; default: op = '+'; break; } if (strncmp(fname, "./", 2) == 0) { fname += 2; } /* search space from backward */ for (pkg = fname + strlen(fname)-1; !isspace(*pkg) && pkg > fname; --pkg) { if (*pkg == '/') { nslash++; if (nslash >= 3) { VMSG(("too many /: %s\n", buf)); goto next_line; } } else if (*pkg == ',') { nslash = 0; } else if (!is_validchar(*pkg)) { VMSG(("invalid line: %s\n", buf)); goto next_line; } } if (isspace(*pkg)) pkg += 1; /* search end of fname */ for (p = pkg - 1; isspace(*p) && p > fname; --p) *p = '\0'; for (p = fname; *p; ++p) { if (!is_validchar(*p)) { VMSG(("invalid fname: %s\n", buf)); goto next_line; } } DPRINT(("I: file=[%s] pkg=[%s]\n", fname, pkg)); t1 = time(NULL); switch (op) { case '+': pkgcdb_put(pnt, fname, pkg, &nent); n++; if (t1 > t0) { MSG(("put: %d files, %d entries\r", n, nent)); fflush(stdout); t0 = t1; } break; case '-': pkgcdb_del(pnt, fname, pkg, &nent); n++; if (t1 > t0) { MSG(("put: %d files, %d entries\r", n, nent)); fflush(stdout); t0 = t1; } break; } if (profile) { tt = timer_stop(&tv); ta += tt; if (tt < min_t) min_t = tt; if (tt > max_t) { max_t = tt; if (max_file) free(max_file); max_file = strdup(fname); } } next_line: free(buf); } if (profile) MSG(("total %f sec/%d = avg %f sec\n" " min = %f, max = %f<%s>\n", ta, n, ta/n, min_t, max_t, max_file)); if (profile) timer_start(&tv); pkgcdb_save(dbfile, pnt, 1); if (profile) MSG(("db save: %f sec\n", timer_stop(&tv))); t1 = time(NULL); MSG(("put: %d files, %d entries done (%ld sec)\n", n, nent, (long)(t1 - t))); } else if (strcmp(cmd, "get") == 0) { struct path_node *match; char *key, *mfile = NULL, *ext = NULL; if (argc < optind + 2) { usage(); } key = argv[optind+1]; if (profile) timer_start(&tv); pnt = pkgcdb_load(dbfile, 0, 0); if (pnt == NULL) { PERROR(("pkgcdb_load")); exit(1); } if (profile) MSG(("db load: %f sec\n", timer_stop(&tv))); if (profile) timer_start(&tv); match = pkgcdb_get(pnt, key, &mfile, &ext); if (profile) MSG(("db search: %f sec\n", timer_stop(&tv))); if (profile) timer_start(&tv); if (match) { struct path_node *pn; int found = 0; for (pn = match; pn != NULL; pn = pathnode_next(pnt, pn)) { if (pn != match) printf(","); printf("%s", pathnode_packagename(pnt, pn)); if (strlen(pathnode_packagename(pnt, pn)) > 0) { found = 1; } } if (found) printf("\n"); if (mfile) { VMSG(("%s\n", mfile)); } if (ext) { VMSG(("%s\n", ext)); free(ext); } if (found == 0) ret = 1; /* not found */ } else { ret = 1; /* not found */ } if (profile) MSG(("output: %f sec\n", timer_stop(&tv))); } else if (strcmp(cmd, "del") == 0) { char *package; pkg_id delpkg; if (argc < optind + 2) { usage(); } package = argv[optind+1]; pnt = pkgcdb_load(dbfile, 0, 0); if (pnt == NULL) { PERROR(("pkgcdb_load")); exit(1); } delpkg = pkg_intern(pathnode_strtab(pnt), package); pkgcdb_traverse(pnt, delete_pathnode_entry, &delpkg); pkgcdb_save(dbfile, pnt, 1); } else if (strcmp(cmd, "list") == 0) { pnt = pkgcdb_load(dbfile, 0, 0); if (pnt == NULL) { PERROR(("pkgcdb_load")); exit(1); } pkgcdb_traverse(pnt, print_pathnode_entry, NULL); } else { usage(); } exit(ret); } auto-apt-0.3.23ubuntu0.14.04.1/paths.list0000664000000000000000000000472510026624571014377 0ustar # auto-apt paths list # # # #:= # ! - ignore files under this directory # * - standard dirs, no package own this directory # other - ignore auto installation # home/ ! proc/ ! dev/ ! boot/ * bin/ * sbin/ * tmp/ ! lib/modules/ * lib/security/ * lib/ * etc/cron.d/ * etc/cron.daily/ * etc/cron.weekly/ * etc/cron.monthly/ * etc/logrotate.d/ * etc/init.d/ * etc/menu-methods/ * etc/X11/Xresources/ * etc/texmf/ * etc/pam.d/ * etc/X11/fonts/misc/ * etc/X11/fonts/ * etc/X11/ * etc/emacs/site-start.d * etc/emacs/ * etc/sound/events/ * etc/sound/ * etc/CORBA/servers/ * etc/CORBA/ * etc/ppp/ip-up.d/ * etc/ppp/ip-down.d/ * etc/ppp/ * etc/news/ * etc/ * usr/doc/ * usr/local/ ! usr/info/ * usr/man/ man-db usr/bin/ * usr/sbin/ * usr/X11R6/bin/ * usr/X11R6/include/X11/bitmaps/ * usr/X11R6/include/X11/pixmaps/ * usr/X11R6/include/X11/ * usr/X11R6/include/ * usr/X11R6/lib/X11/app-defaults/ * usr/X11R6/lib/X11/fonts/misc/ * usr/X11R6/lib/X11/fonts/ * usr/X11R6/lib/X11/ * usr/X11R6/lib/ * usr/X11R6/share/locale/ * usr/X11R6/share/ * usr/X11R6/man/ man-db usr/X11R6/ * usr/i486-linuxlibc1/include/X11/ * usr/i486-linuxlibc1/include/ * usr/i486-linuxlibc1/lib/ * usr/i486-linuxlibc1/bin/ * usr/i486-linuxlibc1/ * usr/games/ * usr/include/ * usr/lib/mime/packages/ * usr/lib/menu/ * usr/lib/debian-test/tests/ * usr/lib/debian-test/ * usr/lib/emacsen-common/packages/install/ * usr/lib/emacsen-common/packages/remove/ * usr/lib/games/ * usr/lib/cgi-bin/ * usr/lib/GNUstep/Libraries/ * usr/lib/GNUstep/Headers/ * usr/lib/GNUstep/Tools/ * usr/lib/GNUstep/ * usr/lib/libc5-compat/ * usr/lib/ruby/1.6/ * usr/lib/ruby/ * usr/lib/python1.5/ * usr/lib/php4/ * usr/lib/php3/ * usr/lib/perl5/File/ * usr/lib/perl5/IO/ * usr/lib/perl5/5.005/ * usr/lib/perl5/5.6/ * usr/lib/perl5/ * usr/lib/pkgconfig/ * usr/lib/ * usr/share/doc/ * usr/share/doc-base/ * usr/share/man/ man-db usr/share/info/ * usr/share/texmf/fonts/vf * usr/share/texmf/fonts/ * usr/share/texmf/tfm/ * usr/share/texmf/tex/ * usr/share/texmf/ * usr/share/doc-base/ * usr/share/locale/ * usr/share/gnome/help/ * usr/share/gnome/apps/ * usr/share/gnome/ * usr/share/games/ * usr/share/pixmaps/ * usr/share/emacs/site-lisp/ * usr/share/emacs/ * usr/share/perl5/File/ * usr/share/perl5/IO/ * usr/share/ * usr/src/kernel-patches/ * usr/src/ * usr/info/ * usr/man/ man-db usr/etc/ * usr/ * var/spool/mail/ ! var/spool/news/ ! var/tmp/ ! var/lib/games/ * var/lib/ * var/log/ * var/cache/ * var/games/ * var/spool/ * var/state/ * var/run/ * var/www/ * var/ * auto-apt-0.3.23ubuntu0.14.04.1/auto-apt.sh0000664000000000000000000003664412330411273014447 0ustar #!/bin/sh # auto-apt -- on demand package installation tool # Copyright (c) 2000 Fumitoshi UKAI # GPL # # AUTO_APT_DEBUG= # AUTO_APT_VERBOSE= # AUTO_APT_QUIET= # AUTO_APT_LOG= -- obsolate? # AUTO_APT_ACCEPT={main,non-US,non-free,contrib,none} # AUTO_APT_SIMULATE= # AUTO_APT_CACHEDIR=/var/cache/auto-apt/ # AUTO_APT_DETECT= # AUTO_APT_YES= # AUTO_APT_DB=/var/cache/auto-apt/pkgcontents.bin # AUTO_APT_HOOK={exec,open,access,stat} # # APT_CONFIG=/etc/apt/apt.conf # SOURCES_LIST=/etc/auto-apt/sources.list (cf: apt-config -dump) prog=`basename $0` AUTO_APT_ID='$Id: auto-apt.sh,v 1.58 2004/03/19 17:53:25 ukai Exp $' AUTO_APT_PKGCDB=${AUTO_APT_PKGCDB:-'/usr/lib/auto-apt/auto-apt-pkgcdb'} AUTO_APT_SO=${AUTO_APT_SO:-/lib/auto-apt.so} AUTO_APT_ACCEPT=${AUTO_APT_ACCEPT:-"main,non-US,non-free,contrib"} AUTO_APT_CACHEDIR=${AUTO_APT_CACHEDIR:-"/var/cache/auto-apt"} AUTO_APT_DB=${AUTO_APT_DB:-"${AUTO_APT_CACHEDIR}/pkgcontents.bin"} AUTO_APT_FILEDB=${AUTO_APT_FILEDB:-"${AUTO_APT_CACHEDIR}/pkgfiles.bin"} AUTO_APT_HOOK=${AUTO_APT_HOOK:-"all"} AUTO_APT_SOURCES_LIST=${AUTO_APT_SOURCES_LIST:-"/etc/auto-apt/sources.list"} export AUTO_APT_ACCEPT export AUTO_APT_HOOK LIBC_PATH=`ldd /bin/sh | grep libc.so | awk '{print $3}'` if test -f $LIBC_PATH; then export LIBC_PATH fi requirepkg() { cmd=$1 pkg=$2 if test -e "$1";then : else echo "I: Install:$2 file:$1 by:$0" >&2 apt-get -y install $2 >&2 fi } usage() { echo "$AUTO_APT_ID Usage: auto-apt [options] command [arg ...] auto-apt is a simple command line interface for setting up auto-apt environment and/or search packages by filename. Commands: run - Enter auto-apt environment run [command [cmdarg]] update - Retrieve new lists of Contents (available file list) update updatedb - Regenerate lists of Contents (available file list, no download) updatedb update-local - Generate installed file lists update-local merge - Merge lists of Contents merge del - Delete package list del package check - Check which package will provide the filename check [-v] [-f] filename list - List filelist in dbfile list [-v] [-f] search - Search package by filename (grep) search [-v] [-f] pattern debuild - debuild with auto-apt useful to get build-depends: status - Report current environments (auto-apt or not) For some commands, command name with "-local" suffix, it will use pkgfiles.db, which is created by update-local command, instead of pkgcontents.db Options: [-s] [-y] [-q] [-i] [-x] [-X] [-a dists] [-p hooks] [-D pkgcontents.bin] [-F pkgfiles.bin] [-L detect.list] See the auto-apt(1) manual pages. " >&2 exit } run() { if test -e /usr/bin/apt-get; then : else echo E: You need apt-get to run auto-apt. exit 1 fi if test -e /usr/bin/sudo; then : else echo W: without sudo, you can not install new packages automatically. fi if test "$1" = ""; then set -- $SHELL fi if test "$AUTO_APT_QUIET" = ""; then echo Entering auto-apt mode: "$@" echo Exit the command to leave auto-apt mode. fi command -v "$1" |grep -q / > /dev/null 2>&1 && LD_PRELOAD=$AUTO_APT_SO:$LD_PRELOAD exec "$@" echo "E: Exec $1 failed, auto-apt failed" } update() { if test "$1" = db; then nodownload=1 shift fi # dirname in shellutils, which is required CACHEDIR=`dirname $AUTO_APT_DB` test -d "$CACHEDIR" || { echo "E: update: cache dir not found: $CACHEDIR" >&2; exit } test -w "$CACHEDIR" || { echo "E: You need write permission for $CACHEDIR" >&2; exit } ARCH=$(dpkg --print-architecture) cd "$CACHEDIR" && { rm -f "$AUTO_APT_DB" test -f $AUTO_APT_SOURCES_LIST || { eval `apt-config shell APT_ETC Dir::Etc/ SOURCES_LIST Dir::Etc::sourcelist` test -f $APT_ETC/$SOURCES_LIST || { echo "E: apt sources.list:$APT_ETC/$SOURCES_LIST not found" >&2; exit } ln -sf $APT_ETC/$SOURCES_LIST $AUTO_APT_SOURCES_LIST } cat $AUTO_APT_SOURCES_LIST | \ sed -ne 's=^[[:space:]]*deb[[:space:]][[:space:]]*\([^:[:space:]]*\):\([^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]][[:space:]]*.*=\1 \2/dists/\3=p' | while read method url do u=`echo $url | sed -e 's,^/*,,' -e 's:/:_:g' -e 's:__*:_:g'` case "$method" in http|ftp) if test "$nodownload" = 1; then : else echo "Downloading $method:$url Contents-$ARCH.gz ..." >&2 # proxy setting if test "${method}_proxy" = ""; then host=`echo $url | sed -e 's=^//==' -e 's=/.*=='` eval `apt-config shell ${method}_proxy Acquire::${method}::Proxy` eval `apt-config shell ${method}_proxy Acquire::${method}::Proxy::${host}` if test "${method}_proxy" = "DIRECT"; then unset ${method}_proxy else export ${method}_proxy fi fi # other options wgetopt="--timestamping --continue --progress=bar:force" if test "$method" = "ftp"; then passive_ftp="true" eval `apt-config shell passive_ftp Acquire::ftp::Passive` if test "$passive_ftp" = "true"; then wgetopt="$wgetopt --passive-ftp" fi fi requirepkg /usr/bin/wget wget # /usr/bin/wget -q -O ${u}_Contents-$ARCH.gz $method:$url/Contents-$ARCH.gz >&2 wget $wgetopt -O ${u}_Contents-$ARCH.gz $method:$url/Contents-$ARCH.gz 2>&1 | tail -n +8 >&2 fi ;; rsh|ssh) if test "$nodownload" = 1; then : else echo -n "Downloading $method:$url Contents-$ARCH.gz ..." >&2 case "$method" in rsh) requirepkg /usr/bin/rsh rsh-client; cmd=rcp;; ssh) requirepkg /usr/bin/ssh ssh; cmd=scp;; esac path=`echo $url | sed -e 's=//\([^/]*\)/\(.*\)$=\1:/\2='` $cmd $path/Contents-$ARCH.gz ${u}_Contents-$ARCH.gz > /dev/null 2>&1 echo "done" >&2 fi ;; file) if test "$nodownload" = 1; then : else ln -fs $url/Contents-$ARCH.gz ${u}_Contents-$ARCH.gz fi ;; *) echo "W: Unsupported apt-line: $method, ignored" >&2 ;; esac test -s ${u}_Contents-$ARCH.gz && gunzip < ${u}_Contents-$ARCH.gz | sed -e '1,/^FILE/d' echo "" >&2 done | $AUTO_APT_PKGCDB -f "$AUTO_APT_DB" put "$@" } } updatelocal() { test -f "$AUTO_APT_FILEDB" && rm -f "$AUTO_APT_FILEDB" ls -1rt /var/lib/dpkg/info/*.list | while read list do pkg=`echo $list | sed -ne 's:.*/dpkg/info/\(.*\).list:\1:p'` awk -v pkg=$pkg '{print $1, " ", pkg}' $list done | $AUTO_APT_PKGCDB -f "$AUTO_APT_FILEDB" put "$@" } merge() { $AUTO_APT_PKGCDB -f "$AUTO_APT_DB" put "$@" } del() { if test "$1" = ""; then echo "E: del: missing packagename" >&2 exit fi $AUTO_APT_PKGCDB -f "$AUTO_APT_DB" del "$@" } check() { while getopts "fv" opt; do case "$opt" in f) full=yes;; v) verbose=yes;; *) echo "$0 check [-f] filename" >&2; exit;; esac done shift $(($OPTIND -1)) if test "$1" = ""; then echo "E: check: missing filename" >&2 exit fi if test "$full" = "yes"; then pat=`echo $1 | sed -e 's:^\/::'` (cd `dirname $AUTO_APT_DB` for contents in *_Contents-*.gz do test -s $contents || continue gunzip < $contents | sed -e '1,/^FILE/d' done ) | grep -E "^/?$pat[[:space:]]" | awk '{ print $2; if ("'$verbose'" == "yes") { print $1; } }' else pkgcdbopt= test "$verbose" = "yes" && pkgcdbopt="-v" $AUTO_APT_PKGCDB -f "$AUTO_APT_DB" get $pkgcdbopt "$@" fi } install() { while getopts "sduyv" opt; do case "$opt" in s) simulate=yes;; d) download=yes;; u) upgraded=yes;; y) assumeyes=yes;; v) verbose=yes;; *) echo "$0 install [-s] [-d] [-u] [-y] [-v] filename" >&2; exit;; esac done shift $(($OPTIND -1)) filename="$1" test "$verbose" = "yes" && echo "N: try to install a package providing $filename" pkgs=$($0 check "$filename") IFS0="$IFS"; IFS=,; set -- $pkgs; IFS="$IFS0" test "$verbose" = "yes" && echo "N: $@" if [ $# -eq 0 ]; then echo "E: no candidate found for $filename" >&2; exit 1 fi if [ $# -gt 1 ]; then echo "E: multiple candidates found for $filename" >&2 echo "I: $@" >&2 exit 1 fi pkgname=${1##*/} aptopt= test "$simulate" = "yes" && aptopt="$aptopt -s" test "$download" = "yes" && aptopt="$aptopt -d" test "$upgraded" = "yes" && aptopt="$aptopt -u" test "$assumeyes" = "yes" && aptopt="$aptopt -y" test "$verbose" = "yes" && echo "apt-get $aptopt intall $pkgname" apt-get $aptopt install $pkgname } list() { while getopts "fv" opt; do case "$opt" in f) full=yes;; v) verbose=yes;; *) echo "$0 list [-f]" >&2; exit;; esac done shift $(($OPTIND -1)) if test "$verbose" = "yes"; then set -- -v "$@" fi if test "$full" = "yes"; then (cd `dirname $AUTO_APT_DB` founddb=false for contents in *_Contents-*.gz do test -s $contents || continue founddb=true gunzip < $contents | sed -e '1,/^FILE/d' done if test "$founddb" = false; then echo "E: no auto-apt db, run 'auto-apt update' first" exit 1 fi ) else if test -f "$AUTO_APT_DB"; then $AUTO_APT_PKGCDB -f "$AUTO_APT_DB" list else echo "E: $AUTO_APT_DB not found, run 'auto-apt update' first" exit 1 fi fi } search() { if test "$1" = ""; then echo "E: search: missing search pattern" >&2 exit fi while getopts "fv" opt; do case "$opt" in f) full=yes;; v) verbose=yes;; *) echo "$0 search [-f] pattern" >&2; exit;; esac done shift $(($OPTIND -1)) pat=$1 if test "$verbose" = "yes"; then set -- -v fi if test "$full" = "yes"; then set -- -f "$@" fi list "$@" | grep "$pat" } debuild() { test -f $AUTO_APT_FILEDB || { if test "$AUTO_APT_YES" = ""; then fdb=`basename $AUTO_APT_FILEDB` echo "You have no $AUTO_APT_FILEDB" echo "It is recommended to create $fdb to get right build-depends, " echo "but it takes too much time to generate $fdb." echo -n "Create it now ? [Y/n] " while read yn; do test "$yn" = "" && yn=y case "$yn" in Y|y) auto-apt update-local; break;; N|n) echo "ok, run without $fdb"; break;; *) echo -n "Create it now ? [Y/n] "; continue;; esac done else auto-apt update-local fi } if test "$AUTO_APT_DETECT" = ""; then requirepkg /usr/bin/dpkg-parsechangelog dpkg-dev package=`dpkg-parsechangelog | sed -n 's/^Source: //p'` test "$package" = "" && { echo "E: badly formatted changelog file, no Source:?" >&2; exit } version=`dpkg-parsechangelog | sed -n 's/^Version: //p'` test "$version" = "" && { echo "E: badly formatted changelog file, no Version:?" >&2; exit } # dpkg-architecture is dpkg-dev arch=`dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null` \ && test "${arch}" != "" \ || arch=`dpkg --print-architecture` sversion=`echo "$version"| perl -pe 's/^\d+://'` pva="${package}_${sversion}${arch:+_${arch}}" DDB=../${pva}.lists AUTO_APT_DETECT=`pwd`/$DDB export AUTO_APT_DETECT else DDB=$AUTO_APT_DETECT fi test -f $AUTO_APT_DETECT && { if test "$AUTO_APT_YES" = ""; then echo "detect.lists $AUTO_APT_DETECT already existed" echo -n "Remove it, before running debuild? [Y/n] " while read yn; do test "$yn" = "" && yn=y case "$yn" in Y|y) rm -f $AUTO_APT_DETECT; break;; N|n) echo "ok, append record to $AUTO_APT_DETECT"; break;; *) echo -n "Remove it, before running debuild? [Y/n]"; continue;; esac done else rm -f $AUTO_APT_DETECT fi } rm -f $AUTO_APT_DETECT echo "$prog: record file access to $DDB" requirepkg /usr/bin/debuild devscripts auto-apt -L $AUTO_APT_DETECT run /usr/bin/debuild -E "$@" echo "Build dependencies will be ... (in ../${pva}.build-depends)" rm -f ../essential-packages-list requirepkg /usr/share/doc/build-essential/essential-packages-list build-essential sed -e '1,/^$/d' /usr/share/doc/build-essential/essential-packages-list \ > ../essential-packages-list cat $DDB | sed -ne '/^\//p' | awk '$2 !~ /[*!]/ {print $2}' | grep -Fvf ../essential-packages-list | sort | uniq | \ perl -e 'print " " . join(", ", grep {chomp} ) . "\n"' \ > ../${pva}.build-depends rm -f ../essential-packages-list cat ../${pva}.build-depends echo "Note: file access record is stored $DDB" } status() { case $LD_PRELOAD in /lib/auto-apt.so|/lib/auto-apt.so:*|*:/lib/auto-apt.so|*:/lib/auto-apt.so:*) echo "auto-apt mode"; if test "$AUTO_APT_QUIET" != "yes"; then test "$AUTO_APT_SIMULATE" = "yes" && echo -n " -s" test "$AUTO_APT_YES" = "yes" && echo -n " -y" test "$AUTO_APT_NOBG" = "yes" && echo -n " -i" test "$AUTO_APT_X" = "yes" && echo -n " -X" echo -n " -a $AUTO_APT_ACCEPT"; echo -n " -p $AUTO_APT_HOOK"; echo -n " -D $AUTO_APT_DB"; echo -n " -F $AUTO_APT_FILEDB"; test -f "$AUTO_APT_DETECT" && echo -n " -L $AUTO_APT_DETECT"; echo ""; fi exit 0;; *) echo "normal mode"; exit 1;; esac } ## general command line parsing # /usr/bin/getopt in util-linux (required) ## XXX: use getopts? # default -X enable case X"$AUTO_APT_X" in Xoff|Xno) ;; X*) if test "$DISPLAY" != "" && test -x /usr/bin/x-terminal-emulator; then AUTO_APT_X=yes; export AUTO_APT_X; fi ;; esac while getopts "hsyqixXa:c:p:D:F:L:" opt; do # echo "opt=$opt OPTIND=$OPTIND OPTARG=$OPTARG" case "$opt" in h) usage;; s) AUTO_APT_SIMULATE=yes; export AUTO_APT_SIMULATE ;; y) AUTO_APT_YES=yes; export AUTO_APT_YES;; q) AUTO_APT_QUIET=yes; export AUTO_APT_QUIET;; i) AUTO_APT_NOBG=yes; export AUTO_APT_NOBG;; x) AUTO_APT_X=no; export AUTO_APT_X ;; X) if test "$DISPLAY" != "" && test -x /usr/bin/x-terminal-emulator; then AUTO_APT_X=yes; export AUTO_APT_X else echo "no \$DISPLAY or x-terminal-emulator, X support disabled" >&2 fi;; a) case "$OPTARG" in none) AUTO_APT_ACCEPT;; *) AUTO_APT_ACCEPT="$AUTO_APT_ACCEPT,$OPTARG";; esac export AUTO_APT_ACCEPT;; p) case "$OPTARG" in none) AUTO_APT_HOOK;; *) AUTO_APT_HOOK="$AUTO_APT_HOOK,$OPTARG";; esac export AUTO_APT_HOOK;; D) AUTO_APT_DB="$OPTARG"; export AUTO_APT_DB;; F) AUTO_APT_FILEDB="$OPTARG"; export AUTO_APT_FILEDB ;; L) AUTO_APT_DETECT="$OPTARG"; export AUTO_APT_DETECT AUTO_APT_FILEDB ;; *) usage;; esac done # echo "opt=$opt OPTIND=$OPTIND OPTARG=$OPTARG" shift $(($OPTIND - 1)) if [ $# -lt 1 ]; then usage fi CMD=$1; shift case "$CMD" in run) run "$@";; update) update "$@";; updatedb) update db "$@";; updatedb-local) AUTO_APT_DB="$AUTO_APT_FILEDB" update "$@" ;; update-local) updatelocal "$@";; merge) merge "$@";; merge-local) AUTO_APT_DB="$AUTO_APT_FILEDB" merge "$@" ;; check) check "$@";; check-local) AUTO_APT_DB="$AUTO_APT_FILEDB" check "$@" ;; install) install "$@";; list) list "$@";; list-local) AUTO_APT_DB="$AUTO_APT_FILEDB" list "$@" ;; del) del "$@";; del-local) AUTO_APT_DB="$AUTO_APT_FILEDB" del "$@" ;; search) search "$@";; search-local) AUTO_APT_DB="$AUTO_APT_FILEDB" search "$@" ;; debuild) debuild "$@";; status|mode) status "$@";; *) echo "unknown command: $CMD" >&2; usage ;; esac exit auto-apt-0.3.23ubuntu0.14.04.1/TODO0000664000000000000000000000157307134352151013047 0ustar $Id: TODO,v 1.19 2000/07/16 15:27:37 ukai Exp $ auto-apt-installer cool GUI support commands.list(?) to control auto-apt eg dpkg AUTO_APT_SIMULATE=yes syslog? remove debug message auto-apt add (user to /etc/sudoers) dynamic link database module redirect apt-get message?; interactive maintainer script ? auto-apt log: fifo or pty? ~/.auto-apt/$$ tty only auto apt-get hook() { if (!apt && detect) detect_package(filename, func, 0); /* exec */ result = origrunc(); if (!apt && detect) detect_package(filename, func, result); /* other,err */ if (result < 0) { ... } } hook unlink(2) to dpkg -r fake readdir? fake man(1) from /bin,/usr/bin.. user filter normalize path? multi packages: follow diversion/alternatives? record all file access? pkgcdb put; "replace data" option auto-menu, auto-emacsen auto-apt-0.3.23ubuntu0.14.04.1/Makefile0000664000000000000000000000241311346206237014014 0ustar # # Makefile # $Id: Makefile,v 1.13 2001/12/19 16:36:05 ukai Exp $ # DESTDIR= package=auto-apt SHLIBDIR=$(DESTDIR)/lib BINDIR=$(DESTDIR)/usr/bin LIBDIR=$(DESTDIR)/usr/lib/$(package) CACHEDIR=$(DESTDIR)/var/cache/$(package) ETCDIR=$(DESTDIR)/etc/$(package) DEFS=-DUSE_DETECT -DDEBUG CC=gcc CFLAGS=-g -Wall -finline-functions -Ipkgcdb $(DEFS) all: auto-apt.so auto-apt-pkgcdb auto-apt.so: auto-apt.o pkgcdb/pkgcdb2.a $(CC) -shared -o auto-apt.so auto-apt.o -lc -ldl auto-apt.o: auto-apt.c $(CC) $(CFLAGS) -fPIC -o auto-apt.o -c auto-apt.c auto-apt-pkgcdb: auto-apt-pkgcdb.o pkgcdb/pkgcdb2.a $(CC) $(CFLAGS) -o auto-apt-pkgcdb auto-apt-pkgcdb.o pkgcdb/pkgcdb2.a pkgcdb/pkgcdb2.a: (cd pkgcdb && \ $(MAKE) pkgcdb2.a CC="$(CC)" DEFS="$(DEFS)" CFLAGS="$(CFLAGS)") install: all install -m 755 auto-apt.sh $(BINDIR)/auto-apt install -m 755 auto-apt-pkgcdb $(LIBDIR)/ install -m 755 auto-apt-installer.pl $(LIBDIR)/auto-apt-installer install -m 644 auto-apt.so $(SHLIBDIR)/ install -m 644 paths.list $(ETCDIR)/ # install -m 644 paths.list commands.list $(ETCDIR)/ clean: (cd pkgcdb && $(MAKE) clean) -rm -f auto-apt.so auto-apt.o -rm -f auto-apt-pkgcdb auto-apt-pkgcdb.o -rm -rf cache distclean: clean (cd pkgcdb && $(MAKE) distclean) -rm -f *~ *.bak *.orig *.db *.o *.so auto-apt-0.3.23ubuntu0.14.04.1/examples/0000775000000000000000000000000010026632073014165 5ustar auto-apt-0.3.23ubuntu0.14.04.1/examples/auto-apt-get-menu.sh0000664000000000000000000000373607643611652020016 0ustar #!/bin/bash -e # Retrieve debian menu files # Copyright (C) 2000 Masato Taruishi. All rights reserved. # # 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, or (at your option) any later version if [ -z "$TMP" ]; then tmpdir=/tmp else tmpdir=$TMP fi tmpdir=$tmpdir/auto-apt-get-menu.$$ install -d $tmpdir pwd=`pwd` function copy_debian_menus() { \ls -1 debian/*.menu | while read f do cp $f ../`basename $f .menu` 2> /dev/null basename $f .menu done } function copy_debian_menu() { if cp debian/menu ../$p 2> /dev/null; then pkg="$p" return 0 fi \ls debian/*.menu > /dev/null 2> /dev/null || return 1 pkg=`copy_debian_menus` return 0 } ## lookup packages that have debian menu file. echo -n "Fetching package info... " auto-apt search usr/lib/menu | awk -F' ' '{print $2;}' | sed 's/.*\///' | sort | uniq > $tmpdir/menu echo done. ## calculates the number of the packages. pnum=`cat $tmpdir/menu |wc -l` pnum=`expr $pnum` tail -n `expr $pnum - 1` $tmpdir/menu > $tmpdir/menu.new mv $tmpdir/menu.new $tmpdir/menu ## for all the packages, creates a local menu file for auto-apt. for p in `cat $tmpdir/menu` do echo -n "($pnum) Fetching $p... " mkdir $tmpdir/$p.d cd $tmpdir/$p.d if apt-get --download-only source $p > /dev/null; then zcat *.diff.gz 2> /dev/null | patch -p1 -f > /dev/null || tar zxf *.orig.tar.gz if copy_debian_menu ; then export IFS=" " echo $pkg | while read eachpkg do echo -n "[$eachpkg] " sed -e '/command="/s/command="\([^"]*\)"/command="auto-apt run sh -c \1"/' -e '/ command=[^"]/s/command=\([^ \\]*\)/command="auto-apt run sh -c \1"/' -e 's/package([^)]*)/package(local.auto-apt)/' ../$eachpkg > ../$eachpkg.new mv ../$eachpkg.new $pwd/$eachpkg done else echo -n "menu not found " fi echo done. else echo failed. fi pnum=`expr $pnum - 1` cd .. rm -rf $p.d done rm -rf $tmpdir auto-apt-0.3.23ubuntu0.14.04.1/examples/strace2builddepends.pl0000664000000000000000000000454507643611652020473 0ustar #!/usr/bin/perl -w #use strict comes after prototyping! # a list of files that do not belong to a Debian package but are known # to never create a dependency @known_files = ("/etc/ld.so.cache"); # generate a list of the versions of all Debian packages and # all Essential as well as all Build-Essential packages open(F,"/var/lib/dpkg/status") || die $!; $/="\n\n"; while (defined ($block=)) { $block =~ /Package: (.*)\n/; $package=$1; $block =~ /Version: (.*)\n/; $version=$1; $dpkg_package_versions{$package}=$version; if ($block =~ /Essential: yes\n/) {; $dpkg_build_essential_packages{$package}=1 } } close(F); $/="\n"; open(F,"/usr/share/doc/build-essential/essential-packages-list") || die $!; while (defined ($line=)) { $dpkg_build_essential_packages{$package}=1; } close(F); # generate a list of all known installed Debian files foreach $filename () { open(F,$filename) || die $!; $filename =~ m#^.*/(.*)\.list$#; $file = $1; while (defined ($line=)) { chomp($line); $dpkg_files{$line} = $file; } close(F); } # extrace filenames from open and exec calls and add them if their # system call was successfull (e.g. files that didn't exists at build time # won't give a dependency entry!) while (defined ($line=<>)) { next if $line !~ /^[0-9]+ (open|exec)/; if ($line =~ m/^[0-9]+ open\(\"(\/[^\"]+)\", \S+ = ([-\d]+)$/) { $files{$1}=1 if $2 >= 0; } elsif ($line =~ m/^[0-9]+ execve\(\"(\/[^\"]+)\", .* ([-\d]+)([a-zA-Z\(\) ]+)?$/) { $files{$1}=1 if $2 >= 0; } } # filter directories that are known to never be dependency-worth foreach $key (keys %files) { if (($key =~ m#^(/dev/|/tmp/|/proc/|/var/lib/dpkg/|/usr/share/locale/)#) || (-d $key) || (-l $key)) { delete $files{$key}; } } # filter files that are known to never be dependency-worth foreach $key (@known_files) { delete $files{$key}; } # now get those files that belong to a Debian package foreach $key (keys %files) { if ($dpkg_files{$key}) { $packages{ $dpkg_files{$key} }++; delete $files{$key}; } else { print "UNKNOWN: $key\n"; } } # filter files that belong to (build-)essential packages foreach $key (keys %dpkg_build_essential_packages) { delete $packages{$key}; } ##################################### # print all dependend packages foreach $key (sort keys %packages) { print "$key (>= ".$dpkg_package_versions{$key}.")\n"; } auto-apt-0.3.23ubuntu0.14.04.1/auto-apt.10000664000000000000000000001173610460537701014177 0ustar .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH auto-apt 1 "29 Jun 2000" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME auto-apt \- on demand package installation tool .SH SYNOPSIS .B auto-apt .RI [ options ] " " [ command ] " " [ args... ] .SH DESCRIPTION This manual page documents briefly the .B auto-apt commands. .PP \fBauto-apt\fP is a program that checks file access of programs running within \fBauto-apt\fP environments. If a program will access a file of uninstalled package, \fBauto-apt\fP will install the package containing the file, by using apt-get. .SH OPTIONS A summary of options is included below. .TP .B "-h" Usage. .TP .B "-s" No action, perform a simulation of action. .TP .B "-y" Automatic yes to prompt. .TP .B "-q" Quiet .TP .B "-i" Don't install in background process. .TP .B "-x" Disable X interface. .TP .B "-X" Enable X interface. Run apt-get in another \fBx-terminal-emulator\fP if you run in X environments. .TP .BI "-a [" dist [, dist... ]] Select installable distribution from .BR main , contrib , non-free , non-US or .B none. If you set "-a none", it means almost same as "-s". .TP .BI "-p [" hook [, hook... ]] Select hook functions from .BR exec , open , access , stat or .B none If you set "-p none", it means almost same as "-s". .TP .BI "-D [" dbfile ] Change \fIdbfile\fP from default .B /var/cache/auto-apt/pkgcontents.db .TP .BI "-F [" filedb ] Change \fIfiledb\fP from default .B /var/cache/auto-apt/pkgfiles.db, which is generated by \fBauto-apt update-local\fP commands. It is used as default \fIdbfile\fP for commands with \fB-local\fP postfix. In many cases, it is used with .B -L option to detect file access .TP .BI "-L [" record.lists ] Append file access data to \fIrecord.lists\fP file. .SH COMMANDS A summary of command is included below. .TP .BI "run [" command ] Run command controlled by \fPauto-apt\fP. If \fIcommand\fP is not specified, user's shell will be used. .TP .B "update [" -a ] Recreate \fIdbfile\fP from sources.list information. \fIdbfile\fP can be specified by \fB-D\fP option. With \fB-a\fP option, all files are stored in \fIdbfile\fP. Note that \fIdbfile\fP become too big with \fB-a\fP option. .TP .B "update-local [" -a ] Generate \fIfiledb\fP from installed package information. \fIfiledb\fP can be specified by \fB-F\fP option. With \fB-a\fP option, all files are stored in \fIdbfile\fP. Note that \fIdbfile\fP become too big with \fB-a\fP option. .TP .B "merge [" -a ] Merge package,filename information to \fIdbfile\fP, which can be specified by \fB-D\fP option. With \fB-a\fP option, all files are stored in \fIdbfile\fP. Note that \fIdbfile\fP become too big with \fB-a\fP option. .TP .BI del " package " Delete file information of \fIpackage\fP from \fIdbfile\fP database. .TP .BI check " " "[-v] [-f] " file Check which package provides \fIfile\fP, from \fIdbfile\fP database. options: \fB-v\fP means verbose. \fB-f\fP uses Contents-*.gz file instead of \fIdbfile\fP database. .TP .BI install " " "[-s] [-d] [-u] [-y] [-v] " file Try to install a package that provides \fIfile\fP by using apt-get. You need root privilege to run apt-get install. .TP .B list [-v] [-f] List file information in \fIdbfile\fP database. options: \fB-v\fP means verbose. \fB-f\fP uses Contents-*.gz file instead of \fIdbfile\fP database. .TP .BI search " " "[-v] [-f] " pattern Search file information by .BR grep (1) \fIpattern\fP in \fIdbfile\fP database. options: \fB-v\fP means verbose. \fB-f\fP uses Contents-*.gz file instead of \fIdbfile\fP database. .TP .BI "debuild [" debuildopts ] Run .BR debuild (1) in auto-apt environments, and show \fBBuild-Depends:\fP estimation. Recommended to use with \fB-s\fP option of auto-apt. .TP .B status Show whether current environment is in \fBauto-apt\fP or not. .\" .SH SEE ALSO .\" .BR auto-apt-pkgcdb (8) .br .SH FILES .IP o /etc/auto-apt/paths\&.list path lists .IP o /var/cache/auto-apt cache/database directory .IP o /etc/auto-apt/sources.list sources.list for auto-apt. if not found, symlink to apt-get's sources.list will be created. .\" .IP .\" .IP o .\" /etc/auto-apt/commands\&.list .\" command configuration (not yet implemented) .SH ENVIRONMENTS .IP o AUTO_APT_CACHEDIR override default cache/database directory .SH BUGS Known bugs. See .B /usr/share/doc/auto-apt/BUGS. and/or http://bugs.debian.org/auto-apt .SH AUTHOR This program was written by Fumitoshi UKAI , inspired by idea/comments from Debian Guru (debian.gr.jp) and Project Dice members. auto-apt-0.3.23ubuntu0.14.04.1/commands.list0000664000000000000000000000016707132747504015063 0ustar # configuration for each command # NOT YET IMPLEMENTED # /usr/bin/dpkg dpkg AUTO_APT_SIMULATE=yes auto-apt-0.3.23ubuntu0.14.04.1/auto-apt.fr.10000664000000000000000000001615210460540150014572 0ustar .\" This file was generated with po4a. Translate the source file. .\" .\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH auto\-apt 1 "29 juin 2000" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NOM auto\-apt \- Installation de paquets à la volée. .SH SYNOPSIS \fBauto\-apt\fR [\fIoptions\fR]\fI \fR[\fIcommande\fR]\fI \fR[\fIarguments...\fR] .SH DESCRIPTION Cette page de manuel décrit succinctement la commande \fBauto\-apt\fR. .PP \fBauto\-apt\fR est un programme qui contrôle les tentatives d'accès aux fichiers, effectuées par des programmes exécutés dans l'environnement \fBauto\-apt\fR. Lorsqu'un programme tente d'accéder à un fichier inclus dans un paquet non installé, \fBauto\-apt\fR utilise apt\-get pour installer, à la volée, le paquet contenant ce fichier. .SH OPTIONS Voici un résumé des options. .TP .B "\-h" Mode d'emploi. .TP .B "\-s" Aucune action, simule une action. .TP .B "\-y" Répond automatiquement «\ Y\ » (oui) à toutes les questions. .TP .B "\-q" Mode non bavard. .TP .B "\-i" N'installe rien en tâche de fond. .TP .B "\-x" Désactive l'interface graphique X. .TP .B "\-X" Active l'interface graphique X. Si vous êtes déjà dans un environnement graphique, apt\-get sera exécuté dans un autre terminal graphique (\fBx\-terminal\-emulator\fR). .TP .BI "\-a [" dist [, dist... ]] Choisit la distribution à installer parmi \fBmain\fR, \fBcontrib\fR, \fBnon\-free\fR, \fBnon\-US\fR ou \fBnone\fR (aucune). «\ \-a none\ » a presque la même signification que «\ \-s\ ». .TP .BI "\-p [" action [, action... ]] Choisit l'action parmi \fBexec\fR, \fBopen\fR, \fBaccess\fR, \fBstat\fR ou \fBnone\fR (aucune). «\ \-a none\ » a presque la même signification que «\ \-s\ ». .TP .BI "\-D [" fichierbdd ] Remplace la valeur par défaut \fB/var/cache/auto\-apt/pkgcontents.db\fR par \fIfichierbdd\fR. (NdT\ : le suffixe de la valeur par défaut semble être .bin et non .db). .TP .BI "\-F [" fichierbdd ] Remplace la valeur par défaut \fB/var/cache/auto\-apt/pkgfiles.db\fR par \fIfichierbdd\fR. Cette base de données est générée par la commande \fBauto\-apt update\-local\fR. L'option \fI\-F\ fichierbdd\fR, ou sa valeur par défaut, est utilisée pour toutes les commandes suffixées \fB\-local\fR. Dans de nombreux cas, cette valeur est utilisée avec l'option \fB\-L\fR pour détecter les accès aux fichiers. (NdT\ : le suffixe de la valeur par défaut semble être .bin et non .db). .TP .BI "\-L [" liste.d'enregistrements ] Ajoute, à la \fIliste.d'enregistrements\fR, des informations sur les tentatives d'accès aux fichiers. .SH COMMANDES Voici un résumé des commandes. .TP .BI "run [" commande ] Exécute la \fIcommande\fR sous le contrôle de \fBauto\-apt\fR. Si \fIcommande\fR n'est pas indiquée, l'interpréteur de commandes (shell) de l'utilisateur sera utilisé. .TP .B "update [" \-a ] (Re)constitue \fIfichierbdd\fR à partir des informations de sources.list. \fIfichierbdd\fR peut être indiqué avec l'option \fB\-D\fR. Avec l'option \fB\-a\fR, tous les fichiers sont stockés dans \fIfichierbdd\fR. Remarquez que \fIfichierbdd\fR devient très/trop volumineux avec l'option \fB\-a\fR. .TP .B "update\-local [" \-a ] Crée \fIfichierbdd\fR à partir des informations sur les paquets installés. \fIfichierbdd\fR peut être indiqué avec l'option \fB\-F\fR. Avec l'option \fB\-a\fR, tous les fichiers sont stockés dans \fIfichierbdd\fR. Remarquez que \fIfichierbdd\fR devient très/trop volumineux avec l'option \fB\-a\fR. .TP .B "merge [" \-a ] Trie les paquets d'après leur nom dans \fIfichierbdd\fR. La base de données \fIfichierbdd\fR peut être indiquée avec l'option \fB\-D\fR. Avec l'option \fB\-a\fR, tous les fichiers sont stockés dans \fIfichierbdd\fR. Remarquez que \fIfichierbdd\fR devient très/trop volumineux avec l'option \fB\-a\fR. .TP .BI del " paquet " Supprime de la base de données \fIfichierbdd\fR les informations sur les fichiers inclus dans \fIpaquet\fR. .TP .BI check " " "[\-v] [\-f] " fichier Vérifie, dans la base de données \fIfichierbdd\fR, quel paquet fournit le \fIfichier\fR. Option\ : \fB\-v\fR commute en mode bavard. \fB\-f\fR utilise le fichier Contents\-*.gz à la place de la base de données \fIfichierbdd\fR. .TP .BI install " " "[\-s] [\-d] [\-u] [\-y] [\-v] " fichier Tente d'installer le paquet qui fournit le \fIfichier\fR en utilisant apt\-get. Vous devez posséder les privilèges du superutilisateur (root) pour lancer un «\ apt\-get install\ ». .TP .B list [\-v] [\-f] Liste les informations sur les fichiers, contenues dans la base de données \fIfichierbdd\fR. Options\ : \fB\-v\fR commute en mode bavard. \fB\-f\fR utilise le fichier Contents\-*.gz à la place de la base de données \fIfichierbdd\fR .TP .BI search " " "[\-v] [\-f] " motif Cherche, avec \fBgrep\fR(1) \fImotif\fR, les informations sur les fichiers dans la base de données \fIfichierbdd\fR. Options\ : \fB\-v\fR commute en mode bavard. \fB\-f\fR utilise le fichier Contents\-*.gz à la place de la base de données \fIfichierbdd\fR .TP .BI "debuild [" debuildopts ] Exécute \fBdebuild\fR(1) dans l'environnement auto\-apt, et indique une estimation des \fBdépendances\fR («\ Build\-Depends:\ »). Il est recommandé de l'utiliser avec l'option \fB\-s\fR d'auto\-apt. .TP .B status Indique si l'environnement actuel est sous le contrôle d'\fBauto\-apt\fR ou pas. .\" .SH SEE ALSO .\" .BR auto-apt-pkgcdb (8) .br .SH FICHIERS .IP o /etc/auto\-apt/paths\&.list\ : liste des chemins d'accès. .IP o /var/cache/auto\-apt\ : répertoire de cache des fichiers Contents\-*.gz et de stockage des bases de données. .IP o /etc/auto\-apt/sources.list\ : liste des sources à utiliser pour auto\-apt. Si ce fichier n'est pas trouvé, un lien symbolique vers le fichier sources.list d'apt\-get sera créé. .\" .IP .\" .IP o .\" /etc/auto-apt/commands\&.list .\" command configuration (not yet implemented) .SH ENVIRONNEMENTS .IP o AUTO_APT_CACHEDIR remplace la valeur par défaut du répertoire de cache des fichiers Contents\-*.gz et de stockage des bases de données. .SH BOGUES Bogues connus. Voir \fB/usr/share/doc/auto\-apt/BUGS\fR et/ou http://bugs.debian.org/auto\-apt .SH AUTEUR Ce programme a été écrit par Fumitoshi UKAI , d'après une idée et des commentaires de Debian Guru (debian.gr.jp) et des membres du Projet Dice. .SH TRADUCTION Valéry Perrin le 16 octobre 2004. .PP L'équipe de traduction a fait le maximum pour réaliser une adaptation française de qualité. .br La version anglaise la plus à jour de ce document est toujours consultable via la commande man -L en auto-apt .br N'hésitez pas à signaler à l'auteur ou au traducteur, selon le cas, toute erreur dans de cette page de manuel. auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/0000775000000000000000000000000012144264702013604 5ustar auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/strtab.c0000664000000000000000000001240007173544632015255 0ustar /*- * strtab.c * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ static char strtab_rcsid[] __attribute__ ((unused)) = "$Id: strtab.c,v 1.4 2000/10/19 10:14:50 ukai Exp $"; #include "strtab.h" #include "mempool.h" #include #include #include #include #include #include #define HASH_SIZE 16381 /* 8191 */ #define STR_MEMPOOL_SIZE (4096*10) struct str_entry { str_id s_next; char data[0]; }; struct __strtab { str_id hashtab[HASH_SIZE]; struct mempool *s_st; struct str_entry *st_next; int str_avail; /* stat */ int str_alloc; int num_str; int num_hash; int num_conflicts; int num_max_depth; }; static int str_hash(char *s); static str_id str_add(StrTable st, char *s, str_id s_next); static struct str_entry *str_get(StrTable st, str_id sid); static int str_hash(char *s) { int *p; char *ss; int i, n, l; register int h = 0; char buf[sizeof(int)]; l = strlen(s); ss = alloca(l+1); strcpy(ss, s); n = l/sizeof(int); p = (int *)ss; for (i = 0; i < n; i++) { h ^= *p++; } n = l - n*sizeof(int); if (n != 0) { memset(buf, 0, sizeof(buf)); strncpy(buf+n, (char *)p, 4-n); p = (int *)buf; h ^= *p; } return h % HASH_SIZE; } static str_id str_add(StrTable st, char *s, str_id s_next) { int len; struct str_entry *se; assert(st != NULL); assert(s != NULL); len = ((sizeof(str_id) + strlen(s) + 1 + 3) & ~3); /* aligned */ if (st->st_next == NULL || st->str_avail <= len) { st->s_st = mempool_alloc(st->s_st, STR_MEMPOOL_SIZE, 1); st->str_avail = STR_MEMPOOL_SIZE; st->st_next = (struct str_entry *)mempool_mem(st->s_st); st->str_alloc += STR_MEMPOOL_SIZE; } se = st->st_next; se->s_next = s_next; strcpy(se->data, s); st->st_next = (struct str_entry *)((char *)se + len); st->str_avail -= len; st->num_str++; return (str_id)mempool_index(st->s_st, se); } static struct str_entry * str_get(StrTable st, str_id sid) { struct str_entry *se; assert(st != NULL); se = mempool_fetch(st->s_st, sid); return se; } #ifndef PKGCDB_AUTOAPT PKGCDB_API StrTable strtab_alloc() { int i; StrTable st; st = (StrTable)malloc(sizeof(struct __strtab)); if (st == NULL) return NULL; memset(st, 0, sizeof(struct __strtab)); st->num_str = 0; for (i = 0; i < HASH_SIZE; i++) { st->hashtab[i] = str_null; } st->s_st = mempool_alloc(NULL, STR_MEMPOOL_SIZE, 1); st->st_next = (struct str_entry *)mempool_mem(st->s_st); st->str_avail = STR_MEMPOOL_SIZE; st->str_alloc = STR_MEMPOOL_SIZE; str_add(st, "", str_null); /* NULL entry */ return st; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void strtab_release(StrTable st) { assert(st != NULL); assert(st->s_st != NULL); mempool_release(st->s_st); st->s_st = NULL; st->st_next = NULL; st->str_avail = 0; st->str_alloc = 0; free(st); } #endif PKGCDB_API str_id str_intern(StrTable st, char *string, int add) { int h; str_id sid; assert(st != NULL); if (string == NULL || string[0] == '\0') { return str_null; } h = str_hash(string); if (st->hashtab[h] != str_null) { struct str_entry *se; int depth = 0; for (sid = st->hashtab[h], se = str_get(st, sid); se != NULL && sid != str_null; sid = se->s_next, se = str_get(st, sid)) { depth++; if (strcmp(se->data, string) == 0) { if (st->num_max_depth < depth) { st->num_max_depth = depth; } return sid; } } if (add) st->num_conflicts++; } else { if (add) st->num_hash++; } if (!add) { return str_null; } sid = str_add(st, string, st->hashtab[h]); st->hashtab[h] = sid; return sid; } PKGCDB_API char * str_symbol(StrTable st, str_id sid) { struct str_entry *se; assert(st != NULL); se = str_get(st, sid); if (se == NULL) { return ""; /* XXX */ } return se->data; } /* dump/restore */ #ifndef PKGCDB_AUTOAPT PKGCDB_API int strtab_dump(int fd, StrTable st, int shrink) { DPRINT(("strtab: %d strings, new %d alloc, %d bytes left\n" " hash %d used (%3.1f%%), %d conflicts, %d depth\n", st->num_str, st->str_alloc, st->str_avail, st->num_hash, (double)st->num_hash*100.0/HASH_SIZE, st->num_conflicts, st->num_max_depth)); if (shrink) { mempool_shrink(st->s_st, st->str_avail); st->str_avail = 0; } if (write(fd, st->hashtab, HASH_SIZE * sizeof(str_id)) < 1) { return -1; } DPRINT(("strtab: dump ")); return mempool_dump(st->s_st, fd, NULL, NULL); } #endif PKGCDB_API StrTable strtab_restore(int fd, int str_margin) { StrTable st; DPRINT(("strtab: restore ")); st = (StrTable)malloc(sizeof(struct __strtab)); if (st == NULL) { MSG(("not enough memory")); return NULL; } DPRINT(("hash %d ", HASH_SIZE)); memset(st, 0, sizeof(struct __strtab)); if (read_data(fd, st->hashtab, HASH_SIZE * sizeof(str_id)) < 1) { return NULL; } DPRINT(("done\n")); DPRINT((" symtab:")); st->s_st = mempool_restore(fd, NULL, NULL, str_margin); if (st->s_st == NULL) { free(st); return NULL; } st->st_next = mempool_mem_avail(st->s_st, str_margin); st->str_avail = str_margin; return st; } auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/pkgcdb2.h0000664000000000000000000000307207132764467015311 0ustar /*- * pkgcdb2.h * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ #ifndef _pkgcdb_h_ #define _pkgcdb_h_ static char pkgcdb_h_rcsid[] __attribute__ ((unused)) = "$Id: pkgcdb2.h,v 1.1 2000/07/12 03:42:47 ukai Exp $"; #include "pathnode.h" #define PKGCDB_VERSION_TAG "AUTO_APT" #define PKGCDB_VERSION_ID "1" #ifndef PKGCDB_FILE #define PKGCDB_FILE "/var/cache/auto-apt/pkgcontents.bin" #define FILEDB_FILE "/var/cache/auto-apt/pkgfiles.bin" #define PKGCDB_PATH_LIST "/etc/auto-apt/paths.list" #endif #define DEFAULT_PATH_PACKAGE "*" #ifndef PKGCDB_AUTOAPT PKGCDB_API PathNodeTree pkgcdb_alloc(); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pkgcdb_release(PathNodeTree pnt); #endif PKGCDB_API PathNodeTree pkgcdb_load(char *dbfile, int str_margin, int pathnode_margin); #ifndef PKGCDB_AUTOAPT PKGCDB_API int pkgcdb_save(char *dbfile, PathNodeTree pnt, int shrink); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API int pkgcdb_path_list_init(PathNodeTree pnt, char *file); #endif PKGCDB_API struct path_node *pkgcdb_get(PathNodeTree pnt, char *flie, char **matchfile, char **ext); #ifndef PKGCDB_AUTOAPT PKGCDB_API struct path_node *pkgcdb_put(PathNodeTree pnt, char *file, char *pkg, int *nent); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pkgcdb_del(PathNodeTree pnt, char *file, char *pkg, int *nent); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pkgcdb_traverse(PathNodeTree pnt, void (*func)(PathNodeTree pnt, char *path, struct path_node *pn, void *arg), void *arg); #endif #endif /* _pkgcdb_h_ */ auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/pkgcdb2.c0000664000000000000000000003041211367443332015270 0ustar /*- * pkgcdb2.c * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ static char pkgcdb2_rcsid[] __attribute__((unused)) = "$Id: pkgcdb2.c,v 1.4 2000/07/13 16:34:30 ukai Exp $"; #include "pkgcdb2.h" #include "pathnode.h" #include "strtab.h" #include "mempool.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef DEBUG PKGCDB_VARDEF int debug = 0; #endif PKGCDB_VARDEF int verbose = 0; PKGCDB_VARDEF int quiet = 0; typedef PathNodeTree PkgCDB; #ifndef PKGCDB_AUTOAPT PKGCDB_API PathNodeTree pkgcdb_alloc() { PathNodeTree pnt; StrTable st; st = strtab_alloc(); if (st == NULL) { return NULL; } pnt = pathnode_alloc(st); return pnt; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pkgcdb_release(PathNodeTree pnt) { StrTable st; assert(pnt != NULL); st = pathnode_strtab(pnt); assert(st != NULL); pathnode_release(pnt); strtab_release(st); } #endif PKGCDB_API PathNodeTree pkgcdb_load(char *dbfile, int str_margin, int pathnode_margin) { int fd; char buf[8]; PathNodeTree pnt; StrTable st; if (dbfile == NULL) return NULL; fd = open(dbfile, O_RDONLY); if (fd < 0) { return NULL; } if (read(fd, buf, sizeof(buf)) < 0) { return NULL; } if (strncmp(buf, PKGCDB_VERSION_TAG, sizeof(buf)) != 0) { MSG(("magic mismatch: %8s\n", buf)); return NULL; } DPRINT(("fd=%d magic: %8s\n", fd, buf)); st = strtab_restore(fd, str_margin); if (st == NULL) { MSG(("strtab read error\n")); close(fd); return NULL; } pnt = pathnode_restore(fd, st, pathnode_margin); if (pnt == NULL) { MSG(("pathnode read error\n")); close(fd); return NULL; } close(fd); return pnt; } #ifndef PKGCDB_AUTOAPT PKGCDB_API int pkgcdb_save(char *dbfile, PathNodeTree pnt, int shrink) { int fd; char buf[8]; if (dbfile == NULL) return -1; if (pnt == NULL) return -1; fd = open(dbfile, O_WRONLY|O_TRUNC|O_CREAT, 0644); if (fd < 0) return fd; strncpy(buf, PKGCDB_VERSION_TAG, sizeof(buf)); if (write(fd, buf, sizeof(buf)) < 0) { goto error; } if (strtab_dump(fd, pathnode_strtab(pnt), shrink) < 0) { goto error; } if (pathnode_dump(fd, pnt, shrink) < 0) { goto error; } error: close(fd); return 0; } #endif PKGCDB_API struct path_node * pkgcdb_get(PathNodeTree pnt, char *file, char **matchfile, char **ext) { char *p; char *filename; static char matchpath[PATH_MAX]; char path[PATH_MAX]; struct path_node *pn; struct path_node *match; DPRINT(("pkgcdb_get: %s\n", file)); if (file[0] == '/') { file++; } filename = file; p = file; pn = pathnode_top(pnt); match = NULL; matchpath[0] = '\0'; while (*p != '\0') { if (*p != '/' || p - file <= 1) { p++; continue; } p++; assert(p - file < PATH_MAX); strncpy(path, file, p - file); path[p - file] = '\0'; pn = pathnode_retrieve(pnt, pn, path); if (pn == NULL) { if (matchfile != NULL) { assert(file - filename + 2 < PATH_MAX); *matchfile = matchpath; matchpath[0] = '/'; strncpy(matchpath + 1, filename, file - filename); matchpath[1 + file - filename] = '\0'; } return match; } file = p; match = pn; assert(pn != NULL); assert(match != NULL); DPRINT(("match:%s[%s] rest>%s\n", pathnode_pathname(pnt, pn), pathnode_packagename(pnt, match), file)); } DPRINT(("last?%s (%d)\n", file, p - file)); if (p - file >= 1) { pn = pathnode_retrieve(pnt, pn, file); if (pn == NULL) { if (matchfile != NULL) { assert(file - filename + 2 < PATH_MAX); *matchfile = matchpath; matchpath[0] = '/'; strncpy(matchpath + 1, filename, file - filename); matchpath[1 + file - filename] = '\0'; } return match; } } if (matchfile != NULL) { *matchfile = matchpath; matchpath[0] = '/'; strcpy(matchpath + 1, filename); } return pn; } #ifndef PKGCDB_AUTOAPT struct pathlist { struct pathlist *next; char *path; int pathlen; char *pkg; struct path_node *n; } *defpathlist = NULL; PKGCDB_API int pkgcdb_path_list_init(PathNodeTree pnt, char *file) { FILE *fp; char buf[PATH_MAX]; char *p, *pkg; struct pathlist *pl, *plp; int n = 0; if (file == NULL) return -1; VMSG(("paths.list loading from %s...", file)); fp = fopen(file, "r"); if (fp == NULL) { PERROR(("fopen paths.list")); return -1; } while (fgets(buf, sizeof(buf), fp) != NULL) { if (buf[0] == '#') continue; if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0'; for (p = buf; *p != '\0'; p++) { if (isspace(*p)) { *p++ = '\0'; break; } } for (; *p != '\0'; p++) { if (!isspace(*p)) { break; } } pkg = p; if (*p == '\0') { pkg = DEFAULT_PATH_PACKAGE; } else { for (; *p != '\0'; p++) { if (isspace(*p)) { *p = '\0'; break; } } } pl = (struct pathlist *)malloc(sizeof(struct pathlist)); if (pl == NULL) return -1; memset(pl, 0, sizeof(struct pathlist)); pl->path = strdup(buf); pl->pathlen = strlen(pl->path); pl->pkg = strdup(pkg); pl->n = pkgcdb_put(pnt, pl->path, pl->pkg, NULL); if (defpathlist == NULL || pl->pathlen > defpathlist->pathlen) { pl->next = defpathlist; defpathlist = pl; } else { for (plp = defpathlist; plp != NULL && plp->next != NULL; plp = plp->next) { if (pl->pathlen > plp->next->pathlen) { pl->next = plp->next; plp->next = pl; break; } } if (plp != NULL && plp->next == NULL) { plp->next = pl; } } n++; } VMSG(("%d done\n", n)); #ifdef DEBUG if (debug) { for (plp = defpathlist; plp != NULL; plp = plp->next) { printf("%s %s\n", plp->path, plp->pkg); } } #endif return 0; } static int path_list_local_init(PathNodeTree pnt) { struct pathlist *pl, *npl; struct stat st; char buf[PATH_MAX+2]; for (pl = defpathlist; pl != NULL; pl = pl->next) { if (pl->path[pl->pathlen-1] == '/') { snprintf(buf, PATH_MAX, "/%s", pl->path); if (stat(buf, &st) == 0 && S_ISDIR(st.st_mode)) { npl = (struct pathlist *)malloc(sizeof(struct pathlist)); if (npl == NULL) continue; memset(npl, 0, sizeof(struct pathlist)); npl->path = strdup(pl->path); npl->path[pl->pathlen-1] = '\0'; npl->pathlen = pl->pathlen -1; npl->pkg = pl->pkg; npl->n = pkgcdb_put(pnt, npl->path, npl->pkg, NULL); npl->next = pl->next; pl->next = npl; pl = npl; } } } return 0; } static struct pathlist * path_list_check(char *file) { struct pathlist *pl; int len; DPRINT(("path_list check? file=%s\n", file)); len = strlen(file); for (pl = defpathlist; pl != NULL; pl = pl->next) { if (pl->n != NULL) { if (len >= pl->pathlen && strncmp(file, pl->path, pl->pathlen) == 0) { DPRINT(("path list match[%s]:%s <=> %s", pl->pkg, pl->path, file)); return pl; } } } return NULL; } #endif #ifndef PKGCDB_AUTOAPT static char * next_package(char *p, char **np) { int i; static char package[PATH_MAX]; *np = NULL; if (p == NULL || *p == '\0') return NULL; for (i = 0; p[i] != '\0'; i++) { if (p[i] == ',') break; package[i] = tolower(p[i]); } if (p[i] == ',') *np = &p[i+1]; package[i] = '\0'; return package; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API struct path_node * pkgcdb_put(PathNodeTree pnt, char *file, char *pkg, int *nent) { char *package, *dups; char *p; char path[PATH_MAX]; struct path_node *pn, *npn; pkg_id pkgid, npkgid; static int inited = 0; static pkg_id pkg_defs; #ifndef PKGCDB_AUTOAPT static int local_inited = 0; struct pathlist *pl; #endif assert(pnt != NULL); if (!inited) { inited = 1; pkg_defs = pkg_intern(pathnode_strtab(pnt), DEFAULT_PATH_PACKAGE); } DPRINT(("put: <%s><%s>\n", file, pkg)); package = next_package(pkg, &dups); pkgid = pkg_intern(pathnode_strtab(pnt), package); if (strncmp(file, "./", 2) == 0) { file += 2; } pn = pathnode_top(pnt); while (*file != '\0' && *file == '/') file++; #ifndef PKGCDB_AUTOAPT if (strcmp(file, ".") == 0) { if (!local_inited) { /* local mode */ local_inited = 1; MSG(("local file list mode\n")); path_list_local_init(pnt); } return NULL; } /* skip common dirs if available, it increase much performance */ pl = path_list_check(file); if (pl != NULL) { file += pl->pathlen; pn = pl->n; if (strcmp(pl->pkg, DEFAULT_PATH_PACKAGE) == 0) { DPRINT((" start=<%s> %p(%s)", file, pn, pathnode_pathname(pnt, pn))); } else { /* all dir/files under local,man are ignored */ DPRINT((" ignore=<%s> %p(%s)", file, pn, pathnode_pathname(pnt, pn))); return pn; } } #endif p = file; DPRINT((" file? %s\n", p)); while (*p != '\0') { if (*p != '/' || p - file <= 1) { p++; continue; } p++; assert(p - file < PATH_MAX); strncpy(path, file, p - file); path[p - file] = '\0'; DPRINT(("insert=<%s> %s|", path, pkg)); npn = pathnode_insert(pnt, pn, path, pkgid); assert(npn != NULL); npkgid = pathnode_package(pnt, npn); if (nent != NULL) (*nent)++; if (dups) { for (package = next_package(dups, &dups); package != NULL; package = next_package(dups, &dups)) { pkgid = pkg_intern(pathnode_strtab(pnt), package); pathnode_chain(pnt, npn, pkgid); } } if (pkg_cmp(&pkgid, &pkg_defs) != 0 /* default path? */ && pkg_cmp(&npkgid, &pkgid) == 0) { return npn; } file = p; pn = npn; DPRINT(("next=<%s> %p(%s)", file, pn, pathnode_pathname(pnt, pn))); } if (p - file >= 1) { DPRINT(("insert=<%s> %s|", file, pkg)); pn = pathnode_insert(pnt, pn, file, pkgid); if (dups) { for (package = next_package(dups, &dups); package != NULL; package = next_package(dups, &dups)) { pkgid = pkg_intern(pathnode_strtab(pnt), package); pathnode_chain(pnt, pn, pkgid); } } } return pn; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pkgcdb_del(PathNodeTree pnt, char *file, char *pkg, int *nent) { char *package; char *p; int i; char path[PATH_MAX]; struct path_node *pn, *npn; pkg_id pkgid, npkgid; struct pathlist *pl; assert(pnt != NULL); DPRINT(("put: <%s><%s>\n", file, pkg)); package = malloc(strlen(pkg)+1); for (i = 0; pkg[i] != '\0'; i++) { if (pkg[i] == ',') break; package[i] = tolower(pkg[i]); } package[i] = '\0'; pkgid = pkg_intern(pathnode_strtab(pnt), package); free(package); if (strncmp(file, "./", 2) == 0) { file += 2; } pn = pathnode_top(pnt); while (*file != '\0' && *file == '/') file++; pl = path_list_check(file); if (pl != NULL) { file += pl->pathlen; pn = pl->n; if (strcmp(pl->pkg, DEFAULT_PATH_PACKAGE) == 0) { DPRINT((" start=<%s> %p(%s)", file, pn, pathnode_pathname(pnt, pn))); } else { /* all dir/files under local,man are ignored */ DPRINT((" ignore=<%s> %p(%s)", file, pn, pathnode_pathname(pnt, pn))); return; } } p = file; while (*p != '\0') { if (*p != '/' || p - file <= 1) { p++; continue; } p++; assert(p - file < PATH_MAX); strncpy(path, file, p - file); path[p - file] = '\0'; npn = pathnode_retrieve(pnt, pn, path); if (npn == NULL) return; for (pn = npn; pn != NULL; pn = pathnode_next(pnt, pn)) { npkgid = pathnode_package(pnt, pn); if (pkg_cmp(&npkgid, &pkgid) == 0) { pathnode_delete(pnt, pn); if (nent) (*nent)--; } } file = p; pn = npn; DPRINT(("next=<%s> %p(%s)", file, pn, pathnode_pathname(pnt, pn))); } if (p - file >= 1) { pn = pathnode_retrieve(pnt, pn, path); if (pn == NULL) return; for (; pn != NULL; pn = pathnode_next(pnt, pn)) { npkgid = pathnode_package(pnt, pn); if (pkg_cmp(&npkgid, &pkgid) == 0) { pathnode_delete(pnt, pn); if (nent) (*nent)--; } } } return; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pkgcdb_traverse(PathNodeTree pnt, void (*func)(PathNodeTree pnt, char *path, struct path_node *pn, void *arg), void *arg) { struct path_node *pn; pn = pathnode_top(pnt); pathnode_traverse(pnt, NULL, pn, func, arg); } #endif auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/mempool.c0000664000000000000000000001334507666424737015451 0ustar /*- * mempool.c * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ static char mempool_rcsid[] __attribute__ ((unused)) = "$Id: mempool.c,v 1.4 2003/06/01 16:29:19 ukai Exp $"; #include "mempool.h" #include #include #include #include #include struct mempool { struct mempool *m_next; int start; /* start index */ int count; /* count in this pool */ size_t siz; /* element size */ void *mem; /* (count * siz) bytes */ }; PKGCDB_API void mempool_init() { return; } PKGCDB_API struct mempool * mempool_alloc(struct mempool *mp, int count, size_t siz) { int start; struct mempool *nmp; assert(count != 0); assert(siz != 0); if (mp == NULL) { start = 0; } else { start = mp->start + mp->count; assert(mp->siz == siz); } nmp = (struct mempool *)malloc(sizeof(struct mempool)); if (nmp == NULL) { /* not enough memory */ abort(); } memset(nmp, 0, sizeof(struct mempool)); nmp->mem = malloc(count * siz); if (nmp->mem == NULL) { /* not enough memory */ abort(); } memset(nmp->mem, 0, count * siz); nmp->m_next = mp; nmp->start = start; nmp->count = count; nmp->siz = siz; return nmp; } #ifndef PKGCDB_AUTOAPT PKGCDB_API void mempool_release(struct mempool *mp) { struct mempool *cmp, *nmp; assert(mp != NULL); for (cmp = mp; cmp != NULL; cmp = nmp) { nmp = cmp->m_next; if (cmp->mem != NULL) free(cmp->mem); cmp->mem = 0; cmp->start = 0; cmp->count = 0; cmp->siz = 0; cmp->m_next = NULL; free(cmp); } return; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void mempool_shrink(struct mempool *mp, int num) { assert(mp != NULL); assert(num < mp->count); mp->count -= num; } #endif PKGCDB_API void * mempool_mem(struct mempool *mp) { assert(mp != NULL); assert(mp->mem != NULL); return mp->mem; } PKGCDB_API void * mempool_mem_avail(struct mempool *mp, int avail) { assert(mp != NULL); assert(mp->mem != NULL); assert(mp->count >= avail); if (avail == 0) { return NULL; } return ((char *)mp->mem + (mp->count - avail) * mp->siz); } PKGCDB_API int mempool_index(struct mempool *mp, void *ptr) { for (; mp != NULL; mp = mp->m_next) { if (mp->mem <= ptr && (char *)ptr < ((char *)mp->mem + (mp->count * mp->siz))) { assert(((char *)ptr - (char *)mp->mem)%mp->siz == 0); return ((char *)ptr - (char *)mp->mem)/mp->siz + mp->start; } } return -1; } PKGCDB_API void * mempool_fetch(struct mempool *mp, int idx) { for (; mp != NULL; mp = mp->m_next) { if (mp->start <= idx && idx < mp->start + mp->count) { return ((char *)mp->mem + (idx - mp->start) * mp->siz); } } return NULL; } #ifndef PKGCDB_AUTOAPT static int mempool_dump_rec(struct mempool *mp, int count, int siz, int fd, int (*serialize)(void *buf, void *ptr, int count, int siz, void *arg), void *arg) { int e; void *buf = NULL; int len = 0; if (mp == NULL) { DPRINT(("-header: begin\n")); DPRINT((" count=%d\n", count)); e = write(fd, &count, sizeof(int)); if (e < 1) { PERROR(("write count")); return -1; } DPRINT((" siz=%d\n", siz)); e = write(fd, &siz, sizeof(int)); if (e < 1) { PERROR(("write siz")); return -1; } DPRINT(("-header: end\n")); return 0; } e = mempool_dump_rec(mp->m_next, count + mp->count, mp->siz, fd, serialize, arg); if (e < 0) { PERROR(("write data")); return e; } DPRINT((".")); if (serialize != NULL) { buf = malloc(mp->count * mp->siz); len = serialize(buf, mp->mem, mp->count, mp->siz, arg); if (len < 0) { DPRINT(("-serialize error? %d\n", len)); free(buf); return -1; } } else { buf = mp->mem; len = mp->count * mp->siz; } DPRINT(("-data: %d * %d => (%d)\n", mp->count, mp->siz, len)); e = write(fd, buf, len); if (serialize != NULL) free(buf); if (e < 1) { PERROR(("write data")); return -1; } return 0; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API int mempool_dump(struct mempool *mp, int fd, int (*serialize)(void *buf, void *ptr, int count, int siz, void *arg), void *arg) { int e; DPRINT(("\ndump: mem=%p\n", mp)); e = mempool_dump_rec(mp, 0, mp->siz, fd, serialize, arg); DPRINT((" done\n")); return e; } #endif PKGCDB_API struct mempool * mempool_restore(int fd, void (*unserialize)(struct mempool *mp, void *ptr, int count, int siz, void *arg), void *arg, int margin) { struct mempool *mp; int e; DPRINT(("restore ")); mp = (struct mempool *)malloc(sizeof(struct mempool)); if (mp == NULL) { DPRINT(("mempool_restore: not enough memory for mempool header\n")); abort(); } memset(mp, 0, sizeof(struct mempool)); e = read_data(fd, &mp->count, sizeof(int)); if (e != sizeof(int)) { DPRINT(("read count fd:%d e:%d errno:%d\n", fd, e, errno)); PERROR(("read count")); abort(); } DPRINT(("count %d + %d, ", mp->count, margin)); e = read_data(fd, &mp->siz, sizeof(int)); if (e != sizeof(int)) { DPRINT(("read siz fd:%d e:%d errno:%d\n", fd, e, errno)); PERROR(("read siz")); abort(); } DPRINT(("siz %d, ", mp->siz)); mp->mem = malloc((mp->count + margin) * mp->siz); if (mp->mem == NULL) { DPRINT(("mempool_restore: not enough memory for mempool contents\n")); abort(); } e = read_data(fd, mp->mem, mp->count * mp->siz); if (e != mp->count * mp->siz) { DPRINT(("read data fd:%d e:%d errno:%d\n", fd, e, errno)); PERROR(("read data")); abort(); } DPRINT(("...")); if (unserialize != NULL) { unserialize(mp, mp->mem, mp->count, mp->siz, arg); } mp->count += margin; DPRINT(("done\n")); return mp; } auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/pathnode.h0000664000000000000000000000427607132764467015606 0ustar /*- * pathnode.h * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ #ifndef _pathnode_h_ #define _pathnode_h_ static char pathnode_h_rcsid[] __attribute__ ((unused)) = "$Id: pathnode.h,v 1.1 2000/07/12 03:42:47 ukai Exp $"; #include "debug.h" #include "strtab.h" #include "pkgtab.h" typedef struct __pathnode_tree *PathNodeTree; #ifndef PKGCDB_AUTOAPT PKGCDB_API PathNodeTree pathnode_alloc(StrTable st); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pathnode_release(PathNodeTree pnt); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pathnode_ignore_package(PathNodeTree pnt, char *pkg); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API struct path_node *pathnode_insert(PathNodeTree pnt, struct path_node *pn, char *path, pkg_id pkgid); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API struct path_node *pathnode_chain(PathNodeTree pnt, struct path_node *pn, pkg_id pkgid); #endif PKGCDB_API struct path_node *pathnode_retrieve(PathNodeTree pnt, struct path_node *pn, char *path); PKGCDB_API void pathnode_traverse(PathNodeTree pnt, char *path, struct path_node *pn, void (*func)(PathNodeTree pnt, char *path, struct path_node *pn, void *arg), void *arg); #ifndef PKGCDB_AUTOAPT PKGCDB_API StrTable pathnode_strtab(PathNodeTree pnt); #endif PKGCDB_API struct path_node *pathnode_top(PathNodeTree pnt); #ifndef PKGCDB_AUTOAPT PKGCDB_API str_id pathnode_path(PathNodeTree pnt, struct path_node *pn); #endif PKGCDB_API char *pathnode_pathname(PathNodeTree pnt, struct path_node *pn); #ifndef PKGCDB_AUTOAPT PKGCDB_API pkg_id pathnode_package(PathNodeTree pnt, struct path_node *pn); #endif PKGCDB_API char *pathnode_packagename(PathNodeTree pnt, struct path_node *pkg_id); #ifndef PKGCDB_AUTOAPT PKGCDB_API struct path_node *pathnode_next(PathNodeTree pnt, struct path_node *pn); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pathnode_delete(PathNodeTree pnt, struct path_node *pn); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API int pathnode_dump(int fd, PathNodeTree pnt, int shrink); #endif PKGCDB_API PathNodeTree pathnode_restore(int fd, StrTable st, int margin); #endif /* _pathnode_h_ */ auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/strtab.h0000664000000000000000000000145107132764467015273 0ustar /*- * strtab.h * Copyright (c) 2000 Fumitoshi UKAI * GPL */ #ifndef _strtab_h_ #define _strtab_h_ static char strtab_h_rcsid[] __attribute__ ((unused)) = "$Id: strtab.h,v 1.1 2000/07/12 03:42:47 ukai Exp $"; #include "debug.h" #include typedef int str_id; #define str_null 0 typedef struct __strtab *StrTable; #ifndef PKGCDB_AUTOAPT PKGCDB_API StrTable strtab_alloc(); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void strtab_release(StrTable st); #endif PKGCDB_API str_id str_intern(StrTable st, char *string, int add); PKGCDB_API char *str_symbol(StrTable st, str_id sid); /* dump/restore */ #ifndef PKGCDB_AUTOAPT PKGCDB_API int strtab_dump(int fd, StrTable st, int shrink); #endif PKGCDB_API StrTable strtab_restore(int fd, int str_margin); #endif /* _strtab_h_ */ auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/pathnode.c0000664000000000000000000002565607133367626015603 0ustar /*- * pathnode.c * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ static char pathnode_rcsid[] __attribute__ ((unused)) = "$Id: pathnode.c,v 1.3 2000/07/13 16:34:30 ukai Exp $"; #include "pathnode.h" #include "mempool.h" #include "strtab.h" #include "pkgtab.h" #include #include #include #include #define PATH_MEMPOOL_SIZE 8192 /* (4096*10) */ struct path_node { str_id path; char *pathname; pkg_id package; struct path_node *left; struct path_node *right; struct path_node *down; struct path_node *dups; }; struct __pathnode_tree { struct mempool *p_st; struct path_node *top; struct path_node *pn_next; int pn_avail; int pn_alloc; int num_pn; int num_left; int num_right; StrTable st; pkg_id ignore_pkg_id; }; /* XXX: hack * This tree structure show good performance if tree is balanced * so, it's important that cmp()'s ouptput is balanced * * str_id: sequential number (memory index in strtab:mempool) * */ static inline int cmp(str_id s0, str_id s1) { #define h(s) ((s & 0xff) << 24 | (s & 0xff00) << 8 | \ (s & 0xff0000) >> 8 | (s & 0xff000000) >> 24) return h(s0) - h(s1); #undef h } #ifndef PKGCDB_AUTOAPT static struct path_node * pathnode_add(PathNodeTree pnt, str_id pathid, pkg_id pkgid) { struct path_node *pn; assert(pnt != NULL); assert(pnt->st != NULL); if (pnt->pn_next == NULL || pnt->pn_avail <= 0) { pnt->p_st = mempool_alloc(pnt->p_st, PATH_MEMPOOL_SIZE, sizeof(struct path_node)); pnt->pn_next = (struct path_node *)mempool_mem(pnt->p_st); pnt->pn_avail = PATH_MEMPOOL_SIZE; pnt->pn_alloc += PATH_MEMPOOL_SIZE; } pn = pnt->pn_next; memset(pn, 0, sizeof(struct path_node)); pn->path = pathid; pn->pathname = str_symbol(pnt->st, pathid); pn->package = pkgid; pnt->pn_next = pn + 1; pnt->pn_avail--; pnt->num_pn++; return pn; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API PathNodeTree pathnode_alloc(StrTable st) { PathNodeTree pnt; pnt = (PathNodeTree)malloc(sizeof(struct __pathnode_tree)); if (pnt == NULL) return NULL; memset(pnt, 0, sizeof(struct __pathnode_tree)); pnt->st = st; pnt->num_pn = 0; pnt->p_st = mempool_alloc(NULL, PATH_MEMPOOL_SIZE, sizeof(struct path_node)); pnt->pn_next = (struct path_node *)mempool_mem(pnt->p_st); pnt->pn_avail = PATH_MEMPOOL_SIZE; pnt->pn_alloc = PATH_MEMPOOL_SIZE; pnt->top = pathnode_add(pnt, str_null, pkg_null); return pnt; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pathnode_release(PathNodeTree pnt) { assert(pnt != NULL); assert(pnt->p_st != NULL); /* don't release pnt->st for some case StrTable is shared */ pnt->st = NULL; mempool_release(pnt->p_st); pnt->pn_next = NULL; pnt->pn_avail = 0; pnt->pn_alloc = 0; free(pnt); } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pathnode_ignore_package(PathNodeTree pnt, char *pkg) { assert(pnt != NULL); pnt->ignore_pkg_id = pkg_intern(pnt->st, pkg); } #endif /* package should be lowered (case ignored) */ #ifndef PKGCDB_AUTOAPT PKGCDB_API struct path_node * pathnode_insert(PathNodeTree pnt, struct path_node *pn, char *path, pkg_id pkgid) { struct path_node *npn; int r; str_id pathid = str_intern(pnt->st, path, 1); #if DEBUGDEBUG assert(pnt != NULL); DPRINT(("insert: %p(%s) <= [%s, %s]\n", pn, pathnode_pathname(pnt, pn), path, pkg_symbol(pnt->st, pkgid))); #endif if (pn->down == NULL) { npn = pathnode_add(pnt, pathid, pkgid); pn->down = npn; #if DEBUGDEBUG DPRINT(("add: %p(%s)->down = %p [%s, %s]\n", pn, pathnode_pathname(pnt, pn), npn, path, pkg_symbol(pnt->st, pkgid))); #endif return npn; } pn = pn->down; for (;;) { if (pn->pathname == NULL) pn->pathname = str_symbol(pnt->st, pn->path); r = cmp(pn->path, pathid); #if DEBUGDEBUG DPRINT(("check? %s<=>%s [%d]\n", path, pn->pathname, r)); #endif if (r == 0) { /* collision */ return pathnode_chain(pnt, pn, pkgid); } if (r < 0) { if (pn->left == NULL) break; pn = pn->left; pnt->num_left++; } else { if (pn->right == NULL) break; pn = pn->right; pnt->num_right++; } } /* the item was not found in the tree */ npn = pathnode_add(pnt, pathid, pkgid); if (r < 0) { npn->left = pn->left; pn->left = npn; #if DEBUGDEBUG DPRINT(("add: %p(%s)->left = %p [%s, %s]\n", pn, pathnode_pathname(pnt, pn), npn, path, pkg_symbol(pnt->st, pkgid))); #endif } else { npn->right = pn->right; pn->right = npn; #if DEBUGDEBUG DPRINT(("add: %p(%s)->right = %p [%s, %s]\n", pn, pathnode_pathname(pnt, pn), npn, path, pkg_symbol(pnt->st, pkgid))); #endif } return npn; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API struct path_node * pathnode_chain(PathNodeTree pnt, struct path_node *pn, pkg_id pkgid) { struct path_node *p; assert(pn != NULL); if (pkg_cmp(&pkgid, &pn->package) == 0) { return pn; } for (p = pn->dups; p != NULL; p = p->dups) { if (pkg_cmp(&pkgid, &p->package) == 0) { return pn; } if (pkg_cmp(&pnt->ignore_pkg_id, &p->package) == 0) { return pn; } } if (pn->pathname == NULL) pn->pathname = str_symbol(pnt->st, pn->path); /* new one */ p = pathnode_add(pnt, pn->path, pkgid); p->dups = pn->dups; pn->dups = p; #if DEBUGDEBUG DPRINT(("add: %p->dups = %p [%s, %s]\n", pn, p, pn->pathname, pkg_symbol(pnt->st, pkgid))); #endif return pn; } #endif PKGCDB_API struct path_node * pathnode_retrieve(PathNodeTree pnt, struct path_node *pn, char* path) { int r; str_id pathid = str_intern(pnt->st, path, 0); assert(pn != NULL); DPRINT(("retr: %p(%s) %s\n", pn, pathnode_pathname(pnt, pn), path)); pn = pn->down; if (pn == NULL) { DPRINT(("no child?\n")); return pn; } for (;;) { #if DEBUGDEBUG DPRINT(("check?%p %s<=>%s[%d]\n", pn, path, str_symbol(pnt->st, pn->path), pn->path)); #endif if (pn->pathname == NULL) pn->pathname = str_symbol(pnt->st, pn->path); r = cmp(pn->path, pathid); if (r == 0) { DPRINT(("found - ok %p\n", pn)); return pn; } if (r < 0) { #if DEBUGDEBUG DPRINT(("go %p(%s)->left = %p\n", pn, pathnode_pathname(pnt, pn), pn->left)); #endif if (pn->left == NULL) break; pn = pn->left; } else { #if DEBUGDEBUG DPRINT(("go %p(%s)->right = %p\n", pn, pathnode_pathname(pnt, pn), pn->right)); #endif if (pn->right == NULL) break; pn = pn->right; } } DPRINT(("not found\n")); return NULL; } PKGCDB_API void pathnode_traverse(PathNodeTree pnt, char *path, struct path_node *pn, void (*func)(PathNodeTree pnt, char *path, struct path_node *pn, void *arg), void *arg) { char *npath; if (path == NULL) { pathnode_traverse(pnt, "", pn->down, func, arg); return; } if (pn == NULL) return; if (pn->left != NULL) pathnode_traverse(pnt, path, pn->left, func, arg); if (pn->right != NULL) pathnode_traverse(pnt, path, pn->right, func, arg); func(pnt, path, pn, arg); npath = alloca(strlen(path) + strlen(pathnode_pathname(pnt, pn)) + 1); sprintf(npath, "%s%s", path, pathnode_pathname(pnt, pn)); if (pn->down) pathnode_traverse(pnt, npath, pn->down, func, arg); } #ifndef PKGCDB_AUTOAPT PKGCDB_API StrTable pathnode_strtab(PathNodeTree pnt) { assert(pnt != NULL); return pnt->st; } #endif PKGCDB_API struct path_node * pathnode_top(PathNodeTree pnt) { assert(pnt != NULL); return pnt->top; } #ifndef PKGCDB_AUTOAPT PKGCDB_API str_id pathnode_path(PathNodeTree pnt, struct path_node *pn) { assert(pn != NULL); return pn->path; } #endif PKGCDB_API char * pathnode_pathname(PathNodeTree pnt, struct path_node *pn) { assert(pn != NULL); if (pn->pathname == NULL) pn->pathname = str_symbol(pnt->st, pn->path); return pn->pathname; } #ifndef PKGCDB_AUTOAPT PKGCDB_API pkg_id pathnode_package(PathNodeTree pnt, struct path_node *pn) { assert(pn != NULL); return pn->package; } #endif PKGCDB_API char * pathnode_packagename(PathNodeTree pnt, struct path_node *pn) { assert(pn != NULL); return pkg_symbol(pnt->st, pn->package); } #ifndef PKGCDB_AUTOAPT PKGCDB_API struct path_node * pathnode_next(PathNodeTree pnt, struct path_node *pn) { assert(pn != NULL); return pn->dups; } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void pathnode_delete(PathNodeTree pnt, struct path_node *pn) { assert(pn != NULL); pn->package = pkg_null; } #endif #ifndef PKGCDB_AUTOAPT static int pathnode_serialize(void *buf, void *ptr, int count, int siz, void *arg) { int i; PathNodeTree pnt = (PathNodeTree)arg; struct path_node *pn, *pn0; memcpy(buf, ptr, count * siz); pn = (struct path_node *)buf; pn0 = (struct path_node *)ptr; for (i = 0; i < count; i++) { pn->pathname = NULL; /* clear */ if (pn->left) pn->left = (void *)mempool_index(pnt->p_st, pn0->left); if (pn->right) pn->right = (void *)mempool_index(pnt->p_st, pn0->right); if (pn->down) pn->down = (void *)mempool_index(pnt->p_st, pn0->down); if (pn->dups) pn->dups = (void *)mempool_index(pnt->p_st, pn0->dups); pn++; pn0++; } return count * siz; } #endif static void pathnode_unserialize(struct mempool*mp, void *ptr, int count, int siz, void *arg) { int i; /* PathNodeTree pnt = (PathNodeTree)arg; */ struct path_node *pn = ptr; for (i = 0; i < count; i++) { if (pn->left) pn->left = mempool_fetch(mp, (int)pn->left); if (pn->right) pn->right = mempool_fetch(mp, (int)pn->right); if (pn->down) pn->down = mempool_fetch(mp, (int)pn->down); if (pn->dups) pn->dups = mempool_fetch(mp, (int)pn->dups); pn++; } } #ifndef PKGCDB_AUTOAPT PKGCDB_API int pathnode_dump(int fd, PathNodeTree pnt, int shrink) { double rl, rr; if (pnt->num_left > pnt->num_right) { rl = (double)pnt->num_left / pnt->num_right; rr = 1.0; } else { rl = 1.0; rr = (double)pnt->num_right / pnt->num_left; } DPRINT(("pathnode: %d entries, new %d alloc, left %d entries\n" " left=%d times, right=%d times (%f:%f)\n", pnt->num_pn, pnt->pn_alloc, pnt->pn_avail, pnt->num_left, pnt->num_right, rl, rr)); if (shrink) { mempool_shrink(pnt->p_st, pnt->pn_avail); pnt->pn_avail = 0; } DPRINT(("pathnode: dump ")); return mempool_dump(pnt->p_st, fd, pathnode_serialize, pnt); } #endif PKGCDB_API PathNodeTree pathnode_restore(int fd, StrTable st, int margin) { PathNodeTree pnt; DPRINT(("pathnode: ")); pnt = (PathNodeTree)malloc(sizeof(struct __pathnode_tree)); if (pnt == NULL) { DPRINT(("not enough memory\n")); return NULL; } memset(pnt, 0, sizeof(struct __pathnode_tree)); pnt->st = st; pnt->p_st = mempool_restore(fd, pathnode_unserialize, pnt, margin); if (pnt->p_st == NULL) { free(pnt); return NULL; } pnt->top = NULL; pnt->pn_next = mempool_mem_avail(pnt->p_st, margin); pnt->pn_avail = margin; pnt->top = (struct path_node *)mempool_mem(pnt->p_st); return pnt; } auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/pkgtab.h0000664000000000000000000000136707132764467015252 0ustar /*- * pkgtab.h * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ #ifndef _pkgtab_h_ #define _pkgtab_h_ static char pkgtab_h_rcsid[] __attribute__((unused)) = "$Id: pkgtab.h,v 1.1 2000/07/12 03:42:47 ukai Exp $"; #include "debug.h" #include "strtab.h" typedef struct { str_id s[3]; /* [/]/ */ } pkg_id; PKGCDB_VARDECL pkg_id pkg_null; PKGCDB_API void pkgtab_init(); #ifndef PKGCDB_AUTOAPT PKGCDB_API void pkg_init(pkg_id *pid); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API pkg_id pkg_intern(StrTable st, char *pkg); #endif PKGCDB_API char *pkg_symbol(StrTable st, pkg_id pid); #ifndef PKGCDB_AUTOAPT PKGCDB_API int pkg_cmp(pkg_id *p0, pkg_id *p1); #endif /* dump/restore - by strtab */ #endif /* _pkgtab_h_ */ auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/pkgtab.c0000664000000000000000000000364012144264702015223 0ustar /*- * pkgtab.c * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ static char pkgtab_rcsid[] __attribute__((unused)) = "$Id: pkgtab.c,v 1.1 2000/07/12 03:42:47 ukai Exp $"; #include "pkgtab.h" #include #include #include PKGCDB_VARDEF pkg_id pkg_null; PKGCDB_API void pkgtab_init() { static int inited = 0; int i; if (inited) return; inited = 1; for (i = 0; i < 3; i++) pkg_null.s[i] = str_null; } #ifndef PKGCDB_AUTOAPT PKGCDB_API void pkg_init(pkg_id *pid) { assert(pid != NULL); memcpy(pid, &pkg_null, sizeof(pkg_id)); } #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API pkg_id pkg_intern(StrTable st, char *pkg) { char *p; char *buf = NULL; int i = 0; pkg_id pkgid; memset(&pkgid, 0, sizeof(pkgid)); p = pkg; if (*p == '@') { /* special ! */ p = p + strlen(p); goto done; } while (*p != '\0') { if (*p != '/' || p - pkg <= 1) { p++; continue; } p++; buf = (char *)malloc(p - pkg + 1); if (buf == NULL) { abort(); } strncpy(buf, pkg, p - pkg); buf[p - pkg] = '\0'; pkgid.s[i] = str_intern(st, buf, 1); free(buf); i++; pkg = p; assert(i < 3); } done: if (p - pkg >= 1) { pkgid.s[i] = str_intern(st, pkg, 1); } return pkgid; } #endif PKGCDB_API char * pkg_symbol(StrTable st, pkg_id pid) { int len = 0; int i; char *p[3] = { NULL, NULL, NULL }; static char *buf; for (i = 0; i < 3; i++) { if (pid.s[i] == 0) { break; } p[i] = str_symbol(st, pid.s[i]); len += strlen(p[i]); } if (buf != NULL) { free(buf); } buf = (char *)malloc(len + 1); if (buf == NULL) { abort(); } buf[0] = '\0'; for (i = 0; i < 3; i++) { if (p[i]) { strcat(buf, p[i]); } else { break; } } return buf; } #ifndef PKGCDB_AUTOAPT PKGCDB_API int pkg_cmp(pkg_id *p0, pkg_id *p1) { return memcmp(p0, p1, sizeof(pkg_id)); } #endif auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/mempool.h0000664000000000000000000000260007132764467015441 0ustar /*- * mempool.h * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ #ifndef _mempool_h_ #define _mempool_h_ static char mempool_h_rcsid[] __attribute__ ((unused)) = "$Id: mempool.h,v 1.1 2000/07/12 03:42:47 ukai Exp $"; #include "debug.h" #include #include PKGCDB_API void mempool_init(); PKGCDB_API struct mempool *mempool_alloc(struct mempool *mp, int count, size_t siz); #ifndef PKGCDB_AUTOAPT PKGCDB_API void mempool_release(struct mempool *mp); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API void mempool_shrink(struct mempool *mp, int num); #endif PKGCDB_API void *mempool_mem(struct mempool *mp); PKGCDB_API void *mempool_mem_avail(struct mempool *mp, int avail); PKGCDB_API int mempool_index(struct mempool *mp, void *ptr); PKGCDB_API void *mempool_fetch(struct mempool *mp, int idx); #ifndef PKGCDB_AUTOAPT PKGCDB_API int mempool_count(struct mempool *mp); #endif #ifndef PKGCDB_AUTOAPT PKGCDB_API int mempool_dump(struct mempool *mp, int fd, int (*serialize)(void *buf, /* buf[count*siz] */ void *ptr, int count, int siz, void *arg), void *arg); #endif PKGCDB_API struct mempool *mempool_restore(int fd, void (*unserialize)( struct mempool *mp, void *ptr, int count, int siz, void *arg), void *arg, int margin); #endif /* _mempool_h_ */ auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/Makefile0000664000000000000000000000044707132764467015267 0ustar # # Makefile # $Id: Makefile,v 1.1 2000/07/12 03:42:47 ukai Exp $ # DEFS= CC=gcc AR=ar CFLAGS=-g -Wall $(DEFS) OBJS=pkgcdb2.o pathnode.o pkgtab.o strtab.o mempool.o pkgcdb2.a: $(OBJS) $(AR) rc pkgcdb2.a $(OBJS) clean: -rm -f $(OBJS) pkgcdb2.a distclean: clean -rm -f *~ *.bak *.orig *.o auto-apt-0.3.23ubuntu0.14.04.1/pkgcdb/debug.h0000664000000000000000000000212207132764467015056 0ustar /*- * debug.h * Copyright (c) 2000 Fumitoshi UKAI * GPL * */ #ifndef _debug_h_ #define _debug_h_ static char debug_h_rcsid[] __attribute__ ((unused)) = "$Id: debug.h,v 1.1 2000/07/12 03:42:47 ukai Exp $"; #include #include #include #ifdef PKGCDB_AUTOAPT #define PKGCDB_API static #define PKGCDB_VARDECL static #define PKGCDB_VARDEF static #else #define PKGCDB_API #define PKGCDB_VARDECL extern #define PKGCDB_VARDEF #endif #ifdef DEBUG PKGCDB_VARDECL int debug; #define DPRINT(x) if (debug) printf x #else #define DPRINT(x) #endif PKGCDB_VARDECL int verbose; PKGCDB_VARDECL int quiet; #define MSG(x) if (!quiet) printf x #define VMSG(x) if (!quiet && verbose) printf x #define PERROR(x) if (!quiet) perror x static inline int read_data(int fd, void *buf, int siz) { int r = 0; int n = siz; char *p = (char *)buf; while (n > 0) { r = read(fd, p, n); if (r < 0) { if (errno == EINTR) continue; return r; } if (r == 0) { return siz - n; } p += r; n -= r; } return siz; } #endif /* _debug_h_ */