luser@x60s_GPT /opt/isos % sudo pacman -Su
[sudo] password for luser:
:: Starting full system upgrade...
resolving dependencies...
looking for inter-conflicts...
Targets (2): webkitgtk2-1.10.2-1 webkitgtk3-1.10.2-1
Total Download Size: 20.35 MiB
Total Installed Size: 100.25 MiB
Net Upgrade Size: -23.67 MiB
Proceed with installation? [Y/n]
:: Retrieving packages from extra...
webkitgtk2-1.10.2-1-i686 7.3 MiB 397K/s 00:19 [#####] 100%
webkitgtk3-1.10.2-1-i686 13.1 MiB 454K/s 00:29 [#####] 100%
(2/2) checking package integrity [#####] 100%
(2/2) loading package files [#####] 100%
(2/2) checking for file conflicts [#####] 100%
(2/2) checking available disk space [#####] 100%
(1/2) upgrading webkitgtk2 [#####] 100%
(2/2) upgrading webkitgtk3 [#####] 100%
lundi 10 décembre 2012
lundi 3 décembre 2012
html pager `onliner` with xmllint aka Y U NO RTFM
TIL xmllint can interpret XPath expressions, and has a html parser. No more ugly frankensed expressions to deals with trees. Ahhh DSLs.
dummy@x60s_GPT ~ % for page in $(hrefs URL | egrep $(basename URL) | sort | uniq) ;
do
curl -sL ${page}
| xmllint --html --xpath '//*[@id="content"]' -
| html2text;
done | less
where hrefs is, note the old school sedism which will soon be deprecated:
dummy@x60s_GPT ~ % cat $(which hrefs)
#!/usr/bin/env dash
URL="${1}"
curl -sL ${URL} | sed 's.>.>\n.g' | sed -n '/href/I s@^.*href="\([^"]\+\)".*$@\1@Igp'
ps: no need to criticize my fault-tolerantless style; I'm still waiting for a whole lisp user-space so why bother...
dummy@x60s_GPT ~ % for page in $(hrefs URL | egrep $(basename URL) | sort | uniq) ;
do
curl -sL ${page}
| xmllint --html --xpath '//*[@id="content"]' -
| html2text;
done | less
where hrefs is, note the old school sedism which will soon be deprecated:
dummy@x60s_GPT ~ % cat $(which hrefs)
#!/usr/bin/env dash
URL="${1}"
curl -sL ${URL} | sed 's.>.>\n.g' | sed -n '/href/I s@^.*href="\([^"]\+\)".*$@\1@Igp'
ps: no need to criticize my fault-tolerantless style; I'm still waiting for a whole lisp user-space so why bother...
samedi 24 novembre 2012
lennart's day : pulseaudio, systemd, initials and misconfigured system
I stumbled upon some kind of leak. /var/log/journal is eating 2GB. That explains why journalctl is sluggish as hell.
luser@x60s_GPT ~ % journalctl | awk '{print $5}' | sed 's,[^a-zA-Z\-],,g' > log
# 2 hours and 22MB later
luser@x60s_GPT ~ % sort log | uniq -c | sort -nr | head
1953078 pulseaudio
62863 kernel
39051 systemd
14992 sudo
14463 udisks-daemon
7923 USRSBINCROND
4015 usrsbincrond
1601 dhcpcd
733 systemd-logind
704 systemd-journal
So pulseaudio is the prime suspect. A while back I used '-vvvv' for debugging purposes, but removed the vvvverbose option for at least a few weeks. It was dropping dozens of messages every 5 seconds and I can't find a way to trim the old persisted logs. I'm tempted to blindly delete them but will wait a bit before doing so.
tl;dr still looking for a way to manage, meaning trim, systemd journal disk usage a posteriori in case of log bloat.
Trivia: journal log header include LPKSHHRH. I thought it was a compression format magic number, PKZIP comes to mind, but apparently it is more of a signature.
ha, computers. I mean noobs.
luser@x60s_GPT ~ % journalctl | awk '{print $5}' | sed 's,[^a-zA-Z\-],,g' > log
# 2 hours and 22MB later
luser@x60s_GPT ~ % sort log | uniq -c | sort -nr | head
1953078 pulseaudio
62863 kernel
39051 systemd
14992 sudo
14463 udisks-daemon
7923 USRSBINCROND
4015 usrsbincrond
1601 dhcpcd
733 systemd-logind
704 systemd-journal
So pulseaudio is the prime suspect. A while back I used '-vvvv' for debugging purposes, but removed the vvvverbose option for at least a few weeks. It was dropping dozens of messages every 5 seconds and I can't find a way to trim the old persisted logs. I'm tempted to blindly delete them but will wait a bit before doing so.
tl;dr still looking for a way to manage, meaning trim, systemd journal disk usage a posteriori in case of log bloat.
Trivia: journal log header include LPKSHHRH. I thought it was a compression format magic number, PKZIP comes to mind, but apparently it is more of a signature.
LP KS HH RH ;) |
ha, computers. I mean noobs.
dimanche 18 novembre 2012
correcting pacman scriptlet syntax error with gdb
On Nov 18 2012, archlinux openntpd-3.9p1-20-i686 package install script had a syntax error. An empty bash function (it seems) caused upgrade abortion. I thought I could intercept package decompression so that I can correct the script but pacman is fine grained and clean everything as soon as it can. So I used that as an excuse to mess with it using gdb. I never ran a real program in gdb before, not even one without debugging symbols, so it wasn't a breeze. After 10 minutes of useless `continue` I tried to locate function calls of interest. Not knowing the linux C ecosystem I started with a guess `mkdir`, then saw `mkdtemp`. I was monitoring /tmp for new entries made by pacman. But by the time I see a .INSTALL it's already too late. After poking through pacman github's repo, I saw new names but these are non loaded shared libraries and I don't understand how to declare a breakpoint on these. Anyway the script execution is done in a forked process, so the .INSTALL file still exists at the time a `b fork` will pop, that's where vim comes into play for a little on-the-fly monkeypatch.
tl;dr: gdb breakpoints on mkdtemp and fork leaves an open window to edit pacman's .INSTALL script, and successfully install this package, one that people on #archlinux consider obsolete, too late, I'll brag anyway.
references:
https://projects.archlinux.org/pacman.git/tree/lib/libalpm/util.c
edit: few wordings, and forgot the end. * facepalm *
tl;dr: gdb breakpoints on mkdtemp and fork leaves an open window to edit pacman's .INSTALL script, and successfully install this package, one that people on #archlinux consider obsolete, too late, I'll brag anyway.
references:
https://projects.archlinux.org/pacman.git/tree/lib/libalpm/util.c
edit: few wordings, and forgot the end. * facepalm *
jeudi 8 novembre 2012
About Desktop Environments, *nix, asynchronous monitoring
Simplest reactive UI, the unix way ?
I was happy when I saw KDE4 and recent Gnome DE include sophisticated notifications system (finally) but field testing wasn't so good. Using a not so recent ThinkPad laptop, I aimed toward a simpler, lighter graphical interface, namely Xmonad/Xmobar in almost vanilla state. Being new to haskell, and to tweaking a basic (arch)linux, I delayed for many monthes until I finally eat it.
Adding a bunch of sensors to xmobar/dzen is easy. dzen even handles mouse events so you can have active notifications. There's also dunst to pop notification bubbles when you need it, where you need it. Basically with the right amount of pretty-good glue, you'd have enough asynchronousness to monitor secondary tasks without needing anything more than 2 simple programs.
to be continued...
I was happy when I saw KDE4 and recent Gnome DE include sophisticated notifications system (finally) but field testing wasn't so good. Using a not so recent ThinkPad laptop, I aimed toward a simpler, lighter graphical interface, namely Xmonad/Xmobar in almost vanilla state. Being new to haskell, and to tweaking a basic (arch)linux, I delayed for many monthes until I finally eat it.
Adding a bunch of sensors to xmobar/dzen is easy. dzen even handles mouse events so you can have active notifications. There's also dunst to pop notification bubbles when you need it, where you need it. Basically with the right amount of pretty-good glue, you'd have enough asynchronousness to monitor secondary tasks without needing anything more than 2 simple programs.
to be continued...
mercredi 31 octobre 2012
powertop2 : make power saving changes persistent with a linux shell script
Based on ideas seen in archlinux forums, this will run powertop2, parse its report and extract commands into a shellscript/config file, you can run it, or put it in a boot time service to enforce settings.
luser@x60s_GPT ~ (master*) % uname -a
Linux x60s_GPT 3.6.4-1-ARCH #1 SMP PREEMPT Mon Oct 29 15:13:56 CET 2012 i686 GNU/Linux
luser@x60s_GPT ~ (master*) % cat powertop.config.sh
#!/usr/bin/env dash
PREFIX="powertop.$(date '+%d%b%g-%H:%M:%S')"
HTMLNAME="${PREFIX}.html"
CONFNAME="${PREFIX}.conf"
POWERTOP=$(which powertop)
echo "running ${POWERTOP}"
sudo ${POWERTOP} --html=${HTMLNAME}
echo "report -> commands -> ${CONFNAME}"
cat ${HTMLNAME} | sed 's,<,\n<,g' | sed -ne '/echo/ s,^.*\(echo.*\);.*$,\1,gp' | tee ${CONFNAME} | less
jeudi 20 septembre 2012
Raspberry pi underclock, from 200 to 50MHz
Underclocking the raspberry pi, running a fresh archlinuxarm install, is funny.
At 50MHz text mode runs fine. But the usb chip seems to have issues (unresponsive keyboard). The provided firmware for the rpi isn't really an all purpose driver pack, IIUC they made decisions based on the original use-case for the SoC (video/dsp applications) like having naive hi-freq polling of the usb chip (again IIUC) which might overwhelm the throttled cpu.
At 100MHz almost no glitches, except on full terminal/screen redraw (htop, less, etc). Anything fancier will becoming a zen exercise.
I ran xorg + dwm + emacs (gtk) at 200MHz, it's harsh, but mostly because of graphic render; since I've used the lo-perf vesa driver I can't be too surprised, maybe with some X tweakings it can get smoother.
I'll try to run it around 20MHz, with ssh instead of usb keyboard. All this reminded me that my first computer was a Pentium 60 (fanless of course ;).
ps: clock settings are located in /boot/config.txt, a simple arm_freq=200 and a reboot will do. You can have min/max values to be used by cpufreq dynamic throttling. Follow here : http://www.raspberrypi.org/phpBB3/viewtopic.php?f=2&t=3042
At 50MHz text mode runs fine. But the usb chip seems to have issues (unresponsive keyboard). The provided firmware for the rpi isn't really an all purpose driver pack, IIUC they made decisions based on the original use-case for the SoC (video/dsp applications) like having naive hi-freq polling of the usb chip (again IIUC) which might overwhelm the throttled cpu.
At 100MHz almost no glitches, except on full terminal/screen redraw (htop, less, etc). Anything fancier will becoming a zen exercise.
I ran xorg + dwm + emacs (gtk) at 200MHz, it's harsh, but mostly because of graphic render; since I've used the lo-perf vesa driver I can't be too surprised, maybe with some X tweakings it can get smoother.
I'll try to run it around 20MHz, with ssh instead of usb keyboard. All this reminded me that my first computer was a Pentium 60 (fanless of course ;).
ps: clock settings are located in /boot/config.txt, a simple arm_freq=200 and a reboot will do. You can have min/max values to be used by cpufreq dynamic throttling. Follow here : http://www.raspberrypi.org/phpBB3/viewtopic.php?f=2&t=3042
lundi 16 juillet 2012
Bedroom museum, part 1 : IDE HDD
Who said hard drive fails. Plugged a Seagate ST32122A 2GB 4500RPM IDE. Didn't like its first boot but runs fine now, crunchy though. Debian 3.0 on it (300MB used), as soft NAT router.
For fun, reading tests:
luser@x60s_GPT ~ (master*) % sudo hdparm -tT /dev/sdb
/dev/sdb:
Timing cached reads: 1586 MB in 2.00 seconds = 793.22 MB/sec
Timing buffered disk reads: 20 MB in 3.02 seconds = 6.62 MB/sec
luser@x60s_GPT ~ (master*) % sudo hdparm -tT /dev/sdb
/dev/sdb:
Timing cached reads: 1582 MB in 2.00 seconds = 791.04 MB/sec
Timing buffered disk reads: 20 MB in 3.04 seconds = 6.58 MB/sec
take that MicroSD.
For fun, reading tests:
luser@x60s_GPT ~ (master*) % sudo hdparm -tT /dev/sdb
/dev/sdb:
Timing cached reads: 1586 MB in 2.00 seconds = 793.22 MB/sec
Timing buffered disk reads: 20 MB in 3.02 seconds = 6.62 MB/sec
luser@x60s_GPT ~ (master*) % sudo hdparm -tT /dev/sdb
/dev/sdb:
Timing cached reads: 1582 MB in 2.00 seconds = 791.04 MB/sec
Timing buffered disk reads: 20 MB in 3.04 seconds = 6.58 MB/sec
take that MicroSD.
samedi 14 avril 2012
Notes about Chrome Tabs. Ctrl, Shift and multiple tabs selection.
Messing with too many opened tabs in Chrome, I'm missing Firefox Tab Groups / Panorama. Just to bitch about Chrome I start shift-clicking tabs .. when they actually start to move together.
It actually does what you'd expect:
note: I run Chrome '20.0.1100.0 canary' on Windows XP.
Can't find any documentation about it, don't know if it's new or not.. but it's sure cute.
Edit: Tab Selection is really thought through. Operations allowed also include :
(*) close a group isn't directly undo-able, Ctrl-Shift-T will re-open one at a time. nothing too bad.
And it's actually one year old. 'multiple tabs selection' or 'multiselect tabs'. cf these :
http://exde601e.blogspot.fr/2011/03/multiple-tab-selection-in-google-chrome.html
http://lifehacker.com/5791787/select-multiple-chrome-tabs-by-domain-or-history
http://www.thechromesource.com/tag/multiselect-chrome-tabs/
http://src.chromium.org/viewvc/chrome?view=rev&revision=78884
There's more: you can also select by domain or by opener.
It actually does what you'd expect:
- Maintain SHIFT, click on two tabs, they're now a selected tab interval.
- Maintain CTRL, click on many tabs, they're now a selected tab set.
note: I run Chrome '20.0.1100.0 canary' on Windows XP.
Can't find any documentation about it, don't know if it's new or not.. but it's sure cute.
Edit: Tab Selection is really thought through. Operations allowed also include :
- pinning
- closing* selection
- closing* all but selection
(*) close a group isn't directly undo-able, Ctrl-Shift-T will re-open one at a time. nothing too bad.
And it's actually one year old. 'multiple tabs selection' or 'multiselect tabs'. cf these :
http://exde601e.blogspot.fr/2011/03/multiple-tab-selection-in-google-chrome.html
http://lifehacker.com/5791787/select-multiple-chrome-tabs-by-domain-or-history
http://www.thechromesource.com/tag/multiselect-chrome-tabs/
http://src.chromium.org/viewvc/chrome?view=rev&revision=78884
There's more: you can also select by domain or by opener.
vendredi 13 avril 2012
LFS : hard drive partition as virtual vmdk drive in Virtual Box 4.1.12
I built LFS on a usb key, Kubuntu as a host. To run it I have to `halt` and then boot the usb key. I wanted to see how it runs on bare metal sort of. But now I want to tinker the system so I tried to see what virtualbox can offert. Turns out they support that (virtualbox do a lot of things, dhcp, port forward, you name it).
version used:
Virtual Box, `VBoxManager --version` => 4.1.12r77245
Kubuntu 12.04b2 ~ 13/04/2012
1) create the vmdk file that represent your real partition:
VBoxManage internalcommands createrawvmdk -filename $path/$name.vmdk -rawdisk /dev/$disk -partitions $partition-number
for my needs it turned out like this:
VBoxManage internalcommands createrawvmdk -filename /home/foobar/VM/lfs.vmdk -rawdisk /dev/sdc -partitions 1
1.5) There's a permission issue, it seems that /dev/sda is only accessible for root, and forbids virtualbox to load the vmdk that points to /dev/sda2. For now run virtualbox as root. Maybe `chown` and `chmod` can correct the problem. I may try that later.
2) create a virtual machine, choose 'use an existing disk' and points to the vmdk. There might be another vmdk beside (name contains '-pt', partition tables ?? maybe), ignore it.
3) adjust the drives
When I boot the usb key on my laptop, remember:
- the lfs system is stored on partition 2 (counting from 1)
- For grub, the internal sata drives is hd0, the usb key is hd1 => grub run `linux (hd1,2)/boot/vmlinuz root=...`
- For linux kernel, the internal sata drives gets 'sda', the usb key gets 'sdb'. => we have to be sure to pass /dev/sdb2 as root for the kernel.
But in virtualbox, at first there's only one drive, the vmdk. So you need to create sata drives to match the configuration in the lfs partition. I added an old vdi virtual image drive, anyone will do, it's just a dummy placeholder that won't be used. Now I got 2 disks, vmdk and vdi. The vmdk being inserted first is plugged on sata port 0, the vdi on port 1. To swap this order, put the vmdk on 2, then the vdi on 0, then vmdk on 1. Now you're virtual boot time config is isomorphic to the real laptop system.
Now it should boot the kernel and reach init without issues. Right now my main problem is that the network interface isn't working. I suck at using `ip` but I got to fix this in order to build blfs.
version used:
Virtual Box, `VBoxManager --version` => 4.1.12r77245
Kubuntu 12.04b2 ~ 13/04/2012
1) create the vmdk file that represent your real partition:
VBoxManage internalcommands createrawvmdk -filename $path/$name.vmdk -rawdisk /dev/$disk -partitions $partition-number
for my needs it turned out like this:
VBoxManage internalcommands createrawvmdk -filename /home/foobar/VM/lfs.vmdk -rawdisk /dev/sdc -partitions 1
1.5) There's a permission issue, it seems that /dev/sda is only accessible for root, and forbids virtualbox to load the vmdk that points to /dev/sda2. For now run virtualbox as root. Maybe `chown` and `chmod` can correct the problem. I may try that later.
2) create a virtual machine, choose 'use an existing disk' and points to the vmdk. There might be another vmdk beside (name contains '-pt', partition tables ?? maybe), ignore it.
3) adjust the drives
When I boot the usb key on my laptop, remember:
- the lfs system is stored on partition 2 (counting from 1)
- For grub, the internal sata drives is hd0, the usb key is hd1 => grub run `linux (hd1,2)/boot/vmlinuz root=...`
- For linux kernel, the internal sata drives gets 'sda', the usb key gets 'sdb'. => we have to be sure to pass /dev/sdb2 as root for the kernel.
But in virtualbox, at first there's only one drive, the vmdk. So you need to create sata drives to match the configuration in the lfs partition. I added an old vdi virtual image drive, anyone will do, it's just a dummy placeholder that won't be used. Now I got 2 disks, vmdk and vdi. The vmdk being inserted first is plugged on sata port 0, the vdi on port 1. To swap this order, put the vmdk on 2, then the vdi on 0, then vmdk on 1. Now you're virtual boot time config is isomorphic to the real laptop system.
Now it should boot the kernel and reach init without issues. Right now my main problem is that the network interface isn't working. I suck at using `ip` but I got to fix this in order to build blfs.
mardi 10 avril 2012
LFS Success. Retrospective.
You have successfully registered!Finally I boot a LFS system.
ID: 23340
Name: agumonkey
First LFS Version: 20120409
© 1998-2012 Gerard Beekmans. Website design by Jeremy Huntwork & Matthew Burgess.
I don't remember, it might be my 5th attempt ? development branch no less.
Never could go further than new system gcc/glibc.
Couldn't put my mind into solving.. too much noise. Weak mental.
Wasn't a walk in the park this time, what went wrong. Or what I should call
'The Overlook List' :
- choose a host
last attempt was on a usb key 1Go for debian live, 6Go for the new lfs
Failed early, stayed that way.
last attempt started bad, I didn't pay attention and used lfslivecd which was obsolete.
=> realize that no special os needed, just a right set of tools
now I thought to reuse the usb key and debian .. but I didn't want to boot another system.
=> realize that no special os needed, I run Kubuntu .. it's actually enough even for the latest SVN branch.
- headfirst style
Created a local lfs user. Used $HOME/lfs as target for $LFS.
I went through the book simply. This time not writing commands, I now understand sed enough
so I can just copy/paste, and avoid time-wasting typos.
By the time I reach the chapter 7 I wonder how I'm gonna boot this local folder.
So I skip the beat, erase the usb key 2nd partition. cp -R $HOME/lfs /media/usb
and try to finish there.
- lfs-bootscript, wrong sudo : host corrupted
In a hurry I try to trick make to install bootscripts using DESTDIR variable.
Except, I think, that sudo doesn't inherit the environment, thus letting make
do its job using the host /.
Luckily, Kubuntu init.d wasn't too corrupted, network setup takes 2 minutes
now but it still boots. At first I thought I was good for a full setup.
- can't compile kernel (predefs.h not found)
Not caring much about Kubuntu, I reach the kernel compilation step.
To my surprise I made something wrong. Someone in the toolchain complains about
about 'predefs.h' and 'bits.h' not being found. Seems related to kernel headers.
Problem : too complex, Brain : too weak.
- redo & build an env
Frustrated by the bare naked, information overload, and fragility. I try to improve a bit
the process. I recreate the lfs user, add a .bash.d with :
- extract function
- lfs specific variable setup
- a little login message to remind me of what variables are set or not.
Nothing fancy at all, but it's already easier.
I also time and log everything:
`time make $cmd 2>&1 | tee $logs/$chapter/$(basename $(pwd))-$cmd.log` ; echo ">>> $?"
I can leverage history key bindings almost blindly. Almost.
- grub road bump
Things are smooth, no more `sudo` havoc, kernel compiles. I'm anxious about the
grub process but anyway.
Grub stops, saying he can't do shit, but even grub1 is nice enough to let you poke
around live. The usb key is hd0, so I prepend the vmlinuz path with (hd0,2).
F10 to run. 'Decompressing Kernel...' followed by kernel panic.
- IRC saves the day again
Can't count how much knowledge I got on IRC channels.
@Ratrophy tell me to add rootdelay=n[seconds] to avoid mounting before the usb key is
fully setup.
Works fine, now the kernel only panics, but for a totally different reason.
- FS drivers !
It's been a long time since I've compiled a kernel, the menu organisation changed a bit.
I didn't see EXT4 because it's written Extended Fileblahblahblah-long-wording Version 4.
Okay, since I kept linux source in their compiled state, I can rebuild it quick with ext4 module.
...
Seems that it needs to be builtin. Oh yeah there's no initrd .. I don't understand it all but
someone has to have ext4 builtin.
Now it .. panics. Saying /dev/sda can't be mounted. My kernel parameters mention /dev/sdb
so Y U NO bOOT ?!?
- fstab ...
Ah I copied the fstab from the book taking a bet on the device name, thinking the usb key would
get sda since I boot on it. Wrong. Let's go vimcorrect that.
Now I reach init ! and then I see a horrifying error message talking about forced halt.
- Stubbornness => single mode peeping.
So :
- the bootloader is fine
- the kernel is fine
- the filesystem is fine
- the userspace is fine ( as in, program runs when chrooted in the host )
This can't be serious. I poke in grub, making the FS rw.. No progress.
Some setups drop the kernel into a shell. I wish I could.. I can only try single user mode.
Rewrite grub.cfg `linux (hd0,2)/boot/vmlinuz-xxx root=/dev/sdb2 ro single init=/bin/bash`
Boot, and here it is, the glorious shell. First time I type in that state.
Can't do shit since the FS is ro, but I understand that only 10 minutes later.
- devtmpfs investigation
I try running the bootscripts by hand, line by line.
`mount -t -o procfs none /proc`
Now ps works ... nice but not what I want.
I mount everything until I realize /dev is quite empty. What is udev waiting for ??
`mount -t devtmpfs .. /dev` => error, unknown fs type devtmpfs. WAT
What is devtmpfs anyway ? isn't it devfs ?
Then my eyes catch the huge NOTE saying not to forget to activate 'devtmpfs' ...
Okay, reboot Kubuntu, recompile (the whole) kernel.
- Register
Yep it boots, grub >= kernel >= init >= login.
60MB used, 38 for cache. Not bad Linus.
- BLFS ? Not so fast
- the network is not setup right
- I got a static IP
- no route to my internet gateway
- there's no ssh, no wget. only ftp is on the system
- Ending notes
Even though I've had a lot of criticizing in my head about LFS, it's a wonderful tutorial.
Thanks a lot to their team.
lundi 9 avril 2012
LFS random discovery : time bash builtin and /usr/bin/time
I'm trying to instrument a bit LFS commands. I often wrap `make` into time + tee.
Exit status is often 0 even if make reports errors. Does time report it's exit status ? or the parameter command's one ? .. well it seems that make or the Makefile was design to return 0 even on 'unexpected FAIL' so time says everything is OK. Meanwhile I googled a bit to investigate and stumbled upon that : http://stackoverflow.com/questions/9715570/gnu-time-and-formatting-output
Ahh noobery strikes again.
Exit status is often 0 even if make reports errors. Does time report it's exit status ? or the parameter command's one ? .. well it seems that make or the Makefile was design to return 0 even on 'unexpected FAIL' so time says everything is OK. Meanwhile I googled a bit to investigate and stumbled upon that : http://stackoverflow.com/questions/9715570/gnu-time-and-formatting-output
Ahh noobery strikes again.
samedi 7 avril 2012
bash_it color generator cost me 8 seconds at login
- trying bash_it
- sluggish login time
- need : bash debug using -x, set PS4
- trace -> inspect under vim
- discover fancy color name generator
- perlishly lispy thing
- large set of nested, args eating, function aggregating bits of term code on the output
- very DSL
- followed by a cute 30-something calls to generate a set of {,bold,underline,blah}color variables.
I may be wrong, it seems this stacking of functions is not very cheap, at least not on my VM on a core duo. When I trace the login, thousands of calls, 90% are color related, mostly identical. I feel like looking at the naive recursive Fibonacci function.
Anyway disabling colors made bash-it invisible (sic) again.
cheat url summary :
- PS4 string to see stack >>> http://wiki.bash-hackers.org/scripting/debuggingtips
- Trace, tee log a script >>> http://www.commandlinefu.com/commands/view/3310/run-a-bash-script-in-debug-mode-show-output-and-save-it-on-a-file
- Mass comment in vim >>> http://vim.wikia.com/wiki/Commenting_out_a_range_of_lines
and the original project :
- bash-it >>> https://github.com/revans/bash-it
lundi 2 avril 2012
nano-hack : wrt54g v2 plus ddwrt plus ssh
$ ps
PID USER VSZ STAT COMMAND
1 root 1464 S /sbin/init noinitrd
2 root 0 SW [keventd]
3 root 0 SWN [ksoftirqd_CPU0]
4 root 0 SW [kswapd]
5 root 0 SW [bdflush]
6 root 0 SW [kupdated]
9 root 0 SW [mtdblockd]
13 root 1500 S watchdog
91 root 1460 S resetbutton
141 root 1100 S telnetd
160 root 808 S dnsmasq --conf-file=/tmp/dnsmasq.conf
164 root 1456 S wland
168 root 692 S udhcpc -i vlan1 -p /var/run/udhcpc.pid -s /tmp/udhcpc
172 root 692 S cron
179 root 1424 S ttraff
200 root 2140 S httpd -p 80
381 root 1536 S dropbear -b /tmp/loginprompt -r /tmp/root/.ssh/ssh_ho
419 root 1456 S process_monitor
572 root 1104 S sh -c alias ping='ping -c 3'; eval "ps" > /tmp/ping.l
573 root 1104 R ps
574 root 1104 S sh -c /sbin/ledtool 1
575 root 1104 R sh -c /sbin/ledtool 1
$ uname -a
Linux DD-WRT 2.4.35 #3392 Mon Nov 2 13:19:34 CET 2009 mips unknown
That, is the output of commands using ddwrt on a wrt54g v2.
Finally tried to upgrade this old device. It uses 192.168.1.1 which collides with my actual internet gateway so I had to think (far too long) to connect to the wrt54g without stopping the gateway. Stopping my laptop's wifi and using ethernet wire between both gave me a functionning network, ping 192.168.1.1 was responding.
I forgot that I set up https on the linksys webadmin. After uploading an almost random firmware found on ddwrt page I saw a 'upload success' but something failed. Rebooting it twice didn't bring the webadmin page back (http nor https). I could ping to the box so I tried to upload another firmware using tftp. First to attempts failed, the third printed a message saying it was cleaning nvram flash then exited. The process was a bit too quick to feel right. I consider resetting using the back button, hoping to reinitiate an upload, then I saw a webpage .. but it was ddwrt webadmin. Somehow it works now, so I fiddled with it, enabled ssh. And that's about it, what's next ?
- Adding usb ports. Nice if you use the device as a server
- Better antennas
- Heatsink
- More recent software. ddwrt last firmware uses linux 2.4 and busybox. Running 3.3 kernel and such might be fun, for the sake of it.
ps: A+ on the hackability of this thing. The case has no screw, just stiff surface bumps that hold the board into a two part case. Really nice.
lundi 26 mars 2012
introducing the filep utility
a UNIXy program that can retrieve a schema for most file types ( some files like mp3 can't have a schema, there's some dynamic tricks in the format IIRC ) and displays it as an API. Then you query it using xpath/css:selector syntax.
That would solve the parser library problem of new languages*, and improve education.
*: well .. it would still be string all the way down, which I despise. 'the hell with strings, it should output json/yaml, it's a decent newer common pivot for atomic types and collections.
ps: there's nothing else but this rant embryo here. Sorry for the phising name
That would solve the parser library problem of new languages*, and improve education.
*: well .. it would still be string all the way down, which I despise. 'the hell with strings, it should output json/yaml, it's a decent newer common pivot for atomic types and collections.
ps: there's nothing else but this rant embryo here. Sorry for the phising name
dimanche 19 février 2012
debugging notes with python
- with pdb, use aliases
# Ned's .pdbrc
# Print a dictionary, sorted. %1 is the dict, %2 is the prefix for the names.
alias p_ for k in sorted(%1.keys()): print "%s%-15s= %-80.80s" % ("%2",k,repr(%1[k]))
alias pi p_ %1.__dict__ %1. .. # instance variables of %1
alias ps pi self .............
# instance variables of self.
alias pl p_ locals() local: .. # Print the locals.
alias nl n;;l ................ # Next and list.
alias sl s;;l ................ #
and step and list.
alias uu u;;u ................ # up the stack
alias dd d;;d ................
# down the stack
source : http://stackoverflow.com/a/1624037- use sys hooks to react on exception
def traceit(frame, event, arg): if event == "line": lineno = frame.f_lineno print "line", lineno return traceit
def main():print "In main" for i in range(5): print i, i*3 print "Done."
sys.settrace(traceit)
main()
source : http://www.dalkescientific.com/writings/diary/archive/2005/04/20/tracing_python_code.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # code snippet, to be included in 'sitecustomize.py'
import sys
def info(type, value, tb):
if hasattr(sys, 'ps1') or not sys.stderr.isatty():
# we are in interactive mode or we don't have a tty-like
# device, so we call the default hook
sys.__excepthook__(type, value, tb)
else:
import traceback, pdb
# we are NOT in interactive mode, print the exception...
traceback.print_exception(type, value, tb)
print
# ...then start the debugger in post-mortem mode.
pdb.pm()
sys.excepthook = info
|
source : http://code.activestate.com/recipes/65287/- simple logging
import logging logging.basicConfig(level=logging.DEBUG)logging.debug('This is a debug message.')
source : http://aymanh.com/python-debugging-techniques#logging
Inscription à :
Articles (Atom)