Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 23116 - coreutils 5: 'head -1', 'tail -1' give errors, need '-n 1' now; breaks lots of Makefiles
Summary: coreutils 5: 'head -1', 'tail -1' give errors, need '-n 1' now; breaks lots o...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High major (vote)
Assignee: John Mylchreest (RETIRED)
URL:
Whiteboard:
Keywords:
: 31871 32582 (view as bug list)
Depends on:
Blocks: 31801 31836 32623 33211 33571 33851 34015 34487 36156
  Show dependency tree
 
Reported: 2003-06-19 09:58 UTC by Boris Tschirschwitz
Modified: 2004-12-01 11:27 UTC (History)
11 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
fixheadtails (tmp.txt,791 bytes, text/plain)
2003-08-11 01:42 UTC, John Mylchreest (RETIRED)
Details
fixheadtails (tmp.txt,322 bytes, text/plain)
2003-08-11 02:03 UTC, John Mylchreest (RETIRED)
Details
list of offending files in gentoo-x86 (some can be safely ignored) (tmp.txt,3.05 KB, text/plain)
2003-08-11 02:23 UTC, John Mylchreest (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Tschirschwitz 2003-06-19 09:58:19 UTC
Many Makefiles use the coreutils 'head' and 'tail'.
In the new version they require that the option '-1' is replaced with '-n 1'.
This breaks lots of builds.

Reproducible: Always
Steps to Reproduce:
1.
2.
3.




I guess it would be nice to have something like a 'sed' line that replaces '-1'
with '-n 1' after 'head' and 'tail' as part of ebuilding a package.
Comment 1 Seemant Kulleen (RETIRED) gentoo-dev 2003-06-21 09:12:57 UTC
can you list some which are broken?
Comment 2 Boris Tschirschwitz 2003-06-21 09:25:34 UTC
Broken builds: (I'll add as I come across them):
1. kde-base/kdeadmin-3.1.2
Comment 3 Boris Tschirschwitz 2003-06-21 10:10:09 UTC
2. dev-util/arch-1.0_pre17
Comment 4 Boris Tschirschwitz 2003-06-25 07:26:45 UTC
3. dev-lang/squeak-3.4.1
4. kernel 2.5.73-mm1: tail bails twice, but compile finishes and kernel works ;(
Comment 5 Boris Tschirschwitz 2003-07-08 05:19:58 UTC
5. app-games/enemy-territory-2.55
6. dev-haskell/hmake-3.08
Comment 6 Rafal Dejewski 2003-07-08 07:40:56 UTC
I've looked at coreutils info page - there are different posix standards for many commands.  
Try setting:  
export _POSIX2_VERSION=199209  
 
  
Comment 7 Boris Tschirschwitz 2003-07-08 08:33:04 UTC
Wow, that solves the problem, perhaps it should be set as default in coreutils for now.
Comment 8 John Mylchreest (RETIRED) gentoo-dev 2003-07-15 07:23:13 UTC
just to note another one is blackdown-jdk which prevents mod_php and other biggies.
doesnt seem to happen with gcc-2.x only gcc-3.x
Comment 9 Martin Schlemmer (RETIRED) gentoo-dev 2003-07-20 09:56:50 UTC
Seemant, what is the status on this (interest sake)?
Comment 10 Seemant Kulleen (RETIRED) gentoo-dev 2003-07-24 03:57:08 UTC
Az, as far as I know, John is working on patching the offending makefiles
Comment 11 Eric Chu 2003-08-06 13:54:04 UTC
7. kde-base/arts-1.1.3
Comment 12 John Mylchreest (RETIRED) gentoo-dev 2003-08-11 01:42:45 UTC
Created attachment 15882 [details]
fixheadtails

This is a quick bash script to replace all those evil occurances of head -X and
tail -X with newer POSIX compliant ones.
This should probably be in distfiles and ran from offending ebuilds, I am ok to
do this.

Anyone have any objections to this method of working?
Comment 13 John Mylchreest (RETIRED) gentoo-dev 2003-08-11 02:03:28 UTC
Created attachment 15883 [details]
fixheadtails
Comment 14 John Mylchreest (RETIRED) gentoo-dev 2003-08-11 02:23:57 UTC
Created attachment 15886 [details]
list of offending files in gentoo-x86 (some can be safely ignored)
Comment 15 John Mylchreest (RETIRED) gentoo-dev 2003-08-11 03:43:36 UTC
just to update you, I have written an eclass and am now testing it with other ebuilds to see how we get on.
I suspect this should be in good working order sometime after work, when i get chance to sit down properly with it.
Comment 16 David Nielsen 2003-08-26 05:36:38 UTC
Let's just add Enemy Territory to the list of stuff that needs fixing. 
Comment 17 SpanKY gentoo-dev 2003-09-05 08:19:19 UTC
actually enemy-territory isnt broken, the unpack_makeself in eutils.eclass is ... i'll fix it shortly
Comment 18 David Nielsen 2003-09-07 13:26:17 UTC
and let's add Arch as well...
Comment 19 Adrian Almenar 2003-09-09 21:58:26 UTC
sun-jdk ebuilds appear in the list of files offending but theyre working ok, i 
have tested with coreutils-5.0-r1,r3. 
 
Any ideas on this ?? 
Comment 20 John Mylchreest (RETIRED) gentoo-dev 2003-09-17 14:36:03 UTC
fixheadtails is now in eclasses.
usage is explained within that although basic usage is:

inherit fixheadtails

src_unpack() {
unpack ${A}
cd ${S}
ht_fix_all
}

i have fixed hmake already, i have problems compiling squeak anyways so i will notify the relevant maintainers.
can people please update this bug with any other packages needing fixing, and i shall do so. i will work on those i am aware of now.
Comment 21 Martin Schlemmer (RETIRED) gentoo-dev 2003-09-17 15:16:51 UTC
You are going to miss calls like 'tail +16c foo'.  From the info pages:

----------------------------------------------------------------
   On older systems, `tail' supports an obsolete option
`-COUNTOPTIONS', which is recognized only if it is specified first.
COUNT is a decimal number optionally followed by a size letter (`b',
`k', `m') as in `-c', or `l' to mean count by lines, or other option
letters (`cfqv').  Some older `tail' implementations also support an
obsolete option `+COUNT' with the same meaning as `-+COUNT'.  POSIX
1003.1-2001 (*note Standards conformance::) does not allow these
options; use `-c COUNT' or `-n COUNT' instead.
----------------------------------------------------------------

That was for tail.  head is pretty much the same, except it only support
'cqv' and not 'cfqv'.

Here is my scripts (ok not optimal in speed ;), which do handle these
cases - hope it helps:

----------------------------------------------------------------
azarah@nosferatu glibc $ cat /usr/src/scripts/fix_head.sh
#!/bin/bash
 
fix_head_arg="$(readlink -f "$1" 2>/dev/null)"
 
source /sbin/functions.sh
 
x=
count=0
 
[ -z "${fix_head_arg}" ] && exit 1
[ ! -d "${fix_head_arg}" ] && exit 1
 
einfo "Scanning ${fix_head_arg} ..."
for x in $(find ${fix_head_arg}/ -type f -exec \
           grep -l -e 'head[[:space:]]\+-[0-9]' -- {} \;)
do
        [ "${count}" -eq 0 ] && eend 0
 
        x_relative="$(echo "${x}" | sed -e "s|^${fix_head_arg}||")"
        einfo " Fixing $(basename "${fix_head_arg}")${x_relative} ..."
        sed -i -e 's|head[[:space:]]\+-\([0-9]\+[bkm]\?\)\([cqv]\?*\)|head -\2 \1|g' \
               -e 's|head -\([^nc ]*\) \([+0-9]\+\)|head -n\1 \2|g' -- "${x}"
        eend $?
 
        [ "${count}" -eq 0 ] && x=1
done
 
[ "${count}" -eq 0 ] && eend 0
 
azarah@nosferatu glibc $ cat /usr/src/scripts/fix_tail.sh
#!/bin/bash
 
fix_tail_arg="$(readlink -f "$1" 2>/dev/null)"
 
source /sbin/functions.sh
 
x=
count=0
 
[ -z "${fix_tail_arg}" ] && exit 1
[ ! -d "${fix_tail_arg}" ] && exit 1
 
einfo "Scanning ${fix_tail_arg} ..."
for x in $(find ${fix_tail_arg}/ -type f -exec \
           grep -l -e 'tail[[:space:]]\+[-+][0-9]' -- {} \;)
do
        [ "${count}" -eq 0 ] && eend 0
 
        x_relative="$(echo "${x}" | sed -e "s|^${fix_tail_arg}||")"
        einfo " Fixing $(basename "${fix_tail_arg}")${x_relative} ..."
        sed -i -e 's|tail[[:space:]]\+\([-+][0-9]\+[bkm]\?\)\([cfqv]\?*\)|tail -\2 \1|g' \
               -e 's|tail -\([^nc ]*\) -\?\([+0-9]\+\)|tail -n\1 \2|g' -- "${x}"
        eend $?
 
        [ "${count}" -eq 0 ] && x=1
done
 
[ "${count}" -eq 0 ] && eend 0
 
azarah@nosferatu glibc $
Comment 22 Martin Schlemmer (RETIRED) gentoo-dev 2003-09-17 15:19:48 UTC
Ok, paste was not good, here is the 'sed' parts again:

----------------------------fix_head.sh-----------------------------
sed -i -e 's|head[[:space:]]\+-\([0-9]\+[bkm]\?\)\([cqv]\?*\)|head -\2 \1|g' \
       -e 's|head -\([^nc ]*\) \([+0-9]\+\)|head -n\1 \2|g' -- "${x}"
--------------------------------------------------------------------

----------------------------fix_tail.sh-----------------------------
sed -i -e 's|tail[[:space:]]\+\([-+][0-9]\+[bkm]\?\)\([cfqv]\?*\)|tail -\2 \1|g' \
       -e 's|tail -\([^nc ]*\) -\?\([+0-9]\+\)|tail -n\1 \2|g' -- "${x}"
--------------------------------------------------------------------

Comment 23 David Nielsen 2003-09-26 15:25:35 UTC
add dev-utils/arch-1.0_pre17 to the list of broken stuff 
Comment 24 Ahmed Farid 2003-09-26 21:10:50 UTC
add also app-text/ispell-3.2.06-r6 :)
Comment 25 Ed Catmur 2003-10-25 17:26:52 UTC
Another offending Makefile is in the 2.4.20 kernel (sys-kernel/gentoo-sources).
It doesn't break the kernel itself but prevents it generating the compile.h
file correctly, which breaks other ebuilds (so far the alsa-driver ebuild):

@echo \#define LINUX_COMPILER \"`$(CC) $(CFLAGS) -v 2>&1 | tail -1`\" >>
.ver

(line 351)
Comment 26 Ed Catmur 2003-10-25 17:31:03 UTC
*** Bug 31871 has been marked as a duplicate of this bug. ***
Comment 27 John Mylchreest (RETIRED) gentoo-dev 2003-10-28 10:55:22 UTC
this will also be expanded to handle sort/chown and other issues addressed
in future.
Working on a sort issue as we speak but i dont expect a commit until tomorrow.
Comment 28 AlterEgo 2003-11-22 05:22:42 UTC
Changes in the chown user.group syntax cause errors in
/etc/cron.daily/syslog.cron:      
/bin/chown root:adm $LOG   does work correctly.
However, the default syntax is /bin/chown root.adm $LOG.

Comment 29 Marius Mauch (RETIRED) gentoo-dev 2003-11-22 07:43:03 UTC
*** Bug 32582 has been marked as a duplicate of this bug. ***
Comment 30 Seemant Kulleen (RETIRED) gentoo-dev 2003-11-22 12:39:56 UTC
actually, looks like avenj fixed sysklogd's cron.daily script a while ago, so a remerge should sort you out.
Comment 31 Don Seiler (RETIRED) gentoo-dev 2003-11-26 07:05:03 UTC
media-sound/abcde emerges, but cddb/freedb lookups are broken until I set the _POSIX2_VERSION as indicated earlier.
Comment 32 Hermann Gundel 2003-11-27 07:27:03 UTC
There is also a problem on the alpha platform, where the (binary) compaq-jdk uses "head -1" in its java wrapper. Setting _POSIX2_VERSION seemed to help.
Comment 33 Martin Holzer (RETIRED) gentoo-dev 2003-11-27 09:32:18 UTC
alpha-team see comment #32
Comment 34 Andrea Cerrito 2003-12-03 03:30:32 UTC
Is it possible to fix this bug directly during compile of coureutils?
Not only ebuilds are broken, even installers (eg: install-crossover-office-2.0.1.sh).
Comment 35 Decade 2003-12-22 16:50:32 UTC
kde_base/arts-1.1.2

Add to that a substantial amount of KDE. Newer versions with variations of the head fix are marked stable for almost every architecture. That doesn't help me when I'm running an Alpha.
Comment 36 Aron Griffis (RETIRED) gentoo-dev 2004-01-12 19:52:21 UTC
I fixed compaq-jre and compaq-jdk, and since I'm in the midst of working on kde-3.1.4 for alpha-stable, Decade's comment should be moot soon. :-)
Comment 37 Martin Holzer (RETIRED) gentoo-dev 2004-01-12 23:16:59 UTC
this issue isn't resent in debian
maybe we could patch head and tail to accept the old syntax
Comment 38 Martin Holzer (RETIRED) gentoo-dev 2004-01-12 23:48:59 UTC
s/resent/represent
Comment 39 Seemant Kulleen (RETIRED) gentoo-dev 2004-01-12 23:57:10 UTC
5.0.91-r3 and -r4 are patched already, actually
Comment 40 Martin Holzer (RETIRED) gentoo-dev 2004-01-13 00:23:09 UTC
and how about the coreutils-5.0 ?
how about patching it too and remove all old ebuilds without patch
Comment 41 Seemant Kulleen (RETIRED) gentoo-dev 2004-01-13 00:38:46 UTC
No, I'm rather pushing 5.0.91 more than 5.0, as I stated recently on one of the mailing lists, I'd like to get -r4 to stable in the next 2 or 3 weeks. At that point, I'll remove 5.0 from the tree entirely
Comment 42 Aron Griffis (RETIRED) gentoo-dev 2004-01-15 07:20:41 UTC
coreutils-5.0.91-r4.ebuild is now marked stable on alpha and ia64
Comment 43 Aiko Barz 2004-01-17 11:57:22 UTC
Broken builds:
All qmail-ebuilds
Comment 44 Martin Holzer (RETIRED) gentoo-dev 2004-01-19 11:25:22 UTC
coreutils-5.0.91-r4 is stable on x86
Comment 45 Seemant Kulleen (RETIRED) gentoo-dev 2004-01-19 14:47:27 UTC
but those syntax fixes should still go in
Comment 46 David Röhr 2004-04-01 09:17:28 UTC
The -n switch also destroys all the sun-jdks as of now.

In each sun-jdk, SUN uses tail +345 and tail -1

tail -1 works, and the file gives a nice warning, but the script tailes terribly. And against the gentoo script, nothing works. This may be an error that should end up at the dev-java guys.

I've fixed it, with manually hacking the downloaded sun-jdks, and replaced the "tail +345" with "tail --lines=+345". This fixes one problem, but there still i some sync problems against the scripts from the gentoo developers. I guess this should end up in a patch though.
Comment 47 David Röhr 2004-04-01 09:42:30 UTC
Forgot to mention

tail -1 file (works, but gives a warning that might break scripts, like the sun-jdks)
tail +1 file (doesn't work at all anymore, but works with "tail --lines=+1 file"). This breaks alot more than - that just gives a warning right now.
Comment 48 David Röhr 2004-04-01 09:48:04 UTC
And yes, I will stop bombing you soon :) My testes was on amd64 with both 5.0.91-r4 and 5.2.0. Guess the same problem is in x86 though..
Comment 49 Gregory P. Smith 2004-10-07 12:38:50 UTC
This is insane.  Other distros have all been smart enough to leave the default behaviour of supporting the old style standard -123 way of telling head and tail what to do without a stupid warning message to stderr.  *PLEASE* make it the default so people will stop laughing at you and scripts will stop breaking.

head -123
tail -123
tail +321

those should all work forever on into the future.  its the way they have always worked.
anything else is incompatible with the real world.
Comment 50 SpanKY gentoo-dev 2004-10-07 14:03:08 UTC
actually, before you start/continue anymore flames, realize the simple fact, it's a bug

as David noted in comment #47, tail -# works, tail +# does not work

the compat patches are incomplete and no developers ever really noticed ... i'll take a look at what i missed later
Comment 51 SpanKY gentoo-dev 2004-10-07 18:40:25 UTC
Bug 66713 handles the `tail +#` syntax fix
Comment 52 John Mylchreest (RETIRED) gentoo-dev 2004-12-01 11:27:38 UTC
I'm going to assume this is now being handled correctly and the bug can be closed.