From 6c42c53cd5d488b4877601ad7de94442e49ecaf5 Mon Sep 17 00:00:00 2001 From: Bart Ribbers Date: Tue, 22 Oct 2019 23:44:28 +0200 Subject: [PATCH] main/postmarketos-splash: build from new repo (!694) --- .gitlab-ci/static_code_analysis.sh | 6 -- main/postmarketos-splash/APKBUILD | 18 ++-- main/postmarketos-splash/make-splash.py | 127 ------------------------ 3 files changed, 10 insertions(+), 141 deletions(-) delete mode 100644 main/postmarketos-splash/make-splash.py diff --git a/.gitlab-ci/static_code_analysis.sh b/.gitlab-ci/static_code_analysis.sh index dac91f10c..1cb14dacd 100755 --- a/.gitlab-ci/static_code_analysis.sh +++ b/.gitlab-ci/static_code_analysis.sh @@ -20,12 +20,6 @@ sh_files=" ./main/postmarketos-mkinitfs/init_functions.sh ./main/postmarketos-mkinitfs-hook-debug-shell/20-debug-shell.sh ./main/postmarketos-update-kernel/update-kernel.sh - ./main/postmarketos-android-recovery-installer/build_zip.sh - ./main/postmarketos-android-recovery-installer/pmos_chroot - ./main/postmarketos-android-recovery-installer/pmos_install - ./main/postmarketos-android-recovery-installer/pmos_install_functions - ./main/postmarketos-android-recovery-installer/pmos_setpw - ./main/postmarketos-android-recovery-installer/update-binary ./main/mdss-fb-init-hack/mdss-fb-init-hack.sh ./main/postmarketos-ui-hildon/postmarketos-ui-hildon.post-install $(find . -path './main/postmarketos-ui-hildon/*.sh') diff --git a/main/postmarketos-splash/APKBUILD b/main/postmarketos-splash/APKBUILD index c9faf7c0a..31c4b408c 100644 --- a/main/postmarketos-splash/APKBUILD +++ b/main/postmarketos-splash/APKBUILD @@ -1,18 +1,20 @@ +# Contributor: Martijn Braam +# Maintainer: Martijn Braam pkgname=postmarketos-splash -pkgver=3 +pkgver=1.0.0 pkgrel=0 pkgdesc="Splash screen for postmarketOS" url="https://gitlab.com/postmarketos" arch="noarch" -license="mit" +license="MIT" depends="ttf-dejavu ttf-droid py3-pillow" -makedepends="" -install="" -subpackages="" -source="make-splash.py config.ini https://gitlab.com/postmarketOS/artwork/raw/master/logo/pmos.ttf" +source="https://gitlab.com/postmarketos/postmarketos-splash/-/archive/$pkgver/postmarketos-splash-$pkgver.tar.gz + config.ini + https://gitlab.com/postmarketOS/artwork/raw/master/logo/pmos.ttf" +options="!check" # No tests package() { - install -D -m755 "$srcdir"/make-splash.py \ + install -D -m755 make-splash.py \ "$pkgdir"/usr/bin/pmos-make-splash install -D -m644 "$srcdir"/config.ini \ "$pkgdir"/etc/postmarketos/splash.ini @@ -20,6 +22,6 @@ package() { "$pkgdir"/usr/share/fonts/ttf-pmos/pmos.ttf } -sha512sums="e731405d1c3eae265058d2a9f32286b36aa614d26fa86b915bef006b157008fb83c22031d1cffac5034d50d92cdf1d39f4148b46d249fc5db0db67a3a1bdfb7d make-splash.py +sha512sums="20d775f7cfb6e71eaa093ce254086eb64ed720573e94185bd09b9258e5707dd74ad20d593026fc5dd1edd1190e44e726bce74a5093ee991ee5fa5c0c1373817a postmarketos-splash-1.0.0.tar.gz cdde481bf7c68840515b839d974dd1dddfb37551a2939780e13dce11331f7d1964043de48f8902a30372e9fc9f042bd4ee133e2098694739c452a76b70e97111 config.ini 81e5df350bf7f435ab5480f7028fc3cabf5a947fa0dff1ed219f6d9ac18a1250f5114887a9f5f270cc699af48cd77f23d14a84578ac8d2d0f3a3e90ec3211c45 pmos.ttf" diff --git a/main/postmarketos-splash/make-splash.py b/main/postmarketos-splash/make-splash.py deleted file mode 100644 index 1bc761556..000000000 --- a/main/postmarketos-splash/make-splash.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/env python3 -from PIL import Image, ImageFont, ImageDraw -import configparser -import os -import sys -import itertools - - -def make_splash(width, height, filename, landscape=False, text="", config_file=None, center=False, raw=False): - print("Creating ({}x{}) splashscreen {}".format(width, height, os.path.basename(filename))) - - config = configparser.ConfigParser() - if config_file is not None: - config.read(config_file) - - im = Image.new('RGB', (width, height), color=config.get('background', 'color', fallback=0)) - draw = ImageDraw.Draw(im) - - spacing = width / 100 * float(config.get('logo', 'spacing', fallback='0')) - - font_size = int(width / 13) - logo_size = int(width / 10) - text_size = int(width / 30) - - name = config.get('name', 'text', fallback='postmarketOS') - logo = config.get('logo', 'text', fallback='♻') - - name_font = check_font(config, 'name') - logo_font = check_font(config, 'logo') - text_font = check_font(config, 'text') - - name_font = ImageFont.truetype(name_font, font_size) - logo_font = ImageFont.truetype(logo_font, logo_size) - text_font = ImageFont.truetype(text_font, text_size) - - name_width, name_height = draw.textsize(name, font=name_font) - logo_width, logo_height = draw.textsize(logo, font=logo_font) - - draw.text(((width - (name_width + logo_width)) / 2 + logo_width + spacing, (height - name_height) / 2), name, - config.get('name', 'color', fallback='#ffffff'), font=name_font) - - draw.text(((width - (name_width + logo_width + spacing)) / 2, (height - name_height) / 2), logo, - config.get('logo', 'color', fallback='#009900'), - font=logo_font) - - if text != "" and text is not None: - - text_top = (height / 2) + name_height - _, line_height = draw.textsize('A', font=text_font) - text_left = width * 0.05 - for hardcoded_line in text.replace("\\n", "\n").splitlines(): - lines = visual_split(hardcoded_line, text_font, width * 0.9) - for line in lines: - - if center: - line_width, _ = draw.textsize(line, font=text_font) - text_left = (width / 2) - (line_width / 2) - - draw.text((text_left, text_top), line, fill=config.get('text', 'color', fallback='#cccccc'), - font=text_font) - text_top += line_height + (text_size * 0.4) - - del draw - - if landscape: - im = im.transpose(Image.ROTATE_270) - - if raw: - data = list(im.getdata()) # [(R,G,B), (R,G,B)] - flat = list(itertools.chain.from_iterable(data)) # [R, G, B, R, G, B] - with open(filename, 'wb') as handle: - handle.write(bytes(flat)) - else: - im.save(filename, format='PPM') - - -def check_font(config, section): - fallback_font = '/usr/share/fonts/ttf-dejavu/DejaVuSans.ttf' - font_file = config.get(section, 'font', fallback=fallback_font) - if not os.path.isfile(font_file): - print("Font file '{}' does not exist ({}).".format(font_file, section), file=sys.stderr) - exit(1) - return font_file - - -def visual_split(text, font, width, response_type='list'): - font = font - words = text.split() - - word_lengths = [(word, font.getsize(word)[0]) for word in words] - space_length = font.getsize(' ')[0] - - lines = [''] - line_length = 0 - - for word, length in word_lengths: - - if line_length + length <= width: - lines[-1] = '{line}{word} '.format(line=lines[-1], word=word) - line_length += length + space_length - else: - lines.append('{word} '.format(word=word)) - line_length = length + space_length - - if response_type == 'list': - return [line.strip() for line in lines] - elif response_type == 'str': - return '\n'.join(line.strip() for line in lines) - else: - raise ValueError('Invalid response type. Valid values are "list" and "str".') - - -if __name__ == '__main__': - import argparse - - parser = argparse.ArgumentParser(description="Splash generator for postmarketOS") - parser.add_argument('width', type=int) - parser.add_argument('height', type=int) - parser.add_argument('filename') - parser.add_argument('--landscape', action='store_true', help='Rotate splash screen for landscape device') - parser.add_argument('--text', type=str, help='Additional text for the splash screen') - parser.add_argument('--center', action='store_true', help='Center text') - parser.add_argument('--config', type=str, help='Config file for splash screen style') - parser.add_argument('--raw', action='store_true', help='Output raw rgb instead of ppm') - args = parser.parse_args() - - make_splash(args.width, args.height, args.filename, args.landscape, args.text, args.config, args.center, args.raw)