Bug 185189 - [patch] freeing graphics/netpbm from bash dep
Summary: [patch] freeing graphics/netpbm from bash dep
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Dirk Meyer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-25 21:20 UTC by Matthieu Volat
Modified: 2013-12-30 12:00 UTC (History)
0 users

See Also:


Attachments
file.shar (2.69 KB, text/plain)
2013-12-25 21:20 UTC, Matthieu Volat
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthieu Volat 2013-12-25 21:20:00 UTC
Here's an attempt to de-bashify graphics/netpbm, there is two routes possibles :
1. Moderatly fix editor/ppmquantall to run with /bin/sh
2. Lightly fix editor/ppmquantall.csh and copy it to replace editor/ppmquantall

Both would work, I've attached patches to fix said scripts. Solution 1 use a bigger patch, but is more straightforward.

Fix: See joined shar archives for ppmquantall(.csh) fixes. Then remove bash dependency and enjoy a (more) bash-free netpbm :)

Patch attached with submission follows:
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-12-30 03:19:31 UTC
Responsible Changed
From-To: freebsd-ports-bugs->dinoex

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 dfilter service freebsd_committer freebsd_triage 2013-12-30 11:51:15 UTC
Author: dinoex
Date: Mon Dec 30 11:51:07 2013
New Revision: 338093
URL: http://svnweb.freebsd.org/changeset/ports/338093

Log:
  - convert from bash to sh
  PR:		185189
  Submitted by:	Matthieu Volat
  
  - bugfix for filenames with spaces.

Added:
  head/graphics/netpbm/files/patch-ppmquantall.csh   (contents, props changed)
Modified:
  head/graphics/netpbm/Makefile
  head/graphics/netpbm/files/patch-ppmquantall

Modified: head/graphics/netpbm/Makefile
==============================================================================
--- head/graphics/netpbm/Makefile	Mon Dec 30 11:46:38 2013	(r338092)
+++ head/graphics/netpbm/Makefile	Mon Dec 30 11:51:07 2013	(r338093)
@@ -18,7 +18,6 @@ LIB_DEPENDS=	libtiff.so:${PORTSDIR}/grap
 		libjbig.so:${PORTSDIR}/graphics/jbigkit \
 		libjasper.so:${PORTSDIR}/graphics/jasper \
 		libxml2.so:${PORTSDIR}/textproc/libxml2
-RUN_DEPENDS=	bash:${PORTSDIR}/shells/bash
 
 USES=		gmake perl5
 CFLAGS+=	-DPNG_DEPSTRUCT= -Iutil

Modified: head/graphics/netpbm/files/patch-ppmquantall
==============================================================================
--- head/graphics/netpbm/files/patch-ppmquantall	Mon Dec 30 11:46:38 2013	(r338092)
+++ head/graphics/netpbm/files/patch-ppmquantall	Mon Dec 30 11:51:07 2013	(r338093)
@@ -1,8 +1,55 @@
---- editor/ppmquantall.orig	2012-03-09 22:16:02.000000000 +0900
-+++ editor/ppmquantall	2012-03-09 22:16:29.000000000 +0900
-@@ -1,4 +1,4 @@
--#!/bin/sh
-+#!/usr/local/bin/bash
- #
- # ppmquantall - run ppmquant on a bunch of files all at once, so they share
- #               a common colormap
+--- editor/ppmquantall.orig	2009-04-28 03:43:45.000000000 +0200
++++ editor/ppmquantall	2013-12-30 12:26:49.000000000 +0100
+@@ -53,8 +53,6 @@
+ 
+ newcolors=$1
+ shift
+-nfiles=$#
+-files=($@)
+ 
+ # Extract the width and height of each of the images.
+ # Here, we make the assumption that the width and height are on the
+@@ -62,14 +60,6 @@
+ # To be robust, we need to use Pnmfile to get that information, or 
+ # Put this program in C and use ppm_readppminit().
+ 
+-widths=()
+-heights=()
+-
+-for i in ${files[@]}; do
+-    widths=(${widths[*]} `grep -v '^#' $i | sed '1d; s/ .*//; 2q'`)
+-    heights=(${heights[*]} `grep -v '^#' $i | sed '1d; s/.* //; 2q'`)
+-done
+-
+ tempdir="${TMPDIR-/tmp}/ppmquantall.$$"
+ mkdir $tempdir || { echo "Could not create temporary file. Exiting."; exit 1;}
+ chmod 700 $tempdir
+@@ -78,7 +68,7 @@
+ 
+ all=$tempdir/pqa.all.$$
+ 
+-pnmcat -topbottom -jleft -white ${files[@]} | pnmquant $newcolors > $all
++pnmcat -topbottom -jleft -white "$@" | pnmquant $newcolors > $all
+ if [ $? != 0 ]; then
+     exit $?
+ fi
+@@ -86,12 +76,15 @@
+ y=0
+ i=0
+ 
+-while [ $i -lt $nfiles ]; do
+-    pamcut -left 0 -top $y -width ${widths[$i]} -height ${heights[$i]} $all \
+-        > ${files[$i]}$ext
++for f in "$@"; do
++    width=`grep -v '^#' "$f" | sed '1d; s/ .*//; 2q'`
++    height=`grep -v '^#' "$f" | sed '1d; s/.* //; 2q'`
++
++    pamcut -left 0 -top $y -width $width -height $height $all \
++        > "$f$ext"
+     if [ $? != 0 ]; then
+         exit $?
+     fi
+-    y=$(($y + ${heights[$i]}))
++    y=$(($y + $height))
+     i=$(($i + 1))
+ done

Added: head/graphics/netpbm/files/patch-ppmquantall.csh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/graphics/netpbm/files/patch-ppmquantall.csh	Mon Dec 30 11:51:07 2013	(r338093)
@@ -0,0 +1,13 @@
+--- editor/ppmquantall.csh.orig	2006-08-19 05:12:28.000000000 +0200
++++ editor/ppmquantall.csh	2013-12-25 21:56:17.183814873 +0100
+@@ -30,8 +30,8 @@
+ set widths=()
+ set heights=()
+ foreach i ( $files )
+-    set widths=( $widths `sed '1d; s/ .*//; 2q' $i` )
+-    set heights=( $heights `sed '1d; s/.* //; 2q' $i` )
++    set widths=( $widths `grep -v '^#' "$i" | sed '1d; s/ .*//; 2q'` )
++    set heights=( $heights `grep -v '^#' "$i" | sed '1d; s/.* //; 2q'` )
+ end
+ 
+ set all=/tmp/pqa.all.$$
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 3 Dirk Meyer freebsd_committer freebsd_triage 2013-12-30 11:51:40 UTC
State Changed
From-To: open->closed

committed with changes, thanks. 

while we are here, allow files with spaces.