Skip to content

Commit

Permalink
add bulk build package script
Browse files Browse the repository at this point in the history
  • Loading branch information
FreaxMATE committed Jan 13, 2023
1 parent c736ce3 commit e98fa5d
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
97 changes: 97 additions & 0 deletions bulkpkgbuild.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/python3

import os
import sys
import csv
import subprocess
import numpy as np

class Packages:

git_dir = ''
pkg_dir = ''
pkg_urls = []
pkg_names = []

def __init__(self, pkgs_file_path):
self.pkg_names, self.pkg_urls = self._process_csv(pkgs_file_path)

def build_packages(self):
self._download()
self._build()
self._collect_packages()

def _download(self):
self.git_dir = os.path.join(os.getcwd(), 'pkgbuild-repos')
os.mkdir(self.git_dir)
i = 0
self.p = []
for i, url in enumerate(self.pkg_urls):
self.p.append(subprocess.Popen(args=['git', 'clone', url], cwd=self.git_dir))
print(self.p[i].args)

def _build(self):
for i, pkg in enumerate(self.pkg_names):
self.p[i].wait()
self.p[i] = subprocess.Popen(args=['makepkg'], cwd=os.path.join(self.git_dir,pkg))
print(self.p[i].args)

def _collect_packages(self):
self.pkg_dir = os.path.join(os.getcwd(), 'built-packages')
os.mkdir(self.pkg_dir)
failed_builds_error = []
for i, pkg in enumerate(self.pkg_names):
self.p[i].wait()
if self.p[i].returncode > 0:
failed_builds_error.append(pkg + ' build failed. Error code ' + self.p[i].returncode)
self.p[i] = subprocess.Popen(args=['cp *.pkg.tar.zst ' + self.pkg_dir + '/'], shell=True, cwd=os.path.join(self.git_dir,pkg))
print(self.p[i].args)
print('Failed packages:')
for failed_pkg in failed_builds_error:
print(' ', failed_pkg)

def _process_csv(self, pkgs_file_path):
pkgs_file = open(pkgs_file_path)
content = pkgs_file.read()
pkg_names = []
pkg_urls = []
word = ''
i = 0
while i < len(content):
if content[i] == ',':
pkg_name = str(word)
word = ''
i += 1
continue
if content[i] == '\n':
pkg_url = str(word)
if pkg_url == 'AUR':
pkg_url = 'https://aur.archlinux.org/' + pkg_name + '.git'
pkg_names.append(pkg_name)
pkg_urls.append(pkg_url)
word = ''
i += 1
continue
word += content[i]
i += 1
return pkg_names, pkg_urls


def print_usage():
print('Bulk Package Builder')
print('usage: bulkpkgbuild PKGSFILEPATH')
print(' -h, --help print usage')

def handle_arguments():
n = len(sys.argv)
if n < 2:
print_usage()
if not os.path.exists(sys.argv[1]):
print('File path ', sys.argv[1], ' does not exist. Aborting.')
exit()
return sys.argv[1]

if __name__=="__main__":
pkgs_file_path = handle_arguments()
pkg_obj = Packages(pkgs_file_path)
pkg_obj.build_packages()
23 changes: 23 additions & 0 deletions packages.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake-extras,AUR
libayatana-common,AUR
ayatana-indicator-session,AUR
ayatana-indicator-datetime,AUR
ayatana-indicator-sound,AUR
ayatana-indicator-power,AUR
ayatana-indicator-messages,AUR
ayatana-indicator-keyboard,AUR
ayatana-indicator-application,AUR
ayatana-indicator-notifications,AUR
ayatana-indicator-printers,AUR
ayatana-indicator-bluetooth,AUR
ayatana-settings,AUR
caja-admin,AUR
mate-menu,AUR
mate-hud,AUR
mate-layouts,AUR
libreoffice-style-yaru-fullcolor,AUR
papirus-mate-icon-theme,AUR
pluma-plugins,AUR
rhythmbox-plugin-alternative-toolbar,AUR
manjaro-freaxmate-settings,https://github.com/FreaxMATE/manjaro-freaxmate-settings
manjaro-freaxmate-backgrounds,https://github.com/FreaxMATE/manjaro-freaxmate-backgrounds

0 comments on commit e98fa5d

Please sign in to comment.