~bzoltan/click/transition_mirrors

« back to all changes in this revision

Viewing changes to lib/click/user.vala

  • Committer: CI bot
  • Author(s): Colin Watson
  • Date: 2014-09-29 14:18:29 UTC
  • mfrom: (425.1.104 devel)
  • Revision ID: ps-jenkins@lists.canonical.com-20140929141829-vo7vf415d3f6vkq7
Click 0.4.33: Add scope APIs; fix GC; add "click chroot --name"; make "click destroy" more robust; stop apps when uninstalling them. Fixes: 1324853, 1330770
Approved by: Colin Watson

Show diffs side-by-side

added added

removed removed

Lines of Context:
598
598
                                               old_version, version, name);
599
599
        }
600
600
 
 
601
        private bool
 
602
        stop_running_app (string package, string version)
 
603
        {
 
604
                var res = true;
 
605
                if (! find_on_path ("ubuntu-app-stop"))
 
606
                        return false;
 
607
 
 
608
                Json.Object manifest;
 
609
                try {
 
610
                        manifest = get_manifest (package);
 
611
                } catch (Error e) {
 
612
                        warning ("Can not get manifest for %s", package);
 
613
                        return false;
 
614
                }
 
615
                
 
616
                if (! manifest.has_member ("hooks")) {
 
617
                        warning ("No hooks in manifest %s", package);
 
618
                        return false;
 
619
                }
 
620
                var hooks = manifest.get_object_member ("hooks");
 
621
                foreach (unowned string app_name in hooks.get_members ())
 
622
                {
 
623
                        // FIXME: move this into a "stop_single_app" helper
 
624
                        string[] command = {
 
625
                                "ubuntu-app-stop",
 
626
                                @"$(package)_$(app_name)_$(version)"
 
627
                        };
 
628
                        try {
 
629
                                int exit_status;
 
630
                                Process.spawn_sync
 
631
                                        (null, command, null,
 
632
                                         SpawnFlags.SEARCH_PATH |
 
633
                                         SpawnFlags.STDOUT_TO_DEV_NULL,
 
634
                                         null, null, null, out exit_status);
 
635
                                res &= Process.check_exit_status (exit_status);
 
636
                        } catch (Error e) {
 
637
                                res &= false;
 
638
                        }
 
639
                }
 
640
                return res;
 
641
        }
 
642
 
601
643
        /**
602
644
         * remove:
603
645
         * @package: A package name.
636
678
                                regain_privileges ();
637
679
                        }
638
680
                }
 
681
 
 
682
                drop_privileges ();
 
683
                try {
 
684
                        stop_running_app (package, old_version);
 
685
                } finally {
 
686
                        regain_privileges ();
 
687
                }
 
688
 
639
689
                if (! is_pseudo_user)
640
690
                        package_remove_hooks (db, package, old_version, name);
641
691
        }