Esempio n. 1
0
static void
pkg_disappear(struct pkginfo *pkg, struct pkginfo *infavour)
{
  printf(_("(Noting disappearance of %s, which has been completely replaced.)\n"),
         pkg_name(pkg, pnaw_nonambig));
  log_action("disappear", pkg, &pkg->installed);
  debug(dbg_general, "pkg_disappear disappearing %s",
        pkg_name(pkg, pnaw_nonambig));

  trig_activate_packageprocessing(pkg);
  maintainer_script_installed(pkg, POSTRMFILE,
                              "post-removal script (for disappearance)",
                              "disappear",
                              infavour->set->name,
                              versiondescribe(&infavour->available.version,
                                              vdew_nonambig),
                              NULL);

  /* OK, now we delete all the stuff in the ‘info’ directory .. */
  debug(dbg_general, "pkg_disappear cleaning info directory");
  pkg_infodb_foreach(pkg, &pkg->installed, pkg_infodb_remove_file);
  dir_sync_path(pkgadmindir());

  pkg_set_status(pkg, stat_notinstalled);
  pkg_set_want(pkg, want_unknown);
  pkg_reset_eflags(pkg);

  blankversion(&pkg->configversion);
  pkgbin_blank(&pkg->installed);

  pkg->clientdata->fileslistvalid = false;

  modstatdb_note(pkg);
}
Esempio n. 2
0
/*
 * If mask is nonzero, will not write any file whose filenamenode
 * has any flag bits set in mask.
 */
void
write_filelist_except(struct pkginfo *pkg, struct pkgbin *pkgbin,
                      struct fileinlist *list, enum fnnflags mask)
{
  static struct varbuf newvb;
  const char *listfile;
  FILE *file;

  listfile = pkgadminfile(pkg, pkgbin, LISTFILE);

  varbuf_reset(&newvb);
  varbuf_add_str(&newvb, listfile);
  varbuf_add_str(&newvb, NEWDBEXT);
  varbuf_end_str(&newvb);

  file= fopen(newvb.buf,"w+");
  if (!file)
    ohshite(_("unable to create updated files list file for package %s"),
            pkg_describe(pkg, pdo_foreign));
  push_cleanup(cu_closestream, ehflag_bombout, NULL, 0, 1, (void *)file);
  while (list) {
    if (!(mask && (list->namenode->flags & mask))) {
      fputs(list->namenode->name,file);
      putc('\n',file);
    }
    list= list->next;
  }
  if (ferror(file))
    ohshite(_("failed to write to updated files list file for package %s"),
            pkg_describe(pkg, pdo_foreign));
  if (fflush(file))
    ohshite(_("failed to flush updated files list file for package %s"),
            pkg_describe(pkg, pdo_foreign));
  if (fsync(fileno(file)))
    ohshite(_("failed to sync updated files list file for package %s"),
            pkg_describe(pkg, pdo_foreign));
  pop_cleanup(ehflag_normaltidy); /* file = fopen() */
  if (fclose(file))
    ohshite(_("failed to close updated files list file for package %s"),
            pkg_describe(pkg, pdo_foreign));
  if (rename(newvb.buf, listfile))
    ohshite(_("failed to install updated files list file for package %s"),
            pkg_describe(pkg, pdo_foreign));

  dir_sync_path(pkgadmindir());

  note_must_reread_files_inpackage(pkg);
}
Esempio n. 3
0
static void
pkg_infodb_update(struct pkginfo *pkg, char *cidir, char *cidirrest)
{
  struct match_node *match_node;
  DIR *dsd;
  struct dirent *de;

  /* Deallocate the match list in case we aborted previously. */
  while ((match_node = match_head)) {
    match_head = match_node->next;
    match_node_free(match_node);
  }

  pkg_infodb_foreach(pkg, &pkg->available, pkg_infodb_update_file);

  while ((match_node = match_head)) {
    strcpy(cidirrest, match_node->filetype);

    if (!rename(cidir, match_node->filename)) {
      debug(dbg_scripts, "process_archive info installed %s as %s",
            cidir, match_node->filename);
    } else if (errno == ENOENT) {
      /* Right, no new version. */
      if (unlink(match_node->filename))
        ohshite(_("unable to remove obsolete info file `%.250s'"),
                match_node->filename);
      debug(dbg_scripts, "process_archive info unlinked %s",
            match_node->filename);
    } else {
      ohshite(_("unable to install (supposed) new info file `%.250s'"), cidir);
    }
    match_head = match_node->next;
    match_node_free(match_node);
  }

  /* The control directory itself. */
  cidirrest[0] = '\0';
  dsd = opendir(cidir);
  if (!dsd)
    ohshite(_("unable to open temp control directory"));
  push_cleanup(cu_closedir, ~0, NULL, 0, 1, (void *)dsd);
  while ((de = readdir(dsd))) {
    const char *newinfofilename;

    if (strchr(de->d_name, '.')) {
      debug(dbg_scripts,"process_archive tmp.ci script/file `%s' contains dot",
            de->d_name);
      continue;
    }
    if (strlen(de->d_name) > MAXCONTROLFILENAME)
      ohshit(_("package contains overly-long control info file name (starting `%.50s')"),
             de->d_name);

    strcpy(cidirrest, de->d_name);

    /* First we check it's not a directory. */
    if (rmdir(cidir) == 0)
      ohshit(_("package control info contained directory `%.250s'"), cidir);
    else if (errno != ENOTDIR)
      ohshite(_("package control info rmdir of `%.250s' didn't say not a dir"),
              de->d_name);

    /* Ignore the control file. */
    if (strcmp(de->d_name, CONTROLFILE) == 0) {
      debug(dbg_scripts, "process_archive tmp.ci script/file `%s' is control",
            cidir);
      continue;
    }
    if (strcmp(de->d_name, LISTFILE) == 0) {
      warning(_("package %s contained list as info file"),
              pkgbin_name(pkg, &pkg->available, pnaw_nonambig));
      continue;
    }

    /* Right, install it */
    newinfofilename = pkgadminfile(pkg, &pkg->available, de->d_name);
    if (rename(cidir, newinfofilename))
      ohshite(_("unable to install new info file `%.250s' as `%.250s'"),
              cidir, newinfofilename);

    debug(dbg_scripts,
          "process_archive tmp.ci script/file `%s' installed as `%s'",
          cidir, newinfofilename);
  }
  pop_cleanup(ehflag_normaltidy); /* closedir */

  dir_sync_path(pkgadmindir());
}