From 00a6021aae396c140e786382007064f10ca254a1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 7 Feb 2016 18:00:44 -0500 Subject: Update librefetch to work with pacman 5. --- src/librefetch/Makefile | 2 + src/librefetch/librefetch | 92 +++++----------------- src/librefetch/librefetch.8.ronn | 7 +- src/librefetch/librefetchdir/Makefile | 56 +++++++++++++ .../librefetchdir/libmakepkg/source.sh.gen | 25 ++++++ .../librefetchdir/libmakepkg/tidy/purge.sh | 58 ++++++++++++++ .../libmakepkg/tidy/~source_date_epoch.sh | 31 ++++++++ src/librefetch/librefetchdir/makepkg.gen | 42 ++++++++++ 8 files changed, 237 insertions(+), 76 deletions(-) create mode 100644 src/librefetch/librefetchdir/Makefile create mode 100755 src/librefetch/librefetchdir/libmakepkg/source.sh.gen create mode 100755 src/librefetch/librefetchdir/libmakepkg/tidy/purge.sh create mode 100755 src/librefetch/librefetchdir/libmakepkg/tidy/~source_date_epoch.sh create mode 100755 src/librefetch/librefetchdir/makepkg.gen (limited to 'src/librefetch') diff --git a/src/librefetch/Makefile b/src/librefetch/Makefile index bbc2384..dcb64dc 100644 --- a/src/librefetch/Makefile +++ b/src/librefetch/Makefile @@ -1,3 +1,5 @@ progs = librefetch-install confs = librefetch-makepkg.conf +libexecs = $(shell find librefetchdir -type f -executable) +libs = $(shell find librefetchdir -type f -not -executable) include ../../common.mk diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index 2c8e456..2b8af61 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -1,7 +1,7 @@ #!/usr/bin/env bash # librefetch # -# Copyright (C) 2013-2015 Luke Shumaker +# Copyright (C) 2013-2016 Luke Shumaker # # For just the create_signature() function: # Copyright (C) 2006-2013 Pacman Development Team @@ -14,20 +14,20 @@ # # License: GNU GPLv3+ # -# This file is part of Parabola. +# This file is part of LibreFetch. # -# Parabola is free software: you can redistribute it and/or modify +# LibreFetch is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# Parabola is distributed in the hope that it will be useful, +# LibreFetch is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with Parabola. If not, see . +# along with LibreFetch. If not, see . # create_signature() is taken from pacman:makepkg, which is GPLv2+, # so we take the '+' to combine it with our GPLv3+. @@ -37,7 +37,8 @@ setup_traps tmpfiles=() -trap 'rm -f -- "${tmpfiles[@]}"' EXIT +tmpdirs=() +trap 'rm -f -- "${tmpfiles[@]}"; rm -rf -- "${tmpdirs[@]}"' EXIT cmd=${0##*/} usage() { @@ -86,7 +87,8 @@ usage() { 'Alternate modes:' \ "-g, --geninteg" "Generate integrity checks for source files" \ "-S, --srcbuild" "Print the effective build script (SRCBUILD)" \ - "-M, --makepkg" "Print the effective makepkg script" \ + "-M, --makepkg" "Generate and print the location of the + effective makepkg script" \ "-h, --help" "Show this message" } @@ -113,14 +115,15 @@ doit() { ######################################################################## - makepkg="$(modified_makepkg "$(which makepkg)")" - tmpfiles+=("$makepkg") + makepkg="$(modified_makepkg)" # Mode: makepkg ######################################################## if [[ $mode =~ makepkg ]]; then - cat "$makepkg" + printf '%s\n' "$makepkg" exit 0 + else + tmpdirs+=("${makepkg%/*}") fi ######################################################################## @@ -306,67 +309,10 @@ parse_options() { # Modify makepkg ############################################################### -# an ERE -makepkg_modify=' -/create_package\(\) \{/,/^\}$/ { - /pkg_file=/d # allow us to set pkg_file - s/"?\$\{comp_files\[@\]\}"?// # do not include .{PKGINFO,INSTALL,CHANGELOG} - # This is long/gross. What it does: - # - pass --format=ustar to bsdtar, to inhibit it using the pax format - # - take the files that would be included in the tarball, and use - # find/sort/--files-from to order them for bsdtar - s/bsdtar(.*) - ([^|]*) \|/find \2 -print0 | LC_ALL=C sort --zero-terminated | bsdtar --null --files-from - --format=ustar --no-recursion \1 - |/ - s/create_signature .*/&; return $?/ # do not procede to create symlinks -} - -/tidy_install\(\) \{/,/^\}$/ { - /for .*PURGE_TARGETS/itidy_install_purge - /for .*PURGE_TARGETS/,/done/d - /^\}$/ifind . -exec touch --no-dereference --date="1990-01-01 0:0:0 +0" -- {} + -} - -/download_sources\(\) \{/ { - arm -rf "$srcdir"\nmkdir "$srcdir" -} - -s|Making package:|Making source:| -s|Checking runtime dependencies\.\.\.|Checking source dependencies...| - /Checking buildtime dependencies\.\.\./d - -s|srcdir=.*|&-libre| -s|pkgdirbase=.*|&-libre| -s|check_build_status$|:| -' - -tidy_install_purge() { - local pt - for pt in "${PURGE_TARGETS[@]}"; do - if [[ ${pt} = "${pt%/}" ]]; then - if [[ ${pt} = "${pt//\/}" ]]; then - find . ! -type d -name "${pt}" -exec rm -f -- '{}' + - else - rm -f "${pt}" - fi - else - if [[ ${pt%/} = "${pt//\/}" ]]; then - find . -type d -name "${pt%/}" -exec rm -rf -- '{}' + - else - rm -rf "${pt}" - fi - fi - done -} - modified_makepkg() { - local makepkg_orig=$1 - local makepkg_mine="$(mktemp --tmpdir "${cmd}.XXXXXXXXXXX.makepkg")" - { - echo '#!/bin/bash' - declare -f tidy_install_purge - sed -r "$makepkg_modify" < "$makepkg_orig" - } > "$makepkg_mine" - chmod 755 "$makepkg_mine" - realpath -es "$makepkg_mine" + local dir="$(mktemp --tmpdir --directory "${cmd}.XXXXXXXXXXX.makepkg")" + make -s -f "$(librelib librefetchdir/Makefile)" new="$dir" + realpath -es "$dir/makepkg" } # Modify PKGBUILD ############################################################## @@ -397,7 +343,7 @@ checkdepends=() ; unset "checkdepends_${CARCH}" makedepends=("${mkdepends[@]}") ; unset "makedepends_${CARCH}" #### -options=(!strip docs libtool staticlibs emptydirs !zipman purge !upx) +options=(!strip docs libtool staticlibs emptydirs !zipman purge !upx !optipng !debug) PURGE_TARGETS=(.bzr/ .cvs/ .git/ .hg/ .svn/ .makepkg/) #### @@ -439,8 +385,8 @@ create_signature() { if [[ -n $GPGKEY ]]; then SIGNWITHKEY=(-u "${GPGKEY}") fi - # The signature will be generated directly in ascii-friendly format - gpg --detach-sign --use-agent "${SIGNWITHKEY[@]}" "$filename" || ret=$? + + gpg --detach-sign --use-agent "${SIGNWITHKEY[@]}" --no-armor "$filename" &>/dev/null || ret=$? if (( ! ret )); then diff --git a/src/librefetch/librefetch.8.ronn b/src/librefetch/librefetch.8.ronn index 7d3550f..5720c8d 100644 --- a/src/librefetch/librefetch.8.ronn +++ b/src/librefetch/librefetch.8.ronn @@ -32,7 +32,8 @@ There are 5 modes: * `create`: Create the tarball from a `PKGBUILD`/`SRCBUILD`. * `checksums`: Generate integrity checks for source files. * `srcbuild`: Print the effective build script. - * `makepkg`: Print the effective makepkg script. + * `makepkg`: Generate and print the location of the effective makepkg + script. * `help`: Print `librefetch` usage information. The normal mode of operation is `download` mode. If `download` mode @@ -49,8 +50,8 @@ fails, it may choose to try `create` mode. checks for source files. * `-S` | `--srcbuild`: Use `srcbuild` mode: print the effective build script. - * `-M` | `--makepkg`: Use `makepkg` mode: print the effective makepkg - script. + * `-M` | `--makepkg`: Use `makepkg` mode: generate and print the + location of the effective makepkg script. * `-h` | `--help`: Use `help` mode: Show usage information. Other options, if they are documented in `makepkg -h`, are passed to diff --git a/src/librefetch/librefetchdir/Makefile b/src/librefetch/librefetchdir/Makefile new file mode 100644 index 0000000..58116bb --- /dev/null +++ b/src/librefetch/librefetchdir/Makefile @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# librefetchdir/Makefile +# +# Copyright (C) 2016 Luke Shumaker +# +# License: GNU GPLv3+ +# +# This file is part of LibreFetch. +# +# LibreFetch is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# LibreFetch is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreFetch. If not, see . + +# new = +librefetchdir := $(dir $(lastword $(MAKEFILE_LIST))) + +old_makepkg := $(shell which makepkg) +old_library := $(shell $(shell grep LIBRARY= $(old_makepkg)); echo $$LIBRARY) + +new_makepkg = $(new)/makepkg +new_library = $(new)/libmakepkg + +targets += $(new_makepkg) +targets += $(patsubst $(old_library)/%,$(new_library)/%,$(shell find $(old_library) -type f)) +targets += $(new_library)/tidy/~source_date_epoch.sh + +all: $(targets) +.PHONY: all + +.SECONDARY: +.DELETE_ON_ERROR: + +$(new_makepkg): $(old_makepkg) $(librefetchdir)/makepkg.gen + <$^ | install -Dm755 /dev/stdin $@ + +$(new_library)/source.sh: \ +$(new_library)/%: $(old_library)/% $(librefetchdir)/libmakepkg/%.gen + <$^ | install -Dm755 /dev/stdin $@ + +$(new_library)/tidy/purge.sh $(new_library)/tidy/~source_date_epoch.sh: \ +$(new_library)/%: $(librefetchdir)/libmakepkg/% + mkdir -p $(@D) + ln -sfT $(abspath $< $@) + +$(new_library)/%: $(old_library)/% + mkdir -p $(@D) + ln -sfT $(abspath $< $@) diff --git a/src/librefetch/librefetchdir/libmakepkg/source.sh.gen b/src/librefetch/librefetchdir/libmakepkg/source.sh.gen new file mode 100755 index 0000000..269f9fd --- /dev/null +++ b/src/librefetch/librefetchdir/libmakepkg/source.sh.gen @@ -0,0 +1,25 @@ +#!/usr/bin/sed -rf +# librefetchdir/makepkg.gen +# +# Copyright (C) 2013, 2016 Luke Shumaker +# +# License: GNU GPLv3+ +# +# This file is part of LibreFetch. +# +# LibreFetch is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# LibreFetch is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreFetch. If not, see . + +/download_sources\(\) \{/ { + arm -rf "$srcdir"\nmkdir "$srcdir" +} diff --git a/src/librefetch/librefetchdir/libmakepkg/tidy/purge.sh b/src/librefetch/librefetchdir/libmakepkg/tidy/purge.sh new file mode 100755 index 0000000..acb0030 --- /dev/null +++ b/src/librefetch/librefetchdir/libmakepkg/tidy/purge.sh @@ -0,0 +1,58 @@ +#!/usr/bin/bash +# +# purge.sh - Remove unwanted files from the package +# +# Copyright (c) 2008-2016 Pacman Development Team +# Copyright (c) 2013-2016 Luke Shumaker +# +# License: GNU GPLv2+ +# +# This file is part of LibreFetch +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +[[ -n "$LIBMAKEPKG_TIDY_PURGE_SH" ]] && return +LIBMAKEPKG_TIDY_PURGE_SH=1 + +LIBRARY=${LIBRARY:-'/usr/share/makepkg'} + +source "$LIBRARY/util/message.sh" +source "$LIBRARY/util/option.sh" + + +packaging_options+=('purge') +tidy_remove+=('tidy_purge') + +tidy_purge() { + if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then + msg2 "$(gettext "Purging unwanted files...")" + local pt + for pt in "${PURGE_TARGETS[@]}"; do + if [[ ${pt} = "${pt%/}" ]]; then + if [[ ${pt} = "${pt//\/}" ]]; then + find . ! -type d -name "${pt}" -exec rm -f -- '{}' + + else + rm -f "${pt}" + fi + else + if [[ ${pt%/} = "${pt//\/}" ]]; then + find . -type d -name "${pt%/}" -exec rm -rf -- '{}' + + else + rm -rf "${pt}" + fi + fi + done + fi +} diff --git a/src/librefetch/librefetchdir/libmakepkg/tidy/~source_date_epoch.sh b/src/librefetch/librefetchdir/libmakepkg/tidy/~source_date_epoch.sh new file mode 100755 index 0000000..562820b --- /dev/null +++ b/src/librefetch/librefetchdir/libmakepkg/tidy/~source_date_epoch.sh @@ -0,0 +1,31 @@ +#!/usr/bin/bash +# +# librefetchdir/libmakepkg/tidy/~source_date_epoch.sh +# +# Copyright (C) 2013-2016 Luke Shumaker +# +# License: GNU GPLv3+ +# +# This file is part of LibreFetch. +# +# LibreFetch is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# LibreFetch is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreFetch. If not, see . + +[[ -n "$LIBMAKEPKG_TIDY_SOURCE_DATE_EPOCH_SH" ]] && return +LIBMAKEPKG_TIDY_SOURCE_DATE_EPOCH_SH=1 + +tidy_modify+=('tidy_source_date_epoch') + +tidy_source_date_epoch() { + find . -exec touch --no-dereference --date="1990-01-01 0:0:0 +0" -- {} + +} diff --git a/src/librefetch/librefetchdir/makepkg.gen b/src/librefetch/librefetchdir/makepkg.gen new file mode 100755 index 0000000..8928d91 --- /dev/null +++ b/src/librefetch/librefetchdir/makepkg.gen @@ -0,0 +1,42 @@ +#!/usr/bin/sed -rf +# librefetchdir/makepkg.gen +# +# Copyright (C) 2013-2016 Luke Shumaker +# +# License: GNU GPLv3+ +# +# This file is part of LibreFetch. +# +# LibreFetch is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# LibreFetch is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with LibreFetch. If not, see . + +/LIBRARY=/iexport LIBRARY="${0%/*}/libmakepkg" + +/create_package\(\) \{/,/^\}$/ { + /pkg_file=/d # allow us to set pkg_file + s/"?\$\{comp_files\[@\]\}"?// # do not include .{PKGINFO,BUILDINGO,CHANGELOG,INSTALL,MTREE} + # This is long/gross. What it does: + # - pass --format=ustar to bsdtar, to inhibit it using the pax format + # - take the files that would be included in the tarball, and use + # find/sort/--files-from to order them for bsdtar + s/bsdtar(.*) - ([^|]*) \|/find \2 -print0 | LC_ALL=C sort --zero-terminated | bsdtar --null --files-from - --format=ustar --no-recursion \1 - |/ + s/create_signature .*/&; return $?/ # do not procede to create symlinks +} + +s|Making package:|Making source:| +s|Checking runtime dependencies\.\.\.|Checking source dependencies...| + /Checking buildtime dependencies\.\.\./d + +s|srcdir=.*|&-libre| +s|pkgdirbase=.*|&-libre| +s|check_build_status$|:| -- cgit v1.2.2