Skip to content

Commit

Permalink
Merge pull request #50 from pop-os/repoman-fix
Browse files Browse the repository at this point in the history
Fix if a source does not have a name set
  • Loading branch information
isantop committed Oct 7, 2022
2 parents 4424a39 + 688e898 commit 02efbc4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
repolib (2.0.1) jammy; urgency=medium

* Fix for sources missing names (pop-os/repolib/#49)

-- Ian Santopietro <ian@system76.com> Wed, 05 Oct 2022 14:25:59 -0600

repolib (2.0.0) jammy; urgency=medium

* Newly rewritten architecture
Expand Down
2 changes: 1 addition & 1 deletion repolib/command/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def list_all(self):
if self.verbose or self.debug:
print('\nDetails about failing files:')
for err in util.errors:
print(f'{err}: {util.errors[err]}')
print(f'{err}: {util.errors[err].args[0]}')

return True

Expand Down
7 changes: 7 additions & 0 deletions repolib/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ def load(self) -> None:
item += 1
self.contents.append('')

for source in self.sources:
if not source.has_required_parts:
raise SourceFileError(
f'The file {self.path.name} is malformed and contains '
'errors. Maybe it has some extra new-lines?'
)

self.log.debug('File %s loaded', self.path)

def save(self) -> None:
Expand Down
11 changes: 11 additions & 0 deletions repolib/parsedeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
along with RepoLib. If not, see <https://www.gnu.org/licenses/>.
"""

import logging

from . import util

log = logging.getLogger(__name__)

class DebParseError(util.RepoError):
""" Exceptions related to parsing deb lines."""

Expand Down Expand Up @@ -126,7 +130,9 @@ def parse_name_ident(tail:str) -> tuple:

# Used for sanity checking later
has_name = 'X-Repolib-Name' in tail
log.debug('Line name found: %s', has_name)
has_ident = 'X-Repolib-ID' in tail
log.debug('Line ident found: %s', has_ident)

parts: list = tail.split()
name_found = False
Expand All @@ -135,6 +141,7 @@ def parse_name_ident(tail:str) -> tuple:
ident:str = ''
comment:str = ''
for item in parts:
log.debug("Checking line item: %s", item)
item_is_name = item.strip('#').strip().startswith('X-Repolib-Name')
item_is_ident = item.strip('#').strip().startswith('X-Repolib-ID')

Expand Down Expand Up @@ -169,6 +176,10 @@ def parse_name_ident(tail:str) -> tuple:
ident = ident.strip()
comment = comment.strip()

if not name:
if ident:
name = ident

# Final sanity checking
if has_name and not name:
raise DebParseError(
Expand Down
12 changes: 9 additions & 3 deletions repolib/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,16 @@ def generate_default_name(self) -> str:
A name based on the ident
"""
name:str = self.ident
if not self['X-Repolib-Name']:
self['X-Repolib-Name'] = name
try:
name = self['X-Repolib-Name']
except KeyError:
self['X-Repolib-Name'] = self.ident
return self['X-Repolib-Name']

if not name:
self['X-Repolib-Name'] = self.ident

return name
return self['X-Repolib-Name']

def load_key(self, ignore_errors:bool = True) -> None:
"""Finds and loads the signing key from the system
Expand Down

0 comments on commit 02efbc4

Please sign in to comment.