Gentoo Archives: gentoo-commits

From: "André Erdmann" <dywi@×××××××.de>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/overlay/pkgdir/distroot/, roverlay/overlay/pkgdir/, roverlay/overlay/
Date: Thu, 29 Aug 2013 13:53:18
Message-Id: 1377784377.97b236b9c2deecb109a7bf484f1d795eb9ad74fd.dywi@gentoo
1 commit: 97b236b9c2deecb109a7bf484f1d795eb9ad74fd
2 Author: André Erdmann <dywi <AT> mailerd <DOT> de>
3 AuthorDate: Thu Aug 29 13:52:57 2013 +0000
4 Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
5 CommitDate: Thu Aug 29 13:52:57 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=97b236b9
7
8 roverlay/overlay: comments
9
10 ---
11 roverlay/overlay/base.py | 27 +++++++++++++----
12 roverlay/overlay/pkgdir/distroot/distroot.py | 45 +++++++++++++++++++++++-----
13 roverlay/overlay/pkgdir/packagedir_base.py | 2 +-
14 3 files changed, 60 insertions(+), 14 deletions(-)
15
16 diff --git a/roverlay/overlay/base.py b/roverlay/overlay/base.py
17 index b380e8f..74ab29e 100644
18 --- a/roverlay/overlay/base.py
19 +++ b/roverlay/overlay/base.py
20 @@ -9,8 +9,15 @@ import logging
21 import roverlay.util.objects
22
23 class OverlayObject ( roverlay.util.objects.ReferenceTree ):
24 + """Base object for overlay objects (Overlay, Category, PackageDir) that
25 + provides some basic functionality:
26
27 - # always keep a (weak) reference to self:
28 + * common data variables: name, logger, physical_location, parent_ref
29 + * self-referencing: get_ref() (cached unless CACHE_REF is set to False)
30 + * back-referencing: get_parent()/get_upper(), set_parent()
31 + """
32 +
33 + # by default, keep a (weak) reference to self:
34 # (a) Overlay: multiple Category objects use this ref
35 # (b) Category: ^ PackageDir ...
36 # (c) PackageDir: ^ PackageInfo ...
37 @@ -18,6 +25,19 @@ class OverlayObject ( roverlay.util.objects.ReferenceTree ):
38 CACHE_REF = True
39
40 def __init__ ( self, name, logger, directory, parent ):
41 + """OverlayObject constructor. Sets up common variables.
42 +
43 + arguments:
44 + * name -- name of the overlay/category/package dir/...
45 + * logger -- parent logger. Passing None results in using the root
46 + logger. The object's logger is then
47 + <parent logger>.getChild ( <name> )
48 + * directory -- filesystem location of the object
49 + * parent -- parent object (object that "owns" this object)
50 + This would be None when initializing the overlay's root,
51 + the overlay's root when creating a category and the
52 + category when creating a package dir.
53 + """
54 super ( OverlayObject, self ).__init__ ( parent )
55 self.name = name
56 self.logger = (
57 @@ -26,9 +46,4 @@ class OverlayObject ( roverlay.util.objects.ReferenceTree ):
58 self.physical_location = directory
59 # --- end of __init__ (...) ---
60
61 - # inherited:
62 - #def get_parent
63 - #def get_upper
64 - #def get_ref
65 -
66 # --- end of OverlayObject ---
67
68 diff --git a/roverlay/overlay/pkgdir/distroot/distroot.py b/roverlay/overlay/pkgdir/distroot/distroot.py
69 index 34f61d9..e38fccd 100644
70 --- a/roverlay/overlay/pkgdir/distroot/distroot.py
71 +++ b/roverlay/overlay/pkgdir/distroot/distroot.py
72 @@ -73,11 +73,21 @@ class DistrootBase ( object ):
73 # --- end of __init__ (...) ---
74
75 def _atexit_run ( self ):
76 + """Performs at-exit actions unless already done."""
77 if self.finalize_at_exit:
78 self.finalize()
79 # --- end of _atexit_run (...) ---
80
81 def finalize ( self, backup_distmap=True ):
82 + """Finalizes this object, that is
83 + (a) disable at-exit behavior
84 + (b) clean up the distroot
85 + (c) write the distmap (if any)
86 +
87 + arguments:
88 + * backup_distmap -- whether to create a copy of the old distmap before
89 + writing the new one
90 + """
91 # disable finalize_at_exit first so that exceptions cannot trigger
92 # _atexit_run()->this function
93 #
94 @@ -225,7 +235,7 @@ class DistrootBase ( object ):
95 # --- end of iter_distfiles (...) ---
96
97 def _remove_broken_symlinks ( self ):
98 - """Recursively remove broken/dead symlinks."""
99 + """Recursively removes broken/dead symlinks."""
100
101 def recursive_remove ( dirpath, rel_dirpath, rmdir ):
102 for item in os.listdir ( dirpath ):
103 @@ -256,16 +266,22 @@ class DistrootBase ( object ):
104 # --- end of _remove_broken_symlinks (...) ---
105
106 def _try_remove ( self, dest ):
107 + """Tries to remove a file (from the distmap and the filesystem)
108 + and suppresses "file does not exist" exceptions.
109 +
110 + arguments:
111 + * dest -- file to remove (absolute path)
112 + """
113 try:
114 os.unlink ( dest )
115 - if self.distmap is not None:
116 - relpath = os.path.relpath ( dest, self.get_root() )
117 -
118 except OSError as e:
119 - if e.errno == errno.ENOENT:
120 - pass
121 - else:
122 + if e.errno != errno.ENOENT:
123 raise
124 + else:
125 + if self.distmap is not None:
126 + self.distmap.try_remove (
127 + os.path.relpath ( dest, self.get_root() )
128 + )
129 # --- end of _try_remove (...) ---
130
131 def get_distdir ( self, ebuild_name ):
132 @@ -288,14 +304,28 @@ class DistrootBase ( object ):
133 # --- end of get_distdir (...) ---
134
135 def get_root ( self ):
136 + """Returns the filesystem path to this distroot (as str)."""
137 return str ( self._root )
138 # --- end of get_root (...) ---
139
140 def distmap_register ( self, p_info ):
141 + """Adds a new entry for the given PackageInfo instance to the distmap.
142 +
143 + arguments:
144 + p_info --
145 + """
146 return self.distmap.add_entry_for ( p_info )
147 # --- end of distmap_register (...) ---
148
149 def check_integrity ( self ):
150 + """Verifies (and regenerates) the distmap:
151 +
152 + (a) creates checksums for all files in the distroot [threaded]
153 + (b) compares the checksums with the distmap's entries
154 + -> create entries for missing files
155 + -> drop entries if checksums do not match
156 + (c) drop distmap entries whose file do not exist
157 + """
158 if self.distmap is not None:
159 root = self.get_root()
160 distfiles = set()
161 @@ -365,6 +395,7 @@ class DistrootBase ( object ):
162
163
164 class TemporaryDistroot ( DistrootBase ):
165 + # TODO/FIXME: remove this class, it's not used
166
167 def __init__ ( self, logger=None ):
168 # temporary distroots always use the non-flat distdir layout
169
170 diff --git a/roverlay/overlay/pkgdir/packagedir_base.py b/roverlay/overlay/pkgdir/packagedir_base.py
171 index e8567b9..5196815 100644
172 --- a/roverlay/overlay/pkgdir/packagedir_base.py
173 +++ b/roverlay/overlay/pkgdir/packagedir_base.py
174 @@ -183,7 +183,7 @@ class PackageDirBase ( roverlay.overlay.base.OverlayObject ):
175 physical_only=True, pvr=pvr, ebuild_file=efile, name=self.name
176 )
177
178 - # link distfiles to distmap
179 + # link distfiles to the distmap
180 for distfile in p.parse_ebuild_distfiles ( self.get_parent().name ):
181 self.DISTROOT.set_distfile_owner ( self.get_ref(), distfile )