diff --git a/.gitignore b/.gitignore index 9e55ce3..6e4266f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ __pycache__/ *.py[cod] *$py.class - -packages/ -pkgbuilds/ -output/ -run.sh diff --git a/config.yaml b/config.yaml index 0072186..abbd89c 100644 --- a/config.yaml +++ b/config.yaml @@ -3,4 +3,9 @@ repo: db_name: "casio.db" arch: "x86_64" -maintainer: "Eldeberen " +chroot: + pacman: "/etc/pacman.conf" + makepkg: "/etc/makepkg.conf" + +templates: "./pkgtmpl" +pkgbuilds: "/home/eldeberen/tmp/pkgbuild" diff --git a/middlearch/__main__.py b/middlearch/__main__.py index eeefefd..92a1663 100644 --- a/middlearch/__main__.py +++ b/middlearch/__main__.py @@ -2,14 +2,18 @@ import argparse, logging import os.path as path -from config import Config, make_chroot + +from chroot import Chroot +from config import Config +from package import Package +from repository import Repository parser = argparse.ArgumentParser(description='Build some packages.') -parser.add_argument('-c', metavar='config', dest="config", +parser.add_argument('-c', '--config', dest='config_dir', default="/etc/middlearch", help="configuration directory") -parser.add_argument('--verbose', '-v', action='count', default=0) +parser.add_argument('-v', '--verbose', action='count', default=0) args = parser.parse_args() @@ -17,6 +21,12 @@ verbosities = [logging.WARNING, logging.INFO, logging.DEBUG] logging.basicConfig(format="[%(asctime)s] %(levelname)s (%(filename)s.%(funcName)s): %(message)s", level=verbosities[min(args.verbose, len(verbosities)-1)]) -config = Config(args.config) +config = Config(args.config_dir) +repository = Repository(**config.get('repo')) +packages = Package.load(args.config_dir, repository) +#chroot = Chroot(config) -make_chroot(args.config) +for package in packages: + package.render_pkgbuild(config) +# if package.build: +# chroot.makepkg(package, config) diff --git a/middlearch/chroot.py b/middlearch/chroot.py new file mode 100644 index 0000000..146e6b7 --- /dev/null +++ b/middlearch/chroot.py @@ -0,0 +1,31 @@ +import logging, os, tempfile +import os.path as path + + +class Chroot(object): + def __init__(self, config): + # Create directories + self.basedir = tempfile.mkdtemp() + rootdir = path.join(self.basedir, "root") + logging.info(f"created temporary directory in {self.basedir}") + + # Initialize base-devel packages + pacman = f"-C {p}" if (p := config.get('chroot.pacman')) else "" + makepkg = f"-M {p}" if (p := config.get('chroot.makepkg')) else "" + _exec(f"mkarchroot {pacman} {makepkg} {rootdir} base-devel") + + # Make sure everything is up-to-date + _exec(f"arch-nspawn {rootdir} pacman -Syu") + + logging.info("chroot initialized") + + def makepkg(self, package, config): + current_dir = os.getcwd() + os.chdir(path.join(config.get('pkgbuilds'), package.name)) + _exec(f"makechrootpkg -c -r {self.basedir}") + os.chdir(current_dir) + +def _exec(cmd): + logging.info(cmd) + r = os.popen(cmd) + logging.debug(r.read()) diff --git a/middlearch/config.py b/middlearch/config.py new file mode 100644 index 0000000..961bd73 --- /dev/null +++ b/middlearch/config.py @@ -0,0 +1,22 @@ +import logging +import os +import os.path as path +import yaml + + +class Config(object): + def __init__(self, config_dir): + with open(path.join(config_dir, "config.yaml")) as file: + self.conf = yaml.load(file, Loader=yaml.SafeLoader) + logging.info(f"{path.join(config_dir, 'config.yaml')} loaded") + logging.debug('configuration:\n'+yaml.dump(self.conf)) + + def get(self, key, default=None): + v = self.conf + for k in key.split("."): + try: + v = v[k] + except KeyError: + logging.debug(f"{key} not found") + return default + return v diff --git a/middlearch/config/__init__.py b/middlearch/config/__init__.py deleted file mode 100644 index 7df46ac..0000000 --- a/middlearch/config/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .config import Config -from .chroot import make_chroot diff --git a/middlearch/config/chroot.py b/middlearch/config/chroot.py deleted file mode 100644 index df75bc1..0000000 --- a/middlearch/config/chroot.py +++ /dev/null @@ -1,21 +0,0 @@ -import logging, os, tempfile -import os.path as path - - -def make_chroot(configdir): - # Create directories - basedir = tempfile.mkdtemp() - rootdir = path.join(basedir, "root") - logging.info(f"created temporary directory in {basedir}") - - # Initialize base-devel packages - pacman = path.join(configdir, "pacman.conf") - makepkg = path.join(configdir, "makepkg.conf") - r = os.popen(f"mkarchroot -C {pacman} -M {makepkg} {rootdir} base-devel") - logging.debug(r.read()) - - # Make sure everything is up-to-date - r = os.popen(f"arch-nspawn {rootdir} pacman -Syu") - logging.debug(r.read()) - - logging.info("chroot initialized") diff --git a/middlearch/config/config.py b/middlearch/config/config.py deleted file mode 100644 index 298204f..0000000 --- a/middlearch/config/config.py +++ /dev/null @@ -1,16 +0,0 @@ -import logging -import os, shutil -import yaml -import os.path as path - - -class Config(): - def __init__(self, config_dir): - with open(path.join(config_dir, "config.yaml")) as file: - self.params = yaml.load(file, Loader=yaml.SafeLoader) - logging.info(f"{path.join(config_dir, 'config.yaml')} loaded") - logging.debug('\n'+yaml.dump(self.params)) - with open(path.join(config_dir, "packages.yaml")) as file: - self.packages = yaml.load(file, Loader=yaml.SafeLoader) - logging.info(f"{len(self.packages)} packages loaded") - logging.debug('\n'+yaml.dump(self.packages)) diff --git a/middlearch/git.py b/middlearch/git.py new file mode 100644 index 0000000..a551506 --- /dev/null +++ b/middlearch/git.py @@ -0,0 +1,28 @@ +import logging +import os +import re + + +def get_tag_from_git(remote): + if remote is None: + logging.warning("cannot retreive tags from None remote") + return None + + regex = re.compile("^refs/tags/v?(\d+\.\d+\.\d+)$") + def extract_tag(tag): + m = regex.search(tag) + if m: + return m.groups()[0] + return "" + + raw_tags = os.popen(f"git ls-remote --tags {remote}").read().split() + tags = sorted( + list( + filter(''.__ne__, + map(extract_tag, raw_tags) + ), + ) + ) + logging.debug(f"{remote}: {', '.join(tags)}") + + return tags[-1] diff --git a/middlearch/package.py b/middlearch/package.py new file mode 100644 index 0000000..15e0709 --- /dev/null +++ b/middlearch/package.py @@ -0,0 +1,87 @@ +import hashlib, logging, os, re +import jinja2 as j2 +import os.path as path +import requests as r +import yaml + +from git import get_tag_from_git + +class Package(object): + def __init__(self, name, **params): + self.name = name + self.repo = params.get("repo") + self.tag = params.get("tag") or get_tag_from_git(self.repo) + self.force = params.get("force", False) + self.render = params.get("render", True) + self.maintainers = params.get("maintainers", {}) + self.contributors = params.get("contributors", {}) + self.build = False + logging.debug(self) + + def __repr__(self): + return f"{self.name} [repo: {self.repo}, tag: {self.tag}, force: {self.force}]" + + def load(config_dir, repository): + with open(path.join(config_dir, "packages.yaml")) as file: + p_list = yaml.load(file, Loader=yaml.SafeLoader) + + packages = [] + for p in p_list: + package = Package(**p) + packages.append(package) + + current_tag = repository.get_package_version(package.name) + + if package.tag > current_tag: + logging.info(f"{package.name} will be updated ({current_tag} → {package.tag})") + package.build = True + elif package.force: + logging.info(f"{package.name} will be updated ({package.tag})") + package.build = True + else: + logging.info(f"{package.name} will be skipped") + + logging.info(f"{len(packages)} packages loaded") + + return packages + + def render_pkgbuild(self, config): + def get_hash(name, tag): + regex = re.compile("^source=.+(https://.+\.tar\.[a-z]+)", re.MULTILINE) + with open(f"{config.get('templates', 'templates')}/{name}.j2") as file: + content = file.read() + try: + url = regex.search(content).group(1) + except: + logging.warning(f"cannot find valid source for {name} (is it a git version?)") + return "SKIP" + url = url.replace("${pkgver}", tag) + url = url.replace("${pkgname}", name) + + archive = r.get(url) + hash = hashlib.sha256(archive.content).hexdigest() + + return hash + + env = j2.Environment( + loader=j2.FileSystemLoader(config.get('templates', 'templates')), + autoescape=j2.select_autoescape([]) + ) + template = env.get_template(f"{self.name}.j2") + hash = get_hash(self.name, self.tag) + + sysenv = j2.Environment( + loader=j2.FileSystemLoader('templates'), + autoescape=j2.select_autoescape([]) + ) + maintainers_template = sysenv.get_template("maintainers.j2") + + dest_dir = path.join(config.get('pkgbuilds', "pkgbuilds"), self.name) + os.makedirs(dest_dir, exist_ok=True) + + with open(f"{config.get('pkgbuilds')}/{self.name}/PKGBUILD", "w") as file: + file.write(maintainers_template.render( + maintainers=self.maintainers, + contributors=self.contributors + )) + file.write(template.render(name=self.name, tag=self.tag, hash=hash)) diff --git a/middlearch/repository.py b/middlearch/repository.py new file mode 100644 index 0000000..9189491 --- /dev/null +++ b/middlearch/repository.py @@ -0,0 +1,37 @@ +from io import BytesIO +import logging +import re +import requests as r +import tarfile + + +class Repository(object): + def __init__(self, base_url, arch, db_name): + self.base_url = base_url + self.arch = arch + self.db_name = db_name + self.db = tarfile.open(fileobj=BytesIO(r.get(self.db_url).content)) + logging.info(f"{self} loaded") + + @property + def db_url(self): + return f"{self.base_url}/{self.arch}/{self.db_name}" + + def __repr__(self): + return self.db_url + + def get_package_version(self, pkgname): + try: + name = list(filter( + lambda item: item.isdir() and pkgname in item.name, + self.db.getmembers() + ))[0].name + except IndexError: + logging.warning(f"{pkgname} is not online") + version = "0.0.0" + else: + regex = re.compile(".+-(\d+\.\d+(?:\.\d+)?)-\d+") + version = regex.search(name).group(1) + logging.debug(f"{pkgname} is {version} online") + + return version diff --git a/middlearch/build/template.py b/middlearch/template.py similarity index 60% rename from middlearch/build/template.py rename to middlearch/template.py index 9dddb22..8b143a5 100644 --- a/middlearch/build/template.py +++ b/middlearch/template.py @@ -1,13 +1,9 @@ import hashlib, logging, os, re import jinja2 as j2 +import os.path as path import requests as r -env = j2.Environment( - loader=j2.FileSystemLoader('templates'), - autoescape=j2.select_autoescape([]) -) - def get_hash(name, tag): regex = re.compile("^source=.+(https://.+\.tar\.[a-z]+)", re.MULTILINE) with open(f"templates/{name}.j2") as file: @@ -24,12 +20,3 @@ def get_hash(name, tag): hash = hashlib.sha256(archive.content).hexdigest() return hash - -def render_pkgbuild(name, tag): - template = env.get_template(f"{name}.j2") - hash = get_hash(name, tag) - - os.mkdir(f"pkgbuilds/{name}") - - with open(f"pkgbuilds/{name}/PKGBUILD", "w") as file: - file.write(template.render(tag=tag, hash=hash, maintainer=MAINTAINER)) diff --git a/packages.yaml b/packages.yaml index 21e3904..cba6d80 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1,44 +1,82 @@ - name: isl + tag: "0.24" + maintainers: + - "Andrew Sun " + contributors: + - "Kritias " + - "sudokode " + - "Allan McRae " + - "Eldeberen " + - name: sh-elf-binutils-casio + tag: "2.37" + maintainers: + - "Eldeberen " + - name: sh-elf-gcc-casio + tag: "11.2.0" + maintainers: + - "Eldeberen " - name: openlibm-casio repo: https://gitea.planet-casio.com/Lephenixnoir/OpenLibm.git - force: true + maintainers: + - "Eldeberen " -- name: mkg3a - repo: https://github.com/tari/mkg3a.git - force: true +- name: "mkg3a" + repo: "https://github.com/tari/mkg3a.git" + maintainers: + - "Peter Marheine " + contributors: + - "Eldeberen " -- name: fxsdk - repo: https://gitea.planet-casio.com/Lephenixnoir/fxsdk.git - force: true +- name: "fxsdk" + repo: "https://gitea.planet-casio.com/Lephenixnoir/fxsdk.git" + maintainers: + - "Eldeberen " -- name: fxlibc - repo: https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc.git - force: true +- name: "fxlibc" + repo: "https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc.git" + maintainers: + - "Eldeberen " -- name: gint - repo: https://gitea.planet-casio.com/Lephenixnoir/gint.git - force: true +- name: "gint" + repo: "https://gitea.planet-casio.com/Lephenixnoir/gint.git" + maintainers: + - "Eldeberen " -- name: libimg - repo: https://gitea.planet-casio.com/Lephenixnoir/libimg.git - force: true +- name: "libimg" + repo: "https://gitea.planet-casio.com/Lephenixnoir/libimg.git" + maintainers: + - "Eldeberen " -- name: libprof - repo: https://gitea.planet-casio.com/Lephenixnoir/libprof.git - force: true +- name: "libprof" + repo: "https://gitea.planet-casio.com/Lephenixnoir/libprof.git" + maintainers: + - "Eldeberen " -- name: justui - repo: https://gitea.planet-casio.com/Lephenixnoir/justui.git - force: true +- name: "justui" + repo: "https://gitea.planet-casio.com/Lephenixnoir/justui.git" + maintainers: + - "Eldeberen " -- name: libp7 +- name: "libp7" tag: "3.0" + maintainers: + - "Breizh " + contributors: + - "Eldeberen " -- name: p7 +- name: "p7" tag: "3.0" + maintainers: + - "Breizh " + contributors: + - "Eldeberen " -- name: p7screen +- name: "p7screen" tag: "3.0" + maintainers: + - "Breizh " + contributors: + - "Eldeberen " diff --git a/templates/fxlibc.j2 b/pkgtmpl/fxlibc.j2 similarity index 91% rename from templates/fxlibc.j2 rename to pkgtmpl/fxlibc.j2 index 1142601..f349df1 100644 --- a/templates/fxlibc.j2 +++ b/pkgtmpl/fxlibc.j2 @@ -1,12 +1,11 @@ -# Maintainer: {{ maintainer }} -pkgname=fxlibc +pkgname={{ name }} pkgver={{ tag }} pkgrel=1 pkgdesc="A C standard library for fx Casio calculators, built for gint" arch=('i686' 'x86_64') url="https://gitea.planet-casio.com/Lephenixnoir/${pkgname}" licence=('unkwown') -depends=('fxsdk') +depends=('fxsdk' 'openlibm-casio') makedepends=('fxsdk') options=('!buildflags' '!strip') source=("$pkgname-$pkgver.tar.gz::https://gitea.planet-casio.com/Vhex-Kernel-Core/fxlibc/archive/${pkgver}.tar.gz") diff --git a/templates/fxsdk.j2 b/pkgtmpl/fxsdk.j2 similarity index 96% rename from templates/fxsdk.j2 rename to pkgtmpl/fxsdk.j2 index 4f248a6..f42d191 100644 --- a/templates/fxsdk.j2 +++ b/pkgtmpl/fxsdk.j2 @@ -1,5 +1,4 @@ -# Maintainer: {{ maintainer }} -pkgname=fxsdk +pkgname={{ name }} pkgver={{ tag }} pkgrel=1 pkgdesc='Tools to program for the Casio fx9860 calculators' diff --git a/templates/gint.j2 b/pkgtmpl/gint.j2 similarity index 94% rename from templates/gint.j2 rename to pkgtmpl/gint.j2 index 0a93197..48e9507 100644 --- a/templates/gint.j2 +++ b/pkgtmpl/gint.j2 @@ -1,5 +1,4 @@ -# Maintainer: {{ maintainer }} -pkgname=gint +pkgname={{ name }} pkgver={{ tag }} pkgrel=1 pkgdesc='Alternative library and kernel for add-in development on fx-9860G and fx-CG50 under Linux' diff --git a/pkgtmpl/isl.j2 b/pkgtmpl/isl.j2 new file mode 100644 index 0000000..23cbddf --- /dev/null +++ b/pkgtmpl/isl.j2 @@ -0,0 +1,33 @@ +pkgname={{ name }} +pkgver={{ tag }} +pkgrel=1 +pkgdesc="Library for manipulating sets and relations of integer points bounded by linear constraints" +arch=('i686' 'x86_64') +url="http://isl.gforge.inria.fr/" +depends=('gmp') +license=('MIT') +conflicts=('isl-git' 'isl14' 'isl15' 'isl16' 'isl17') +source=("http://isl.gforge.inria.fr/isl-${pkgver}.tar.gz") +sha256sums=('{{ hash }}') + +build() { + cd ${srcdir}/${pkgname}-${pkgver} + ./configure --prefix=/usr + make +} + +check() { + cd ${srcdir}/${pkgname}-${pkgver} + make check || true +} + +package() { + cd ${srcdir}/${pkgname}-${pkgver} + + make DESTDIR="$pkgdir" install + + install -dm755 "$pkgdir"/usr/share/gdb/auto-load/usr/lib/ + mv "$pkgdir"/usr/lib/libisl.so.*-gdb.py "$pkgdir"/usr/share/gdb/auto-load/usr/lib/ + + install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/isl/LICENSE +} diff --git a/templates/justui.j2 b/pkgtmpl/justui.j2 similarity index 93% rename from templates/justui.j2 rename to pkgtmpl/justui.j2 index cc97676..37449b0 100644 --- a/templates/justui.j2 +++ b/pkgtmpl/justui.j2 @@ -1,7 +1,6 @@ -# Maintainer: {{ maintainer }} -pkgname=justui +pkgname={{ name }} pkgver={{ tag }} -pkgrel=1 +pkgrel=2 pkgdesc="Lephe's GUI toolkit for gint" arch=('i686' 'x86_64') url="https://gitea.planet-casio.com/Lephenixnoir/${pkgname}" diff --git a/templates/libimg.j2 b/pkgtmpl/libimg.j2 similarity index 92% rename from templates/libimg.j2 rename to pkgtmpl/libimg.j2 index 9ceaf65..84e5719 100644 --- a/templates/libimg.j2 +++ b/pkgtmpl/libimg.j2 @@ -1,7 +1,6 @@ -# Maintainer: {{ maintainer }} -pkgname=libimg +pkgname={{ name }} pkgver={{ tag }} -pkgrel=1 +pkgrel=2 pkgdesc="Lephe's GUI toolkit for gint" arch=('i686' 'x86_64') url="https://gitea.planet-casio.com/Lephenixnoir/${pkgname}" diff --git a/templates/libp7.j2 b/pkgtmpl/libp7.j2 similarity index 87% rename from templates/libp7.j2 rename to pkgtmpl/libp7.j2 index 722fb5a..696bf66 100644 --- a/templates/libp7.j2 +++ b/pkgtmpl/libp7.j2 @@ -1,6 +1,4 @@ -# Maintainer: Breizh -# Contributor: {{ maintainer }} -pkgname=libp7 +pkgname={{ name }} pkgver={{ tag }} pkgrel=1 pkgdesc="Casio Communication Protocol 7.00 implementation" diff --git a/templates/libprof.j2 b/pkgtmpl/libprof.j2 similarity index 92% rename from templates/libprof.j2 rename to pkgtmpl/libprof.j2 index 6b2f0d6..6154788 100644 --- a/templates/libprof.j2 +++ b/pkgtmpl/libprof.j2 @@ -1,7 +1,6 @@ -# Maintainer: {{ maintainer }} -pkgname=libprof +pkgname={{ name }} pkgver={{ tag }} -pkgrel=1 +pkgrel=2 pkgdesc="A microsecond-level performance profiling library for gint" arch=('i686' 'x86_64') url="https://gitea.planet-casio.com/Lephenixnoir/${pkgname}" diff --git a/templates/mkg3a.j2 b/pkgtmpl/mkg3a.j2 similarity index 85% rename from templates/mkg3a.j2 rename to pkgtmpl/mkg3a.j2 index 9322b26..89206a3 100644 --- a/templates/mkg3a.j2 +++ b/pkgtmpl/mkg3a.j2 @@ -1,6 +1,4 @@ -# Maintainer: Peter Marheine -# Contributor: {{ maintainer }} -pkgname=mkg3a +pkgname={{ name }} pkgver={{ tag }} pkgrel=1 pkgdesc="A tool to create Casio FX-CG addon (.g3a) files." diff --git a/templates/openlibm-casio.j2 b/pkgtmpl/openlibm-casio.j2 similarity index 94% rename from templates/openlibm-casio.j2 rename to pkgtmpl/openlibm-casio.j2 index 1179c4c..c7165e0 100644 --- a/templates/openlibm-casio.j2 +++ b/pkgtmpl/openlibm-casio.j2 @@ -1,7 +1,6 @@ -# Maintainer: {{ maintainer }} -pkgname=openlibm-casio +pkgname={{ name }} pkgver={{ tag }} -pkgrel=2 +pkgrel=3 pkgdesc='Fork of the OpenLibm math library with support for fx-9860G and fx-CG 50' arch=('i686' 'x86_64') url="https://gitea.planet-casio.com/Lephenixnoir/OpenLibm" diff --git a/templates/p7.j2 b/pkgtmpl/p7.j2 similarity index 85% rename from templates/p7.j2 rename to pkgtmpl/p7.j2 index e046788..7f96536 100644 --- a/templates/p7.j2 +++ b/pkgtmpl/p7.j2 @@ -1,6 +1,4 @@ -# Maintainer: Breizh -# Contributor: {{ maintainer }} -pkgname=p7 +pkgname={{ name }} pkgver={{ tag }} pkgrel=1 pkgdesc="Casio Communication Protocol 7.00 implementation" diff --git a/templates/p7screen.j2 b/pkgtmpl/p7screen.j2 similarity index 71% rename from templates/p7screen.j2 rename to pkgtmpl/p7screen.j2 index 5614cd1..dcef9e9 100644 --- a/templates/p7screen.j2 +++ b/pkgtmpl/p7screen.j2 @@ -1,26 +1,15 @@ -# Maintainer: Breizh -# Contributor: {{ maintainer }} -pkgname=p7screen +pkgname={{ name }} pkgver={{ tag }} pkgrel=1 pkgdesc="Casio Communication Protocol 7.00 implementation" arch=('i686' 'x86_64') url="https://p7.planet-casio.com/" license=('GPL2') -groups=() depends=('libusb>=1.0' 'libp7>=3.0' 'sdl>=1.2.15') makedepends=('asciidoc>=8.6.9') -optdepends=() provides=('p7screen') -conflicts=() -replaces=() -backup=() -options=() -install= -changelog= source=(https://p7.planet-casio.com/pub/p7utils-${pkgver}.tar.gz) sha256sums=('{{ hash }}') -noextract=() build() { cd "p7utils-$pkgver" diff --git a/pkgtmpl/sh-elf-binutils-casio.j2 b/pkgtmpl/sh-elf-binutils-casio.j2 new file mode 100644 index 0000000..6731202 --- /dev/null +++ b/pkgtmpl/sh-elf-binutils-casio.j2 @@ -0,0 +1,49 @@ +pkgname={{ name }} +pkgver={{ tag }} +pkgrel=1 +pkgdesc="GNU binary utilities for the Casio calculators SuperH processors." +arch=('i686' 'x86_64') +url="https://www.gnu.org/software/binutils/" +license=('GPL') +depends=('binutils' 'flex' 'zlib') +makedepends=('gcc') +options=('!emptydirs' '!libtool') +source=("https://ftp.gnu.org/gnu/binutils/binutils-${pkgver}.tar.xz") +sha256sums=('{{ hash }}') +_target="sh-elf" + +prepare() { + cd "${srcdir}/binutils-${pkgver}" + + # ensure a clean build + [[ -d binutils-build ]] && rm -rf binutils-build + mkdir binutils-build +} + +build() { + export CPPFLAGS="" + cd "${srcdir}/binutils-${pkgver}/binutils-build" + ../configure \ + --prefix=/usr \ + --target=sh3eb-elf \ + --with-multilib-list=m3,m4-nofpu \ + --program-prefix=${_target}- \ + --disable-nls \ + --enable-libssp \ + --enable-lto + + make configure-host + make +} + +package() { + cd "${srcdir}/binutils-${pkgver}/binutils-build" + echo "Install on ${pkgdir}" + make DESTDIR="${pkgdir}" install-strip + + # Remove info documents that conflicts with host version + rm -rf "${pkgdir}/usr/share/info" + + # Remove libraries that conflict with host version + rm -rf "${pkgdir}/usr/lib" +} diff --git a/pkgtmpl/sh-elf-gcc-casio.j2 b/pkgtmpl/sh-elf-gcc-casio.j2 new file mode 100644 index 0000000..6cc5d23 --- /dev/null +++ b/pkgtmpl/sh-elf-gcc-casio.j2 @@ -0,0 +1,49 @@ +pkgname={{ name }} +pkgver={{ tag }} +pkgrel=1 +pkgdesc="The GNU Compiler Collection for the Casio calculators SuperH processors." +arch=(i686 x86_64) +license=('GPL' 'LGPL') +url='http://gcc.gnu.org' +depends=("sh-elf-binutils-casio" 'libmpc' 'elfutils' 'gmp' 'mpfr') +optdepends=('isl: integer set library') +options=('!buildflags' '!libtool' '!emptydirs' 'zipman' 'docs' '!strip') +source=("https://gcc.gnu.org/pub/gcc/releases/gcc-${pkgver}/gcc-${pkgver}.tar.xz") +sha256sums=('{{ hash }}') +_target="sh-elf" + +prepare() { + cd "${srcdir}/gcc-${pkgver}" + + # Ensure a clean build + [[ -d gcc-build ]] && rm -rf gcc-build + mkdir gcc-build +} + +build() { + cd "${srcdir}/gcc-${pkgver}/gcc-build" + + ../configure \ + --prefix=/usr \ + --target=sh3eb-elf \ + --with-multilib-list=m3,m4-nofpu \ + --program-prefix=${_target}- \ + --enable-languages=c,c++ \ + --without-headers \ + --with-newlib \ + --disable-nls \ + --enable-libssp \ + --enable-lto \ + --disable-werror + + make all-gcc all-target-libgcc +} + +package() { + cd "${srcdir}/gcc-${pkgver}/gcc-build" + + make DESTDIR="${pkgdir}" install-strip-gcc install-strip-target-libgcc + + # Remove unwanted files + rm -rf "${pkgdir}/usr/share/" +} diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100644 index 4ec6053..0000000 --- a/scripts/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -cd $1 -makepkg -si --noconfirm diff --git a/templates/maintainers.j2 b/templates/maintainers.j2 new file mode 100644 index 0000000..57270c6 --- /dev/null +++ b/templates/maintainers.j2 @@ -0,0 +1,2 @@ +{% for maintainer in maintainers %}# Maintainer: {{ maintainer }}{% endfor %} +{% for contributor in contributors %}# Contributor: {{ contributor }}{% endfor %}