summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2017-04-15 12:43:13 +0200
committerMichał Górny <mgorny@gentoo.org>2017-04-20 22:38:48 +0200
commit674ed22900df3e6a2054adb1b49f3e0fddbd64b2 (patch)
tree5ed6b06d8f7a54c08a9355ec9430726984dfeff3
parentdepgraph._in_blocker_conflict: call _validate_blockers if needed (bug 615982) (diff)
downloadportage-674ed22900df3e6a2054adb1b49f3e0fddbd64b2.tar.gz
portage-674ed22900df3e6a2054adb1b49f3e0fddbd64b2.tar.bz2
portage-674ed22900df3e6a2054adb1b49f3e0fddbd64b2.zip
repoman: Add a check for relative dosym candidates
Add a check for dosym with target path matching absolute paths controlled by the package manager, e.g. /bin, /etc... Example output: ebuild.absdosym 5 app-editors/nano/nano-2.5.3.ebuild: dosym '/bin/nano'... could use relative path on line: 81 Approved-by: Brian Dolbec <dolsen@gentoo.org> (on IRC)
-rw-r--r--repoman/man/repoman.14
-rw-r--r--repoman/pym/repoman/modules/scan/ebuild/checks.py13
-rw-r--r--repoman/pym/repoman/qa_data.py4
3 files changed, 21 insertions, 0 deletions
diff --git a/repoman/man/repoman.1 b/repoman/man/repoman.1
index 9b106906f..78e4b7275 100644
--- a/repoman/man/repoman.1
+++ b/repoman/man/repoman.1
@@ -292,6 +292,10 @@ Some files listed in SRC_URI aren't referenced in the Manifest
.B digest.unused
Some files listed in the Manifest aren't referenced in SRC_URI
.TP
+.B ebuild.absdosym
+Ebuild uses 'dosym' with explicit absolute path where relative path
+could be used
+.TP
.B ebuild.badheader
This ebuild has a malformed header
.TP
diff --git a/repoman/pym/repoman/modules/scan/ebuild/checks.py b/repoman/pym/repoman/modules/scan/ebuild/checks.py
index db6b6c8b4..e6e5d78ba 100644
--- a/repoman/pym/repoman/modules/scan/ebuild/checks.py
+++ b/repoman/pym/repoman/modules/scan/ebuild/checks.py
@@ -911,6 +911,19 @@ class PortageInternalVariableAssignment(LineCheck):
e += ' on line: %d'
return e
+
+class EbuildNonRelativeDosym(LineCheck):
+ """Check ebuild for dosym using absolute paths instead of relative."""
+ repoman_check_name = 'ebuild.absdosym'
+ regex = re.compile(
+ r'^\s*dosym\s+["\']?(/(bin|etc|lib|opt|sbin|srv|usr|var)\S*)')
+
+ def check(self, num, line):
+ match = self.regex.match(line)
+ if match:
+ return "dosym '%s'... could use relative path" % (match.group(1), ) + " on line: %d"
+
+
_base_check_classes = (InheritEclass, LineCheck, PhaseCheck)
_constant_checks = None
diff --git a/repoman/pym/repoman/qa_data.py b/repoman/pym/repoman/qa_data.py
index 132a55be3..a59fed778 100644
--- a/repoman/pym/repoman/qa_data.py
+++ b/repoman/pym/repoman/qa_data.py
@@ -195,6 +195,9 @@ qahelp = {
"Some files listed in SRC_URI aren't referenced in the Manifest"),
"digest.unused": (
"Some files listed in the Manifest aren't referenced in SRC_URI"),
+ "ebuild.absdosym": (
+ "This ebuild uses absolute target to dosym where relative symlink"
+ " could be used instead"),
"ebuild.majorsyn": (
"This ebuild has a major syntax error"
" that may cause the ebuild to fail partially or fully"),
@@ -262,6 +265,7 @@ qawarnings = set((
"RDEPEND.suspect",
"virtual.suspect",
"RESTRICT.invalid",
+ "ebuild.absdosym",
"ebuild.minorsyn",
"ebuild.badheader",
"ebuild.patches",