From de9b2c68ad4ed51e81bda373c12c810d31298a79 Mon Sep 17 00:00:00 2001 From: sukanka Date: Fri, 4 Nov 2022 12:21:08 +0800 Subject: [PATCH] fix: bug in bump_pkgrel --- pkg_archiver.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg_archiver.py b/pkg_archiver.py index bd70d85..09efb64 100644 --- a/pkg_archiver.py +++ b/pkg_archiver.py @@ -4,8 +4,6 @@ Update the PKGBUILD and lilac.yaml of archived pkgs in `pkgname.txt` ''' import os -import fileinput -import re import yaml import argparse @@ -35,12 +33,16 @@ def archive_pkg_by_file_list(file, bioarch_path="BioArchLinux", biconductor_vers def bump_pkgrel(step=1): - with fileinput.input(r"PKGBUILD", inplace=True) as f: - for line in f: + with open("PKGBUILD", "r") as f: + lines = f.readlines() + for i in range(len(lines)): + line = lines[i] if line.startswith("pkgrel="): new_pkgrel = int(line.split("=")[1])+step - line = re.sub( - r'pkgrel=\d+', f'pkgrel={new_pkgrel}', line) + lines[i] = f'pkgrel={new_pkgrel}\n' + break + with open("PKGBUILD", "w") as f: + f.writelines(lines) def archive_pkg_yaml(bioconductor_version=3.15, yaml_file="lilac.yaml"):