summaryrefslogtreecommitdiff
path: root/libre/netpbm/PKGBUILD
blob: 9bb74cbc2d0f8fda33d412b7131543214cb6e6ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor (Hyperbola): André Silva <emulatorman@hyperbola.info>
# Maintainer (Arch):
# parabola changes and rationale:
# - Added armv7h and i686 support
# - Removed nonfree parts

pkgname=netpbm
pkgver=10.73.36
pkgrel=1
pkgrel+=.parabola1
pkgdesc="A toolkit for manipulation of graphic images"
pkgdesc+=", without nonfree parts"
arch=('x86_64')
arch+=('i686' 'armv7h')
license=('custom' 'BSD' 'GPL' 'LGPL')
url="http://netpbm.sourceforge.net/"
depends=('perl' 'libpng' 'libtiff' 'libxml2')
makedepends=('python2' 'jbigkit' 'subversion')
options=('!makeflags')
# Get docs with: wget --recursive --relative -nH http://netpbm.sourceforge.net/doc/
source=(https://downloads.sourceforge.net/project/netpbm/super_stable/$pkgver/netpbm-$pkgver.tgz
        https://sources.archlinux.org/other/packages/netpbm/netpbm-doc-31Jan2014.tar.xz{,.sig}
        netpbm-CAN-2005-2471.patch netpbm-security-code.patch netpbm-security-scripts.patch
        reproducible-man-gzip.patch use-source-date-epoch.patch)
sha256sums=('93b31b11b003082d5fd4037ae5c768b91ea7330b10247a25086c10b5dd71e445'
            '74bcf840ee643c6917330c382484010cb99c004a3fcf05391bebcac63815acb3'
            'SKIP'
            '991aba7897e0710687369b4e2edfba1397ecd77d62578eac496afbc47b5ca970'
            '83d75a80ce999d8b69572e54f04c4d220c60b0d09f9e52d3236264535c3bf216'
            '2c397588d9cba2c40dee55c07713d5e77e0e04245db939fdc1962d7de4cf4a33'
            '8e3efdb4fcbfdc8e9a5c8e9663c7d6b9ecef3a2379ce38d2acc5669c339f6814'
            '68055341833f482c6910a56c2fdfe046978a1a92fd8442a2a9209c82ce3e4d13')
validpgpkeys=('5357F3B111688D88C1D88119FCF2CB179205AC90')

remove_program() {
    file="$1"
    progname="$(basename ${file} | sed 's/\.c$//')"

    rm -v "${file}"
    sed -i "s/${progname}//g" "$(dirname ${file})/Makefile"
    sed -i "s/${progname}\.1//g" buildtools/manpage.mk
}

prepare() {
  cd $pkgname-$pkgver

  patch -p1 < ../netpbm-CAN-2005-2471.patch
  patch -p1 < ../netpbm-security-code.patch
  patch -p1 < ../netpbm-security-scripts.patch
  patch -p1 < ../reproducible-man-gzip.patch
  patch -p1 < ../use-source-date-epoch.patch
  sed -i 's|#!/usr/bin/python|#!/usr/bin/python2|' buildtools/makeman
  sed -i 's|@python|@python2|' buildtools/manpage.mk

  cp config.mk.in  config.mk
  [ "${CARCH}" = 'x86_64' ] && echo 'CFLAGS_SHLIB = -fPIC' >> config.mk
  [ "${CARCH}" = 'armv7h' ] && echo 'CFLAGS_SHLIB = -fPIC' >> config.mk
  echo "NETPBM_DOCURL = file://${srcdir}/doc" >> config.mk
  echo 'TIFFLIB = libtiff.so' >> config.mk
  echo 'JPEGLIB = libjpeg.so' >> config.mk
  echo 'PNGLIB = libpng.so' >> config.mk
  echo 'ZLIB = libz.so' >> config.mk
  echo 'JBIGLIB = /usr/lib/libjbig.a' >> config.mk

  sed -i 's|misc|share/netpbm|' common.mk
  sed -i 's|/link|/lib|' lib/Makefile
  sed -i 's|install.manwebmain install.manweb install.man|install.man|' GNUmakefile

  # Remove the converter/ppm/hpcdtoppm directory:
  # - hpcdtoppm: as hpcdtoppm is not even redistributable, this hpcdtoppm only
  #   prints a message to steer users toward downloading "the real hpcdtoppm"
  #   which is nonfree
  # - pcdovtoppm: no license information
  rm -rv converter/ppm/hpcdtoppm
  sed '/\.\/converter\/ppm\/hpcdtoppm \\/d' -i GNUmakefile
  sed 's/hpcdtoppm//g' -i converter/ppm/Makefile

  # Removing programs without license information
  remove_program converter/other/pamtopnm.c
  remove_program converter/pbm/pbmto4425.c
  remove_program converter/pbm/pbmtoln03.c
  remove_program converter/pbm/pbmtolps.c
  remove_program converter/pbm/pbmtopk.c
  remove_program converter/pbm/pktopbm.c
  remove_program converter/pgm/spottopgm.c
  remove_program converter/ppm/ppmtogif.c
  remove_program converter/ppm/ppmtopjxl.c
  remove_program other/pamchannel.c

  # Tests have no license information
  rm -v -rf test/
  # Remove test from "SUPPORT_SUBDIRS = urt icon buildtools test"
  awk '{
    if ($1 != "SUPPORT_SUBDIRS") {
      print $0
    } else {
      for (i=1;i<=NF;i++) {
        if($i != "test") {
          printf $i " "
        }
      }
    }
  }' GNUmakefile > GNUmakefile.1
  mv -f GNUmakefile.1 GNUmakefile

  sed -i '/pnmtopnm/d' netpbm.c

  #Removing references about nonfree licenses part
  sed -i '338,383d' doc/copyright_summary

}

build() {
  cd $pkgname-$pkgver
  make
  # Generating useful man pages with html doc
  make MAKEMAN="${srcdir}/$pkgname-$pkgver/buildtools/makeman" USERGUIDE=. \
    -C ../doc -f "${srcdir}/$pkgname-$pkgver/buildtools/manpage.mk" manpages
}

package() {
  cd $pkgname-$pkgver
  make pkgdir="${pkgdir}/usr" PKGMANDIR=share/man install-run install-dev

# Removing dummy man pages
  rm "${pkgdir}"/usr/share/man/man{1,3,5}/*

  make MAKEMAN="${srcdir}/$pkgname-$pkgver/buildtools/makeman" MANDIR="${pkgdir}/usr/share/man" \
    -C ../doc -f "${srcdir}/$pkgname-$pkgver/buildtools/manpage.mk" installman

# Replace obsolete utility
  echo -e '#!/bin/sh\npamditherbw $@ | pamtopnm\n' > "${pkgdir}/usr/bin/pgmtopbm"

# Licensing.  Note that each program in the package has a separate license.
  install -D -m644 "${srcdir}/$pkgname-$pkgver/doc/copyright_summary" \
    "${pkgdir}/usr/share/licenses/${pkgname}/copyright_summary.txt"
}