You are not logged in.
Pages: 1
... looks messy when it is piped into a logfile. Is there anything I can do to improve this, maybe with a run over the logfile that replaces the tabs with spaces? I once wrote this for a different purpose, ...
[c]for pkg in $INSTALLED
do
[ -f $pkg/receipt ] || continue
. $pkg/receipt
printf "%s %$((25-${#PACKAGE}))s" "$PACKAGE" >> $COPY_PATH/$1/$1.txt
printf "%s %$((18-${#VERSION}))s" "$VERSION" >> $COPY_PATH/$1/$1.txt
echo "$CATEGORY" >> $COPY_PATH/$1/$1.txt
packages=$(($packages+1))
done[/c]
... the output of which looks neat. But it isn't suitable here.
Offline
What output? There are so many commands.
If you want the list of installed packages, there is for example:
[c]cut -d$'\t' -f1 /var/lib/tazpkg/installed.info[/c]
Offline
Hi Darjeeling,
Seems, you mean list of installed packages using command [c]tazpkg -l[/c].
List this way already realized 3 months ago, with tazpkg-828:
http://hg.slitaz.org/tazpkg/rev/2f3580bd8c0c#l8.135
So, maybe you using old tazpkg?
Sorry, can't check this command right now — I'm at work, not home, and write using smartphone.
Offline
Sorry guys, I wasn't specific enough. For my diy SliTaz I'm using a long script run from the console of a special justX LiveCD derived from the latest 5.0 Rolling release. The script has got plenty of ...
yes | tazpkg -r xyz
tazpkg -gi xyz
tazpkg -i xyz
... in it and runs (a slightly modified) tazlito at the end. Quite often I see something 'red' and other error messages whizzing past but I'm too slow to read and take notes. This is why I've always piped the output of the whole script (or of functions inside the script) into a logfile ...
[c]
makecd 2>&1 | tee makecd.log
[/c]
or
[c]
inst() {
tazpkg -gi alsaplayer
}
inst 2>&1 | tee makecd.log
[/c]
... which looks a bit messy and is difficult to read. So, yes, it's mainly about 'tazpkg -gi'. I should have said so in the first place.
> List this way already realized 3 month ago, with tazpkg-828 ...
Wow. I wasn't aware of it, Aleksej. The last time I tried 'tazpkg -l >xyz' (maybe a year ago) it wasn' like this, which is why I wrote that script.
Offline
Please take a look to /lib/slitaz.sh: http://hg.slitaz.org/slitaz-base-files/file/af25e2951d08/rootfs/lib/libtaz.sh
We use it to output different types of the messages in almost all our scripts.
You can tweak output type using variable "output": it can get one of four values: "raw", "gtk", "html", and fourth type is for something different or undefined. Type "raw" is for textual logs, I think you need it. Type "gtk" is for Yad-based dialogs. Type "html" is for TazPanel. Fourth type (when "output" is undefined) is for terminal or console; it contains some Escape sequences for best look on the contemporary terminals.
Please, prepend your script with
[c]export output=raw[/c]
and try again. Is it solves your problem?
Offline
Earlier I was browsing through tazpkg, trying to figure out how the formatting is done. But couldn't find anything useful. It seems so much smarter now than it used to be in 3.0, but also more complex. Thanks for hinting to libtaz.sh. Yesss, this is exactly what I've been looking for! I'm too tired now but I will try tomorrow how I can use libtaz in my script. I will let you know.
P.S.:
I have a small number of self-made packages which are installed and then blocked to prevent any corruption on upgrade. Strangely, tazpkg confirms this with ...
[c]
Package xyz is not installed.
[/c]
... which always gives me a heart attack when I see it whizzing past :-) Wouldn't it be better if it said "Package xyz has been blocked."?
Offline
PS: Please give me more information to debug: which commands you are executed? I need more explanation to understand.
Offline
Yes, because if you install packages normally you get this when trying to upgrade:
[c]java-jre Main 1.8.0_40 → 1.9.9 (Blocked)
scilab Main 5.5.2 New build (Blocked)[/c]
(Last column is written in red when in terminal.)
Offline
Please, try out new libtaz.sh: http://cook.slitaz.org/cooker.cgi?pkg=slitaz-base-files
Changeset: http://hg.slitaz.org/slitaz-base-files/rev/efc8f188db6e#l12.1
Summary:
I've made changes to functions action() and status() that you can see a lot in the tazpkg.
Action... [ Done ]
Now it should have better look literally everywhere: in the textual logs, in the cooking log at cook.slitaz.org, in the Yad-based tazpkg-box (when you click local *.tazpkg files, click Install, and then see installing log). But here in the last case I need also to set log's font to be monospace and enlarge window to fit without scrollbar — I already made it home but not make changes in the tazpkg sources in the Hg repo.
Also it now can wrap long actions that don't fit one line, and long statuses in some languages now also looks better and not wraps to next line. Screenshot as it was:
http://forum.slitaz.org/topic/libreoffice/page/2#post-40124
Excuse my English, just try 
Offline
Using a locale-provided field width: very clever!
Don't worry for your English, your post is very clear. And your English is probably better than the Ukrainian of the rest of us
(except az_ua's, of course)
Offline
I had a lot less time today than I normally have on a Saturday. Still, I found out that there's absolutely nothing wrong with 'tazpkg block'. I had made the stupid mistake to pass the full physical path of the package to the function instead of just the package name. I have changed my script and when I now install and subsequently block my spacefm-mod package ...
[c]
tazpkg -i /media/seagate/.5.0/make/install/spacefm-mod.tazpkg
tazpkg block spacefm-mod
[/c]
... the result (copied from sakura) looks like this:
[c]
Installation of package "spacefm-mod"
==============================================================================================================================================
Light and fast file manager.
----------------------------------------------------------------------------------------------------------------------------------------------
Copying package... [ Done ]
Extracting package... [ Done ]
Remember modified packages... [ Done ]
Installing package... [ Done ]
Removing all tmp files... [ Done ]
Execute post-install commands... [ Done ]
Update system databases... [ Done ]
==============================================================================================================================================
Package "spacefm-mod" (next) is installed.
Package "spacefm-mod" blocked.
[/c]
Of course, when I peek into the logfile it's still like this ...
[c]
[1mInstallation of package "spacefm-mod"[0m
==============================================================================================================================================
Light and fast file manager.
----------------------------------------------------------------------------------------------------------------------------------------------
[0;33mCopying package...[0m[132G[ [1;32mDone[0;39m ]
[0;33mExtracting package...[0m[132G[ [1;32mDone[0;39m ]
[0;33mRemember modified packages...[0m[132G[ [1;32mDone[0;39m ]
[0;33mInstalling package...[0m[132G[ [1;32mDone[0;39m ]
[0;33mRemoving all tmp files...[0m[132G[ [1;32mDone[0;39m ]
[0;33mExecute post-install commands...[0m[132G[ [1;32mDone[0;39m ]
[0;33mUpdate system databases...[0m[132G[ [1;32mDone[0;39m ]
==============================================================================================================================================
Package "spacefm-mod" (next) is installed.
Package "spacefm-mod" blocked.
[/c]
... but I hope I can make something prettier out of it with the help of libtaz. I'll let you know ...
Offline
Aleksej, I only saw your last message just now. This is so cool! I'll try it out immediately.
Offline
Hi Darjeeling,
Oh, thank you. Glad to help 
But do you prepended your script with the next line???
[c]export output=raw[/c]
Hi Lucas,
There a bit tricky code because printf counts bytes, not characters (or double byte words for UTF32) and simple command just not works as expected for any language but English:
[c]printf “%-${width}s", $action[/c]
As for locale provided width. It can be solved in other way (calculating once at the beginning max length of two localized strings), but I think present solution is simpler (although not clear for translators).
Offline
I think present solution is simpler (although not clear for translators)
I agree to both statements
Maybe call the field something like "numeric-max-width-for-ok-or-error-msg"?
Offline
No 
Not elegant at all. We can add comments, and here's example:
http://hg.slitaz.org/cookutils/file/a328952982d6/po/cook.pot#l153
Offline
This is brilliant, Aleksej! When the new Rolling came out last night I first ran a little test script that installs Abiword ...
[c]tst() {
tazpkg -gi abiword
}
tst $1 2>&1 | tee tst.log[/c]
The log file of this looked already much more readable because the vertical columns had been preserved. But there were still escape sequences in it, so I mopped them up with this ...
[c]sed -i 's/'$'\x1b''\[0m//g' tst.log
sed -i 's/'$'\x1b''\[1m//g' tst.log
sed -i 's/'$'\x1b''\[1;32m//g' tst.log
sed -i 's/'$'\x1b''\[0;33m//g' tst.log
sed -i 's/'$'\x1b''\[0;39m//g' tst.log[/c]
... which made the log file practically indistinguishable from what I had seen on the screen when Abiword was being installed. Great! But it is not very elegant to 're-format' a text file like this and, more importantly, it only works properly on 80 character terminals and not at the 5.0 console. So, I dumped it all and put your magic one-liner ...
[c]export output=raw[/c]
... at the top of the test script, which produced a perfectly formatted log file straight away, without the need to go over it again. Ingenious, Aleksej! Thanks a lot for this.
Offline
Oh no! That's the last thing I wanted to happen. I'm sorry for this ... and thanks for correcting it, Aleksej.
Offline
Pages: 1
[ Generated in 0.019 seconds, 7 queries executed - Memory usage: 1.58 MiB (Peak: 1.77 MiB) ]