src/install-ebuild-deps: fix some stupid bugs; update copyright

Signed-off-by: Maciej Barć <xgqt@riseup.net>
This commit is contained in:
Maciej Barć 2021-04-18 01:59:44 +02:00
parent e2cd817f72
commit ba55fe2f2d
No known key found for this signature in database
GPG Key ID: 031C9FE65BED714A

View File

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with scripts. If not, see <https://www.gnu.org/licenses/>. along with scripts. If not, see <https://www.gnu.org/licenses/>.
Original author: Maciej Barć (xgqt@protonmail.com) Original author: Maciej Barć (xgqt@protonmail.com)
Copyright (c) 2020, src_prepare group Copyright (c) 2020-2021, src_prepare group
Licensed under the GNU GPL v3 License Licensed under the GNU GPL v3 License
Install Ebuild Dependencies Install Ebuild Dependencies
@ -29,12 +29,13 @@ to emerge dependencies we would just do "emerge --oneshot --onlydeps PKG".
import argparse import argparse
import sys
from subprocess import call from subprocess import call
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Install Ebuild Dependencies", description="Install Ebuild Dependencies",
epilog="Copyright (c) 2020, src_prepare group (License: ISC)" epilog="Copyright (c) 2020-2021, src_prepare group (License: GPLv3)"
) )
parser.add_argument( parser.add_argument(
"ebuild", "ebuild",
@ -45,16 +46,14 @@ args = parser.parse_args()
def pkg_name(pkg_str): def pkg_name(pkg_str):
"""Parse string and return a pkg name""" """
Parse string and return a pkg name.
"""
# TODO: don't strip but force # TODO: don't strip but force
proper = ""
# Strip required use # Strip required use
for i in ["["]: proper = pkg_str.split("[")[0]
if i in pkg_str:
proper = pkg_str.split(i)[0]
# Strip conditional use # Strip conditional use
for i in ["$", "DEPEND", "||", "!", "?", "(", ")"]: for i in ["$", "DEPEND", "||", "!", "?", "(", ")"]:
@ -65,12 +64,21 @@ def pkg_name(pkg_str):
def ebuild_deps(ebuild_file): def ebuild_deps(ebuild_file):
"""Returns dependencies from a ebuild file""" """
Returns dependencies from a ebuild file.
"""
deps = [] deps = []
adddeps = False adddeps = False
with open(ebuild_file) as ebuild: with open(ebuild_file) as ebuild:
for line in ebuild.read().splitlines(): for line in ebuild.read().splitlines():
if adddeps:
# TODO: Find a better way to find the depend "block"
if "DEPEND" in line:
adddeps = True
elif adddeps:
# TODO: Find a better pkg match method # TODO: Find a better pkg match method
if "/" in line: if "/" in line:
deps.append( deps.append(
@ -78,16 +86,20 @@ def ebuild_deps(ebuild_file):
) )
elif "\"" in line: elif "\"" in line:
adddeps = False adddeps = False
# TODO: Find a better way to find the depend "block"
elif "DEPEND" in line:
adddeps = True
return deps return deps
def main(): def main():
"""The main function""" """
The main function.
"""
print("Ebuilds:", args.ebuild) print("Ebuilds:", args.ebuild)
if args.ebuild == []:
print("[ERROR]: No ebuilds given")
sys.exit(1)
all_deps = [] all_deps = []
for ebuild in args.ebuild: for ebuild in args.ebuild: