Date: Wednesday, April 11, 2018 @ 20:26:44 Author: heftig Revision: 321595
archrelease: copy trunk to extra-x86_64 Added: eclipse/repos/extra-x86_64/PKGBUILD (from rev 321594, eclipse/trunk/PKGBUILD) eclipse/repos/extra-x86_64/commonify (from rev 321594, eclipse/trunk/commonify) Deleted: eclipse/repos/extra-x86_64/PKGBUILD eclipse/repos/extra-x86_64/commonify -----------+ PKGBUILD | 194 ++++++++++++++++++------------------- commonify | 314 ++++++++++++++++++++++++++++++------------------------------ 2 files changed, 255 insertions(+), 253 deletions(-) Deleted: PKGBUILD =================================================================== --- PKGBUILD 2018-04-11 20:20:37 UTC (rev 321594) +++ PKGBUILD 2018-04-11 20:26:44 UTC (rev 321595) @@ -1,96 +0,0 @@ -# $Id$ -# Maintainer: Jan Alexander Steffens (heftig) <jan.steff...@gmail.com> -# Contributor: Ionut Biru <ib...@archlinux.org> -# Contributor: Paul Mattal <p...@archlinux.org> -# Contributor: Andrew Wright <andr...@photism.org> -# Contributor: Andreas W. Hauser <andy-...@splashground.de> -# Contributor: Marco Crosio <marco.cro...@gmail.com> - -pkgbase=eclipse -pkgname=(eclipse-{common,java,jee,cpp,php,javascript}) -pkgver=4.7.3 -pkgrel=1 -_release=oxygen-3 -pkgdesc="Highly extensible IDE" -license=(EPL) -arch=(x86_64) -url="https://eclipse.org" -makedepends=(python3) -options=(!emptydirs) -source=(commonify) -noextract=() - -for _pkg in ${pkgname[@]}; do - [[ $_pkg == 'eclipse-common' ]] && continue - source+=(http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/technology/epp/downloads/release/${_release/-//}/$_pkg-$_release-linux-gtk-x86_64.tar.gz) - noextract+=($_pkg-$_release-linux-gtk-x86_64.tar.gz) - eval "package_$_pkg() { _package $_pkg; }" -done - -sha256sums=('da1eaf6239cb0c2b5009cd8c261e96e7b17a7536b12fe60fcb1e903f5e67dbdc' - '5fb8170a0c384914fcb8fcead3f89ad488cb0d0f360a04d247952fa34819ba4a' - '319fe8ab21fc6df7dab85e4e5bdfaeb51b08d254ca5e5c79c2710a0f81cefa2d' - '04663a7815c283240ceda544b58eca697f5c5b47ca518a9b148f062022fd2af9' - '6a7519201185669e614d1cbd11ace0c52b5ab0669d26def5653aba42f9fde670' - 'fd0f3fe288c5385f35ab3fb860666bcf5d8ab4e03d749333b88bda1e442073e9') - -prepare() { - for _pkg in ${pkgname[@]}; do - mkdir $_pkg - [[ $_pkg == eclipse-common ]] && continue - bsdtar -xf "$_pkg-$_release-linux-gtk-x86_64.tar.gz" -C $_pkg --strip-components 1 - done -} - -build() { - mkdir eclipse-common/dropins - touch eclipse-common/dropins/.keep - ./commonify --identical ${pkgname[@]} -} - -package_eclipse-common() { - pkgdesc+=" (common files)" - depends=("java-environment>=8" webkit2gtk unzip) - - install -d "$pkgdir/usr/lib" - cp -a eclipse-common "$pkgdir/usr/lib/eclipse" - - install -D /dev/stdin "$pkgdir/usr/bin/eclipse" <<END -#!/bin/bash -export ECLIPSE_HOME=/usr/lib/eclipse -exec \$ECLIPSE_HOME/eclipse "\$@" -END - - install -Dm644 /dev/stdin "$pkgdir/usr/share/applications/eclipse.desktop" <<END -[Desktop Entry] -Name=Eclipse -Comment=A Java Development Environment -Icon=eclipse -Exec=eclipse -Terminal=false -Type=Application -Categories=Development;IDE;Java; -StartupNotify=true -END - - for _i in 16 32 48 256; do - install -Dm644 eclipse-common/plugins/org.eclipse.platform_*/eclipse${_i}.png \ - "$pkgdir/usr/share/icons/hicolor/${_i}x${_i}/apps/eclipse.png" - done -} - -_package() { - _variant=${1#eclipse-} - pkgdesc+=" (${_variant^^} variant)" - depends=(eclipse-common) - provides=("eclipse=$pkgver-$pkgrel") - conflicts=(eclipse) - - case $_variant in - java) replaces=(eclipse) ;; - cpp) replaces=(eclipse-cdt) ;; - esac - - install -d "$pkgdir/usr/lib" - cp -a $1 "$pkgdir/usr/lib/eclipse" -} Copied: eclipse/repos/extra-x86_64/PKGBUILD (from rev 321594, eclipse/trunk/PKGBUILD) =================================================================== --- PKGBUILD (rev 0) +++ PKGBUILD 2018-04-11 20:26:44 UTC (rev 321595) @@ -0,0 +1,98 @@ +# $Id$ +# Maintainer: Jan Alexander Steffens (heftig) <jan.steff...@gmail.com> +# Contributor: Ionut Biru <ib...@archlinux.org> +# Contributor: Paul Mattal <p...@archlinux.org> +# Contributor: Andrew Wright <andr...@photism.org> +# Contributor: Andreas W. Hauser <andy-...@splashground.de> +# Contributor: Marco Crosio <marco.cro...@gmail.com> + +pkgbase=eclipse +pkgname=(eclipse-{common,java,jee,cpp,php,javascript}) +pkgver=4.7.3.a +pkgrel=1 +_release=oxygen-3a +pkgdesc="Highly extensible IDE" +license=(EPL) +arch=(x86_64) +url="https://eclipse.org" +makedepends=(python3) +options=(!emptydirs) +source=(commonify) +noextract=() + +for _pkg in ${pkgname[@]}; do + [[ $_pkg == 'eclipse-common' ]] && continue + source+=(http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/technology/epp/downloads/release/${_release/-//}/$_pkg-$_release-linux-gtk-x86_64.tar.gz) + noextract+=($_pkg-$_release-linux-gtk-x86_64.tar.gz) + eval "package_$_pkg() { _package $_pkg; }" +done + +sha256sums=('da1eaf6239cb0c2b5009cd8c261e96e7b17a7536b12fe60fcb1e903f5e67dbdc' + '35325e7bd5e2b9149c844bc9fbbc9fb04a69e3c46515997a003c15509d3cfe54' + 'ca2146c31587c41200408ba509f617df3c1a9831c9886c7abcfebbaf94a59408' + '82e790efa5c02a7447506c85a138a2cef4fae815201c157480d630da1a55d5d9' + 'e991ed63ffed013729977175318ecd7945d0a16e3026cce0256e45e8c89b9632' + 'afc9a897736c6e4ad8199a7e7733363cf91569e8dde8e21e24c859577fc35c32') + +prepare() { + local pkg + for pkg in ${pkgname[@]}; do + mkdir $pkg + [[ $pkg == eclipse-common ]] && continue + bsdtar -xf "$pkg-$_release-linux-gtk-x86_64.tar.gz" -C $pkg --strip-components 1 + done +} + +build() { + mkdir eclipse-common/dropins + touch eclipse-common/dropins/.keep + ./commonify --identical ${pkgname[@]} +} + +package_eclipse-common() { + pkgdesc+=" (common files)" + depends=("java-environment>=8" webkit2gtk unzip) + + install -d "$pkgdir/usr/lib" + cp -a eclipse-common "$pkgdir/usr/lib/eclipse" + + install -D /dev/stdin "$pkgdir/usr/bin/eclipse" <<END +#!/bin/bash +export ECLIPSE_HOME=/usr/lib/eclipse +exec \$ECLIPSE_HOME/eclipse "\$@" +END + + install -Dm644 /dev/stdin "$pkgdir/usr/share/applications/eclipse.desktop" <<END +[Desktop Entry] +Name=Eclipse +Comment=A Java Development Environment +Icon=eclipse +Exec=eclipse +Terminal=false +Type=Application +Categories=Development;IDE;Java; +StartupNotify=true +END + + local i + for i in 16 32 48 256; do + install -Dm644 eclipse-common/plugins/org.eclipse.platform_*/eclipse$i.png \ + "$pkgdir/usr/share/icons/hicolor/${i}x$i/apps/eclipse.png" + done +} + +_package() { + local variant=${1#eclipse-} + pkgdesc+=" (${variant^^} variant)" + depends=(eclipse-common) + provides=("eclipse=$pkgver-$pkgrel") + conflicts=(eclipse) + + case $variant in + java) replaces=(eclipse) ;; + cpp) replaces=(eclipse-cdt) ;; + esac + + install -d "$pkgdir/usr/lib" + cp -a $1 "$pkgdir/usr/lib/eclipse" +} Deleted: commonify =================================================================== --- commonify 2018-04-11 20:20:37 UTC (rev 321594) +++ commonify 2018-04-11 20:26:44 UTC (rev 321595) @@ -1,157 +0,0 @@ -#!/usr/bin/env python3 -from argparse import ArgumentParser -from asyncio.subprocess import DEVNULL, PIPE -from asyncio import (get_event_loop, gather, BoundedSemaphore, create_subprocess_exec, - IncompleteReadError) -from enum import Enum, auto -from logging import getLogger, basicConfig, INFO -from os import cpu_count -from pathlib import Path -from sys import exit - - -logger = getLogger(__name__) - - -class Mode(Enum): - identical = auto() - nonconflicting = auto() - - -def parse_args(args=None): - parser = ArgumentParser(description='Extract common files.') - - modes = parser.add_mutually_exclusive_group(required=True) - for m in Mode: - modes.add_argument(f'--{m.name}', dest='mode', action='store_const', const=m, - help=f'extract {m.name} common files') - - parser.add_argument('-n', '--dry-run', action='store_true', help='Dry run (do nothing)') - parser.add_argument('common_dir', metavar='COMMON_DIR', - help='common files directory to move to') - parser.add_argument('targets', nargs='+', metavar='INPUT_DIR', help='directory to move from') - - return parser.parse_args(args) - - -class bounded_exec: - semaphore = BoundedSemaphore(value=cpu_count() + 1) - - def __init__(self, *args, **kwargs): - self.args = args - self.kwargs = kwargs - - async def __aenter__(self): - await self.semaphore.acquire() - p = self.process = await create_subprocess_exec(*self.args, **self.kwargs) - return p - - async def __aexit__(self, exc_type, exc, tb): - p = self.process - if p.returncode is None: - try: - p.kill() - except: - pass - await p.wait() - self.semaphore.release() - - -class DiffError(RuntimeError): - pass - - -async def diff(file1, file2): - async with bounded_exec('diff', '-q', str(file1), str(file2), - stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL) as p: - ret = await p.wait() - - if ret != 0: - raise DiffError() - - -async def identical(files): - if len(files) < 2: - return True - first, *rest = files - fut = gather(*[diff(first, f) for f in rest]) - try: - await fut - except DiffError as e: - return False - else: - return True - finally: - fut.cancel() - -def commonify_file(common_file, files): - common_file.parent.mkdir(parents=True, exist_ok=True) - first, *rest = files - first.rename(common_file) - for f in rest: - f.unlink() - - -async def commonify_identical(common_file, files, *, dry_run=False): - if await identical(files): - if not dry_run: - commonify_file(common_file, files) - return 1 - else: - logger.info('Divergent file: %s', common_file) - return 0 - - -async def find_files(path): - async with bounded_exec('find', str(path), '-type', 'f', '-print0', - stdin=DEVNULL, stdout=PIPE, stderr=DEVNULL) as p: - while True: - try: - line = await p.stdout.readuntil(b'\x00') - except IncompleteReadError as e: - line = e.partial - if not line: - break - raise - yield Path(line[:-1].decode()) - - -async def scan(target, files_targetfiles): - n = 0 - async for f in find_files(target): - files_targetfiles.setdefault(f.relative_to(target), []).append(f) - n += 1 - logger.info('%s: Found %d files', target, n) - - -def arg_dir(s): - p = Path(s) - if not p.is_dir(): - raise ValueError(f'{s!r} is not a directory') - return p - - -async def main(settings): - ignore_len = settings.mode == Mode.nonconflicting - common_dir = arg_dir(settings.common_dir) - targets = [arg_dir(t) for t in settings.targets] - - files_targetfiles = {} - await gather(*[scan(t, files_targetfiles) for t in targets]) - - results = await gather(*[ - commonify_identical(common_dir / f, tf, dry_run=settings.dry_run) - for f, tf in files_targetfiles.items() - if ignore_len or len(tf) == len(targets) - ]) - - logger.info('%s: %d %s files', - common_dir, sum(results), settings.mode.name) - return 0 - - -if __name__ == '__main__': - basicConfig(level=INFO) - settings = parse_args() - loop = get_event_loop() - exit(loop.run_until_complete(main(settings))) Copied: eclipse/repos/extra-x86_64/commonify (from rev 321594, eclipse/trunk/commonify) =================================================================== --- commonify (rev 0) +++ commonify 2018-04-11 20:26:44 UTC (rev 321595) @@ -0,0 +1,157 @@ +#!/usr/bin/env python3 +from argparse import ArgumentParser +from asyncio.subprocess import DEVNULL, PIPE +from asyncio import (get_event_loop, gather, BoundedSemaphore, create_subprocess_exec, + IncompleteReadError) +from enum import Enum, auto +from logging import getLogger, basicConfig, INFO +from os import cpu_count +from pathlib import Path +from sys import exit + + +logger = getLogger(__name__) + + +class Mode(Enum): + identical = auto() + nonconflicting = auto() + + +def parse_args(args=None): + parser = ArgumentParser(description='Extract common files.') + + modes = parser.add_mutually_exclusive_group(required=True) + for m in Mode: + modes.add_argument(f'--{m.name}', dest='mode', action='store_const', const=m, + help=f'extract {m.name} common files') + + parser.add_argument('-n', '--dry-run', action='store_true', help='Dry run (do nothing)') + parser.add_argument('common_dir', metavar='COMMON_DIR', + help='common files directory to move to') + parser.add_argument('targets', nargs='+', metavar='INPUT_DIR', help='directory to move from') + + return parser.parse_args(args) + + +class bounded_exec: + semaphore = BoundedSemaphore(value=cpu_count() + 1) + + def __init__(self, *args, **kwargs): + self.args = args + self.kwargs = kwargs + + async def __aenter__(self): + await self.semaphore.acquire() + p = self.process = await create_subprocess_exec(*self.args, **self.kwargs) + return p + + async def __aexit__(self, exc_type, exc, tb): + p = self.process + if p.returncode is None: + try: + p.kill() + except: + pass + await p.wait() + self.semaphore.release() + + +class DiffError(RuntimeError): + pass + + +async def diff(file1, file2): + async with bounded_exec('diff', '-q', str(file1), str(file2), + stdin=DEVNULL, stdout=DEVNULL, stderr=DEVNULL) as p: + ret = await p.wait() + + if ret != 0: + raise DiffError() + + +async def identical(files): + if len(files) < 2: + return True + first, *rest = files + fut = gather(*[diff(first, f) for f in rest]) + try: + await fut + except DiffError as e: + return False + else: + return True + finally: + fut.cancel() + +def commonify_file(common_file, files): + common_file.parent.mkdir(parents=True, exist_ok=True) + first, *rest = files + first.rename(common_file) + for f in rest: + f.unlink() + + +async def commonify_identical(common_file, files, *, dry_run=False): + if await identical(files): + if not dry_run: + commonify_file(common_file, files) + return 1 + else: + logger.info('Divergent file: %s', common_file) + return 0 + + +async def find_files(path): + async with bounded_exec('find', str(path), '-type', 'f', '-print0', + stdin=DEVNULL, stdout=PIPE, stderr=DEVNULL) as p: + while True: + try: + line = await p.stdout.readuntil(b'\x00') + except IncompleteReadError as e: + line = e.partial + if not line: + break + raise + yield Path(line[:-1].decode()) + + +async def scan(target, files_targetfiles): + n = 0 + async for f in find_files(target): + files_targetfiles.setdefault(f.relative_to(target), []).append(f) + n += 1 + logger.info('%s: Found %d files', target, n) + + +def arg_dir(s): + p = Path(s) + if not p.is_dir(): + raise ValueError(f'{s!r} is not a directory') + return p + + +async def main(settings): + ignore_len = settings.mode == Mode.nonconflicting + common_dir = arg_dir(settings.common_dir) + targets = [arg_dir(t) for t in settings.targets] + + files_targetfiles = {} + await gather(*[scan(t, files_targetfiles) for t in targets]) + + results = await gather(*[ + commonify_identical(common_dir / f, tf, dry_run=settings.dry_run) + for f, tf in files_targetfiles.items() + if ignore_len or len(tf) == len(targets) + ]) + + logger.info('%s: %d %s files', + common_dir, sum(results), settings.mode.name) + return 0 + + +if __name__ == '__main__': + basicConfig(level=INFO) + settings = parse_args() + loop = get_event_loop() + exit(loop.run_until_complete(main(settings)))