tag:blogger.com,1999:blog-11347239252658054272018-03-18T22:05:26.227+02:00Rambling around footending to depart from the main point or cover a wide range of subjectseddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.comBlogger275125tag:blogger.com,1999:blog-1134723925265805427.post-5346223305003684822018-01-26T16:57:00.000+02:002018-01-26T16:57:14.533+02:00Detecting binary files in the history of a git repository<h3>Git, VCSes and binary files</h3>Git is famous and has become popular even in the enterprise/commercial environments. But Git is also infamous regarding storage of large and/or binary files that change often, in spite of the fact they can be efficiently stored. For large files there have been several attempts to fix the issue, with varying degree of success, the most successful being <a href="https://git-lfs.github.com/" target="_blank">git-lfs</a> and <a href="https://git-annex.branchable.com/" target="_blank">git-annex</a>.<br /><br />My personal view is that, contrary to many practices, is a bad idea to store binaries in any VCS. Still, this practice has been and still is in use in may projects, especially in closed source projects. I won't go into the reasons, and how legitimate they are, let's say that we might finally convince people that binaries should be removed from the VCS, git, in particular.<br /><br />Since the purpose of a VCS is to make sure all versions of the stored objects are never lost, Linus designed git in such a way that knowing the exact hash of the tip/head of your git branch, it is guaranteed the whole history of that branch hasn't changed even if the repository was stored in a non-trusted location (I will ignore hash collisions, for practical reasons).<br /><br />The consequence of this is that if the history is changed one bit, all commit hashes and history after that change will change also. This is what people refer to when they say they rewrite the (git) history, most often, in the context of a rebase.<br /><br />But did you know that you could use git rebase to traverse the history of a branch and do all sorts of operations such as detecting all binary files that were ever stored in the branch?<br /><h3>Detecting any binary files, only in the current commit</h3>As with everything on *nix, we start with some building blocks, and construct our solution on top of them. Let's first find all files, except the ones in .git:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">find . -type f -print | grep -v '^\.\/\.git\/'</span></blockquote>Then we can use the 'file' utility to list for non-text files:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">(find . -type f -print | grep -v '^\.\/\.git\/' | xargs file )| egrep -v '(ASCII|Unicode) text'</span></blockquote>And if there are any such file, then it means the current git commit is one that needs our attention, otherwise, we're fine.<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">(find . -type f -print | grep -v '^\.\/\.git\/' | xargs file )| egrep -v '(ASCII|Unicode) text' &amp;&amp; (echo 'ERROR:' &amp;&amp; git show --oneline -s) || echo OK</span></blockquote>&nbsp;Of course, we assume here, the work tree is clean.<br /><h3>Checking all commits in a branch</h3>Since we want to make this an efficient process and we only care if the history contains binaries, and branches are cheap in git, we can use a temporary branch that can be thrown away after our processing is finalized.<br />Making a new branch for some experiments is also a good idea to avoid losing the history, in case we do some stupid mistakes during our experiment.<br /><br />Hence, we first create a new branch which points to the exact same tip the branch to be checked points to, and move to it:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">git checkout -b test_bins</span></blockquote>Git has many commands that facilitate automation, and my case I want to basically run the chain of commands on all commits. For this we can put our chain of commands in a script:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">cat &gt; ../check_file_text.sh</span></blockquote><blockquote><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">#!/bin/sh</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;"></span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">(find . -type f -print | grep -v '^\.\/\.git\/' | xargs file )| egrep -v '(ASCII|Unicode) text' &amp;&amp; (echo 'ERROR:' &amp;&amp; git show --oneline -s) || echo OK</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;"></span></blockquote>then (ab)use 'git rebase' to execute that for us for all commits:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">git rebase --exec="sh ../check_file_text.sh" -i $startcommit</span></blockquote>After we execute this, the editor window will pop up, just save and exit. Assuming $startcommit is the hash of the first commit we know to be clean or beyond which we don't care to search for binaries, this will look in all commits since then.<br /><br />Here is an example output when checking the newest 5 commits:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">$ git rebase --exec="sh ../check_file_text.sh" -i HEAD~5</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">Executing: sh ../check_file_text.sh</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">OK</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">Executing: sh ../check_file_text.sh</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">OK</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">Executing: sh ../check_file_text.sh</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">OK</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">Executing: sh ../check_file_text.sh</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">OK</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">Executing: sh ../check_file_text.sh</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">OK</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">Successfully rebased and updated refs/heads/test_bins.</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;"></span></blockquote><br />Please note this process can change the history on the test_bins branch, but that is why we used a throw-away branch anyway, right? After we're done, we can go back to another branch and delete the test branch.<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;, Courier, monospace;"><br /></span><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">$ git co master<br />Switched to branch 'master'</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">Your branch is up-to-date with 'origin/master' </span></blockquote><blockquote><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">$ git branch -D test_bins</span><br /><span style="font-family: &quot;Courier New&quot;, Courier, monospace;">Deleted branch test_bins (was 6358b91).</span></blockquote>Enjoy!<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/c0oyc90HThU" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com3http://ramblingfoo.blogspot.com/2018/01/detecting-binary-files-in-history-of.htmltag:blogger.com,1999:blog-1134723925265805427.post-23039995553124909812018-01-11T17:22:00.000+02:002018-01-19T08:51:11.723+02:00Suppressing color output of the Google Repo toolOn Windows, in the cmd shell, the color control caracters generated by the Google Repo tool (or its <a href="https://github.com/esrlabs/git-repo" target="_blank">windows port made by ESRLabs</a>) or git appear as garbage. Unfortunately, the Google Repo tool, besides the fact it has a non-google-able name, lacks documentation regarding its options, so sometimes the only way to find out what is the option I want is to look in the code.<br />To avoid repeatedly look over the code to dig up this, future self, here is how you disable color output in the repo tool with the info subcommand:<br /><blockquote class="tr_bq"><span style="font-family: &quot;courier new&quot; , &quot;courier&quot; , monospace;">repo --color=never info</span></blockquote>Other options are 'auto' and 'always', but for some reason, auto does not do the right thing (tm) in Windows and garbage is shown with auto. <img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/_QNz3jM3WNE" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2018/01/suppressing-color-output-of-google-repo.htmltag:blogger.com,1999:blog-1134723925265805427.post-53598062907587351882017-03-25T17:39:00.002+02:002017-03-25T17:39:50.891+02:00LVM: Converting root partition from linear to raid1 leads to boot failure... and how to recoverI have a system which has 3 distinct HDDs used as physucal volumes for Linux LVM. One logical volume is the root partition and it was initally created as a linear LV (vg0/OS).<br />Since I have PV redundancy, I thought it might be a good idea to convert the root LV from liear to raid1 with 2 mirrors.<br /><br /><span style="color: red;">WARNING: It seems LVM raid1 logicalvolume for / is not supported with grub2, at least not with Ubuntu's </span><span style="color: red;">2.02~beta2-9ubuntu1.6 (14.04LTS) or Debian Jessie's grub-pc </span><span style="color: red;">2.02~beta2-22+deb8u1!</span><br /><br />So I did this:<br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">lvconvert -m2 --type raid1 vg0/OS</span><br /><br /><span style="font-family: inherit;">Then I restarted to find myself at the 'grub rescue&gt;' prompt.</span><br /><br /><span style="font-family: inherit;">The initial problem was seen on an Ubuntu 14.04 LTS (aka trusty) system, but I reproduced it on a VM with Debian Jessie.</span><br /><br /><span style="font-family: inherit;">I downloaded the <a href="http://www.supergrubdisk.org/wizard-step-download-super-grub2-disk/" target="_blank">Super Grub2 Disk</a> and tried to boot the VM. After choosing the option to load the LVM and RAID support, I was able to boot my previous system.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">I tried several times to reinstall GRUB, thinking that was the issue, but I always got this&nbsp; kind of error:</span><br /><span style="font-family: inherit;"><br /></span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">/usr/sbin/grub-probe: error: disk `lvmid/QtJiw0-wsDf-A2zh-2v2y-7JVA-NhPQ-TfjQlN/phCDlj-1XAM-VZnl-RzRy-g3kf-eeUB-dBcgmb' not found.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">In the end, after digging for more than 4 hours for answers,&nbsp; I decided I might be able to revert the config to linear configuration, from the (initramfs) prompt.</span><br /><br /><span style="font-family: inherit;">Initally the LV was inactive, so I activated it:</span><br /><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">lvchange -a y /dev/vg0/OS</span><br /><br /><b><span style="font-family: inherit;">Then restored the LV to linear:</span></b><br /><b><span style="font-family: inherit;"><br /></span></b><b><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">lvconvert -m0 vg0/OS</span></b><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">Then tried to reboot without reinstalling GRUB, just for kicks, which succeded.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">In order to confirm this was the issue, I redid the whole thing, and indeed, with a raid1 root, I always got the error lvmid error.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">I'll have to check on Monday at work if I can revert it the same way the Ubuntu 14.04 system, but I suspect I will have no issues.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">Is it true root on lvm-raid1 is nto supported?</span><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/eBPohNUWLp8" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com2http://ramblingfoo.blogspot.com/2017/03/lvm-converting-root-partition-from.htmltag:blogger.com,1999:blog-1134723925265805427.post-2880034207068209932015-12-10T20:22:00.001+02:002015-12-10T20:22:30.459+02:00HOWTO: Setting and inserting/using MS Word 2013 document properties in the body of the documentI wrote this so I won't forget it and for others to find, if confronted with the same issue. <br /><br />I hate Microsoft Office in all its incarnations, but I have to use it at work for various stuff. One of them is maintaining some technical documentation. we now use Office 365 and Office 2013.<br /><br />Since MS Office Word 2013 is not a technical documentation program, some of the support for it is clunky. For things such as version numbers or others strings that might repeat throughout the document, (advanced) document properties is a way to go.<br /><br /><b>To set them select<span style="font-family: &quot;Courier New&quot;,Courier,monospace;"> File &gt; Info &gt; Properties &gt; Advanced Properties &gt; Custom</span> then fill in the '<span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Name:</span>', '<span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Type:</span>' and '<span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Value:</span>', then press <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Add</span>, then <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">OK</span>.</b><br /><br /><b>Once the properties are set, it can be inserted in the document by selecting its name in the '<span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Property:</span>' list from the menu: <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">INSERT &gt; Quick Parts &gt;&nbsp; Field... &gt; Categories:Document Information &gt; DocProperty</span>.</b><br /><br />After updating the<b> </b>value of any property (from the Advanced Properties dialog), to update all the places where the properties were used in the document, press Ctrl+A then right click &gt; <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Update Filed &gt; Update entire table &gt; OK</span>.<br /><br />And, yes, '<span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Update entire table</span>' will update the values, although it's name is stupid. <img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/_3eubmVH0sg" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/12/howto-setting-and-insertingusing-ms.htmltag:blogger.com,1999:blog-1134723925265805427.post-6760735703313486052015-05-23T17:44:00.002+03:002015-05-23T17:44:40.914+03:00HOWTO: No SSH logins SFTP only chrooted server configuration with OpenSSHIf you are in a situation where you want to set up a SFTP server in a more secure way, don't want to expose anything from the server via SFTP and do not want to enable SSH login on the account allowed to sftp, you might find the information below useful.<br /><br />What do we want to achive:<br /><ul><li>SFTP server</li><li>only a specified account is allowed to connect to SFTP</li><li>nothing outside the SFTP directory is exposed</li><li>no SSH login is allowed</li><li>any extra security measures are welcome</li></ul>To obtain all of the above we will create a dedicated account which will be chroot-ed, its home will be stored on a removable/no always mounted drive (acessing SFTP will not work when the drive is not mounted).<br /><br />Mount the removable drive which will hold the SFTP area (you might need to add some entry in fstab).&nbsp; <br /><br />Create the account to be used for SFTP access (on a Debian system this will do the trick):<br /><blockquote class="tr_bq"># adduser --system --home /media/Store/sftp --shell /usr/sbin/nologin sftp</blockquote><br />This will create the account sftp which has login disabled, shell is /usr/sbin/nologin and create the home directory for this user.<br /><br />Unfortunately the default ownership of the home directory of this user are incompatible with chroot-ing in SFTP (which prevents access to other files on the server). A message like the one below will be generated in this kind of case:<br /><blockquote class="tr_bq">$ sftp -v sftp@localhost<br />[..]<br />sftp@localhost's password: <br />debug1: Authentication succeeded (password).<br />Authenticated to localhost ([::1]:22).<br />debug1: channel 0: new [client-session]<br />debug1: Requesting no-more-sessions@openssh.com<br />debug1: Entering interactive session.<br /><b>Write failed: Broken pipe</b><br /><b>Couldn't read packet: Connection reset by peer</b></blockquote>Also <b>/var/log/auth.log</b> will contain something like this:<br /><blockquote class="tr_bq"><b>fatal: bad ownership or modes for chroot directory "/media/Store/sftp"</b></blockquote><br />The default permissions are visible using the 'namei -l' command on the sftp home directory:<br /><blockquote class="tr_bq"># namei -l /media/Store/sftp<br />f: /media/Store/sftp<br />drwxr-xr-x root root&nbsp;&nbsp;&nbsp; /<br />drwxr-xr-x root root&nbsp;&nbsp;&nbsp; media<br />drwxr-xr-x root root&nbsp;&nbsp;&nbsp; Store<br />drwxr-xr-x sftp nogroup sftp</blockquote>We change the ownership of the sftp directory and make sure there is a place for files to be uploaded in the SFTP area:<br /><blockquote class="tr_bq"># chown root:root /media/Store/sftp<br /># mkdir /media/Store/sftp/upload<br /># chown sftp /media/Store/sftp/upload</blockquote><br />We isolate the sftp users from other users on the system and configure a chroot-ed environment for all users accessing the SFTP server:<br /><blockquote class="tr_bq"># addgroup sftpusers<br /># adduser sftp sftusers</blockquote>Set a password for the sftp user so password authentication works:<br /><blockquote class="tr_bq"># passwd sftp</blockquote>Putting all pieces together, we restrict access only to the sftp user, allow it access via password authentication only to SFTP, but not SSH (and disallow tunneling and forwarding or empty passwords).<br /><br />Here are the changes done in /etc/ssh/sshd_config:<br /><blockquote class="tr_bq">PermitEmptyPasswords no<br />PasswordAuthentication yes<br />AllowUsers sftp<br />Subsystem sftp internal-sftp<br />Match Group sftpusers<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ChrootDirectory %h<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ForceCommand internal-sftp<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X11Forwarding no<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AllowTcpForwarding no <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PermitTunnel no</blockquote>Reload the sshd configuration (I'm using systemd):<br /><blockquote class="tr_bq"># systemctl reload ssh.service</blockquote>Check sftp user can't login via SSH:<br /><blockquote class="tr_bq">$ ssh sftp@localhost<br />sftp@localhost's password: <br />This service allows sftp connections only.<br />Connection to localhost closed.</blockquote>But SFTP is working and is restricted to the SFTP area:<br /><blockquote class="tr_bq">$ sftp sftp@localhost<br />sftp@localhost's password: <br />Connected to localhost.<br />sftp&gt; ls<br />upload&nbsp; <br />sftp&gt; pwd<br />Remote working directory: /<br />sftp&gt; put netbsd-nfs.bin<br />Uploading netbsd-nfs.bin to /netbsd-nfs.bin<br />remote open("/netbsd-nfs.bin"): Permission denied<br />sftp&gt; cd upload<br />sftp&gt; put netbsd-nfs.bin<br />Uploading netbsd-nfs.bin to /upload/netbsd-nfs.bin<br />netbsd-nfs.bin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 100% 3111KB&nbsp;&nbsp; 3.0MB/s&nbsp;&nbsp; 00:00 </blockquote>Now your system is ready to accept sftp connections, things can be uploaded in the upload directory and whenever the external drive is unmounted, SFTP will NOT work.<br /><br /><b>Note: Since we added 'AllowUsers sftp', you can test no local user can login via SSH. If you don't want to restrict access only to the sftp user, you can whitelist other users by adding them in the AllowUsers directive, or dropping it entirely so all local users can SSH into the system.</b><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/hVue3sUQcVg" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com1http://ramblingfoo.blogspot.com/2015/05/howto-no-ssh-logins-sftp-only-chrooted.htmltag:blogger.com,1999:blog-1134723925265805427.post-1011150812518392722015-05-20T04:07:00.002+03:002015-05-23T18:15:40.600+03:00Linksys NSLU2 adventures into the NetBSD land passed through JTAG highlands - part 2 - RedBoot reverse engineering and APEX hacking(continuation of <a href="http://ramblingfoo.blogspot.ro/2015/05/linksys-nslu2-adventures-into-netbsd.html" target="_blank">Linksys NSLU2 adventures into the NetBSD land passed through JTAG highlands - part 1</a>; meanwhile, my article was mentioned briefly in <a href="http://www.bsdnow.tv/episodes/2015_05_13-exclusive_disjunction" target="_blank">BSDNow Episode 89 - Exclusive Disjunction</a> around minute <a href="https://www.youtube.com/watch?v=f1Owgoj9TXc#t=36m25s" target="_blank">36:25</a>)<br /><br /><h4>Choosing to call RedBoot from a hacked Apex</h4><br />As I was saying in my previous post, in order to be able to automate the booting of the NetBSD image via TFTP, I opted for using a 2nd stage bootloader (planning to flash it in the NSLU2 instead of a Linux kernel), and since Debian was already using Apex, I chose Apex, too.<br /><br />The first problem I found was that the networking support in Apex was relying on an old version of the Intel NPE library which I couldn't find on Intel's site. The new version was incompatible/not building with the old build wrapper in Apex, so I was faced with 3 options:<br /><ol><li>Fight with the availabel Intel code and try to force it to compile in Apex</li><li>Incorporate the NPE driver from NetBSD into a rump kernel to be included in Apex instead of the original Intel code, since the NetBSD driver only needed an easily compilable binary blob</li><li>Hack together an Apex version that simulates the typing necessary RedBoot commands to load via TFTP the netbsd image and execute it.</li></ol>After taking a look at the NPE driver buildsystem, I concluded there were very few options less attractive that option 1, among which was hammering nails through my forehead as a improvement measure against the severe brain damage which I would probably be likely to be inflicted with after dealing with the NPE "build system".<br /><br />Option 2 looked like the best option I could have, given the situation, but my NetBSD foo was too close to 0 to even dream to endeavor on such a task. In my opinion, this still remains the technically superior solution to the problem since is very portable and a flexible way to ensure networking works in spite of the proprietary NPE code.<br /><br />But, in practice, the best option I could implement at the time was option 3. I initially planned to pre-fill from Apex my desired commands into the RedBoot buffer that stored the keyboard strokes typed by the user:<br /><blockquote class="tr_bq"><br />load -r -b 0x200000 -h 192.168.0.2 netbsd-nfs.bin<br />g</blockquote>Since this was the first time ever for me I was going to do less than trivial reverse engineering in order to find the addresses and signatures of interesting functions in the RedBoot code, it wasn't bad at all that I had a version of the RedBoot source code.<br /><br /><h4>When stuck with reverse engineering, apply JTAG</h4><br />The bad thing was that the code Linksys published as the source of the RedBoot running inside the NSLU2 was, in fact, a different code which had some significant changes around the code pieces I was mostly interested in. That in spite of the GPL terms.<br /><br />But I thought that I could manage. After all, how hard could it be to identify the 2-3 functions I was interested in and 1 buffer? Even if I only had the disassembled code from the slug, it shouldn't be that hard.<br /><br />I struggled with this for about 2-3 weeks on the few occasions I had during that time, but the excitement of leaning something new kept me going. Until I got stuck somewhere between the misalignment between the published RedBoot code and the disassembled code, the state of the system at the time of dumping the contents from RAM (for purposes of disassemby), the assembly code generated by GCC for some specific C code I didn't have at all, and the particularities of ARM assembly.<br /><br />What was most likely to unblock me was to actually see the code in action, so I decided attaching a JTAG dongle to the slug and do a session of in-circuit-debugging was in order.<br /><br />Luckily, the <a href="http://www.nslu2-linux.org/wiki/Info/PinoutOfJTAGPort" target="_blank">pinout of the JTAG interface</a> was already identified in the NSLU2 Linux project, so I only had to solder some wires to the specified places and a 2x20 header to be able to connect through JTAG to the board.<br /><br /><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-Bd-8ATPRiNc/VVvEVzfL5SI/AAAAAAAAAjw/bu4vrmZ022I/s1600/kinder-jtag.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img alt="" border="0" height="400" src="http://4.bp.blogspot.com/-Bd-8ATPRiNc/VVvEVzfL5SI/AAAAAAAAAjw/bu4vrmZ022I/s400/kinder-jtag.jpg" title="JTAG connections on Kinder" width="276" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">JTAG connections on Kinder (the NSLU2 targeting NetBSD)</td></tr></tbody></table><br />After this was done I tried immediately to see if when using a JTAG debugger I could break the execution of the code on the system. The answer was sadly, no.<br /><br />The chip was identified, but breaking the execution was not happening. I tried this in OpenOCD and in another proprietary debugger application I had access to, and the result was the same, breaking <a href="http://pastebin.com/fFLiwdrF" target="_blank">was not happening</a>.<br /><div id="selectable"><div class="text"><blockquote class="tr_bq"><div class="de1">$ openocd -f interface/ftdi/olimex-arm-usb-ocd.cfg -f board/linksys_nslu2.cfg</div><div class="de2">Open On-Chip Debugger 0.8.0 (2015-04-14-09:12)</div><div class="de1">Licensed under GNU GPL v2</div><div class="de2">For bug reports, read</div><div class="de1">&nbsp; &nbsp; http://openocd.sourceforge.net/doc/doxygen/bugs.html</div><div class="de2"></div><div class="de1">Info : only one transport option; autoselect 'jtag'</div><div class="de2">adapter speed: 300 kHz</div><div class="de1">Info : ixp42x.cpu: hardware has 2 breakpoints and 2 watchpoints</div><div class="de2">0</div><div class="de1">Info : clock speed 300 kHz</div><div class="de2">Info : JTAG tap: ixp42x.cpu tap/device found: 0x29277013 (mfg: 0x009,</div><div class="de1">part: 0x9277, ver: 0x2)</div><div class="de1">[..]</div></blockquote><br /><blockquote class="tr_bq"><div class="de2">$ telnet localhost 4444</div><div class="de1">Trying ::1...</div><div class="de2">Trying 127.0.0.1...</div><div class="de1">Connected to localhost.</div><div class="de2">Escape character is '^]'.</div><div class="de1">Open On-Chip Debugger</div><div class="de2">&gt; halt</div><div class="de1">target was in unknown state when halt was requested</div><div class="de2">in procedure 'halt'</div><div class="de1">&gt; poll</div><div class="de2">background polling: on</div><div class="de1">TAP: ixp42x.cpu (enabled)</div><div class="de2">target state: unknown </div></blockquote></div></div>Looking into the documentation I found a bit of information on the XScale processors[X] which suggested that XScale processors might necessarily need the (otherwise optional) SRST signal on the JTAG interface to be able to single step the chip.<br /><br />This confused me a lot since I was sure other people had already used JTAG on the NSLU2.<br /><br />The options I saw at the time were:<br /><ol><li>my NSLU2 did have a fully working JTAG interface (either due to the missing SRST signal on the interface or maybe due to a JTAG lock on later generation NSLU-s, as was my second slug)</li><li>nobody ever single stepped the slug using OpenOCD or other JTAG debugger, they only reflashed, and I was on totally new ground </li></ol>I even contacted Rod Whitby, the project leader of the NSLU2 project to try to confirm single stepping was done before. Rod told me he never did that and he only reflashed the device.<br /><br />This confused me even further because, from what I encountered on other platforms, in order to flash some device, the code responsible for programming the flash is loaded in the RAM of the target microcontroller and that code is executed on the target after a RAM buffer with the to be flashed data is preloaded via JTAG, then the operation is repeated for all flash blocks to be reprogrammed.<br /><br />I was aware it was possible to program a flash chip situated on the board, outside the chip, by only playing with the chip's pads, strictly via JTAG, but I was still hoping single stepping the execution of the code in RedBoot was possible.<br /><br />Guided by that hope and the possibility the newer versions of the device to be locked, I decided to add a JTAG interface to my older NSLU2, too. But this time I decided I would also add the TRST and SRST signals to the JTAG interface, just in case single stepping would work.<br /><br />This mod involved even more extensive changes than the ones done on the other NSLU, but I was so frustrated by the fact I was stuck that I didn't mind poking a few holes through the case and the prospect of a connector always sticking out from the other NSLU2, which was doing some small, yet useful work in my home LAN.<br /><br /><h4>It turns out NOBODY single stepped the NSLU2</h4><h4>&nbsp;</h4>After biting the bullet and soldering JTAG interface with also the TRST and the SRST signals connected as the <a href="http://www.nslu2-linux.org/wiki/Info/PinoutOfJTAGPort" target="_blank">pinout page</a> from the NSLU2 Linux wiki suggested, I was disappointed to observe that I was not able to single step the older NSLU2 either, in spite of the presence of the extra signals.<br /><br />I even tinkered with the reset configurations of OpenOCD, but had not success. After obtaining the same result on the proprietary debugger, digging through a presentation made by Rod back in the hay day of the project and the conversations on the <a href="https://groups.yahoo.com/neo/groups/nslu2-linux/info" target="_blank">NSLU2 Linux Yahoo mailing list</a>, I finally concluded:<br /><blockquote class="tr_bq"><b>Actually nobody single stepped the NSLU2, no matter the version of the NSLU2 or connections available on the JTAG interface!</b></blockquote>So I was back to square 1, I had to either struggle with disassembly, reevaluate my initial options, find another option or even drop entirely the idea. At that point I was already committed to the project, so dropping entirely the idea didn't seem like the reasonable thing to do.<br /><br />Since I was feeling I was really close to finish on the route I had chosen a while ago, I was not any significantly more knowledgeable in the NetBSD code, and looking at the NPE code made me feel like washing my hands, the only option which seemed reasonable was to go on.<br /><br />Digging a lot more through the internet, I was finally able to find <a href="https://github.com/nslu2/iop-redboot" target="_blank">another version of the RedBoot source which was modified for Intel ixp42x systems</a>. A few checks here and there revealed this newly found code was actually almost identical to the code I had disassembled from the slug I was aiming to run NetBSD on. This was a huge step forward.<br /><br />Long story short, a couple of days later I had a <a href="https://github.com/nslu2/apex/tree/netbsd" target="_blank">hacked Apex</a> that could go through the RedBoot data structures, search for available commands in RedBoot and successfully call any of the built-in RedBoot commands!<br /><br />Testing with loading this modified Apex by hand in RAM via TFTP then jumping into it to see if things woked as expected revealed a few small issues which I corrected right away.<br /><br /><h4>Flashing a modified RedBoot?! But why? Wasn't Apex supposed to avoid exactly that risky operation?</h4><br />Since the tests when executing from RAM were successful, my <a href="https://github.com/nslu2/apex/commits/netbsd" target="_blank">custom second stage Apex bootloader for NetBSD net booting</a> was ready to be flashed into the NSLU2.<br /><br />I added two more targets in the Makefile in the code on the dedicated netbsd branch of my Apex repository to generate the images ready for flashing into the NSLU2 flash (RedBoot needs to find a Sercomm header in flash, otherwise it will crash) and the exact commands to be executed in RedBoot are also print out after generation. This way, if the command is copy-pasted, there is no risk the NSLU2 is bricked by mistake.<br /><br />After some flashing and reflashing of the <i><b><span class="blob-code-inner"><span class="pl-en">apex_nslu2.flash</span></span></b></i> image into the NSLU2 flash, some manual testing, tweaking and modifying the default built in APEX commands, checking that the sequence of commands 'move', 'go 0x01d00000' would jump into Apex, which, in turn, would call RedBoot to transfer the netbsd-nfs.bin image from a TFTP to RAM and then execute it successfully, it was high time to check NetBSD would boot automatically after the NSLU was powered on.<br /><br />It didn't. Contrary to my previous tests, no call made from Apex to the RedBoot code would return back to Apex, not even the execution of a basic command such as the 'version' command.<br /><br />It turns out the default commands hardcoded into RedBoot were '<i>boot; exec 0x01d00000</i>', but I had tested '<i>boot; go 0x01d0000</i>', which is not the same thing.<br /><br />While 'go' does a plain jump at the specified address, the 'exec' command also does some preparations so it allows a jump into the Linux kernel and those preparations break some environment the RedBoot commands expect. I don't know which those are and didn't had the mood or motivation to find out.<br /><br />So the easiest solution was to change the RedBoot's built-in command and turn that 'exec' into a 'go'. But that meant this time I was actually risking to brick the NSLU, unless I <br />was able to reflash via JTAG the NSLU2.<br /><br /><br />(to be continued - next, changing RedBoot and bisecting through the NetBSD history)<br /><br />[X] Linksys NSLU2 has an XScale IXP420 processor which is compatible at ASM level with the ARMv5TEJ instruction set<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/9H_SgDPlCVw" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/05/linksys-nslu2-adventures-into-netbsd_20.htmltag:blogger.com,1999:blog-1134723925265805427.post-38781758847370599192015-05-08T03:08:00.001+03:002015-05-23T18:21:09.580+03:00Linksys NSLU2 adventures into the NetBSD land passed through JTAG highlands - part 1About 2 months ago I set a goal to run some kind of BSD on the spare Linksys NSLU2 I had. This was driven mostly by curiosity, after listening to a few <a href="http://www.bsdnow.tv/" target="_blank">BSDNow</a> episodes and becoming a regular listener, but it was a really interesting experience (it was also somewhat frustrating, mostly due to lacking documentation or proprietary code).<br /><br />Looking for documentation on how to install any BSD flavour on the Linksys NSLU2, I have found what appears to be some too-incomplete-to-be-useful-for-a-BSD-newbie information about <a href="https://wiki.freebsd.org/FreeBSDSlug" target="_blank">installing FreeBSD</a>, no information about OpenBSD and some <a href="http://wiki.netbsd.org/tutorials/how_to_install_netbsd_on_the_linksys_nslu2___40__slug__41___without_a_serial_port__44___using_nfs_and_telnet/" target="_blank">very detailed information about NetBSD on the Linksys NSLU2</a>.<br /><br />I was very impressed by the NetBSD build.sh script which can be used to <a href="http://www.netbsd.org/docs/guide/en/chap-build.html" target="_blank">cross-compile the entire NetBSD</a> system - to do that, it also builds the appropriate toolchain - NetBSD kernel and the base system, even when ran on a Linux host. Having some experience with cross compilation for GNU/Linux embedded systems I can honestly say this is immensely impressive, well done NetBSD!<br /><br />Gone were a few failed attempts to properly follow the instruction and lots of hours of (re)building, but then I had the kernel and the sets (the NetBSD system is split into several parts which are grouped by functionality, these are the sets), so I was in the position to have to set things up to be able to net boot - kernel loading via TFTP and rootfs on NFS.<br /><br />But it wouldn't be challenging if the instructions were followed to the letter, so the first thing I wanted to change was that I didn't want to run dhcpd just to pass the DHCP boot configuration to the NSLU2, that seemed like a waste of resources since I already had dnsmasq running.<br /><br />After some effort and struggling with missing documentation, I managed to <a href="http://ramblingfoo.blogspot.com/2015/04/howto-dnsmasq-server-for-network.html" target="_blank">use dnsmasq to pass DHCP boot parameters to the slug, but also use it as TFTP</a> server - after some time I documented this for future reference on my blog and expect to refer to it in the future.<br /><br />Setting up NFS wasn't a problem, but, when trying to boot, I found that I managed to misread at least 3 or 4 times some of the <a href="http://wiki.netbsd.org/tutorials/how_to_install_netbsd_on_the_linksys_nslu2___40__slug__41___without_a_serial_port__44___using_nfs_and_telnet/" target="_blank">NSLU2 related information on the NetBSD wiki</a>. To be able to debug what was happening I concluded the slug should have a serial console attached to it, which helped a lot.<br /><br />Still the result was that I wasn't able to boot the trunk version of the NetBSD code on my NSLU2.<br /><br />Long story short, with the help of some people from the #netbsd IRC channel on Freenode and from the port-arm NetBSD mailing list I found out that I might have a better chance with specific older versions. In practice <a href="http://mail-index.netbsd.org/port-arm/2015/03/24/msg002963.html" target="_blank">what really worked was the code from the netbsd_6_1</a> branch.<br /><br />Discussions on the port-arm mailing list, some digging into the (recently found) PR (problem reports), and <a href="http://mail-index.netbsd.org/port-arm/2015/03/27/msg002975.html" target="_blank">a successful execution of the trunk kernel (at the time, version 7.99.4) together with 6.1.5 userspace</a> lead me to the conclusion the NetBSD userspace for armbe was broken in the trunk branch.<br /><br />And since I concluded this would be a good occasion to learn a few details about NetBSD, I set out to git bisect through the trunk history to identify when this happened. But that meant being able to easily load kernels and run them from TFTP, which was not how the RedBoot bootloader flashed into the slug behaves by default.<br /><br />Be default, the RedBoot bootloader flashed into the NSLU2 waits for 2 seconds for a manual interaction (it waits for a ^C) on the serial console or on the <a href="http://www.nslu2-linux.org/wiki/HowTo/TelnetIntoRedBoot" target="_blank">telnet RedBoot prompt</a>, then, if no such event happens, it copies the Linux image it has in flash starting with adress 0x50060000 into RAM at address 0x01d00000 (after stripping the Sercomm header) and then executes the copied code from RAM.<br /><br />Of course, this is not a very handy way to try to boot things from TFTP, so my first idea to overcome this limitation was to use a second stage bootloader which would do the loading via TFTP of the NetBSD kernel, then execute it from RAM. Flashing this second stage bootloader instead of the Linux kernel at 0x50060000 would make sure that no manual intervention except power on would be necessary when a new kernel+userspace pair is ready to be tested.<br /><br />Another advantage was that I would not risk bricking the NSLU2 since I would not be changing RedBoot, the original bootloader.<br /><br />I knew Apex was used as the second stage bootloader in Debian, so I started configuring <a href="https://github.com/nslu2/apex" target="_blank">my own version of the APEX bootloader to make it work for the netbsd-nfs.bin image</a> to be loaded via TFTP. <br /><br />My first disappointment was that Apex was did not support receiving the boot parameters via DHCP, but only via RARP (it was clear it was less tested with BOOTP or DHCP) and TFTP was documented in the code as being problematic. That meant that I would have to hard code the boot configuration or configure RARP, but that wasn't too bad.<br /><br />Later I found out that I wasted time on that avenue because the network driver in Apex was some Intel code (NPE Access Library) which can't be freely distributed, but could have been downloaded from Intel's site back in 2008-2009. The bad news was that current versions did not work at all with the old patch work that was done in Apex to allow for the driver made for Linux to compile in a world of its own so it could be incorporated in Apex.<br /><br />I was stuck and the only options I were:<br /><ol><li>Fight with the available Intel code and make it compile in Apex</li><li>Incorporate the NPE driver from NetBSD into a <a href="http://wiki.netbsd.org/rumpkernel/" target="_blank">rump kernel</a> which will be included in Apex, since I knew the NetBSD driver only needed a very easily obtainable binary blob, instead of the entire driver as was in Apex before</li><li>Hack together an Apex version that simulates the typing of the necessary commands to load the netbsd-nfs.bin image inside RedBoot, or in other words, call from Apex the RedBoot functions necessary to load from TFTP and execute NetBSD.</li></ol>Option 1 did not look that appealing after looking into the horrible Intel build system and its endless dependencies into a specific Linux kernel version.<br /><br />Option 2 was more appealing, but since I didn't knew NetBSD and only tried once to build and run a NetBSD rump kernel, it seemed like a doable project only for an experienced NetBSD developer or at least an experienced NetBSD user, which I was not.<br /><br />So I was left with option 3, which meant I had to do some reverse engineering of the code, because, although RedBoot is GPL, Linksys did not publish the source from which the running RedBoot was built from.<br /><br /><br />(continues <a href="http://ramblingfoo.blogspot.com/2015/05/linksys-nslu2-adventures-into-netbsd_20.html" target="_blank">here</a>)<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/iEqFAJMOBt8" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/05/linksys-nslu2-adventures-into-netbsd.htmltag:blogger.com,1999:blog-1134723925265805427.post-91130565342449659472015-04-30T03:42:00.001+03:002015-04-30T03:42:29.139+03:00Linksys NSLU2 JTAG help requestedSome time ago I have embarked on a jurney to install NetBSD on one of my two NSLU2-s. I have ran into all sorts of hurdles and problems which I finally managed to overcome, except one:<br /><br />The NSLU I am using has a standard 20 pin ARM JTAG connector attached to it (as per this page <a href="http://www.nslu2-linux.org/wiki/Info/PinoutOfJTAGPort">http://www.nslu2-linux.org/wiki/Info/PinoutOfJTAGPort</a>, only TDI, TDO, TMS, TCK, Vref and GND signals), but, although the chip is identified, I am <a href="http://pastebin.com/fFLiwdrF" target="_blank">unable to halt the CPU</a>:<br /><div id="selectable"><div class="text"><ol><div class="de1"><span style="font-size: x-small;">$ openocd -f interface/ftdi/olimex-arm-usb-ocd.cfg -f board/linksys_nslu2.cfg</span></div><div class="de2"><span style="font-size: x-small;">Open On-Chip Debugger 0.8.0 (2015-04-14-09:12)</span></div><div class="de1"><span style="font-size: x-small;">Licensed under GNU GPL v2</span></div><div class="de2"><span style="font-size: x-small;">For bug reports, read</span></div><div class="de1"><span style="font-size: x-small;">&nbsp; &nbsp; http://openocd.sourceforge.net/doc/doxygen/bugs.html</span></div><div class="de2"></div><div class="de1"><span style="font-size: x-small;">Info : only one transport option; autoselect 'jtag'</span></div><div class="de2"><span style="font-size: x-small;">adapter speed: 300 kHz</span></div><div class="de1"><span style="font-size: x-small;">Info : ixp42x.cpu: hardware has 2 breakpoints and 2 watchpoints</span></div><div class="de2"><span style="font-size: x-small;">0</span></div><div class="de1"><span style="font-size: x-small;"><b>Info : clock speed 300 kHz</b></span></div><div class="de2"><span style="font-size: x-small;"><b>Info : JTAG tap: ixp42x.cpu tap/device found: 0x29277013 (mfg: 0x009,</b></span></div><div class="de1"><span style="font-size: x-small;"><b>part: 0x9277, ver: 0x2)</b></span></div><div class="de2"><span style="font-size: x-small;">[..]</span></div><div class="de1"></div><div class="de2"><span style="font-size: x-small;">$ telnet localhost 4444</span></div><div class="de1"><span style="font-size: x-small;">Trying ::1...</span></div><div class="de2"><span style="font-size: x-small;">Trying 127.0.0.1...</span></div><div class="de1"><span style="font-size: x-small;">Connected to localhost.</span></div><div class="de2"><span style="font-size: x-small;">Escape character is '^]'.</span></div><div class="de1"><span style="font-size: x-small;">Open On-Chip Debugger</span></div><div class="de2"><span style="font-size: x-small;">&gt; halt</span></div><div class="de1"><span style="font-size: x-small;"><b>target was in unknown state when halt was requested</b></span></div><div class="de2"><span style="font-size: x-small;"><b>in procedure 'halt'</b></span></div><div class="de1"><span style="font-size: x-small;">&gt; poll</span></div><div class="de2"><span style="font-size: x-small;"><b>background polling: on</b></span></div><div class="de1"><span style="font-size: x-small;"><b>TAP: ixp42x.cpu (enabled)</b></span></div><div class="de2"><span style="font-size: x-small;"><b>target state: unknown </b></span></div></ol></div></div>My main goal is to make sure I can&nbsp; flash the device via JTAG, in case I break it, but it would be ideal if I could use the JTAG to single step through the code.<br /><br />I have found that other people have managed to flash the device via <a href="https://groups.yahoo.com/neo/groups/nslu2-linux/conversations/messages/16493" target="_blank">JTAG without the other signals</a>, and some have even <a href="https://groups.yahoo.com/neo/groups/nslu2-linux/conversations/messages/10655" target="_blank">changed the bootloader</a> (and had JTAG confirmed as backup solution), so I am stuck.<br /><br />So if anyone can give some insights into ixp42x / Xscale / NSLU2 specific JTAG issues or hints regarding this issue on OpenOCD or other such tool, I would be really grateful.<br /><br /><br /><i><span style="font-size: x-small;">Note: I have made a hacked second stage Apex bootloader to laod the NetBSD image via TFTP, but the default RedBoot sequence 'boot; exec 0x01d00000' should be 'boot; go 0x01d00000' for NetBSD to work, so I am considering changing the RedBoot partition to alter that command. The gory details can be summed as my Apex is calling RedBoot functions to be network enabled (because Intel's NPE current code is not working on Apex) and I have tested this to work with go, but not with exec.</span></i><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/75Y0IehZetA" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/04/linksys-nslu2-jtag-help-requested.htmltag:blogger.com,1999:blog-1134723925265805427.post-26673064926858255862015-04-06T10:27:00.003+03:002015-04-06T10:27:58.153+03:00HOWTO: Dnsmasq server for network booting using TFTP and DHCP<a href="http://www.thekelleys.org.uk/dnsmasq/doc.html" target="_blank">Dnsmasq</a> is a very lightweight server that besides the expected DNS caching functionality, it also offers DHCP and TFTP functionality in a single binary.<br /><br />This makes it very useful if one needs to network boot a system since you can have the TFTP and DHCP part of the setup done easily, and only add NFS for a complete network boot.<br /><br />Add to that that <br /><br />One extra nice thing dnsmasq has is that it can mark specific hosts, addresses or ranges with some internal markers, then use those markers as symbolic names to apply settings based for classes of devices.<br /><br />In the configuration snippet below, there is a rule I set up to make sure I would apply the 'netbsd' label to any system connecting through specific ethernet interfaces (one is the interface of the system, the other is a USB NIC I use from time to time):<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">#You will need a range for static IPs in the main file<br />dhcp-range=192.168.77.250,192.168.77.254,static<br /><br /># give the name 'kinder' to any machine connecting through the given ethernet nics and apply 'netbsd' label<br />dhcp-host=00:1a:70:99:60:BB,00:06:4F:0D:B1:95, kinder, 192.168.77.251, set:netbsd<br /><br /># Machines tagged 'netbsd' shall use the given NFS root path<br />dhcp-option=tag:netbsd, option:root-path,/export/netbsd-nslu2/root<br /># Enable dnsmasq's built-in TFTP server<br />enable-tftp<br /><br /># Set the root directory for files available via FTP.<br />tftp-root=/srv/tftp</span></blockquote>Saving this configuration file in /etc/dnsmasq.d/kinder-netboot will enable this to be used by dnsmasq if this line is present in /etc/dnsmasq.conf<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">conf-dir=/etc/dnsmasq.d</span></blockquote>Commenting it will disable the netbsd part easily.<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/-L1BUb_TTHc" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/04/howto-dnsmasq-server-for-network.htmltag:blogger.com,1999:blog-1134723925265805427.post-8092292453701311242015-03-29T01:52:00.002+02:002015-03-29T16:30:52.235+03:00HOWTO: Disassemble a big endian Arm raw memory dump with objdumpThis is trivial and very useful for embedded code dumps, but in case somebody (including future me) needs this, here it goes:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">arm-none-eabi-objdump -D -b binary -m arm -EB dump.bin | less</span></blockquote>The options mean:<br /><ul><li>-D - disassemble</li><li>-b binary - input file is a raw file</li><li>-m arm - arm architecture</li><li>-EB - big endian</li></ul>By default, endianness is assumed to be little endian, or at least that's happened with my toolchain.<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/uZVC2ugR7uI" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/03/howto-disassembly-big-endian-arm-raw.htmltag:blogger.com,1999:blog-1134723925265805427.post-70834438203558447592015-03-11T11:30:00.000+02:002015-03-29T01:40:37.299+02:00Net NeutralityI have seen <a href="http://theoatmeal.com/blog/net_neutrality" target="_blank">this awesomeness</a> way too late, but is still awesome.<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/IglCdz16i-I" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/03/net-netrality.htmltag:blogger.com,1999:blog-1134723925265805427.post-83047455633129077482015-03-06T23:32:00.000+02:002015-03-06T23:39:57.446+02:00Occasional Rsnapshot v1.3.1I was writing in the <a href="http://ramblingfoo.blogspot.ro/2015/02/occasional-rsnapshot-v130.html" target="_blank">previous post</a> about <a href="https://github.com/eddyp/occasional_rsnapshot" target="_blank">Occasional Rsnapshot</a> and&nbsp; how I ended up writing it.<br /><br />Just before releasing v1.2.1 I realized it would make sense <a href="http://semver.org/" target="_blank">Semantic Versioning</a> which, in just a few words means:<br /><blockquote class="tr_bq">Given a version number MAJOR.MINOR.PATCH, increment the:<br /><pre><code>MAJOR version when you make incompatible API changes,<br />MINOR version when you add functionality in a backwards-compatible manner, and<br />PATCH version when you make backwards-compatible bug fixes.<br /></code></pre></blockquote>I just released Occasional Rsnapshot v1.3.1 which mainly fixed <a href="https://github.com/eddyp/occasional_rsnapshot/issues/4" target="_blank">issue 4</a>:<br /><div class="edit-comment-hide"><div class="comment-body markdown-body markdown-format js-comment-body"><blockquote class="tr_bq">When deciding to do a backup for interval INT, there should be a check that the oldest snapshot in INT-1 interval is older than the threshold for the INT interval. Otherwise the INT interval will be populated with backups more frequent than desired and it is possible older backups in INT interval to completely lost.<br />The condition should be:<br /><pre><code>ts(oldest(INT-1)) - ts(newest(INT)) &gt;= threshold(INT)<br /></code></pre>For example:<br /><ul class="task-list"><li>if <code>weekly.0</code> is from 15th of February and <code>daily.6</code> is from 17th of February, <code>weekly</code> should not be triggered, but</li><li>if <code>weekly.0</code> is from 15th of February and <code>daily.6</code> is from 23rd of February, <code>weekly</code> shall be triggered</li></ul>This extra check should probably added in <code>can_backup_interval</code>.</blockquote>It was a small bug, but it might have lead to losing important older backups because newer and more frequent backups would be pushed from hourly, interval by interval up to the yearly interval, in spite of the fact that the distance between backups wouldn't have been respecting the upper interval minimum distance in time.<br /><br />There was also a small syntax bugfix, but functionally nothing has changed because bash was doing the right thing even with that small error.<br /><br />If you have started using <a href="https://github.com/eddyp/occasional_rsnapshot" target="_blank">Occasional Rsnapshot</a>, you definitely want now Occasional&nbsp; Rsnapshot<a href="https://github.com/eddyp/occasional_rsnapshot/releases/tag/v1.3.1" target="_blank"> v1.3.1</a>. If you haven't started and you don't have backups, please start doing backups, and while you're at it, you might want to try Occasional Rsnapshot (with Rsnapshot).<br /><br /></div></div><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/Gn9dMjVFfw8" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/03/occasioal-rsnapshot-v131.htmltag:blogger.com,1999:blog-1134723925265805427.post-71285820041618949932015-02-25T21:39:00.002+02:002015-02-25T21:41:44.312+02:00Occasional Rsnapshot v1.3.0It is almost exactly 1 year and a half since I came up with the idea of having a way of making backups using Rsnapshot automatically triggered by my laptop when I have the backup media connected to my laptop. This could mean connecting a USB drive directly to the laptop or mounting a NFS/sshfs share in my home network. Today I tagged <a href="https://github.com/eddyp/occasional_rsnapshot">Occasional Rsnapshot</a> the <a href="https://github.com/eddyp/occasional_rsnapshot/releases/tag/v1.3.0">v1.3.0</a> version, the first released version that makes sure even when you connect your backup media occasionally, your <a href="http://www.rsnapshot.org/">Rsnapshot</a> backups are done if and when it makes sense to do it, according to the rsnapshot.conf file and the status of the existing backups on the backup media.<br /><br />Quoting from the <a href="https://github.com/eddyp/occasional_rsnapshot/blob/master/README.md">README</a>, here is what Occasional Rsnapshot does:<br /><blockquote class="tr_bq"><br />This is a tool that allows automatic backups using rsnapshot when the external backup drive or remote backup media is connected.<br /><br />Although the ideal setup would be to have periodic backups on a system that is always online, this is not always possible. But when the connection is done, the backup should start fairly quickly and should respect the daily/weekly/... schedules of rsnapshot so that it accurately represents history.<br /><br />In other words, if you backup to an external drive or to some network/internet connected storage that you don't expect to have always connected (which is is case with laptops) you can use <code>occasional_rsnapshot</code> to make sure your data is backed up when the backup storage is connected.<br /><br /><code>occasional_rsnapshot</code> is appropriate for:<br /><ul class="task-list"><li>laptops backing up on: <ul class="task-list"><li>a NAS on the home LAN or</li><li>a remote or an internet hosted storage location</li></ul></li><li>systems making backups online (storage mounted locally somehow)</li><li>systems doing backups on an external drive that is not always connected to the system</li></ul>The only caveat is that all of these must be mounted in the local file system tree somehow by any arbitrary tool, <code>occasional_rsnapshot</code> or <code>rsnapshot</code> do not care, as long as the files are mounted.<br /><br />So if you find yourself in a simillar situation, this script might help you to easily do backups in spite of the occasional availability of the backup media, instead of no backups at all. You can even trigger backups semi-automatically when you remember to or decide is time to backup, by simply pulging in your USB backup HDD.</blockquote><br />But how did I end up here, you might ask?<br /><br />In December 2012 I was asking about suggestions for <a href="http://ramblingfoo.blogspot.ro/2012/12/looking-for-backup-application-for.html" target="_blank">backup solutions that would work for my very modest setup with Linux and Windows</a> so I can backup my and my wife's system without worrying about loss of data.<br /><br />One month later <a href="http://ramblingfoo.blogspot.ro/2013/01/rsnapshot-backup-and-security-some.html" target="_blank">I was explaining my concept of a backup solution</a> that would not trust the backup server, and leave to the clients as much as possible the decision to start the backup at their desired time. I was also pondering on the problems I might encounter.<br /><br />From a security PoV, what I wanted was that:<br /><ol><li>clients would be isolated from each other</li><li>even in the case of a server compromise:</li><ol></ol><ul><li>the data would not be accessible since they would be already encrypted before leaving the client</li><li>the clients could not be compromised </li></ul></ol><br /><br />The general concept was sane and supplemental security measures such as <a href="http://linux.die.net/man/1/knockd" target="_blank">port knocking</a> and initiation of backups only during specific time frames could be added.<br /><br />The problem I ran to was that when I set up this in my home network a sigle backup cycle would take more than a day, due to the fact that I wanted to do backup of all of my data and my server was a humble Linksys NSLU2 with a 3TB storage attached on USB.<br /><br />Even when the initial copy was done by attaching the USB media directly to the laptop, so the backup would only copy changed data, the backup with the HDD attached to the NSLU2 was not finished even after more than 6 hours.<br /><br />The bottleneck was the CPU speed and the USB speed. I tried even mounting the storage media over sshfs so the tiny xscale processor in the NSLU2 would not be bothered by any of the rsync computation. This proved to an exercise in futility, any attempt to put the NSLU2 anywhere in the loop resulted in an unacceptable and impractically long backup time.<br /><br />All these attempts, of course, took time, but that meant that I was aware I still didn't have appropriate backups and I wasn't getting closer to the desired result.<br /><br />So this brings us August 2013, when I realized I was trying to manually trigger Rsnapshot backups from time to time, but having to do all sorts of mental gymnastics and manual listing to evaluate if I needed to do monthly, weekly and daily backups or if weekly and daily was due.<br /><br />This had to stop.<br /><blockquote class="tr_bq">Triggering a backup should happen automatically as soon as the backup media is available, without any intervention from the user.</blockquote>I said.<br /><br />Then I came up with the basic concept for <a href="https://github.com/eddyp/occasional_rsnapshot">Occasional Rsnapshot</a>: a very silent script that would be called from&nbsp; cron every 5 minutes, would check if the backup media is mounted, if is not, exit silently to not generate all sorts of noise in cron emails, but if mounted, compute which backup intervals should be triggered, and trigger them, if the appropriate amount of time passed since the most recent backup in that backup interval.<br /><br /><a href="https://github.com/eddyp/occasional_rsnapshot">Occasional Rsnapshot</a> version <a href="https://github.com/eddyp/occasional_rsnapshot/releases/tag/v1.3.0">v1.3.0</a> is the 8th and most recent release of the script. Even if I used Occasional Rsnapshot since the day 1, v1.3.0 is the first one I can recommend to others, without fearing they might lose data due to it.<br /><br />The backup media can be anything, starting from your regular USB mounted HDD, your sshfs mounted backup partition on the home NAS server to even a remote storage such as <a href="https://en.wikipedia.org/wiki/Amazon_S3">Amazon S3</a> online storage, and there are even brief instructions on how to do encrypted backups for the cases where you don't trust the remote storage.<br /><br />So if you think you might find anything that I described remotely interesting, I recommend downloading the latest <a href="https://github.com/eddyp/occasional_rsnapshot/releases">release of Occasional Rsnapshot</a>, go through the README and trying it out.<br /><br />Feedback and bug reports are welcome.<br />Patches are welcomed with a 'thank you'.<br /><a href="https://github.com/eddyp/occasional_rsnapshot/pulls">Pull requests</a> are eagerly waited for :) .<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/PxqvnVGRxcQ" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/02/occasional-rsnapshot-v130.htmltag:blogger.com,1999:blog-1134723925265805427.post-3838593907727406062015-02-09T23:40:00.002+02:002015-02-09T23:40:54.114+02:00uClibc based toolchain using Gentoo for NSLU2I was asked in <a href="http://ramblingfoo.blogspot.com/2015/02/using-gentoo-to-create-cross-toolchain.html" target="_blank">the previous post</a> why I didn't used the Debian armel port for my NSLU2.<br /><br />My intention was to create a uclibc based system (and a uclibc based toolchain) for my NSLU2. This was not obvious in the post because building the uclibc based toolchain resulted in this error:<br /><blockquote class="tr_bq"><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><b>crossdev armv5-softfloat-linux-uclibceabi</b></span></span></blockquote><blockquote><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">[..]</span></span></span></span><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">/var/tmp/portage/cross-armv5-softfloat-linux-uclibceabi/gcc-4.9.2/work/gcc-4.9.2/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:67:21: fatal error: wordexp.h: No such file or directory</span></span><br /><b><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp;#include <wordexp .h=""></wordexp></span></span><br /><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^</span></span></b><br /><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">compilation terminated.</span></span><br /><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Makefile:416: recipe for target 'sanitizer_platform_limits_posix.lo' failed</span></span><br /><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">make[4]: *** [sanitizer_platform_limits_posix.lo] Error 1</span></span><br /><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">make[4]: *** Waiting for unfinished jobs....</span></span><br /><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"></span></span></blockquote><br />So, yesterday, to not forget what I did, I tried building a glibc based toolchain and posted that.<br /><br />Today, after looking at the offending error, it seems gcc 4.9.2 assumes wordexp.h is always available on non-Android platforms and Gentoo does not make that file availble when installing uclibc.<br /><br /><br /><strike>I think the problem was introduced in gcc in 2013 with <a href="https://gcc.gnu.org/viewcvs/gcc/trunk/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc?r1=204367&amp;r2=204368&amp;" target="_blank">this</a> commit, but I haven't cheked in detail. </strike>What I know for sure is that gcc 4.8.3 works at this moment with uclibc and the buildroot guys are still using gcc 4.8.4 in their default uClibc based toolchain. So here it is the command that generated the uClibc based toolchain:<br /><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><b>crossdev --g 4.8.3 armv5-softfloat-linux-uclibceabi</b></span><br /><br />I hope this helps other people. Yes, I know I should report the issue to GCC/Gentoo after further investigation.<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/uUjY79dWOUY" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2015/02/uclibc-based-toolchain-using-gentoo-for.htmltag:blogger.com,1999:blog-1134723925265805427.post-82619109208589248392015-02-07T21:07:00.000+02:002015-02-07T21:07:26.258+02:00Using Gentoo to create a cross toolchain for the old NSLU2 systems (armv5te)<i>This is mostly written so I don't forget how to create a custom (Arm) toolchain the Gentoo way (in a Gentoo chroot).</i><br /><br />I have been a Debian user since 2001, and I like it a lot. Yet I have had my share of problems with it, mostly because due to lack of time I have very little disposition to try to track unstable or testing, so I am forced to use stable.<br /><br />This led me to be a fan of <a href="http://www.eyrie.org/~eagle/software/scripts/backport.html" target="_blank">Russ Albery's backport</a> script and to create a lot of local backports of packages that are already in unstable or testing.<br /><br />But this does not help when packages are simply missing from Debian or when something like creating an arm uclibc based system that should be kept up to date, from a security PoV.<br /><br />I have experience with <a href="http://buildroot.org/" target="_blank">Buildroot</a> and I must say I like it a lot for creating custom root filesystems and even toolchains. It allows a lot of flexibility that binary distros like Debian don't offer, it does its designated work, creating root filesystems. But buildroot is not appropriate for a system that should be kept up to date, because it lacks a mechanism by which to be able to update to new versions of packages without recompiling the entire rootfs.<br /><br />So I was hearing from the guys from the <a href="http://www.jupiterbroadcasting.com/show/linuxactionshow/" target="_blank">Linux Action Show</a> (and <a href="http://www.jupiterbroadcasting.com/show/linuxun/" target="_blank">Linux Unplugged</a> - <span style="font-size: xx-small;">by the way, Jupiter Broadcast, why do I need scripts enabled from several sites just to see the links for the shows?</span>) how Arch is great and all, that is a binary rolling release, and that you can customize packages by building your own packages from source using <a href="https://wiki.archlinux.org/index.php/Makepkg" target="_blank">makepkg</a>. I tried it, but Arm support is provided for some specific (modern) devices, my venerable Linksys NSLU2's (I have 2 of them) not being among them.<br /><br />So I tried Arch in a chroot, then dropped it in favour of a Gentoo chroot since I was under the feeling running Arch from a chroot wasn't such a great idea and I don't want to install Arch on my SSD.<br /><br />I used succesfully Gentoo in the past to create an arm-unknown-linux-gnueabi chroot back in 2008 and I always liked the idea of USE flags from Gentoo, so I knew I could do this.<br /><br /><br />So here it goes:<br /><br /><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"># create a local portage overlay - necessary for cross tools</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">export LP=/usr/local/portage</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">mkdir -p $LP/{metadata,profiles}</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">echo 'mycross' &gt; $LP/profiles/repo_name</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">echo 'masters = gentoo' &gt; $LP/metadata/layout.conf</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">chown -R portage:portage $LP</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">echo 'PORTDIR_OVERLAY="'$LP' ${PORTDIR_OVERLAY}"' &gt;&gt; /etc/portage/make.conf</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">unset LP</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><br /></span><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"># install crossdev, setup for the desired target, build toolchain</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">emerge crossdev</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">crossdev --init-target -t arm-</span><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">softfloat</span>-linux-gnueabi -oO /usr/local/portage/mycross</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">crossdev -t arm-softfloat-linux-gnueabi</span><br /><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp;</span><br /><br /><br /><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/Vl09aDtp8pw" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com1http://ramblingfoo.blogspot.com/2015/02/using-gentoo-to-create-cross-toolchain.htmltag:blogger.com,1999:blog-1134723925265805427.post-43595158405823637272013-10-28T23:46:00.002+02:002013-10-29T09:52:38.559+02:00The stupidest trend in laptop design is...... numpads on laptop keyboards.<br /><br />Just because a very, very, very restricted segment of the population is into accounting or other jobs needing frequent numeric input, almost all laptop manufacturers feel the stupid urge to place a numpad on laptops with screens over 14''.<br /><br /><b>Reasons why a numpad on a laptop is a bad idea</b>:<br /><ul><li>can lead to health issues: it forces the user to assume a bad position in front of the screen; this can affect the eyes and the backbone; It's bad enough many people have a bad posture in front of the computer as it is, no need to pump up Scoliosis' position in the laundry list of modern day health risks</li></ul><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-VlghglAst_k/Um7WEO0i7jI/AAAAAAAAAbg/eK-HqmIQv5o/s1600/54398-hp-envy-17-box.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="300" src="http://1.bp.blogspot.com/-VlghglAst_k/Um7WEO0i7jI/AAAAAAAAAbg/eK-HqmIQv5o/s1600/54398-hp-envy-17-box.png" width="400" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">The numpad forces eye focus and users' hands to be way off center.<br />The touchpad looks as if it was thrown to the side by accident<br />Note how the designer tried to offset the misalignment forced<br />by the numpad by "positioning" the touchpad closer to center,<br />but not in line with the space bar (and the keyboard)</td></tr></tbody></table><br /><ul><li>ugly design: it simply looks ugly; why do people think Apple didn't jump into this stupid bandwagon? Because it's ugly design!</li></ul><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-uwZXEK-HI_E/Um7ZjRGP-1I/AAAAAAAAAbs/HqSW-V32yzI/s1600/52274-dell-inspiron-xps-box.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="264" src="http://4.bp.blogspot.com/-uwZXEK-HI_E/Um7ZjRGP-1I/AAAAAAAAAbs/HqSW-V32yzI/s1600/52274-dell-inspiron-xps-box.png" width="320" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Without numpad the position is almost perfect!<br />The symmetry of the laptop improves on the design.<br />Notice how the touchpad is also centered.</td><td class="tr-caption" style="text-align: center;"></td><td class="tr-caption" style="text-align: center;"></td><td class="tr-caption" style="text-align: center;"><br /></td><td class="tr-caption" style="text-align: center;"><br /></td></tr></tbody></table><br /><ul><li>the numpad is useless for the vast majority of people, and those who need numpads, already use them at desktop (keyboard) or, can buy numpads</li><li>it's more expensive to manufacture (more moving parts, more complex wiring and more expensive materials - plastic is cheaper than plastic+copper+rubber)</li><li>less resilient: more ways to fail, higher risk to get liquids inside</li><li>bad mechanical design: wider keyboard means less distance from the edge to the keyboard, which can mean a more fragile case</li><li>makes the laptop heavier: the plastic or material that covers the keys would be enough to cover the insides; the extra rubber, wiring, support etc, add extra weight</li><li>it kills the opportunity to use the real estate for other useful things (or things which improve the overall design): speakers, volume keys, finger print readers, other special function keys, LEDs or other output devices</li></ul>What's worse is that most resellers do not have filters for this particular mis-feature, so you can't easily exclude laptops corrupted by this horrendous idea.<br /><span style="font-size: x-large;"><br /></span><span style="font-size: x-large;">So, if you're a laptop designer, please stop putting numpads on laptops.</span><br /><br />It will make for better looking laptops and you'll have the opportunity to be the one stating the obvious: numpads are generally useless! Even on desktop keyboards!<img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/v6HYsRcsN-g" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com46http://ramblingfoo.blogspot.com/2013/10/the-stupidest-trend-in-laptop-design-is.htmltag:blogger.com,1999:blog-1134723925265805427.post-62176260944401506612013-09-02T00:46:00.001+03:002013-09-02T00:51:28.306+03:00Integrating Beyond Compare with Semanticmerge<i>Note: This post will probably not be on the liking of those who think free software is always preferable to closed source software, so if you are such a person, please take this article as an invitation to implement better open source alternatives that can realistically compete with the closed source applications I am mentioning here. I am not going to mention here where the open source alternatives are not up to the same level as the commercial tools, I'll leave that for the readers or for another article.</i><br /><br /><br /><br /><a href="http://www.semanticmerge.com/" target="_blank">Semanticmerge</a> is a merge tool that attempts to do the right thing when it comes to merging source code. It is language aware and it currently supports Java and C#. Just today the creators of the software have <a href="http://plasticscm.uservoice.com/forums/196398-mergebegins/suggestions/3866314-c-support?tracking_code=a086fa1a750914b9a523a22d6eed3ec8" target="_blank">started working on the support for C</a>.<br /><br />Recently they added Debian packages, so I installed it on my system. For open source development Codice Software, the creators of Semanticmerge, offers free licenses, so I decided to ask for one today, and, although is Sunday, I received an answer and I will get my license on Monday.<br /><br />When a method is moved from one place to another and changed in a conflicting way in two parallel development lines, Semanticmerge can isolate the offending method and can pass all its incarnations (base, source and destination or, if you prefer, base, mine and theirs) to a text based merge tool to allow the developer to decide how to resolve the merge. On Linux, the Semanticmerge samples are using <a href="http://kdiff3.sourceforge.net/" target="_blank">kdiff3</a> as the text-based merge tool, which is nice, but I don't use kdiff3, I use <a href="http://meldmerge.org/" target="_blank">Meld</a>, another open source visual tool for merges and comparisons.<br /><br /><br />OTOH, <a href="http://www.scootersoftware.com/" rel="nofollow" target="_blank">Beyond Compare</a> is a merge and compare tool made by Scooter Software which provides a very good text based 3-way merge with a 3 sources + 1 result pane, and can compare both files and directories. Two of its killer features is having the ability split differences into important and non-important ones according to the syntax of the compared/merged files, and the ability to easily change or add to the syntax rules in a very user-friendly way. This allows to easily ignore changes in comments, but also basic refactoring such as variable renaming, or other trivial code-wide changes, which allows the developer to focus on the important changes/differences during merges or code reviews.<br /><br />Syntax support for usual file formats like C, Java, shell, Perl etc. is built in (but can be modified, which is a good thing) and new file types with their syntaxes can be added via the GUI from scratch or based on existing rules.<br /><br />I evaluated Beyond Compare at my workplace and we decided it would be a good investment to purchases licenses for it for the people in our department.<br /><br /><br />Having these two software separate is good, but having them integrated with each other would be even better. So I decided I would try to see how it can be done. I installed Beyond compare on my system, too and looked through the examples <br /><br /><br />The first thing I discovered is that the main assumption of Semanticmerge developers was that the application would be called via the SCM when merges are to be done, so passing lots of parameters would not be problem. I realised that when I saw how one of the samples' starting script invoked semantic merge:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace; font-size: x-small;">semanticmergetool -s=$sm_dir/src.java -b=$sm_dir/base.java -d=$sm_dir/dst.java -r=/tmp/semanticmergetoolresult.java -edt="kdiff3 \"#sourcefile\" \"#destinationfile\"" -emt="kdiff3 \"#basefile\" \"#sourcefile\" \"#destinationfile\" --L1 \"#basesymbolic\" --L2 \"#sourcesymbolic\" --L3 \"#destinationsymbolic\" -o \"#output\"" -e2mt="kdiff3 \"#sourcefile\" \"#destinationfile\" -o \"#output\""</span></blockquote>Can you see the problem? It seems Semanticmerge has no persistent knowledge of the user preferences with regards to the text-based merge tool and exports the issue to the SCM, at the price of overcomplicating the command line. I already mentioned this issue in my license request mail and added <a href="http://plasticscm.uservoice.com/forums/196398-mergebegins/suggestions/4371367-external-merge-tool-and-diff-tool-should-be-persis" target="_blank">the issue</a> and my fix suggestion in their voting system of features to be implemented.<br /><br />The upside was that by comparing the command line for kdiff3 invocations, the <a href="http://kdiff3.sourceforge.net/doc/documentation.html#id2488370" target="_blank">kdiff3 documentation</a> and, by comparison, the Beyond Compare SCM <a href="http://www.scootersoftware.com/support.php?zz=kb_vcs" target="_blank">integration information</a>, I could deduce what is the command line necessary for Semanticmerge to use Beyond Compare as an external merge and diff tool.<br /><br />The -edt, -emt and -e2mt options are the ones which specify how the external diff tool, external 3-way merge tool and external 2-way merge tool is to be called. Once I understood that, I split the problem in its obvious parts, each invocation had to be mapped, from kdiff3 options to beyond compare options, adding the occasional bell and whistle, if possible.<br /><br />The parts to figure out, ordered by compexity, were:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"></span><br /><ol><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><li><span style="font-size: x-small;">-edt="kdiff3 \"#sourcefile\" \"#destinationfile\"</span></li><span style="font-size: x-small;"></span><span style="font-size: x-small;"><br /></span><li><span style="font-size: x-small;">-e2mt="kdiff3 \"#sourcefile\" \"#destinationfile\" -o \"#output\""</span></li><span style="font-size: x-small;"></span><span style="font-size: x-small;"><br /></span><li><span style="font-size: x-small;">-emt="kdiff3 \"#basefile\" \"#sourcefile\" \"#destinationfile\" --L1 \"#basesymbolic\" --L2 \"#sourcesymbolic\" --L3 \"#destinationsymbolic\" -o \"#output\""</span></li></span></ol></blockquote><br />Semantic merge integrates with kdiff3 in diff mode via the <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">-edt</span> option. This was easy to map to Beyond Compare, I just replaced kdiff3 with bcompare:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace; font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">-edt="</span>bcompare \"#sourcefile\" \"#destinationfile\"</span><span style="font-family: &quot;Courier New&quot;,Courier,monospace; font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">"</span></span></blockquote>Integration for 2-way merges was also quite easy, the mapping to Beyond Compare was:<br /><blockquote class="tr_bq"><span style="font-size: x-small;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">-e2mt="bcompare \"#sourcefile\" \"#destinationfile\" <span style="font-size: x-small;">-</span>savetarget=\"#output\""</span></span> </blockquote>For the 3-way merge I was a little confused because the Beyond Compare documentation and options were inconsistent between Windows and Linux. On Windows, for some of the SCMs, the options that set the titles for the panes are '/title1', '/title2', '/title3' and '/title4' (way too descriptive for my taste /sarcasm), but for some others are '/lefttitle', '/centertitle', '/righttitle', '/outputtitle', while on Linux the options are the more explicit kind, but with a '-' instead of a '/'.<br /><br />The basic things were easy, ordering the parameters in the 'source, destination, base, output' instead of kdiff3's 'base, source, destination, -o ouptut', so I wanted to add the bells and whistles, since it really makes more sense for the developer to see something like 'Destination: [method] readOptions' instead of '/tmp/tmp4327687242.tmp', and because that's exactly what is necessary for Semanticmerge when merging methods, since on conflicts the various versions of the functions are placed in temporary files which don't mean anything.<br /><br />So, after some digging into the examples from Beyond Compare and kdiff3 documentation, I ended up with:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><span style="font-size: x-small;">-emt="bcompare&nbsp; \"#sourcefile\" \"#destinationfile\" \"#basefile\" \"#output\" -lefttitle='#sourcesymbolic' -righttitle='#destinationsymbolic' -centertitle='#basesymbolic' -outputtitle='merge result'"</span></span></blockquote><br />Sadly, I wasn't able to identify the symbolic name for the output, so I added the hard coded 'merge result'. If Codice people would like to help with with this information (or if it exists), I would be more than willing to do update the information and do the necessary changes.<br /><br />Then I added the bells and whistles for the -edt and -e2mt options, so I ended up with an even more complicated command line. The end result was this monstrosity:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace; font-size: x-small;">semanticmergetool -s=$sm_dir/src.java -b=$sm_dir/base.java -d=$sm_dir/dst.java -r=/tmp/semanticmergetoolresult.java -edt="bcompare \"#sourcefile\" \"#destinationfile\" -lefttitle='#sourcesymbolic' -righttitle='#destinationsymbolic'" -emt="bcompare&nbsp; \"#sourcefile\" \"#destinationfile\" \"#basefile\" \"#output\" -lefttitle='#sourcesymbolic' -righttitle='#destinationsymbolic' -centertitle='#basesymbolic' -outputtitle='merge result'" -e2mt="bcompare \"#sourcefile\" \"#destinationfile\" -savetarget=\"#output\" -lefttitle='#sourcesymbolic' -righttitle='#destinationsymbolic'"</span></blockquote>So when I 3-way merge a function I get something like this (sorry for high resolution, lower resolutions don't do justice to the tools):<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-PeFa5WysZW4/UiO011ZpFKI/AAAAAAAAAas/fvAob4aFFb4/s1600/semanticmerge_beyondcompare2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="212" src="http://3.bp.blogspot.com/-PeFa5WysZW4/UiO011ZpFKI/AAAAAAAAAas/fvAob4aFFb4/s400/semanticmerge_beyondcompare2.png" width="400" /></a></div><br /><br />I don't expect this post to remain relevant for too much time, because after sending my feedback to Codice, they were open to my suggestion to have persistent settings for the external tool integration, so, in the future, the command line could probably be as simple as:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><span style="font-family: &quot;Courier New&quot;,Courier,monospace; font-size: x-small;">semanticmergetool -s=$sm_dir/src.java -b=$sm_dir/base.java -d=$sm_dir/dst.java -r=/tmp/semanticmergetoolresult.java</span></span></blockquote>And the integration could be done via the GUI, while the command line can become a way to override the defaults. <img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/glK2iXUihlQ" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2013/09/integrating-beyond-compare-with.htmltag:blogger.com,1999:blog-1134723925265805427.post-24367345491609854672013-09-01T11:37:00.000+03:002013-09-02T01:44:05.642+03:00HOWTO add a shell script wrapper and preserve quoting for parametersIf you ever find yourself in the situation where you have to add a shell script wrapper over a command, but the parameters' quoting gets lost and you end up with the wrong parameters in the wrapped command/tool, you might want to read this post.<br /><br />On my system I have some command line tools which are Windows only and, in order to easily use the same build system as on Windows on my Linux machine I added a wrapper script which invokes wine on the commands and made symlinks to the wrapper with the file names as the tools, but without the '.exe' suffix.<br /><br />Of course, I wanted to properly pass the parameters through the wrapper to the tools so I wrote (note the bold text):<br /><blockquote><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">#!/bin/sh<br />wine $0.exe <b>"$@"</b></span></blockquote>So the answer is: use $@ and quote like I did in the code above and the parameters will be passed correctly.<br /><br /><hr /><br /><br />Update: stbuehler suggested to use exec to replace the shell process with wine with this construct: <br /><blockquote>Use:</blockquote><blockquote><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">#!/bin/sh</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">exec wine $0.exe "$@"</span></blockquote><br />Thanks for the suggestion. <img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/-hkLPFHcMlY" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com2http://ramblingfoo.blogspot.com/2013/09/howto-add-shell-script-wrapper-and.htmltag:blogger.com,1999:blog-1134723925265805427.post-39267371823966293522013-07-24T18:02:00.002+03:002013-07-24T18:02:51.225+03:00HOWTO: git - change branch without touching working copy (at all)Did you ever had the need in a git repository to change to another branch without altering AT ALL the working copy and ever wondered how that's done?<br /><br />Usual use cases might be when you mde some changes to the working copy thinking you were on another branch, or you double-track in git a directory which is also tracked by another VCS (e.g. ClearCase).<br /><br />What you need, in fact, is to update the index and not touch the working copy. The command that does that is<br /><br /><blockquote class="tr_bq"><b><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git read-tree otherbranch</span></b></blockquote>If you also need to commit the state of your working tree to the otherbranch, you also need to tell git to actually associate the curent HEAD with the branch you just switched to:<br /><blockquote class="tr_bq"><b><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git symbolic-ref HEAD refs/heads/otherbranch</span></b></blockquote>I use this approach at my work place* to develop/experiment with possible code improvements on my machine before considering the merge into the official code.<br /><br /><span style="font-size: x-small;">* The preferred VCS is (Base) ClearCase, and I keep a git repository over the relevant part of the project in the ClerCase Dynamic View, so for synchronisations, the files in the working copy are updated by ClearCase and I have to resync my git branch (clearcaseint) following the latest official code from time to time, so I can pull in my local disk git repository the clearcaseint branch and merge it with my experimental changes in my git feature branches.&nbsp;</span><br /><br /><span style="font-size: x-small;">If people are curious about how I work with ClearCase and git, I can expand on this in another post. </span><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/LwUlzHhHxzw" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com1http://ramblingfoo.blogspot.com/2013/07/howto-git-change-branch-without.htmltag:blogger.com,1999:blog-1134723925265805427.post-45985804217355797722013-07-20T23:05:00.002+03:002013-07-20T23:26:46.419+03:00(Not a) GNU Make quirk, or why logs should be providedAbout two months ago I was <a href="http://ramblingfoo.blogspot.ro/2013/05/gnu-make-quirk.html" target="_blank">writing about a quirk I found in GNU Make</a> related to the $(patsubst ) function.<br /><br />I have just tried this on my Debian Wheezy laptop which has make 3.81, but I wasn't able to reproduce the issue with the version from Debian (3.81-8.2).<br /><br />The makefile looks like this:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">PATH := ../some/prefixCPU12suf/include<br />CPUINC := $(patsubst ../some/prefix%,%,$(PATH))<br />CPU := $(patsubst %/include,%,$(CPUINC))<br /><br />default:<br />&nbsp;&nbsp;&nbsp; @echo "PATH&nbsp;&nbsp; = $(PATH)"<br />&nbsp;&nbsp;&nbsp; @echo "CPUINC = $(CPUINC)"<br />&nbsp;&nbsp;&nbsp; @echo "CPU&nbsp;&nbsp;&nbsp; = $(CPU)"</span></blockquote>And the result was correct:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">0 eddy@heidi /tmp $ make<br />PATH&nbsp;&nbsp; = ../some/prefixCPU12/include<br />CPUINC = CPU12/include<br />CPU&nbsp;&nbsp;&nbsp; = CPU12<br />0 eddy@heidi /tmp $ make --version<br />GNU Make 3.81<br />Copyright (C) 2006&nbsp; Free Software Foundation, Inc.<br />This is free software; see the source for copying conditions.<br />There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A<br />PARTICULAR PURPOSE.<br /><br />This program built for x86_64-pc-linux-gnu</span></blockquote><span style="font-family: inherit;">The worst part is that I know I tested this issue on 3.82 on Cygwin and on Linux with the 3.82 version and it failed, but I wasn't able to remember how I did it. I started searching through the directory where I knew there could be the test makefile, I wasn't able to find it, until I remembered what I was trying to achieve.</span><br /><br /><span style="font-family: inherit;">From a path like <span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><b><i>../</i></b><b><i>some/prefixCPU12suf/include</i></b></span> I wanted to use % to remove the parts '<i><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><b>some/prefix</b></span>' and '<span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><b>suf/include</b></span>'</i> because in the directory <span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><i><b>../CPU12</b></i></span> there were some files that needed to be processed.</span><br /><span style="font-family: inherit;"><br /></span><span style="font-family: inherit;">The actual issue is that GNU Make's '%' is not analogous to shell's '*', so that means code like this does not work as I assumed anf the 'pref' part is not an anchor:</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><br /></span><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">PATH := ../some/prefCPU12suf/include<br />CPUINC := $(patsubst pref%,%,$(PATH))<br />CPU := $(patsubst %suf/include,%,$(CPUINC))<br /><br />default:<br />&nbsp;&nbsp;&nbsp; @echo "PATH&nbsp;&nbsp; = $(PATH)"<br />&nbsp;&nbsp;&nbsp; @echo "CPUINC = $(CPUINC)"<br />&nbsp;&nbsp;&nbsp; @echo "CPU&nbsp;&nbsp;&nbsp; = $(CPU)"</span></blockquote>Which leads to these results, no matter the version:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">0 eddy@heidi ~/usr/src/make/make-profiler/make-3.82 $ ./make -f /tmp/makefile <br />PATH&nbsp;&nbsp; = ../some/prefCPU12suf/include<br />CPUINC = ../some/prefCPU12suf/include<br />CPU&nbsp;&nbsp;&nbsp; = ../some/prefCPU12<br />0 eddy@heidi ~/usr/src/make/make-profiler/make-3.82 $ ./make --version <br />GNU Make 3.82<br />Built for x86_64-unknown-linux-gnu<br />Copyright (C) 2010&nbsp; Free Software Foundation, Inc.<br />License GPLv3+: GNU GPL version 3 or later <http: gnu.org="" gpl.html="" licenses=""><br />This is free software: you are free to change and redistribute it.<br />There is NO WARRANTY, to the extent permitted by law.<br />0 eddy@heidi ~/usr/src/make/make-profiler/make-3.82 $ make -f /tmp/makefile <br />PATH&nbsp;&nbsp; = ../some/prefCPU12suf/include<br />CPUINC = ../some/prefCPU12suf/include<br />CPU&nbsp;&nbsp;&nbsp; = ../some/prefCPU12<br />0 eddy@heidi ~/usr/src/make/make-profiler/make-3.82 $ make --version <br />GNU Make 3.81<br />Copyright (C) 2006&nbsp; Free Software Foundation, Inc.<br />This is free software; see the source for copying conditions.<br />There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A<br />PARTICULAR PURPOSE.<br /><br />This program built for x86_64-pc-linux-gnu</http:></span></blockquote>Not sure if this could be qualified as a true bug, or a if the way I expected is a nice to have feature, but, in any case, the behaviour is consistent, unlike my brain which failed to initially identify the inconsistency in my code:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">0 eddy@heidi ~/usr/src/make/make-profiler/make-3.82 $ grep patsubst /tmp/makefile <br />CPUINC := $(patsubst pref%,%,$(PATH))<br />CPU := $(patsubst %suf,%,$(CPUINC))<br />0 eddy@heidi ~/usr/src/make/make-profiler/make-3.82 $ make -f /tmp/makefile <br />PATH&nbsp;&nbsp; = ../some/prefCPU12suf/include<br />CPUINC = ../some/prefCPU12suf/include<br />CPU&nbsp;&nbsp;&nbsp; = ../some/prefCPU12suf/include</span></blockquote>Note that this behaviour of patsubst is asymtric to how subst works, as explained in the <a href="http://ramblingfoo.blogspot.com/2013/05/gnu-make-quirk.html" target="_blank">updated old post</a>.<br /><br />This took some extra effort to remember what was the actual issue, and shows why logs are important when reporting an issue, and why reporting issues as soon as they were encountered: because human brains are faulty. (Yes, yours, too!)<br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><br /></span><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/WjCpZFtUlFM" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2013/07/not-gnu-make-quirk-or-why-logs-should.htmltag:blogger.com,1999:blog-1134723925265805427.post-49643560794063400082013-07-18T01:00:00.001+03:002013-07-24T11:38:30.642+03:00HOWTO: git - remove those pesky remotes/origin/Often people create branches to fix various bugs or implement various features, and publish those to a public repository to be pulled in the official repository (e.g. pull requests in the github model).<br /><br />The problem is that after the fix is merged the local repo still has the branch that tracks the origin (your public repository).<br /><br />To remove the local branch it is simple:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git branch -d feature_x</span></blockquote><br />To remove the actual branch in the remote repository:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git push origin --delete feature_x</span></blockquote><br />But, still the local tracking branches remain, those pesky '<span style="font-family: &quot;Courier New&quot;,Courier,monospace;">remotes/origin/feature_x</span>'. Here is an example from one of my repos:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">$ git branch -a</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; activestate</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; master</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; next</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">* py.test</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; sysplatformtest</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/activestate/master</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/HEAD -&gt; origin/master</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/appauthor-fallback</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/linux-fixes</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/master</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/next</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/py.test</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/root-directories</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/sysplatformtest</span><br /><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp; remotes/origin/wrapper-defaults</span></blockquote><br />All of those can be removed with this command:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git remote prune origin</span></blockquote><br />&nbsp;And the output for my appdirs repository is:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">Pruning origin<br />URL: git@github.com:eddyp/appdirs.git<br />&nbsp;* [pruned] origin/appauthor-fallback<br />&nbsp;* [pruned] origin/linux-fixes<br />&nbsp;* [pruned] origin/next<br />&nbsp;* [pruned] origin/root-directories<br />&nbsp;* [pruned] origin/sysplatformtest<br />&nbsp;* [pruned] origin/wrapper-defaults</span></blockquote>Which, finally removes those damned refs:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">$ git branch -a <br />&nbsp; activestate<br />* master<br />&nbsp; py.test<br />&nbsp; remotes/activestate/master<br />&nbsp; remotes/origin/HEAD -&gt; origin/master<br />&nbsp; remotes/origin/master<br />&nbsp; remotes/origin/py.test</span> </blockquote>Great!<br /><br />Update 2013-07-24:&nbsp; There have been also other solutions proposed in the comments section. I am quoting them here for better visibility.<br /><br />Besides the solution I proposed, people commented about other alternatives for pruning remote branches, by using <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git fetch --prune<span style="font-family: inherit;"> or </span></span><span style="font-family: &quot;Courier New&quot;,Courier,monospace;"><span style="font-family: inherit;">by using <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git-push</span>'s <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">--prune</span> option.</span></span><br /><br />Brice provided a method to remove specific branches one by one with <span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git branch -dr</span> command:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">git branch -dr origin/foo</span></blockquote>What is ironic is that in the past I have used this format, and before writing the original article I was looking for this, but haven't found it that easily. I hope this article will help some other poor soul or myself in the future. <img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/x3er52L7NmU" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com4http://ramblingfoo.blogspot.com/2013/07/howto-git-remove-those-pesky.htmltag:blogger.com,1999:blog-1134723925265805427.post-54533366826487608632013-07-17T09:36:00.001+03:002013-07-17T09:36:58.123+03:00Interesting talk on the scalability of git<div xmlns='http://www.w3.org/1999/xhtml'><a href='http://vimeo.com/m/64716825'>http://vimeo.com/m/64716825</a></div><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/bF4VdTouX6g" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2013/07/interesting-talk-on-scalability-of-git.htmltag:blogger.com,1999:blog-1134723925265805427.post-48521485574085127452013-05-29T00:15:00.001+03:002013-07-20T23:24:47.434+03:00GNU Make quirk<div xmlns="http://www.w3.org/1999/xhtml"><i>(Updated 2013-07-20: Correctly describe the issue and provide examples)</i><br /><br />Make has several useful built-in functions, among which <b>$(patsubst <i>pattern</i>,<i>replacer</i>,<i>string</i>)</b>. The <i>pattern</i> can contain the character % which is a wildcard meaning any string and that can be referred in the <i>replacer</i> parameter. Only the first occurrence of % is treated with this special meaning, just as the <a href="http://www.gnu.org/software/make/manual/make.html#Text-Functions">manual says</a>.<br /><br />What the manual doesn't say is that <strike>only the form <i>%bla</i> works, while <b>the form <i>bla%</i> does NOT work</b></strike> GNU Make's '%' is not analogous to shell's '*', so you can't expect to remove substrings in the middle of a string without knowing the exact string until the part you want to remove.<br /><br />This does not work if you want to obtain '<i>../some/CPU12/include</i>' in OTHERPATH:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">PATH := ../some/prefCPU12/include<br />OTHERPATH := $(patsubst pref%,%,$(PATH))<br /><br />default:<br />&nbsp;&nbsp;&nbsp; @echo "OTHERPATH = $(OTHERPATH)</span></blockquote>The result will be:<br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">&nbsp;OTHERPATH = ../some/prefCPU12/include</span></blockquote>This bahaviour is somewhat asymetric to how subst behaves and how one would expect it to, considering '%' is explained as a glob pattern:<br /><br /><blockquote class="tr_bq"><span style="font-family: &quot;Courier New&quot;,Courier,monospace;">0 eddy@heidi /tmp $ cat makefile <br />PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; := ../some/prefCPU12/include<br />OTHERPATH := $(patsubst pref%,%,$(PATH))<br />SPATH&nbsp;&nbsp;&nbsp;&nbsp; := $(subst pref,,$(PATH))<br /><br />default:<br />&nbsp;&nbsp;&nbsp; @echo "PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = $(PATH)"<br />&nbsp;&nbsp;&nbsp; @echo "OTHERPATH = $(OTHERPATH)"<br />&nbsp;&nbsp;&nbsp; @echo "SPATH&nbsp;&nbsp;&nbsp;&nbsp; = $(SPATH)"<br />0 eddy@heidi /tmp $ make<br />PATH&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = ../some/prefCPU12/include<br />OTHERPATH = ../some/prefCPU12/include<br />SPATH&nbsp;&nbsp;&nbsp;&nbsp; = ../some/CPU12/include</span></blockquote>Not sure what make developers would say about this, and I am not sure if having % work as a glob pattern and using it, instead of invoking sed would be better for performance, but sure I would like to have the option :-) .</div><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/X51eAw4wkaw" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com4http://ramblingfoo.blogspot.com/2013/05/gnu-make-quirk.htmltag:blogger.com,1999:blog-1134723925265805427.post-86975220227345968712013-03-28T02:00:00.001+02:002013-03-28T17:12:37.595+02:00The sorry state of the Android universe<div xmlns="http://www.w3.org/1999/xhtml"><br />Update: Corrected the code name for 4.2.2 is Jelly Bean, not Ice Cream Sandwich as I initially stated. I also described in the comments why the calendar application is also crap.<br /><br />I recently bought a phone based on the Android platform (version 4.2.2 aka Jelly Bean). Before the purchase I had the wrong idea that this platform - Android - is the best thing since sliced bread. Let me tell you, that idea is so wrong, it's a shame anybody thinks or has ever thought that.<br /><br />My previous phone was a Nokia E71 and with its stock set of applications and in spite of its old and rusty Symbian OS, I still have a hard time to even match the basic functionalities on the Android phone even using the most praised apps from the Play Store.<br /><br />The dialer is crap, there is no decent speed dialer, the focus is on the apps instead of the phone functionality, the homescreen-type-to-search-in-contacts functionality of E71 is probably impossible due to the retarded decision to forget you're using a phone, notifications, even important ones, are hidden, to the point that the ones needing attention can be missed (e.g. entering the PIN/confirmation for Bluetooth pairing must be searched for in the notification area), when looking in the agenda there is no straight one step to edit a contact, you must jump to another application and do the edit there, treating SMS conversations as one to one instant messages works until you want to reply to multiple people at once.<br /><br />Volume for ringing, SMS notification <b>and</b> the headset are controlled all together, so if during the last conversation you turned down the volume because it was too loud, you can miss a call because our will ring at a lower volume.<br /><br />And these are only broken things in the basic functionality (for a post 2008 cell phone).<br /><br />Android phones are smart phones, so more advanced features are required: playing audio and video files, GPS related applications, podcasting support, email handling and web browsing are among the features that can be expected on such a phone.<br /><br />Only web related functionality and simple media playing are at a reasonable level compared with my old E71, maybe due to Google being web oriented and the new phones having better screens than the old Nokia.<br /><br />But I am an avid podcast listener, so I've been searching for an application that can match Nokia's Podcasts stock application, and I've come to the conclusion Android users which love podcasts either have to wait for Nokia to develop on Android (which seems unlikely) or find one or two talented developers to create a decent application.<br /><br />I don't understand how can such an application not have a playlist with the downloaded episodes, not have download all new episodes or mark all/selected as listened. I have found applications that have at least one of these issues and have an average of over 4 out of 5 stars in Google Play. Poor users!<br /><br />In the light of these issues, I'm having so much difficulty coming up with an excuse for Nokia losing its position as a market leader, but our seems technical superiority is not necessary or enough to dominate the mobile phone market. Sadly, that says a lot about our species, and the words aren't nice.</div><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/VxOlj6bitgk" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com19http://ramblingfoo.blogspot.com/2013/03/the-sorry-state-of-android-universe.htmltag:blogger.com,1999:blog-1134723925265805427.post-64840162523799588252013-03-22T00:30:00.001+02:002013-03-22T00:34:00.737+02:00Finally the XDG fixes are in appdirs<div xmlns="http://www.w3.org/1999/xhtml">Just a few hours ago my XDG fixes landed in the master branch of ActiveState appdirs.<br /><br /><a href="https://github.com/ActiveState/appdirs/pull/17">https://github.com/ActiveState/appdirs/pull/17</a><br /><br />They will be part of version 1.3.0, but the maintainers want first to create some tests, since the test frame was just rewritten recently.</div><img src="http://feeds.feedburner.com/~r/RamblingFoo/~4/MyWxcfc4cCg" height="1" width="1" alt=""/>eddyphttp://www.blogger.com/profile/13986125106284142716noreply@blogger.com0http://ramblingfoo.blogspot.com/2013/03/finally-xdg-fixes-are-in-appdirs.html