aboutsummaryrefslogtreecommitdiff
path: root/tests/guix-pack-localstatedir.sh
blob: 042887ea9b326c22ed732fde4b32a8ad8d2e212b (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# GNU Guix --- Functional package management for GNU
# Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
# GNU Guix is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# GNU Guix is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

#
# Test the 'guix pack --localstatedir' command-line utility.
#

guix pack --version

# 'guix pack --localstatedir' produces derivations that depend on
# guile-sqlite3 and guile-gcrypt.  To make that relatively inexpensive, run
# the test in the user's global store if possible, on the grounds that
# binaries may already be there or can be built or downloaded inexpensively.

storedir="`guile -c '(use-modules (guix config))(display %storedir)'`"
localstatedir="`guile -c '(use-modules (guix config))(display %localstatedir)'`"
NIX_STORE_DIR="$storedir"
GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket"
export NIX_STORE_DIR GUIX_DAEMON_SOCKET

if ! guile -c '(use-modules (guix)) (exit (false-if-exception (open-connection)))'
then
    exit 77
fi

# Build a tarball with '--localstatedir'
the_pack="`guix pack -C none --localstatedir --profile-name=current-guix \
            guile-bootstrap`"
test_directory="`mktemp -d`"
trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT

cd "$test_directory"
tar -xf "$the_pack"

profile="`find -name current-guix`"
test "`readlink $profile`" = "current-guix-1-link"
test -s "`dirname $profile`/../../../db/db.sqlite"
test -x ".`guix build guile-bootstrap`/bin/guile"
cd -

# Make sure the store database is not completely bogus.
guile -c "(use-modules (sqlite3) (guix config) (ice-9 match))

  (define db
    (sqlite-open (string-append \"$test_directory\"
                                %localstatedir
                               \"/guix/db/db.sqlite\")
                 SQLITE_OPEN_READONLY))

  (define stmt
    (sqlite-prepare db \"SELECT * FROM ValidPaths;\"))

  (match (sqlite-fold cons '() stmt)
    ((#(ids paths hashes times derivers sizes) ...)
     (exit (member \"`guix build guile-bootstrap`\" paths))))"
em' style='width: 68.4%;'/>
4 files changed, 14 insertions, 31 deletions
diff --git a/src/hydrilla/item_infos.py b/src/hydrilla/item_infos.py
index eb9a053..9a87b40 100644
--- a/src/hydrilla/item_infos.py
+++ b/src/hydrilla/item_infos.py
@@ -151,8 +151,6 @@ class ItemIdentity:
@dc.dataclass(frozen=True) # type: ignore[misc]
class ItemInfoBase(ABC, ItemIdentity, Categorizable):
"""...."""
- type_name: t.ClassVar[str]
-
source_name: str = dc.field(hash=False, compare=False)
source_copyright: tuple[FileSpecifier, ...] = dc.field(hash=False, compare=False)
uuid: t.Optional[str] = dc.field(hash=False, compare=False)
@@ -254,8 +252,6 @@ class CorrespondsToMappingDCMixin:
@dc.dataclass(frozen=True, unsafe_hash=True)
class ResourceInfo(ItemInfoBase, CorrespondsToResourceDCMixin):
"""...."""
- type_name: t.ClassVar[str] = 'resource'
-
revision: int = dc.field(hash=False, compare=False)
dependencies: tuple[ItemSpecifier, ...] = dc.field(hash=False, compare=False)
scripts: tuple[FileSpecifier, ...] = dc.field(hash=False, compare=False)
@@ -343,8 +339,6 @@ def make_payloads(payloads_obj: t.Mapping[str, t.Any]) \
@dc.dataclass(frozen=True, unsafe_hash=True)
class MappingInfo(ItemInfoBase, CorrespondsToMappingDCMixin):
"""...."""
- type_name: t.ClassVar[str] = 'mapping'
-
payloads: t.Mapping[ParsedPattern, ItemSpecifier] = \
dc.field(hash=False, compare=False)
@@ -412,7 +406,7 @@ def _load_item_info(
"""Read, validate and autocomplete a mapping/resource description."""
instance = json_instances.read_instance(instance_source)
- schema_fmt = f'api_{info_type.type_name}_description-{{}}.schema.json'
+ schema_fmt = f'api_{info_type.type.value}_description-{{}}.schema.json'
schema_compat = json_instances.validate_instance(instance, schema_fmt)
diff --git a/src/hydrilla/proxy/state_impl/_operations/load_packages.py b/src/hydrilla/proxy/state_impl/_operations/load_packages.py
index f8fddfa..ca6baba 100644
--- a/src/hydrilla/proxy/state_impl/_operations/load_packages.py
+++ b/src/hydrilla/proxy/state_impl/_operations/load_packages.py
@@ -271,7 +271,7 @@ def _add_item(
repo_iteration_id: int,
repo_id: int
) -> None:
- item_id = get_or_make_item(cursor, info.type_name, info.identifier)
+ item_id = get_or_make_item(cursor, info.type.value, info.identifier)
if isinstance(info, item_infos.MappingInfo):
make_mapping_status(cursor, item_id)
@@ -343,9 +343,9 @@ AnyInfoVar = t.TypeVar(
item_infos.MappingInfo
)
-def _read_items(malcontent_path: Path, item_class: t.Type[AnyInfoVar]) \
+def _read_items(malcontent_path: Path, info_class: t.Type[AnyInfoVar]) \
-> t.Iterator[tuple[AnyInfoVar, bytes]]:
- item_type_path = malcontent_path / item_class.type_name
+ item_type_path = malcontent_path / info_class.type.value
if not item_type_path.is_dir():
return
@@ -355,7 +355,7 @@ def _read_items(malcontent_path: Path, item_class: t.Type[AnyInfoVar]) \
for item_version_path in item_path.iterdir():
definition = item_version_path.read_bytes()
- item_info = item_class.load(definition)
+ item_info = info_class.load(definition)
assert item_info.identifier == item_path.name
assert versions.version_string(item_info.version) == \
@@ -383,15 +383,11 @@ def _load_packages_no_state_update(
repo_iteration_id = make_repo_iteration(cursor, repo_id)
- types: t.Iterable[t.Type[item_infos.AnyInfo]] = \
- [item_infos.ResourceInfo, item_infos.MappingInfo]
-
- for info_type in types:
+ for type in [item_infos.ItemType.RESOURCE, item_infos.ItemType.MAPPING]:
info: item_infos.AnyInfo
-
for info, definition in _read_items( # type: ignore
malcontent_path,
- info_type
+ type.info_class
):
_add_item(
cursor = cursor,
diff --git a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
index 327a195..b62004c 100644
--- a/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
+++ b/src/hydrilla/proxy/state_impl/_operations/recompute_dependencies.py
@@ -62,7 +62,7 @@ def _get_infos_of_type(cursor: sqlite3.Cursor, info_type: t.Type[AnyInfoVar],) \
WHERE
i.type = ?;
''',
- (info_type.type_name[0].upper(),)
+ (info_type.type.value[0].upper(),)
)
result: dict[int, AnyInfoVar] = {}
diff --git a/src/hydrilla/server/malcontent.py b/src/hydrilla/server/malcontent.py
index ce24330..af925a0 100644
--- a/src/hydrilla/server/malcontent.py
+++ b/src/hydrilla/server/malcontent.py
@@ -120,12 +120,8 @@ class Malcontent:
fmt = _('err.server.malcontent_path_not_dir_{}')
raise HaketiloException(fmt.format(malcontent_dir_path))
- types: t.Iterable[t.Type[item_infos.AnyInfo]] = (
- item_infos.MappingInfo,
- item_infos.ResourceInfo
- )
- for info_type in types:
- type_path = self.malcontent_dir_path / info_type.type_name
+ for type in [item_infos.ItemType.RESOURCE, item_infos.ItemType.MAPPING]:
+ type_path = self.malcontent_dir_path / type.value
if not type_path.is_dir():
continue
@@ -135,7 +131,7 @@ class Malcontent:
for ver_file in subpath.iterdir():
try:
- self._load_item(info_type, ver_file)
+ self._load_item(type, ver_file)
except:
if self.werror:
raise
@@ -174,11 +170,8 @@ class Malcontent:
versioned_info = infos.get(identifier, VersionedItemInfo())
infos[identifier] = versioned_info.register(item_info)
- def _load_item(
- self,
- info_type: t.Type[item_infos.AnyInfo],
- ver_file: Path
- ) -> None:
+ def _load_item(self, type: item_infos.ItemType, ver_file: Path) \
+ -> None:
"""
Reads, validates and autocompletes serveable mapping/resource
definition, then registers information from it in data structures.
@@ -186,7 +179,7 @@ class Malcontent:
version = versions.parse(ver_file.name)
identifier = ver_file.parent.name
- item_info = info_type.load(ver_file)
+ item_info = type.info_class.load(ver_file)
if item_info.identifier != identifier:
fmt = _('err.server.item_{item}_in_file_{file}')