Пример #1
0
static IndexEntryPtr
new_index(char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *deps, int volume)
{
    IndexEntryPtr tmp = safe_malloc(sizeof(IndexEntry));

    tmp->name =		_strdup(name);
    tmp->path =		_strdup(pathto);
    tmp->prefix =	_strdup(prefix);
    tmp->comment =	_strdup(comment);
    tmp->descrfile =	strip(_strdup(descr));
    tmp->maintainer =	_strdup(maint);
    tmp->deps =		_strdup(deps);
    tmp->depc =		0;
    tmp->installed =	package_installed(name);
    tmp->vol_checked =	0;
    tmp->volume =	volume;
    if (volume != 0) {
	have_volumes = TRUE;
	if (low_volume == 0)
	    low_volume = volume;
	else if (low_volume > volume)
	    low_volume = volume;
	if (high_volume < volume)
	    high_volume = volume;
    }
    return tmp;
}
Пример #2
0
int
index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended,
    int current_volume)
{
    int status = DITEM_SUCCESS;
    Boolean notyet = FALSE;
    PkgNodePtr tmp2;
    IndexEntryPtr id = who->data;
    WINDOW *w;

    /* 
     * Short-circuit the package dependency checks.  We're already
     * maintaining a data structure of installed packages, so if a
     * package is already installed, don't try to check to make sure
     * that all of its dependencies are installed.  At best this
     * wastes a ton of cycles and can cause minor delays between
     * package extraction.  At worst it can cause an infinite loop with
     * a certain faulty INDEX file. 
     */

    if (id->installed == 1 || (have_volumes && id->vol_checked == current_volume))
	return DITEM_SUCCESS;

    w = savescr();
    if (id && id->deps && strlen(id->deps)) {
	char t[2048 * 8], *cp, *cp2;

	SAFE_STRCPY(t, id->deps);
	cp = t;
	while (cp && DITEM_STATUS(status) == DITEM_SUCCESS) {
	    if ((cp2 = index(cp, ' ')) != NULL)
		*cp2 = '\0';
	    if ((tmp2 = index_search(top, cp, NULL)) != NULL) {
		status = index_extract(dev, top, tmp2, TRUE, current_volume);
		if (DITEM_STATUS(status) != DITEM_SUCCESS) {
		    /* package probably on a future disc volume */
		    if (status & DITEM_CONTINUE) {
			status = DITEM_SUCCESS;
			notyet = TRUE;
		    } else if (variable_get(VAR_NO_CONFIRM))
			msgNotify("Loading of dependent package %s failed", cp);
		    else
			msgConfirm("Loading of dependent package %s failed", cp);
		}
	    }
	    else if (!package_installed(cp)) {
		if (variable_get(VAR_NO_CONFIRM))
		    msgNotify("Warning: %s is a required package but was not found.", cp);
		else
		    msgConfirm("Warning: %s is a required package but was not found.", cp);
	    }
	    if (cp2)
		cp = cp2 + 1;
	    else
		cp = NULL;
	}
    }

    /*
     * If iterating through disc volumes one at a time indicate failure if
     * dependency install failed due to package being on a higher volume
     * numbered disc, but that we should continue anyway.  Note that this
     * package has already been processed for this disc volume so we don't
     * need to do it again.
     */

    if (notyet) {
    	restorescr(w);
	id->vol_checked = current_volume;
	return DITEM_FAILURE | DITEM_CONTINUE;
    }

    /*
     * Done with the deps?  Try to load the real m'coy.  If iterating
     * through a multi-volume disc set fail the install if the package
     * is on a higher numbered volume to cut down on disc switches the
     * user needs to do, but indicate caller should continue processing
     * despite error return.  Note this package was processed for the
     * current disc being checked.
     */

    if (DITEM_STATUS(status) == DITEM_SUCCESS) {
	/* Prompt user if the package is not available on the current volume. */
	if(mediaDevice->type == DEVICE_TYPE_CDROM) {
	    if (current_volume != 0 && id->volume > current_volume) {
		restorescr(w);
		id->vol_checked = current_volume;
		return DITEM_FAILURE | DITEM_CONTINUE;
	    }
	    while (id->volume != dev->volume) {
		if (!msgYesNo("This is disc #%d.  Package %s is on disc #%d\n"
			  "Would you like to switch discs now?\n", dev->volume,
			  id->name, id->volume)) {
		    DEVICE_SHUTDOWN(mediaDevice);
		    msgConfirm("Please remove disc #%d from your drive, and add disc #%d\n",
			dev->volume, id->volume);
		    DEVICE_INIT(mediaDevice);
		} else {
		    restorescr(w);
		    return DITEM_FAILURE;
		}
	    }
	}
	status = package_extract(dev, who->name, depended);
	if (DITEM_STATUS(status) == DITEM_SUCCESS)
	    id->installed = 1;
    }
    restorescr(w);
    return status;
}
int main() {
  int retval;
  char dev[1024];
  int i=0;

  printf("elh\n");

  if (getuid() != 0) {
    printf("not running as root\n");
    exit(1);
  }

  populate_installed_packages();

  while (packages[i][0] != '\0') {
    if (package_installed(packages[i]) != -1) {
      remove_package(packages[i], i);
    }
    i++;
  }

  getSystemMountPoint(dev);

  errno = 0;
  retval = mount(dev, "/system", "ignored", MS_REMOUNT, NULL);
  llog("mnt rw", retval);

  if (retval != 0) {
    // no use continuing if we can't remount read-write
    exit(1);
  }

  if (file_exists("/system/app/DownloadProvidersManager.apk")) {
    errno = 0;
    retval = unlink("/system/app/DownloadProvidersManager.apk");
    llog("rm DownloadProvidersManager", retval);

    errno = 0;
    printf("pm uninst downloadsmanager:");
    fflush(stdout);
    system("/system/bin/pm uninstall com.android.providers.downloadsmanager");
  }

  if (file_exists("/system/app/com.android.providers.ammanage.apk")) {
    errno = 0;
    retval = unlink("/system/app/com.android.providers.ammanage.apk");
    llog("rm ammanager", retval);

    errno = 0;
    printf("pm uninst ammanager:");
    fflush(stdout);
    system("/system/bin/pm uninstall com.android.providers.ammanage");
  }

  if (file_exists("/system/bin/profile")) {
    errno = 0;
    retval = unlink("/system/bin/profile");
    llog("rm profile", retval);
  }

  if (file_exists("/system/bin/share")) {
    errno = 0;
    retval = unlink("/system/bin/share");
    llog("rm share", retval);
  }

  /*
   * technically it's ok if the next line fails, as the
   * filesystem will be mounted read-only on the next boot
   */
  errno = 0;
  retval = mount(dev, "/system", "ignored", MS_REMOUNT | MS_RDONLY, NULL);
  llog("mnt ro", retval);

  return 0;
}