コード例 #1
0
        def test_info_update_install(self):
                """Test that pkg info will show last update and install time"""

                os.environ["LC_ALL"] = "C"
                self.image_create(self.rurl)
                self.pkg("install [email protected]")
                path = os.path.join(self.img_path(),
                    "var/pkg/state/installed/catalog.base.C")
                entry = json.load(open(path))["test"]["bronze"][0]["metadata"]
                last_install = catalog.basic_ts_to_datetime(
                    entry["last-install"]).strftime("%c")
                self.pkg(("info bronze | grep 'Last Install Time: "
                    "{0}'").format(last_install))

                # Now update the version.
                self.pkg("install [email protected]")
                entry = json.load(open(path))["test"]["bronze"][0]["metadata"]
                last_install = catalog.basic_ts_to_datetime(
                    entry["last-install"]).strftime("%c")
                self.pkg(("info bronze | grep 'Last Install Time: "
                    "{0}'").format(last_install))

                # Last update should be existed this time.
                last_update = catalog.basic_ts_to_datetime(
                    entry["last-update"]).strftime("%c")
                self.pkg(("info bronze | grep 'Last Update Time: "
                    "{0}'").format(last_update))

                if six.PY3:
                        os.environ["LC_ALL"] = "en_US.UTF-8"
コード例 #2
0
    def test_01_info(self):
        """Verify that the info operation works as expected for
                temporary origins.
                """
        # because we compare date strings we must run this in
        # a consistent locale, which we made 'C'

        os.environ['LC_ALL'] = 'C'

        # Create an image and verify no packages are known.
        self.image_create(self.empty_rurl, prefix=None)
        self.pkg("list -a", exit=1)

        # Verify graceful failure for an empty source alone or in
        # combination with another temporary source.
        self.pkg("info -g {0} \\*".format(self.empty_arc), exit=1)
        self.pkg("info -g {0} -g {1} foo".format(self.empty_arc, self.foo_arc),
                 exit=1)

        # Verify graceful failure if source doesn't exist.
        self.pkg("info -g {0} foo".format(self.foo_arc + ".nosuchpkg"), exit=1)

        # Verify graceful failure if user doesn't have permission to
        # access temporary source.
        self.pkg("info -g {0} foo".format(self.perm_arc), su_wrap=True, exit=1)

        # Verify graceful failure if -l is used with -g.
        self.pkg("info -l -g {0} foo".format(self.foo_arc), exit=2)

        # Verify output for a single package temporary source.
        # -r is used here to verify that even though -r is implicit,
        # it is not an error to specify it.
        def pd(pfmri):
            return pfmri.version.get_timestamp().strftime("%c")

        self.pkg("info -r -g {0} foo".format(self.foo_arc), su_wrap=True)
        expected = """\
          Name: foo
       Summary: Example package foo.
         State: Not installed
     Publisher: test
       Version: 1.0
        Branch: None
Packaging Date: {pkg_date}
          Size: 41.00 B
          FMRI: {pkg_fmri}
""".format(pkg_date=pd(self.foo10),
           pkg_fmri=self.foo10.get_fmri(include_build=False))
        self.assertEqualDiff(expected, self.output)

        # Again, as prvileged user.
        self.pkg("info -r -g {0} foo".format(self.foo_arc))
        self.assertEqualDiff(expected, self.output)

        # Note that -r is implicit when -g is used, so all of
        # the following tests purposefully omit it.

        # Verify info output for a multiple package temporary source
        # as an unprivileged user.
        self.pkg("info -g {0} \\*".format(self.all_arc), su_wrap=True)
        expected = """\
          Name: foo
       Summary: Example package foo.
         State: Not installed
     Publisher: test
       Version: 1.0
        Branch: None
Packaging Date: {foo10_pkg_date}
          Size: 41.00 B
          FMRI: {foo10_pkg_fmri}

          Name: incorp
       Summary: Incorporation
         State: Not installed
     Publisher: test
       Version: 2.0
        Branch: None
Packaging Date: {incorp20_pkg_date}
          Size: 0.00 B
          FMRI: {incorp20_pkg_fmri}

          Name: quux
       Summary: Example package quux.
         State: Not installed
     Publisher: test2
       Version: 1.0
        Branch: 0.2
Packaging Date: {quux10_pkg_date}
          Size: 8.00 B
          FMRI: {quux10_pkg_fmri}

          Name: signed
         State: Not installed
     Publisher: test
       Version: 1.0
        Branch: None
Packaging Date: {signed10_pkg_date}
          Size: 10.37 kB
          FMRI: {signed10_pkg_fmri}
""".format(**{"foo10_pkg_date": pd(self.foo10), "foo10_pkg_fmri": \
self.foo10.get_fmri(include_build=False),
              "incorp20_pkg_date": pd(self.incorp20), "incorp20_pkg_fmri": \
self.incorp20.get_fmri(include_build=False),
              "quux10_pkg_date": pd(self.quux10), "quux10_pkg_fmri": \
self.quux10.get_fmri(include_build=False),
              "signed10_pkg_date": pd(self.signed10), "signed10_pkg_fmri": \
self.signed10.get_fmri(include_build=False),
              })
        self.assertEqualDiff(expected, self.output)

        # Verify info output for a multiple package temporary source.
        self.pkg("info -g {0} [email protected] [email protected] [email protected] "
                 "[email protected]".format(self.all_arc))
        self.assertEqualDiff(expected, self.output)

        # Verify info result for multiple temporary sources using
        # different combinations of archives and repositories.
        self.pkg("info -g {0} -g {1} [email protected] [email protected] [email protected]".format(
            self.signed_arc, self.foo_rurl))

        self.pkg("info -g {0} -g {1} -g {2} -g {3} [email protected] [email protected] "
                 "[email protected] [email protected]".format(self.signed_arc, self.incorp_arc,
                                              self.quux_arc, self.foo_arc))

        self.pkg("info -g {0} -g {1} -g {2} -g {3} [email protected] [email protected] "
                 "[email protected] [email protected]".format(self.signed_arc, self.incorp_arc,
                                              self.quux_arc, self.foo_rurl))

        self.pkg("info -g {0} -g {1} [email protected] [email protected] [email protected] "
                 "[email protected]".format(self.all_arc, self.all_rurl))

        # Verify package installed from archive shows in default info
        # output.
        self.pkg("install -g {0} [email protected]".format(self.foo_arc))
        self.pkg("info")

        os.environ["LC_ALL"] = "C"
        path = os.path.join(self.img_path(),
                            "var/pkg/state/installed/catalog.base.C")
        entry = json.load(open(path))["test"]["foo"][0]["metadata"]
        pkg_install = catalog.basic_ts_to_datetime(
            entry["last-install"]).strftime("%c")

        expected = """\
             Name: foo
          Summary: Example package foo.
            State: Installed (Manually installed)
        Publisher: test
          Version: 1.0
           Branch: None
   Packaging Date: {pkg_date}
Last Install Time: {pkg_install}
             Size: 41.00 B
             FMRI: {pkg_fmri}
""".format(pkg_date=pd(self.foo10),
           pkg_fmri=self.foo10.get_fmri(include_build=False),
           pkg_install=pkg_install)
        self.assertEqualDiff(expected, self.output)

        # Verify that when showing package info from archive that
        # package shows as installed if it matches the installed one.
        self.pkg("info -g {0} foo".format(self.foo_arc))
        expected = expected.replace(' (Manually installed)', '')
        self.assertEqualDiff(expected, self.output)

        # Uninstall all packages and verify there are no known packages.
        self.pkg("uninstall \\*")
        self.pkg("info -r \\*", exit=1)

        # Verify that --license works as expected with -g.
        self.pkg("info -g {0} --license [email protected]".format(
            self.licensed_rurl))
        self.assertEqualDiff("tmp/LICENSE\n", self.output)
        self.pkg("info -g {0} --license licensed".format(self.licensed_rurl))
        self.assertEqualDiff("tmp/LICENSE2\n", self.output)

        # Cleanup.
        self.image_destroy()
        # Change locale back to 'UTF-8' to not affect other test cases.
        if six.PY3:
            os.environ["LC_ALL"] = "en_US.UTF-8"
コード例 #3
0
    def test_01_info(self):
        """Verify that the info operation works as expected when
                compositing publishers.
                """
        # because we compare date strings we must run this in
        # a consistent locale, which we made 'C'

        os.environ['LC_ALL'] = 'C'

        # Create an image and verify no packages are known.
        self.image_create(self.empty_rurl, prefix=None)
        self.pkg("list -a", exit=1)

        # Verify info result for multiple disparate sources using
        # different combinations of archives and repositories.
        self.pkg("set-publisher -g {0} -g {1} test".format(
            self.signed_arc, self.foo_rurl))
        self.pkg("info -r [email protected] [email protected]")

        self.pkg("set-publisher -G {0} -g {1} -g {2} test".format(
            self.foo_rurl, self.foo_arc, self.incorp_arc))
        self.pkg("set-publisher -g {0} test2".format(self.quux_arc))
        self.pkg("info -r [email protected] [email protected] [email protected] [email protected]")

        self.pkg("set-publisher -G {0} -g {1} test".format(
            self.foo_arc, self.foo_rurl))
        self.pkg("info -g {0} -g {1} -g {2} -g {3} [email protected] [email protected] "
                 "[email protected] [email protected]".format(self.signed_arc, self.incorp_arc,
                                              self.quux_arc, self.foo_rurl))

        self.pkg("set-publisher -G \* -g {0} -g {1} test".format(
            self.all_arc, self.all_rurl))
        self.pkg("set-publisher -G \* -g {0} -g {1} test2".format(
            self.all_arc, self.all_rurl))
        self.pkg("info -r [email protected] [email protected] [email protected] [email protected]")

        # Verify package installed from archive shows in default info
        # output.
        self.pkg("install [email protected]")
        self.pkg("info")

        path = os.path.join(self.img_path(),
                            "var/pkg/state/installed/catalog.base.C")

        entry = json.load(open(path))["test"]["foo"][0]
        pkg_install = catalog.basic_ts_to_datetime(
            entry["metadata"]["last-install"]).strftime("%c")
        expected = """\
             Name: foo
          Summary: Example package foo.
            State: Installed
        Publisher: test
          Version: 1.0
           Branch: None
   Packaging Date: {pkg_date}
Last Install Time: {pkg_install}
             Size: 41.00 B
             FMRI: {pkg_fmri}
""".format(pkg_date=self.foo10.version.get_timestamp().strftime("%c"),
           pkg_fmri=self.foo10.get_fmri(include_build=False),
           pkg_install=pkg_install)
        self.assertEqualDiff(expected, self.output)

        # Change locale back to 'UTF-8' to not affect other test cases.
        if six.PY3:
            os.environ["LC_ALL"] = "en_US.UTF-8"