aboutsummaryrefslogtreecommitdiff
# Contributor: Wojtek Kosior <kwojtus@protonmail.com>

# Loosely based on Hyperbola's binutils package

pkgname=binutils-source
_pkgver=2.28
pkgver=${_pkgver}.0
_debrel=5
pkgrel=1
pkgdesc="Source of a set of programs to assemble and manipulate binary and object files"
arch=('any')
url="https://www.gnu.org/software/binutils/"
license=('GPL-3' 'LGPL-3')
depends=('quilt')
source=(https://ftp.gnu.org/gnu/binutils/binutils-$_pkgver.tar.bz2{,.sig}
        https://deb.debian.org/debian/pool/main/b/binutils/binutils_$_pkgver-$_debrel.diff.gz)
validpgpkeys=('EAF1C276A747E9ED86210CBAC3126D3B4AE55E93') # Tristan Gingold <gingold@adacore.com>
sha512sums=('ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd'
            'SKIP'
            '77933ab9543db3ad9640f737d4cd688ddc9da7b91d72fe0f18f9f3457a499e31ca9b27674790e00b5e7c29c85a5ec4fd09ed58de92ca0a8622422886d20a6add')

noextract=(binutils-$_pkgver.tar.bz2)

# Many patches fail to apply. These are the files that work. We'll only use them.
_desired_patch_files=(001_ld_makefile_patch.patch
		      006_better_file_error.patch
		      012_check_ldrunpath_length.patch
		      013_bash_in_ld_testsuite.patch
		      128_build_id.patch
		      130_gold_disable_testsuite_build.patch
		      131_ld_bootstrap_testsuite.patch
		      157_ar_scripts_with_tilde.patch
		      i18n-fr.diff
		      pr21074-revert.diff
		      pr21135.diff
		      pr21137.diff
		      pr21139.diff
		      pr21156.diff
		      pr21157.diff
		      pr21342.diff
		      pr21412.diff
		      pr21414.diff
		      pr21431.diff
		      pr21432.diff
		      pr21434.diff
		      pr21438.diff
		      pr21440.diff
		      pr70909.diff
		      pr-ld-16428.diff
		      series)

prepare() {
    cd "${srcdir}"

    # this command creates, among all, the directory debian/patches and fills it
    patch -p1 -i binutils_$_pkgver-$_debrel.diff

    # Patches and 'series' file will go to /usr/src/binutils/debian_patches.
    # We're not interested in rest of the stuff in debian/.

    # here we create script to be used for unpacking binutils sources we'll install
    
    echo "\
#!/bin/sh

mkdir -p \"\$1\" && cd \"\$1\"

bsdtar -xf /usr/src/binutils/binutils-$_pkgver.tar.bz2

export QUILT_PATCHES=/usr/src/binutils/debian_patches
export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'	
export QUILT_DIFF_ARGS='--no-timestamps'

cd binutils-${_pkgver}

quilt push -av
rm -r .pc/" > prepare-binutils-source
}

package () {
    install -m755 -d "${pkgdir}/usr/src/binutils/debian_patches/"

    # install patches
    cd "${srcdir}/debian/patches"
    install -m644 ${_desired_patch_files[@]} "${pkgdir}/usr/src/binutils/debian_patches"

    # install tarballs
    install -m644 "${srcdir}/binutils-$_pkgver.tar.bz2" "${pkgdir}/usr/src/binutils"

    # install our script
    install -m755 -d "${pkgdir}/usr/bin"
    install -m755 "${srcdir}/prepare-binutils-source" "${pkgdir}/usr/bin"
}