Initial commit
This commit is contained in:
commit
1dc4a30084
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# ArchRepo
|
||||
## Version 2
|
||||
|
||||
### Past versions
|
||||
* Version 1 is the current version, running state-fully in a dedicated VM, which uses NFS to mount the repository (and
|
||||
thus works only on a local network)
|
||||
|
||||
### Introduction
|
||||
Version 2 targets an all-new architecture:
|
||||
* written in Python
|
||||
* running in a container
|
||||
* potentially a stateless and ephemeral container
|
80
update-repo.py
Normal file
80
update-repo.py
Normal file
@ -0,0 +1,80 @@
|
||||
# KTO ArchRepo update script
|
||||
# version 2.0
|
||||
|
||||
# The purpose of this script is to automate the maintenance of a custom pacman (Arch Linux) repository, whose goal is to
|
||||
# provide already built packages of AUR software.
|
||||
|
||||
# This version 2 aims at 2 major evolutions:
|
||||
# * manage dependencies (hence Python and object-oriented programming);
|
||||
# * run this script in a stateless Arch container, rather than a full VM as in version 1.
|
||||
# Additionaly, we may like to manage working directory in a better way (check available storage space, and existing
|
||||
# directories).
|
||||
|
||||
# This script should NOT be run as root. Or should it?
|
||||
# * We are in a stateless container, but I don't think we can run makepkg as root...
|
||||
|
||||
# Imports
|
||||
import os
|
||||
|
||||
# Class for AUR package
|
||||
class Package:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
# + version, dependencies (which should contain version as well)
|
||||
|
||||
def parseDb(db_path):
|
||||
# here we should use AWK to parse our repo database file and populate the collection a collection of packages to build
|
||||
# that we then return
|
||||
|
||||
def checkUpdates(packages_to_build): # or checkDependencies?
|
||||
# here we should check for all packages in packages_to_build if they need an update and:
|
||||
# * remove those which do not from the collection
|
||||
# * check (recursively) for all these packages_to_build if they have dependencies
|
||||
# * if AUR dependencies, add them to this collection
|
||||
# * if Arch dependencies, add them to another collection arch_packages_to_install
|
||||
|
||||
def installArchPackages(packages):
|
||||
# packages is a collection of packages (objects or names?) to install
|
||||
os.system("sudo pacman -Syu " + packages.toSpaceString()) # [].toSpaceString() being to define...
|
||||
|
||||
def buildAurPackage(package):
|
||||
# Fetch package (git clone)
|
||||
# cd to directory
|
||||
os.system("makepkg -s --no-confirm --no-progress-bar")
|
||||
|
||||
def addPackageToRepo(package, repo):
|
||||
os.system("cp...")
|
||||
os.system("repo-add...")
|
||||
|
||||
def sortByDependencies():
|
||||
# packages_to_build should be sorted by dependencies here
|
||||
# packages that are dependencies should be tagged adequately
|
||||
|
||||
def init():
|
||||
# Check for main dependencies:
|
||||
deps = ['git', 'awk', 'package-query']
|
||||
installArchPackages(deps)
|
||||
|
||||
# This function is a "main" function
|
||||
def updateRepo():
|
||||
init()
|
||||
packages_to_build = parseDb(db_path)
|
||||
checkUpdates() # ideally, this should directly edit packages_to_build AND arch_packages_to_install (I believe we can return tuples in Python)
|
||||
installArchPackages(arch_packages_to_install)
|
||||
sortByDependencies()
|
||||
for package in packages_to_build:
|
||||
buildAurPackage(package)
|
||||
addPackageToRepo(package, repo)
|
||||
if package.isDependency:
|
||||
installArchPackages([package])
|
||||
|
||||
def newPackage(package):
|
||||
init()
|
||||
checkUpdates([package])
|
||||
installArchPackages(arch_packages_to_install)
|
||||
sortByDependencies()
|
||||
for package in packages_to_build:
|
||||
buildAurPackage(package)
|
||||
addPackageToRepo(package, repo)
|
||||
if package.isDependency:
|
||||
installArchPackages([package])
|
Loading…
Reference in New Issue
Block a user