mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-05 11:02:14 +01:00
Updated for generate sbo
This commit is contained in:
parent
b65dcb0ec5
commit
3643b44d69
1 changed files with 145 additions and 49 deletions
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from multiprocessing import Process, Queue
|
from multiprocessing import Process, Queue
|
||||||
|
|
||||||
|
@ -634,7 +633,10 @@ class UpdateRepository(Configs):
|
||||||
|
|
||||||
self.utils.process(lftp_command)
|
self.utils.process(lftp_command)
|
||||||
|
|
||||||
self.generate_the_slackbuilds_txt(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds)
|
# It checks if there is the SLACKBUILDS.TXT file, otherwise going to create it.
|
||||||
|
if not Path(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds).is_file():
|
||||||
|
self.generate_sbo(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds)
|
||||||
|
|
||||||
self.delete_last_updated(self.repos.ponce_repo_name)
|
self.delete_last_updated(self.repos.ponce_repo_name)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -652,11 +654,105 @@ class UpdateRepository(Configs):
|
||||||
|
|
||||||
self.utils.process(lftp_command)
|
self.utils.process(lftp_command)
|
||||||
|
|
||||||
|
# It checks if there is the SLACKBUILDS.TXT file, otherwise going to create it.
|
||||||
|
if not Path(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds).is_file():
|
||||||
|
self.generate_sbo(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds)
|
||||||
|
|
||||||
self.delete_last_updated(self.repos.sbo_repo_name)
|
self.delete_last_updated(self.repos.sbo_repo_name)
|
||||||
|
|
||||||
self.delete_sbo_database_data()
|
self.delete_sbo_database_data()
|
||||||
self.data.install_sbos_data()
|
self.data.install_sbos_data()
|
||||||
|
|
||||||
|
def generate_sbo(self, path: Path, sbo_txt: str) -> None:
|
||||||
|
""" Creates the SLACKBUILDS.TXT file. """
|
||||||
|
print(f'Generating the {sbo_txt} file... ', end='', flush=True)
|
||||||
|
with open(Path(path, 'SLACKBUILDS.TXT'), 'w') as sbo:
|
||||||
|
|
||||||
|
for p in path.glob('**/*'):
|
||||||
|
if p.name.endswith('.info'):
|
||||||
|
|
||||||
|
sbo_path = Path('/'.join(str(p).split('/')[:-1]))
|
||||||
|
|
||||||
|
name: str = str(p).split('/')[-2]
|
||||||
|
location: str = str(Path('/'.join(str(p).split('/')[-3:-1])))
|
||||||
|
files: str = ' '.join([file.name for file in list(sbo_path.iterdir())])
|
||||||
|
|
||||||
|
version: str = (
|
||||||
|
' '.join([d.replace('"', '').strip()
|
||||||
|
for d in self.read_info_file(
|
||||||
|
p, 'VERSION=', 'HOMEPAGE=')])[len('VERSION='):]
|
||||||
|
)
|
||||||
|
|
||||||
|
download: str = (
|
||||||
|
' '.join([d.replace('\\', '').replace('"', '').strip()
|
||||||
|
for d in self.read_info_file(
|
||||||
|
p, 'DOWNLOAD=', 'MD5SUM=')])[len('DOWNLOAD='):]
|
||||||
|
)
|
||||||
|
|
||||||
|
download_x86_64: str = (
|
||||||
|
' '.join([d.replace('\\', '').replace('"', '').strip()
|
||||||
|
for d in self.read_info_file(
|
||||||
|
p, 'DOWNLOAD_x86_64=', 'MD5SUM_x86_64=')])[len('DOWNLOAD_x86_64='):]
|
||||||
|
)
|
||||||
|
|
||||||
|
md5sum: str = (
|
||||||
|
' '.join([d.replace('\\', '').replace('"', '').strip()
|
||||||
|
for d in self.read_info_file(
|
||||||
|
p, 'MD5SUM=', 'DOWNLOAD_x86_64=')])[len('MD5SUM='):]
|
||||||
|
)
|
||||||
|
|
||||||
|
md5sum_x86_64: str = (
|
||||||
|
' '.join([d.replace('\\', '').replace('"', '').strip()
|
||||||
|
for d in self.read_info_file(
|
||||||
|
p, 'MD5SUM_x86_64=', 'REQUIRES=')])[len('MD5SUM_x86_64='):]
|
||||||
|
)
|
||||||
|
|
||||||
|
requires: str = (' '.join([d.replace('"', '').strip() for d in self.read_info_file(
|
||||||
|
p, 'REQUIRES=', 'MAINTAINER=')])[len('REQUIRES='):]
|
||||||
|
)
|
||||||
|
|
||||||
|
short_description: str = self.read_short_description(sbo_path, name)
|
||||||
|
|
||||||
|
sbo.write(f'SLACKBUILD NAME: {name}\n')
|
||||||
|
sbo.write(f'SLACKBUILD LOCATION: ./{location}\n')
|
||||||
|
sbo.write(f'SLACKBUILD FILES: {files}\n')
|
||||||
|
sbo.write(f'SLACKBUILD VERSION: {version}\n')
|
||||||
|
sbo.write(f'SLACKBUILD DOWNLOAD: {download}\n')
|
||||||
|
sbo.write(f'SLACKBUILD DOWNLOAD_x86_64: {download_x86_64}\n')
|
||||||
|
sbo.write(f'SLACKBUILD MD5SUM: {md5sum}\n')
|
||||||
|
sbo.write(f'SLACKBUILD MD5SUM_x86_64: {md5sum_x86_64}\n')
|
||||||
|
sbo.write(f'SLACKBUILD REQUIRES: {requires}\n')
|
||||||
|
sbo.write(f'SLACKBUILD SHORT DESCRIPTION: {short_description}\n')
|
||||||
|
sbo.write('\n')
|
||||||
|
|
||||||
|
print(f'{self.byellow}Done{self.endc}\n')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_short_description(path: Path, name: str) -> str:
|
||||||
|
""" Returns the short description. """
|
||||||
|
with open(Path(path, 'slack-desc'), 'r') as f:
|
||||||
|
slack = f.readlines()
|
||||||
|
|
||||||
|
for line in slack:
|
||||||
|
pattern: str = f'{name}: {name}'
|
||||||
|
if line.startswith(pattern):
|
||||||
|
return line[len(name) + 1:].strip()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def read_info_file(info_file: Path, start: str, stop: str) -> list:
|
||||||
|
""" Reads the .info file and return the line. """
|
||||||
|
begin = end = 0
|
||||||
|
with open(info_file, 'r') as f:
|
||||||
|
info = f.read().splitlines()
|
||||||
|
|
||||||
|
for i, line in enumerate(info):
|
||||||
|
if line.startswith(start):
|
||||||
|
begin = i
|
||||||
|
if line.startswith(stop):
|
||||||
|
end = i
|
||||||
|
|
||||||
|
return info[begin:end]
|
||||||
|
|
||||||
def check(self, queue) -> None:
|
def check(self, queue) -> None:
|
||||||
compare: dict = self.check_updates.check()
|
compare: dict = self.check_updates.check()
|
||||||
|
|
||||||
|
@ -717,50 +813,50 @@ class UpdateRepository(Configs):
|
||||||
self.session.query(LastRepoUpdated).where(LastRepoUpdated.repo == repo).delete()
|
self.session.query(LastRepoUpdated).where(LastRepoUpdated.repo == repo).delete()
|
||||||
self.session.commit()
|
self.session.commit()
|
||||||
|
|
||||||
def generate_the_slackbuilds_txt(self, path: Path, slackbuilds_txt: str) -> None:
|
# def generate_the_slackbuilds_txt(self, path: Path, slackbuilds_txt: str) -> None:
|
||||||
""" Generates the SLACKBUILDS.TXT file. """
|
# """ Generates the SLACKBUILDS.TXT file. """
|
||||||
|
#
|
||||||
sbo_txt: Path = Path(path, slackbuilds_txt)
|
# sbo_txt: Path = Path(path, slackbuilds_txt)
|
||||||
gen_script: Path = Path(path, 'gen_sbo_txt.sh')
|
# gen_script: Path = Path(path, 'gen_sbo_txt.sh')
|
||||||
|
#
|
||||||
if not sbo_txt.is_file():
|
# if not sbo_txt.is_file():
|
||||||
|
#
|
||||||
if not gen_script.is_file():
|
# if not gen_script.is_file():
|
||||||
with open(gen_script, 'w') as file:
|
# with open(gen_script, 'w') as file:
|
||||||
file.write(self.__class__.gen_sbo_script.__doc__)
|
# file.write(self.__class__.gen_sbo_script.__doc__)
|
||||||
os.chmod(gen_script, 0o775)
|
# os.chmod(gen_script, 0o775)
|
||||||
|
#
|
||||||
# Generating the SLACKBUILDS.TXT file.
|
# # Generating the SLACKBUILDS.TXT file.
|
||||||
print(f'Generating the {slackbuilds_txt} file... ', end='', flush=True)
|
# print(f'Generating the {slackbuilds_txt} file... ', end='', flush=True)
|
||||||
os.chdir(path)
|
# os.chdir(path)
|
||||||
self.utils.process(f'./gen_sbo_txt.sh > {slackbuilds_txt}')
|
# self.utils.process(f'./gen_sbo_txt.sh > {slackbuilds_txt}')
|
||||||
|
#
|
||||||
print(f'{self.byellow}Done{self.endc}\n')
|
# print(f'{self.byellow}Done{self.endc}\n')
|
||||||
|
#
|
||||||
def gen_sbo_script(self) -> None:
|
# def gen_sbo_script(self) -> None:
|
||||||
"""#!/bin/bash
|
# """#!/bin/bash
|
||||||
|
#
|
||||||
# gen_sbo_txt.sh is a script to build a SLACKBUILDS.TXT file.
|
# # gen_sbo_txt.sh is a script to build a SLACKBUILDS.TXT file.
|
||||||
# Thanks to bassmadrigal from LQ forum.
|
# # Thanks to bassmadrigal from LQ forum.
|
||||||
# https://www.linuxquestions.org/questions/slackware-14/script-for-building-a-slackbuilds-txt-4175598436/
|
# # https://www.linuxquestions.org/questions/slackware-14/script-for-building-a-slackbuilds-txt-4175598436/
|
||||||
|
#
|
||||||
for i in */*; do
|
# for i in */*; do
|
||||||
|
#
|
||||||
NAME=$(echo $i | cut -d "/" -f2)
|
# NAME=$(echo $i | cut -d "/" -f2)
|
||||||
FILES=$(ls $i)
|
# FILES=$(ls $i)
|
||||||
source $i/${NAME}.info
|
# source $i/${NAME}.info
|
||||||
DESCRIPTION=$(grep -m 1 $NAME $i/slack-desc | cut -d " " -f2-)
|
# DESCRIPTION=$(grep -m 1 $NAME $i/slack-desc | cut -d " " -f2-)
|
||||||
|
#
|
||||||
echo SLACKBUILD NAME: $NAME
|
# echo SLACKBUILD NAME: $NAME
|
||||||
echo SLACKBUILD LOCATION: ./$i
|
# echo SLACKBUILD LOCATION: ./$i
|
||||||
echo SLACKBUILD FILES: $FILES
|
# echo SLACKBUILD FILES: $FILES
|
||||||
echo SLACKBUILD VERSION: $VERSION
|
# echo SLACKBUILD VERSION: $VERSION
|
||||||
echo SLACKBUILD DOWNLOAD: $DOWNLOAD
|
# echo SLACKBUILD DOWNLOAD: $DOWNLOAD
|
||||||
echo SLACKBUILD DOWNLOAD_x86_64: $DOWNLOAD_x86_64
|
# echo SLACKBUILD DOWNLOAD_x86_64: $DOWNLOAD_x86_64
|
||||||
echo SLACKBUILD MD5SUM: $MD5SUM
|
# echo SLACKBUILD MD5SUM: $MD5SUM
|
||||||
echo SLACKBUILD MD5SUM_x86_64: $MD5SUM_x86_64
|
# echo SLACKBUILD MD5SUM_x86_64: $MD5SUM_x86_64
|
||||||
echo SLACKBUILD REQUIRES: $REQUIRES
|
# echo SLACKBUILD REQUIRES: $REQUIRES
|
||||||
echo SLACKBUILD SHORT DESCRIPTION: $DESCRIPTION
|
# echo SLACKBUILD SHORT DESCRIPTION: $DESCRIPTION
|
||||||
echo
|
# echo
|
||||||
|
#
|
||||||
done"""
|
# done"""
|
||||||
|
|
Loading…
Reference in a new issue