sed command in Porteus

Non release banter
User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

sed command in Porteus

Post#1 by Tonio » 13 Mar 2012, 11:45

Dear all,

I have been trying for a while to successfully install the packages available for KerTEX on porteus to build a complete and portable texing and latexing environment. The author of kerTEX, has been very instrumental in getting it to work as he has helped tremendously get it working for Slackware-current x86_64. However, I am trying to do the same straight from porteus x86_64, and I need devel modules(bison, flex) and a copy of (ed), also (lftp) module from slackware-current, or built from source. I have almost everything working except installing the packages, pkg_latex.sh, pkg_amstex.sh, pkg_cyrillics.sh, pkg_babel.sh, pk_graphcs.sh, etc all from KerTeX website. The author of KerTeX has sent me a script ck_kertex.sh, If you can copy it and save it to ck_kertex.sh,

Code: Select all

olivares@tricore:~/Downloads$ cat ck_kertex.sh 
#!/bin/sh
# Checking some utilities needed for kerTeX packaging system.
#
#$Id: ck_kertex.sh,v 1.1 2012/03/12 21:26:30 tlaronde Exp $
# C) 2012 Thierry Laronde
# All rights reserved and no guarantee!
# Tous droits réservés et aucune garantie !
#

: ${PKG_SED:=sed}

echo "Testing $(command -v $PKG_SED)"
echo

#===== Adapted from pkglib.sh
#
_pkg_x_cid()
{
        ed $0 <<EOT >/dev/null 2>&1
/^BEGIN_CID/+,/^END_CID/-w /tmp/$$.CID
q
EOT
}

#BEGIN_GET_REC_SEDCMD
#/^TAG:/ {
#s///
#/^$/!p
#:tag
#n
#/^[A-Z][A-Z0-9_]*:/b
#p
#b tag
#}
#
#END_GET_REC_SEDCMD

# Extracting will be done at initialization.
#
_pkg_x_get_rec_sedcmd()
{
        $PKG_SED -n -e '/^#BEGIN_GET_REC_SEDCMD/,/^#END_GET_REC_SEDCMD/s/^#//p' \
                $0\
                | $PKG_SED -e '/^BEGIN/d' -e '/^END/d'\
                >/tmp/$$.get_rec_sedcmd
}

pkg_get_rec()
{
        ed /tmp/$$.get_rec_sedcmd <<EOT >/dev/null 2>&1
/^\/\^[A-Z][A-Z0-9_]*:/s!!/^$1:!
w
q
EOT
        $PKG_SED -n -f /tmp/$$.get_rec_sedcmd /tmp/$$.CID
}

_pkg_x_cid
echo "I have extracted this:"
echo "===================="
cat /tmp/$$.CID
echo "===================="
echo

_pkg_x_get_rec_sedcmd
echo "I have extracted the commands:"
echo "===================="
cat /tmp/$$.get_rec_sedcmd
echo "===================="
echo
echo "And $PKG_SED prints:"
echo
pkg_get_rec SOURCES

rm /tmp/$$.*
exit 0

# Since we have exited above, no need to comment out the CID.

BEGIN_CID
NAME: latex
VERSION: 2e
KERTEX_VERSION: 0.999.1.5
SOURCES:
ftp://anonymous:kertex@ftp.dante.de/
        LCD HOME/
        GET /tex-archive/macros/latex/base.zip
        GET /tex-archive/macros/latex/doc.zip
        LCD /lib/fonts/tfm/latex
        GET fonts/tfm/  /\.tfm$/
END:
END_CID

olivares@tricore:~/Downloads$ 
If we run it from Slackware x86_64, FreeBSD, Fedora, or other system we get something like:

Code: Select all

olivares@tricore:~/Downloads$ ./ck_kertex.sh 
Testing /usr/bin/sed

I have extracted this:
====================
NAME: latex
VERSION: 2e
KERTEX_VERSION: 0.999.1.5
SOURCES:
ftp://anonymous:kertex@ftp.dante.de/
        LCD HOME/
        GET /tex-archive/macros/latex/base.zip
        GET /tex-archive/macros/latex/doc.zip
        LCD /lib/fonts/tfm/latex
        GET fonts/tfm/  /\.tfm$/
END:
====================

I have extracted the commands:
====================
/^TAG:/ {
s///
/^$/!p
:tag
n
/^[A-Z][A-Z0-9_]*:/b
p
b tag
}

====================

And sed prints:

ftp://anonymous:kertex@ftp.dante.de/
        LCD HOME/
        GET /tex-archive/macros/latex/base.zip
        GET /tex-archive/macros/latex/doc.zip
        LCD /lib/fonts/tfm/latex
        GET fonts/tfm/  /\.tfm$/
But when run from Porteus it gives different results:

Code: Select all

guest@porteus:~/Downloads$ chmod +x ck_kertex.sh
guest@porteus:~/Downloads$ ls -l ck_kertex.sh
-rwxr-xr-x 1 guest guest 1600 Mar 12 16:43 ck_kertex.sh*
guest@porteus:~/Downloads$ ./ck_kertex.sh
Testing /usr/bin/sed

I have extracted this:
====================
NAME: latex
VERSION: 2e
KERTEX_VERSION: 0.999.1.5
SOURCES:
ftp://anonymous:kertex@ftp.dante.de/
       LCD HOME/
       GET /tex-archive/macros/latex/base.zip
       GET /tex-archive/macros/latex/doc.zip
       LCD /lib/fonts/tfm/latex
       GET fonts/tfm/  /\.tfm$/
END:
====================

I have extracted the commands:
====================
/^TAG:/ {
s///
/^$/!p
:tag
n
/^[A-Z][A-Z0-9_]*:/b
p
b tag
}

====================

And sed prints:

guest@porteus:~/Downloads$
Digging a little, sed is present in the possible form of busybox? I compile sed from source into /usr/local/ and it fails the same :( Can someone shed some light on this?

Thanks in Advance.

Antonio

EDIT
New run from porteus i486, special XFCE edition I get:

Code: Select all

guest@porteus:~/Downloads$ uname -a
Linux porteus 3.1.8-porteus #1 SMP PREEMPT Sat Jan 7 11:08:29 UTC 2012
i686 AMD Phenom(tm) 8250e Triple-Core Processor AuthenticAMD GNU/Linux
guest@porteus:~/Downloads$ cat /etc/porteus-version
Porteus-v1.2
guest@porteus:~/Downloads$ ./ck_kertex.sh
Testing /usr/bin/sed

I have extracted this:
====================
cat: /tmp/2949.CID: No such file or directory
====================

I have extracted the commands:
====================
/^TAG:/ {
s///
/^$/!p
:tag
n
/^[A-Z][A-Z0-9_]*:/b
p
b tag
}

====================

And sed prints:

sed: can't read /tmp/2949.CID: No such file or directory
Posted after 13 hours 19 minutes:
@all who are following the thread. At least for i486, the issue is solved. Now I need to get it fixed for x86_64 Porteus. I will report back. It was a user error :( [PEBKAC]

In i486 porteus version, sed works correctly, but in 64 bit one it does not appear to do so :( If I compile it from source, it(porteus) forces me to use /bin/sed, instead of the one I compiled, /usr/local/bin/sed. Is there something else I can try? Thanks!

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: sed command in Porteus

Post#2 by Ahau » 13 Mar 2012, 14:12

Hi Tonio -- not sure if I'll have a solution for you or not. I don't think /bin/sed in 64-bit porteus is part of busybox (you can see the busybox sed in /mnt/live/bin/), and I'm not sure where sed is failing you here...but if your compiled version works better, could you simply change the PKG_SED variable to point to /usr/local/bin/sed instead of sed?

Posted after 1 hour 19 minutes 30 seconds:
Just looked a little closer at the script:

Code: Select all

_pkg_x_cid()
{
        ed $0 <<EOT >/dev/null 2>&1
/^BEGIN_CID/+,/^END_CID/-w /tmp/$$.CID
q
EOT
}

Code: Select all

pkg_get_rec()
{
        ed /tmp/$$.get_rec_sedcmd <<EOT >/dev/null 2>&1
/^\/\^[A-Z][A-Z0-9_]*:/s!!/^$1:!
w
q
EOT
        $PKG_SED -n -f /tmp/$$.get_rec_sedcmd /tmp/$$.CID
}
Twice it calls 'ed', which is not included in porteus and would probably explain the problems you're having better than some version difference in sed. In both cases, you don't even get a warning that the 'ed' command is not found. Unless you've found this out for yourself already, try this pacakge (64-bit): http://slackware.cs.utah.edu/pub/slackw ... 6_64-1.txz
(32-bit): http://slackware.cs.utah.edu/pub/slackw ... i486-1.txz
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

Re: sed command in Porteus

Post#3 by Tonio » 13 Mar 2012, 14:13

Ahau wrote:Hi Tonio -- not sure if I'll have a solution for you or not. I don't think /bin/sed in 64-bit porteus is part of busybox (you can see the busybox sed in /mnt/live/bin/), and I'm not sure where sed is failing you here...but if your compiled version works better, could you simply change the PKG_SED variable to point to /usr/local/bin/sed instead of sed?
I have tried this, but it fails the same way :( Only 32 bit porteus works :)
It is defintely a busybox one, even if I change using a module or build from source I get the same thing :(

Code: Select all

guest@porteus:~/Downloads$ ls -l /mnt/live/bin/sed 
lrwxrwxrwx 1 root root 7 Dec  9 08:54 /mnt/live/bin/sed -> busybox*
guest@porteus:~/Downloads$ 

guest@porteus:~/Downloads$ PKG_SED=~/Downloads/sed-4.2.1/sed/sed ./ck_kertex.sh
Testing /home/guest/Downloads/sed-4.2.1/sed/sed

I have extracted this:
====================
NAME: latex
VERSION: 2e
KERTEX_VERSION: 0.999.1.5
SOURCES:
ftp://anonymous:kertex@ftp.dante.de/
        LCD HOME/
        GET /tex-archive/macros/latex/base.zip
        GET /tex-archive/macros/latex/doc.zip
        LCD /lib/fonts/tfm/latex
        GET fonts/tfm/  /\.tfm$/
END:
====================

I have extracted the commands:
====================
/^TAG:/ {
s///
/^$/!p
:tag
n
/^[A-Z][A-Z0-9_]*:/b
p
b tag
}

====================

And /home/guest/Downloads/sed-4.2.1/sed/sed prints:

guest@porteus:~/Downloads$ 


User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: sed command in Porteus

Post#4 by Ahau » 13 Mar 2012, 14:17

please see my update in the previous thread about 'ed'. I posted that while you were writing your last post, and I think you missed it :)

I'm not sure how 32-bit would work, since it doesn't have ed either...
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

Re: sed command in Porteus

Post#5 by Tonio » 13 Mar 2012, 14:31

./get_mk_install works all the way through. Have flex, bison, ed, lftp, required modules. However, the sed script does not work correctly. It is desperately needed to have the all the pkg_* programs added to kerTeX :)

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: sed command in Porteus

Post#6 by Ahau » 13 Mar 2012, 14:32

ahh crap, I missed that in your first post (that you had ed)...
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: sed command in Porteus

Post#7 by brokenman » 13 Mar 2012, 20:25

I guess first you should try to test that sed works as expected in Porteus 64bit.

Code: Select all

echo one.two.three|sed 's/two//g'
one..three
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

Re: sed command in Porteus

Post#8 by Tonio » 14 Mar 2012, 00:27

brokenman wrote:I guess first you should try to test that sed works as expected in Porteus 64bit.

Code: Select all

echo one.two.three|sed 's/two//g'
one..three
I apologize in advance, if I sound offensive, but there is definitely something wrong with the package sed in porteus-x86_64. Otherwise, I would have succeeded in my quest.
It has been several days of not being able to get a package built for x86_64 because of this :( If you have a copy of x86_64 bit porteus, v1.2-rc1 version or other please try the script above ck_kertex.sh, and run it

Code: Select all

$./ck_kertex.sh 
What do you get? Does the output look like it is supposed to?

EDIT:
fanthom hopefully on Thursday would take a look at it, but on i486 version it works and I have built a kertex module in my quest to have a portable tex system for porteus. A built script(kertex.Slackbuild) with some instructions is over here and I know it works after several tests and a great deal of help from the author of KerTEX :

http://pastebin.com/QH9iVbd2

Several things are needed, namely, flex, bison, ed, lftp, and patience and after a little while build succeeds, we add the other packages(latex, graphics, babel, cyrillic, and cracs available at KerTeX website) and we have a portable texing & latexing system with porteus that is not as big as texlive and not depracated and unmaintained like TeTeX. See this thread for more information:

http://forum.porteus.org/viewtopic.php? ... cd95762c94

Related thread on Slax forum:
http://www.slax.org/forum.php?action=vi ... ntID=78004

Thanks and sorry again if I sound harsh or my choice of words was not appropriate :( . You are a great person and very helpful, I am frustrated by this blunder as I could announce success for any and all persons interested in a portable texing environment with porteus :)

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: sed command in Porteus

Post#9 by brokenman » 14 Mar 2012, 01:11

No you don't sound offensive at all.

Anyway ... to fix your problem. Link sed to busybox.

Code: Select all

root@porteus:/home/guest# mv /bin/sed /bin/sed.bak
root@porteus:/home/guest# ln -s /mnt/live/bin/busybox /bin/sed
root@porteus:/home/guest# sh c_kertex.sh
Testing /bin/sed

I have extracted this:
====================
NAME: latex
VERSION: 2e
KERTEX_VERSION: 0.999.1.5
SOURCES:
ftp://anonymous:kertex@ftp.dante.de/
        LCD HOME/
        GET /tex-archive/macros/latex/base.zip
        GET /tex-archive/macros/latex/doc.zip
        LCD /lib/fonts/tfm/latex
        GET fonts/tfm/  /\.tfm$/
END:
====================

I have extracted the commands:
====================
/^TAG:/ {
s///
/^$/!p
:tag
n
/^[A-Z][A-Z0-9_]*:/b
p
b tag
}

====================

And sed prints:

ftp://anonymous:kertex@ftp.dante.de/
        LCD HOME/
        GET /tex-archive/macros/latex/base.zip
        GET /tex-archive/macros/latex/doc.zip
        LCD /lib/fonts/tfm/latex
        GET fonts/tfm/  /\.tfm$/
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
Tonio
Contributor
Contributor
Posts: 276
Joined: 28 Dec 2010, 16:37
Distribution: Slackware,porteus,FreeBSD,Slax
Location: 127.0.0.1

Re: sed command in Porteus

Post#10 by Tonio » 14 Mar 2012, 02:12

Thank you very much Brokenman. Sed now works! Now how I can see if I can make a kertex package for 64 bit porteus :) Will report back.

EDIT:
Successfully built a package on x86_64 porteus :) Now I will test it. Hopefully all the binaries are there :)
Thanks a million Brokenman and KerTeX developer too! Without you guys none of this would have been possible. Thanks to Ahau and fanthom for taking notice of this trouble with sed too!
Last edited by Tonio on 14 Mar 2012, 02:51, edited 1 time in total.

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: sed command in Porteus

Post#11 by Ahau » 14 Mar 2012, 02:15

I was able to get what I believe to be the desired output by dropping the -n switch from sed in 64-bit porteus.
$PKG_SED -f /tmp/$$.get_rec_sedcmd /tmp/$$.CID

I also tried brokenman's solution, and linking to the busybox instead does the trick as well, even with -n.

I compared the sed binary from 64-bit 1.2RC1 with the sed binary in the standard slackware package, and they are not the same:

sed from 1.2 RC1 (renamed to .bak per brokenman's suggestion):
-rwxr-xr-x 1 root root 110912 Feb 19 15:17 sed.bak*

sed from standard slackware package:
-rwxr-xr-x 1 root root 132504 Dec 6 2009 sed*

however, that sed binary behaves the same way....this is strange indeed...maybe there's a version off in one of the dependencies?
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: sed command in Porteus

Post#12 by brokenman » 14 Mar 2012, 02:37

Not sure why sed package is present ... since it is compiled into busybox.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: sed command in Porteus

Post#13 by fanthom » 14 May 2012, 13:36

@brokenman
busybox applets have crippled functionality comparing to standard tools. busybox is 250 KB only (linked statically :shock: ) while for example Vim takes 6 MB (as whole package).

i'll try to find out why 64bit 'sed' does not work the same as 32bit version.

EDIT:\\

this issue seems to be connected somehow with UTF-8 encoding in 64bits. please run:

Code: Select all

echo "LC_ALL=C" >> /etc/modprobe.d/lang.sh
and relogin or open another terminal. now sed works properly :crazy:

not sure why the hell UTF-8 and sed works in 32bits though - all files are exactly the same...
i'm stopping debugging at this point - if anobody has an explanation, pls share.

Posted after 16 minutes 53 seconds:
i think i got it:
once LC_ALL is set to UTF-8 then LC_COLLATE is no longer set to C but also UTF-8.
here is the explanation why LC_COLLATE should be set to C to not break scripts:
# One side effect of the newer locales is that the sort order
# is no longer according to ASCII values, so the sort order will
# change in many places. Since this isn't usually expected and
# can break scripts, we'll stick with traditional ASCII sorting.
# If you'd prefer the sort algorithm that goes with your $LANG
# setting, comment this out.
export LC_COLLATE=C
so i'm going to drop LC_ALL variable from /etc/profile.d/lang.sh for 1.2 final so no more workarounds needed.

thanks for reporting Tonio.
Please add [Solved] to your thread title if the solution was found.

Post Reply