[arch-projects] [namcap] possibility to use renamed PKGBUILD files
Whatever patch you were trying to post, it got lost in hoardes of div tags. Alad
<div>Now you cannot randomly rename PKGBUILD files and use them with namcap.</div><div>Â </div><div>I have filed a bug here: https://bugs.archlinux.org/task/57193</div><div>I created a patch for my needs:</div><div>Â </div><div>diff --git a/namcap.py b/namcap.py</div><div>index b62a2fa..aae20c7 100755</div><div>--- a/namcap.py</div><div>+++ b/namcap.py</div><div>@@ -248,7 +248,7 @@ for package in packages:</div><div>Â </div><div>Â Â Â Â Â Â Â Â Â if os.path.isfile(package) and tarfile.is_tarfile(package):</div><div>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process_realpackage(package, active_modules)</div><div>- elif package.endswith('PKGBUILD'):</div><div>+ elif package.startswith('PKGBUILD'):</div><div>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â process_pkgbuild(package, active_modules)</div><div>Â Â Â Â Â Â Â Â Â else:</div><div>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â print("Error: Cannot process %s" % package)</div><div>Â </div><div>But I think it is better to just assume than all non-tar files are pkgbuilds and should be processed accordingly.</div>
What? -- Eli Schwartz Bug Wrangler and Trusted User
I have removed html formatting from my letter, but for some reason yandex still used html. Sorry for that. Here is what I was saying: Now you cannot randomly rename PKGBUILD files and use them with namcap. I have filed a bug here: https://bugs.archlinux.org/task/57193 I created a patch for my needs: diff --git a/namcap.py b/namcap.py index b62a2fa..aae20c7 100755 --- a/namcap.py +++ b/namcap.py @@ -248,7 +248,7 @@ for package in packages: if os.path.isfile(package) and tarfile.is_tarfile(package): process_realpackage(package, active_modules) - elif package.endswith('PKGBUILD'): + elif package.startswith('PKGBUILD'): process_pkgbuild(package, active_modules) else: print("Error: Cannot process %s" % package) But I think it is better to just assume than all non-tar files are pkgbuilds and should be processed accordingly.
On Thu, Jan 25, 2018 at 12:50:40AM +0300, ashark@linuxcomp.ru wrote:
I have removed html formatting from my letter, but for some reason yandex still used html. Sorry for that. Here is what I was saying:
Now you cannot randomly rename PKGBUILD files and use them with namcap.
How is "startswith" any less arbitrary than "endswith"? Because of some habit to move PKGBUILD to PKGBUILD.suffix? Alad
How is "startswith" any less arbitrary than "endswith"? Because of some habit to move PKGBUILD to PKGBUILD.suffix? Yes, as I already told at https://bugs.archlinux.org/task/57193: I keep several PKGBUILD files in one directory, and they are named like "PKGBUILD-project1" "PKGBUILD-project2" "PKGBUILD-project3" It is personally my usage. Maybe somebody else names them differently, even maybe without "PKGBUILD" substring in file name. So, for my need, I just could replase "package.endswith('PKGBUILD')" with "package.startswith('PKGBUILD')". But it would be better to just consider every non-archive file as a PKGBUILD file.
On Wed, 24 Jan 2018 17:17:52 -0500, ashark@linuxcomp.ru wrote:
How is "startswith" any less arbitrary than "endswith"? Because of some habit to move PKGBUILD to PKGBUILD.suffix?
Yes, as I already told at https://bugs.archlinux.org/task/57193: I keep several PKGBUILD files in one directory, and they are named like "PKGBUILD-project1" "PKGBUILD-project2" "PKGBUILD-project3" It is personally my usage. Maybe somebody else names them differently, even maybe without "PKGBUILD" substring in file name. So, for my need, I just could replase "package.endswith('PKGBUILD')" with "package.startswith('PKGBUILD')".
So? *That isn't any less arbitrary*, and breaks my method of keeping several PKGBUILD files in one directory, naming them "project1.PKGBUILD", "project2.PKGBUILD", ...
But it would be better to just consider every non-archive file as a PKGBUILD file.
+1 -- Happy hacking, ~ Luke Shumaker
On 01/25/2018 10:24 AM, Luke Shumaker wrote:
But it would be better to just consider every non-archive file as a PKGBUILD file.
+1
As I said on the bugreport:
Personally, I wonder why we bother checking the filename at all, rather just assuming that the non-tar files are PKGBUILDs and assuming the user is clever enough to understand the errors when no namcap rule passes.
But if we want to get fancy, we could: 1) add a dependency on python-magic and check for text/plain 2) read the file line by line to see if ^pkgname= exists anywhere. -- Eli Schwartz Bug Wrangler and Trusted User
But if we want to get fancy, we could:
1) add a dependency on python-magic and check for text/plain 2) read the file line by line to see if ^pkgname= exists anywhere. Seems like a good idea. And maybe still process as PKGBUILD when file is named just "PKGBUILD".
participants (4)
-
Alad Wenter
-
ashark@linuxcomp.ru
-
Eli Schwartz
-
Luke Shumaker