예제 #1
0
int start_deltaupdate(char* diff_pkg_path_name)
{
    int status;
    int wipe_cache = 0;

    LOGI("Start delta update...\n");

    set_deltaupdate_recovery_bootmessage();

    status = install_package(diff_pkg_path_name, &wipe_cache, TEMPORARY_INSTALL_FILE);

    if (status != INSTALL_SUCCESS)
    {
        ui_set_background(BACKGROUND_ICON_ERROR);
        ui_print("Delta update failed.\n");
        finish_recovery("--send_intent=DELTA_UPDATE_FAILED");
        set_deltaupdate_status(DELTA_UPDATE_FAILED, DELTA_UPDATE_FAILED_410);
        reset_fota_cookie();
        return -1;
    }

    // modem update starts only if android update is successful
    status = start_delta_modemupdate(diff_pkg_path_name);
    reset_fota_cookie();

    // modem update is complete. Handle update result.
    if (status != DELTA_UPDATE_SUCCESS_200)
    {
        ui_set_background(BACKGROUND_ICON_ERROR);
        ui_print("Delta update failed(%d)\n",status);
        finish_recovery("--send_intent=DELTA_UPDATE_FAILED");
        set_deltaupdate_status(DELTA_UPDATE_FAILED, DELTA_UPDATE_FAILED_410);
        return -1;
    }

    finish_recovery("--send_intent=DELTA_UPDATE_SUCCESSFUL");
    set_deltaupdate_status(DELTA_UPDATE_SUCCESSFUL, DELTA_UPDATE_SUCCESS_200);

    ui_print("\nAndroid Delta Update Completed \n");
    // Remove all temp files
    remove_tempfiles(diff_pkg_path_name);
    update_fotaprop();
    return 0;
}
예제 #2
0
파일: tempfile.c 프로젝트: 9b/git
static void remove_tempfiles_on_signal(int signo)
{
	remove_tempfiles(1);
	sigchain_pop(signo);
	raise(signo);
}
예제 #3
0
파일: tempfile.c 프로젝트: 9b/git
static void remove_tempfiles_on_exit(void)
{
	remove_tempfiles(0);
}
예제 #4
0
파일: notify.c 프로젝트: JoshCooley/irrd
/* Control the action of performing the udpates and sending
 * out notifications.  Briefly, for auth failures all referenced
 * upd_to: fields will be notified.  For error-free updates (ie,
 * no syntax and no auth errors) notifications will be sent to
 * all referenced notify: and mnt_nfy: field addresses.  The 
 * sender is always notified unless the '-x' command line flag is set
 * (see below).
 *
 * notify () will send the updates to IRRd.  If IRRd encounters
 * an error and/or cannot apply the update the IRRd error message 
 * will be relayed in the notification.
 *
 * 'null_notification' = 1 causes notify () to skip
 * all notifications.  In this case, notify () will send the
 * updates to IRRd but no notifications will be sent. '*tmpfname'
 * is the file template for 'mkstemp ()' to use to build
 * the notification files.  There will be one notification file
 * per unique notify/updto email address.
 *
 * 'null_submission' means the user sent in an empty submission.
 * For an email submission all we have is the email header and an
 * empty body.  For a TCP submission all we have is an empty body
 * and a return IP address.  Note that 'null_submission' would
 * have been better name 'non_null_lines' since 'null_submission'
 * equal to 0 means we have a NULL submission.
 *
 * Return:
 *   void
 *   Results of the updates are included in the notifications.
 */
void notify (trace_t *tr, char *tmpfname, FILE *fin, 
	     int null_submission, int null_notification, int dump_stdout,
	     char *web_origin_str, int rps_dist_flag, char *IRRd_HOST, int IRRd_PORT, 
	     char *db_admin, char *pgpdir, char *dbdir, char *tlogfn,
	     long tlog_fpos, FILE *ack_fd, char * from_ip) {

  ret_info_t rstart;
  trans_info_t trans_info;
  char buf[MAXLINE];
  irrd_result_t *p;
  long offset = 0;
  char pbuf[256];

  /*fprintf (dfile, "Enter notify()\n");*/

  rstart.first = rstart.last = NULL;

  if (rps_dist_flag)
    perform_rpsdist_trans (tr, fin, &rstart, null_submission, 
			   tlogfn, tlog_fpos, IRRd_HOST, IRRd_PORT, dbdir); 
  else
    perform_transactions (tr, fin, &rstart, null_submission, 
			  IRRd_HOST, IRRd_PORT, pgpdir);
    /* JW want to go to this when we make irr_submit/IRRd transaction compliant
    perform_transactions_new (tr, fin, &rstart, null_submission, 
			      IRRd_HOST, IRRd_PORT, pgpdir);
    */

  p = rstart.first;

  /* just to be safe rewind */
  if (fseek (fin, 0L, SEEK_SET) != 0) {
    fprintf (stderr, "ERROR: cannot rewind input file, exit!\n");
    exit (0);
  }

  /* init global data structures */
  nnext = notify_addrs;
  fnext = forward_addrs;
  snext = sender_addrs;
  num_notify = num_forward = num_sender = 0;
  /* pointer to array of file names and handles to 
   * notify/forward mail replies.
   */
  num_hdls = 0; 

  while (fgets (buf, MAXLINE, fin) != NULL) {
    if (strncmp (HDR_START, buf, strlen (HDR_START) - 1))
      continue;

    /* fprintf (dfile, "found a start header %s strlen-(%d)\n", buf, strlen (buf));*/
    
    if (parse_header (tr, fin, &offset, &trans_info))
      break; /* illegal hdr field found or EOF 
		 * (ie, no object after hdr) 
		 */

    /* Make sure sender is not getting duplicate notifications */
    if (trans_info.hdr_fields & FROM_F)
      remove_sender (trans_info.sender_addrs, trans_info.notify_addrs,
		     &(trans_info.nnext));
    else if (dump_stdout) { /* We have a tcp user, ie, an IRRj user */
     trans_info.hdr_fields |= FROM_F;
     if(from_ip == NULL)
       from_ip = "localhost";
     sprintf(pbuf,"TCP(%s)", from_ip);
     strcpy (trans_info.sender_addrs, pbuf);
     trans_info.snext += strlen (trans_info.sender_addrs) + 1;
    }
    trans_info.web_origin_str = web_origin_str;
    if (web_origin_str != NULL) {
      sprintf(pbuf,"%s Route Registry Update", trans_info.source ? trans_info.source : "");
      trans_info.subject = strdup (pbuf);
    }
    /* JW this is for debug only */
    /* print_hdr_struct (dfile, &trans_info); */
    chk_email_fields (&trans_info);
    if (!(trans_info.hdr_fields & OP_F))
      trans_info.op = strdup ("UPDATE");

    if (!(trans_info.hdr_fields & OBJ_KEY_F))
      trans_info.obj_key = strdup ("");

    if (!(trans_info.hdr_fields & OBJ_TYPE_F))
      trans_info.obj_type = strdup ("");

    if (chk_hdr_flds (trans_info.hdr_fields)) {
      build_notify_responses (tr, tmpfname, fin, &trans_info, p, db_admin, 
			      MAX_IRRD_OBJ_SIZE, null_notification);
      if ((trans_info.hdr_fields & OLD_OBJ_FILE_F) &&
	  (*trans_info.old_obj_fname < '0' || *trans_info.old_obj_fname > '9'))
	unlink (trans_info.old_obj_fname);
    }
    /*else
      fprintf (dfile, "nofify () bad hdr file found, skipping...\n");*/

    free_ti_mem (&trans_info);
    p = p->next;
  }

  send_notifies (tr, null_notification, ack_fd, dump_stdout);
  remove_tempfiles (tr);
  /*fprintf (dfile, "Exit notify ()\n");*/
}