Fxxk U, Blog.com – moved to WordPress.com

I have been suffered enough…from Blog.com! As a paid customer, my blog has been keeping down and down for days and there is no response from their support team. After recent 3-day down, I find my recent post is lost! So finally, Blog.com is beginning to get rid of customer’s post to get their overloaded server up again! Ridiculous? No, that is the truth. I spent the whole morning to export my blog from Blog.com and import it into WordPress.com. I have also paid $99 to promote my account there. Hope everything goes well then.

From now on, http://davejingtian.org is my new home and I will never ever update http://daveti.blog.com

K.R.K.C

-daveti

Posted in Uncategorized | Leave a comment

Build official Debian linux kernel

Comparing with ‘normal’ Linux kernel build, the ‘official’ Linux kernel build for each distribution is confusing and awkward. Debian 7.1 Wheezy may be friendly but still needs cautions. The good thing is you do not need to patch the original kernel with the Debian patches yourself. Have fun!

1. Get the official Debian kernel source pkg

apt-get source linux

This cmd will download the corresponding Debian kernel source pkg based on your current `uname -r`. After download the pkg, Debian pkg management will install the pkg into /usr/src. Moreover, the Debian patches would be patched automatically, which may be the best thing for official kernel build!

debian:/usr/src# apt-get source linux
Reading package lists… Done
Building dependency tree
Reading state information… Done
NOTICE: ‘linux’ packaging is maintained in the ‘Svn’ version control system at:
svn://svn.debian.org/svn/kernel/dists/trunk/linux/
Need to get 69.2 MB of source archives.
Get:1 http://ftp.debian.org/debian/ wheezy/main linux 3.2.46-1 (dsc) [103 kB]
Get:2 http://ftp.debian.org/debian/ wheezy/main linux 3.2.46-1 (tar) [65.9 MB]
Get:3 http://ftp.debian.org/debian/ wheezy/main linux 3.2.46-1 (diff) [3,225 kB]
Fetched 69.2 MB in 6min 36s (175 kB/s)
gpgv: keyblock resource `/root/.gnupg/trustedkeys.gpg’: file open error
gpgv: Signature made Sat 08 Jun 2013 05:56:06 PM PDT using RSA key ID 95861109
gpgv: Can’t check signature: public key not found
dpkg-source: warning: failed to verify signature on ./linux_3.2.46-1.dsc
dpkg-source: info: extracting linux in linux-3.2.46
dpkg-source: info: unpacking linux_3.2.46.orig.tar.xz
dpkg-source: info: unpacking linux_3.2.46-1.debian.tar.xz
dpkg-source: info: applying debian/version.patch
dpkg-source: info: applying debian/kernelvariables.patch
dpkg-source: info: applying bugfix/all/kbuild-Fix-missing-n-for-NEW-symbols-in-yes-make-old.patch
dpkg-source: info: applying bugfix/x86/viafb-autoload-on-olpc-xo1.5-only.patch
dpkg-source: info: applying bugfix/all/cifs-fix-potential-buffer-overrun-when-composing-a-new-options.patch
debian:/usr/src#

debian:/usr/src# ll
total 67588
drwxr-xr-x 24 root root     4096 Jul 28 11:28 linux-3.2.46
-rw-r–r–  1 root root  3224676 Jun  8 18:56 linux_3.2.46-1.debian.tar.xz
-rw-r–r–  1 root root   103051 Jun  8 18:56 linux_3.2.46-1.dsc
-rw-r–r–  1 root root 65871748 Jun  8 18:56 linux_3.2.46.orig.tar.xz
debian:/usr/src#

2. Before you start the build, make sure you have some tools installed besides the ones needed by the ‘normal’ Linux kernel build…

apt-get install debhelper
apt-get install gcc-4.6
apt-get install xmlto
apt-get install filterdiff

3. Choose the arch for your machine and trigger the build only for that arch – to save time and storage!

fakeroot make -f debian/rules.gen setup_i386_none_686-pae
cd /usr/src/linux-3.2.46/debian/build/build_i386_none_686-pae
make menuconfig
cd ../../..
fakeroot make -f debian/rules.gen binary-arch_i386_none_686-pae binary-indep \
DEBIAN_KERNEL_JOBS=${NR_CPUS}

debian:/usr/src# ll
total 349864
drwxr-xr-x 24 root root      4096 Jul 28 20:36 linux-3.2.46
-rw-r–r–  1 root root   3224676 Jun  8 18:56 linux_3.2.46-1.debian.tar.xz
-rw-r–r–  1 root root    103051 Jun  8 18:56 linux_3.2.46-1.dsc
-rw-r–r–  1 root root  65871748 Jun  8 18:56 linux_3.2.46.orig.tar.xz
-rw-r–r–  1 root root   6383274 Jul 29 11:50 linux-doc-3.2_3.2.46-1_all.deb
-rw-r–r–  1 root root    597596 Jul 29 11:00 linux-headers-3.2.0-4-686-pae_3.2.46-1_i386.deb
-rw-r–r–  1 root root  22920680 Jul 29 10:44 linux-image-3.2.0-4-686-pae_3.2.46-1_i386.deb
-rw-r–r–  1 root root 255994142 Jul 29 11:00 linux-image-3.2.0-4-686-pae-dbg_3.2.46-1_i386.deb
-rw-r–r–  1 root root   2942958 Jul 29 11:51 linux-manual-3.2_3.2.46-1_all.deb
-rw-r–r–  1 root root    200430 Jul 29 11:00 xen-linux-system-3.2.0-4-686-pae_3.2.46-1_i386.deb
debian:/usr/src#

4. Install the new kernel image and reboot the machine

dpkg -i linux-image-3.2.0-4-686-pae_3.2.46-1_i386.deb

debian:/usr/src# dpkg -i linux-image-3.2.0-4-686-pae_3.2.46-1_i386.deb
(Reading database … 184013 files and directories currently installed.)
Preparing to replace linux-image-3.2.0-4-686-pae 3.2.46-1 (using linux-image-3.2.0-4-686-pae_3.2.46-1_i386.deb) …
Unpacking replacement linux-image-3.2.0-4-686-pae …
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
Setting up linux-image-3.2.0-4-686-pae (3.2.46-1) …
Running depmod.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
update-initramfs: Generating /boot/initrd.img-3.2.0-4-686-pae
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-4-686-pae /boot/vmlinuz-3.2.0-4-686-pae
Generating grub.cfg …
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-3.2.0-4-686-pae
Found initrd image: /boot/initrd.img-3.2.0-4-686-pae
done
debian:/usr/src#

5. Trigger new build with certain code changes by deleting the build timestamp

rm debian/stamps/build_i386_none_686-pae_plain

6. Reference

https://wiki.debian.org/HowToRebuildAnOfficialDebianKernelPackage

Posted in OS | Tagged , , , , , | 1 Comment

fsl – Fedora Security Lab

fsl (Fedora Security Lab) is a customized Fedora OS for security hack/test based Fedora 19. Like the famous BackTrace Linux, fsl has integrated a butch of security tools. To take the advantage of fsl, either security liveCD or all the security pkgs included in fsl is needed. For the later solution, a shell script – fsli (Fedora Security Lab Install) is written to ease the tedious job.

1. LiveCD

http://spins.fedoraproject.org/security/#downloads

2. yum (Fedora 19)

yum groupinstall security-lab

3. ansible (Fedora <19)

yum install ansible
wget https://git.fedorahosted.org/cgit/security-spin.git/plain/ansible-playbooks/fsl-packages.yml
ansible-playbook fsl-packages.yml -f 10

NOTE: hosts file may needs to configure…

4. fsli.sh (Fedora Any)

#!/bin/sh
# Fedora Security Lab Install
# daveti@cs.uoregon.edu
# http://daveti.blog.com
# Jul 19, 2013

# Clear the old one
FSLFILE=”availableApps?format=txt”
rm -rf “$FSLFILE” 2>&1 > /dev/null

# Get the txt file for fsl
FSLLINK=”https://fedorahosted.org/security-spin/wiki/availableApps?format=txt”
wget “$FSLLINK”
if [ ! -f "$FSLFILE" ]
then
        echo “fsl pkg file does not exists!”
        exit 1
fi

# Get the package name
while read line
do
        #echo “$line”
        STARTSYMBOL=`echo “$line” | cut -d” ” -f1 | tr -d ” “`
        #echo “$STARTSYMBOL”
        if [ "$STARTSYMBOL" == "*" ]
        then
                #echo “$STARTSYMBOL”
                PKGNAME=`echo “$line” | cut -d” ” -f3 | tr -d ” “`
                PKGNAME=`echo “$PKGNAME” | cut -d”]” -f1 | tr -d ” “`
                echo “$PKGNAME:”
                # Install the pkg
                yum -y install “$PKGNAME”
        fi
done < “$FSLFILE”

Posted in Dave's Tools, OS, Security | Tagged , , , , , | Leave a comment

Android 4.0 for x86 – Install Android 4.0 using KVM in your Linux

Thanks to the project Android-x86, now Android 4.0 is able to run in our PC stably. Just installed Android 4.0 in my Fedora 18 Linux using KVM – it is stable and cool! This post shares some key points for running Android in KVM. Have fun!

0. Android_x86

http://www.android-x86.org/

1. Get the ROM

http://code.google.com/p/android-x86/downloads/list
http://code.google.com/p/android-x86/downloads/detail?name=android-x86-4.2-20130228.iso&can=2&q=

2. KVM install for Ubuntu (works great for Fedora)

http://www.upubuntu.com/2012/03/how-to-install-android-x86-40-using.html

3. Hints

a. Choose the format of your virtual disk to be ‘raw’ instead of others.
b. Give the memory for your Android at least 2GB to accelerate the speed.

Posted in OS | Tagged , , , , | Leave a comment

relay – linux kernel relay filesystem

Relay (Relay filesystem) is a mechanisim used to transfer the data from the kernel space to the user space within the Linux OS. The advantage of relay comparing with other means like debugfs or proc is its ability to handle the big data efficiently. This post will show an example of relay using kernel 3.9.6. May it help.

1. relay

http://relayfs.sourceforge.net/

2. kernel doc for relay

https://www.kernel.org/doc/Documentation/filesystems/relay.txt

3. relayArp

relayArp.c under km is the kernel module used to pop up 2 ARP msgs from the kernel space to the user space; relayArp_us.c under us is the user-space programe used to read and decode the 2 ARP msgs from the kernel. All the code could be found in github below. Only key points and running results are listed here for the reference.

/*
 * create_buf_file() callback.  Creates relay file in debugfs.
 */
static struct dentry *create_buf_file_handler(const char *filename,
                                              struct dentry *parent,
                                              int mode,
                                              struct rchan_buf *buf,
                                              int *is_global)
{
        return debugfs_create_file(filename, mode, parent, buf,
                                   &relay_file_operations);
}

/*
 * remove_buf_file() callback.  Removes relay file from debugfs.
 */
static int remove_buf_file_handler(struct dentry *dentry)
{
        debugfs_remove(dentry);

        return 0;
}

/*
 * relay interface callbacks
 */
static struct rchan_callbacks relay_callbacks =
{
        .create_buf_file = create_buf_file_handler,
        .remove_buf_file = remove_buf_file_handler,
};

—————————————————————-

  /* Open the channel */
        global_rchan = relay_open(“cpu_arp”, NULL, 8192, 2, &relay_callbacks, NULL);
        if (global_rchan == NULL)
        {
                printk(KERN_ERR “relay_open failure\n”);
                return -ENOMEM;
        }

        /* Write to the channel – no return value for relay_write */
        relay_write(global_rchan, &arp_msg, sizeof(arp_msg));

[root@daveti debug]# pwd
/sys/kernel/debug
[root@daveti debug]# ll
total 0
drwxr-xr-x.  2 root root 0 Jun 28 09:42 acpi
drwxr-xr-x. 19 root root 0 Jun 28 09:42 bdi
drwxr-xr-x.  2 root root 0 Jun 28 09:42 bluetooth
drwxr-xr-x.  3 root root 0 Jun 28 09:42 boot_params
drwxr-xr-x.  2 root root 0 Jun 28 09:42 cleancache
-r——–.  1 root root 0 Jun 28 10:41 cpu_arp0
-r——–.  1 root root 0 Jun 28 10:41 cpu_arp1
-r——–.  1 root root 0 Jun 28 10:41 cpu_arp2
-r——–.  1 root root 0 Jun 28 10:41 cpu_arp3
drwxr-xr-x.  2 root root 0 Jun 28 09:42 cxgb4
drwxr-xr-x.  4 root root 0 Jun 28 09:42 dri
drwxr-xr-x.  2 root root 0 Jun 28 09:42 dynamic_debug
drwxr-xr-x.  2 root root 0 Jun 28 09:42 extfrag
drwxr-xr-x.  2 root root 0 Jun 28 09:42 frontswap
drwxr-xr-x.  4 root root 0 Jun 28 09:42 hid
drwxr-xr-x.  2 root root 0 Jun 28 09:42 kprobes
drwxr-xr-x.  2 root root 0 Jun 28 09:42 kvm
drwxr-xr-x.  2 root root 0 Jun 28 09:42 mce
drwxr-xr-x.  2 root root 0 Jun 28 09:42 regmap
-rw-r–r–.  1 root root 0 Jun 28 09:42 sched_features
-r–r–r–.  1 root root 0 Jun 28 09:42 suspend_stats
drwxr-xr-x.  6 root root 0 Jun 28 09:42 tracing
drwxr-xr-x.  4 root root 0 Jun 28 09:42 usb
drwxr-xr-x.  2 root root 0 Jun 28 09:42 virtio-ports
-r–r–r–.  1 root root 0 Jun 28 09:42 wakeup_sources
drwxr-xr-x.  2 root root 0 Jun 28 09:42 x86
drwxr-xr-x.  3 root root 0 Jun 28 09:42 xen
[root@daveti debug]# cat cpu_arp0
[root@daveti debug]# cat cpu_arp1
[root@daveti debug]# cat cpu_arp2
€Id
H

€Id
HIx!!#

[root@daveti debug]# cat cpu_arp3
[root@daveti us]# ./relayArp_us
ptr[0] = 0×0
ptr[1] = 0×1
ptr[2] = 0×80
ptr[3] = 0×0
ptr[4] = 0×6
ptr[5] = 0×4
ptr[6] = 0×0
ptr[7] = 0×1
ptr[8] = 0×49
ptr[9] = 0×72
ptr[10] = 0×16
ptr[11] = 0×8
ptr[12] = 0×64
ptr[13] = 0×14
ptr[14] = 0×81
ptr[15] = 0×19
ptr[16] = 0xa
ptr[17] = 0×48
ptr[18] = 0×0
ptr[19] = 0×0
ptr[20] = 0×0
ptr[21] = 0×0
ptr[22] = 0×0
ptr[23] = 0×0
ptr[24] = 0×81
ptr[25] = 0×19
ptr[26] = 0xa
ptr[27] = 0xb
ptr[0] = 0×0
ptr[1] = 0×1
ptr[2] = 0×80
ptr[3] = 0×0
ptr[4] = 0×6
ptr[5] = 0×4
ptr[6] = 0×0
ptr[7] = 0×2
ptr[8] = 0×49
ptr[9] = 0×72
ptr[10] = 0×16
ptr[11] = 0×8
ptr[12] = 0×64
ptr[13] = 0×14
ptr[14] = 0×81
ptr[15] = 0×19
ptr[16] = 0xa
ptr[17] = 0×48
ptr[18] = 0×49
ptr[19] = 0×78
ptr[20] = 0×21
ptr[21] = 0×21
ptr[22] = 0×23
ptr[23] = 0×90
ptr[24] = 0×81
ptr[25] = 0×19
ptr[26] = 0xa
ptr[27] = 0xb
[root@daveti us]# ./relayArp_us
open failure for file /sys/kernel/debug/cpu_arp0: No such file or directory
open failure for file /sys/kernel/debug/cpu_arp1: No such file or directory
open failure for file /sys/kernel/debug/cpu_arp2: No such file or directory
open failure for file /sys/kernel/debug/cpu_arp3: No such file or directory
[root@daveti us]#

Project Name: relayArp
Destination: Linux kernel relay example with ARP msg
Language: C
IDE: Vim
Library:
Project Web: https://github.com/daveti/relayArp
Git Read Only: https://github.com/daveti/relayArp.git

Posted in OS, Programming | Tagged , , , , | Leave a comment

darp – how to write your own arp command

For certain reasons, I need to refer to the source files of arp cmd. However, been searching on the net for long time and ended up with no luck. Actually, there is a SRPM mirror for Fedora 18, where you are supposed to find all the source RPMs for all the cmds included in Fedora 18 (but still, no arp). The good thing is I find sth useful from BusyBox, which is an open-source and lightweighted implementation for embedded Linux. Based on that, darp is written. May it help.

1. SRPMs for Fedora 18 (UO mirror)

http://mirror.uoregon.edu/fedora/linux/releases/18/Fedora/source/SRPMS/

2. BusyBox

http://busybox.net/

3. darp

The behavior of darp and arp is similar. Eventually, that was the intention!
darp -a: read “/proce/net/arp” and print the info to the stdout
darp -d: ioctl(SIOCDARP) to delete an entry within the ARP cache
darp -g: ioctl(SIOCGARP) to get an entry within the ARP cache
darp -s: ioctl(SIOCSARP) to set/add an entry into the ARP cache

[daveti@daveti darp]$ ./darp -h
darp -a:
display all the entries within the ARP cache
darp -v:
enable/disable verbose mode
darp -i <interface>:
change the default name of network interface
darp -d <IP>:
remove the entry with this IP address
darp -g <IP>:
get the entry with this IP address
darp -s <IP> <MAC>:
add an entry into the ARP cache with this IP and MAC addresses
darp -h:
display the usage menu
[daveti@daveti darp]$

[root@daveti darp]# ./darp -a
vl-198-gw.uoregon.edu (184.171.60.1) at 00:00:5e:00:01:01 [ether] on em1
dyn-184-171-61-38.uoregon.edu (184.171.61.38) at ec:1a:59:8a:57:96 [ether] on em1
vl-198.uonet3-gw.uoregon.edu (184.171.60.2) at 00:d0:01:7a:28:00 [ether] on em1
[root@daveti darp]# ./darp -g 184.171.61.38
MAC: ec:1a:59:8a:57:96
[root@daveti darp]# ./darp -s 255.255.255.255 00:ff:00:ff:00:ff
[root@daveti darp]# ./darp -a
vl-198-gw.uoregon.edu (184.171.60.1) at 00:00:5e:00:01:01 [ether] on em1
dyn-184-171-61-38.uoregon.edu (184.171.61.38) at ec:1a:59:8a:57:96 [ether] on em1
vl-198.uonet3-gw.uoregon.edu (184.171.60.2) at 00:d0:01:7a:28:00 [ether] on em1
255.255.255.255 (255.255.255.255) at 00:ff:00:ff:00:ff [ether] on em1
[root@daveti darp]# ./darp -d 255.255.255.255
[root@daveti darp]# ./darp -a
vl-198-gw.uoregon.edu (184.171.60.1) at 00:00:5e:00:01:01 [ether] on em1
dyn-184-171-61-38.uoregon.edu (184.171.61.38) at ec:1a:59:8a:57:96 [ether] on em1
vl-198.uonet3-gw.uoregon.edu (184.171.60.2) at 00:d0:01:7a:28:00 [ether] on em1
255.255.255.255 (255.255.255.255) at <incomplete> on em1
[root@daveti darp]# arp -a
vl-198-gw.uoregon.edu (184.171.60.1) at 00:00:5e:00:01:01 [ether] on em1
dyn-184-171-61-38.uoregon.edu (184.171.61.38) at ec:1a:59:8a:57:96 [ether] on em1
vl-198.uonet3-gw.uoregon.edu (184.171.60.2) at 00:d0:01:7a:28:00 [ether] on em1
? (255.255.255.255) at <incomplete> on em1
[root@daveti darp]#

Project Name: darp
Destination: Dave’s ARP command
Language: C
IDE: Vim
Library:
Project Web: https://github.com/daveti/darp
Git Read Only: https://github.com/daveti/darp.git

Posted in Dave's Tools | Tagged , , | Leave a comment

pyCluster – Python Clustering

pyCluster is a Python implementation for clustering algorithms, including PAM and Clara. Enjoy!

1. PAM

kMedoids – PAM implementation
See more : http://en.wikipedia.org/wiki/K-medoids
The most common realisation of k-medoid clustering is the Partitioning Around Medoids (PAM) algorithm and is as follows:[2]
1. Initialize: randomly select k of the n data points as the medoids
2. Associate each data point to the closest medoid. (“closest” here is defined using any valid distance metric, most commonly Euclidean distance, Manhattan distance or Minkowski distance)
3. For each medoid m
For each non-medoid data point o
Swap m and o and compute the total cost of the configuration
4. Select the configuration with the lowest cost.
5. repeat steps 2 to 4 until there is no change in the medoid.

2. Clara

CLARA implementation
1. For i = 1 to 5, repeat the following steps:
2. Draw a sample of 40 + 2k objects randomly from the
entire data set,2 and call Algorithm PAM to find
k medoids of the sample.
3. For each object Oj in the entire data set, determine
which of the k medoids is the most similar to Oj.
4. Calculate the average dissimilarity of the clustering
obtained in the previous step. If this value is less
than the current minimum, use this value as the
current minimum, and retain the k medoids found in
Step 2 as the best set of medoids obtained so far.
5. Return to Step 1 to start the next iteration.

Project Name: pyCluster
Destination: Python Clustering
Language: Python
IDE: Vim
Library:
Project Web: https://github.com/daveti/pycluster
Git Read Only: https://github.com/daveti/pycluster.git

Posted in Dave's Tools | Tagged , , , | Leave a comment

pyMns – Python Markov Network Solver

pyMns is a python implementation for Markov Network solver, which read the UAI file (and UAI evidence as well) to do inference with some classical algorithms in Probabilistic Graph Model, including Variable Elimination (VE) and Belief Propagation (BP). Have fun!

# pyMNS.py
# Python Markov Network Solver
# pyMNS reads in an uai file with description of a Markov Network
# and outputs the partition function for this MN.
# Ref: http://www.cs.huji.ac.il/project/UAI10/fileFormat.php
# Version 0.4
# 1. Enlarged system recursion limit for t4.uai
# June 5, 2013
# Version 0.3
# 1. Added loopy Belief Propagation
# May 30, 2013
# Version 0.2
# 1. Added Variable Elimination algorithm
# 2. Added min-neighbors heuristic
# 3. Added support for evidence file
# 4. Added support for MAP inference
# 5. Added other ordering heuristics
# May 12, 2013
# Version 0.1
# Input: *.uai
# Output: partition function
# May 1, 2013
# daveti@cs.uoregon.edu
# http://daveti.blog.com

Project Name: pyMns
Destination: Python Markov Network Solver
Language: Python
IDE: Vim
Library:
Project Web: https://github.com/daveti/pymns
Git Read Only: https://github.com/daveti/pymns.git

Posted in Dave's Tools | Tagged , , , , | Leave a comment

Some pitfalls in Python ~ remove, recursion and sign

This post is the summary of some pitfalls of Python programming I have encountered. May it help:)

1. remove()

List’s remove function is used to remove certain item from the list. However, remove function always removes the first item it encounters. If we want to remove an item with certain index, then remove function may introduce a bug:

>>> aList = [0, 1, 2, 1]
>>> index = 3
>>> aList.remove(aList[index])
>>> aList
[0, 2, 1]
>>>
Remove function does remove the item 1, but with index of 1 instead of 3. In this case, to remove certain item within certain index, please use pop():

>>> aList = [0, 1, 2, 1]
>>> index = 3
>>> aList.pop(index)
1
>>> aList
[0, 1, 2]
>>>

2. Recursion Limit

RuntimeError: maximum recursion depth exceeded

The default recursion/stack depth limit is 1000 by default. It is easily to exceed this limitation when you are programming for AI/Machine Learning things. When this happens, enlarge the limitation:

sys.setrecursionlimit(20000)

3. sign()

If you wonder if there was/is/will be a sign function in Python, check the argument about sign function here: http://stackoverflow.com/questions/1986152/why-python-doesnt-have-a-sign-function The key point here is to use copysign instead of sign

math.copysign(1, aNumber) == math.sign(aNumber)

Posted in Programming | Tagged | Leave a comment

libmesa conflicts with Gnome 3 on Fedora 18 – run into black screen after libmesa update

A recent update on libmesa caused my Fedora 18 running into black screen during displaying the login screen. Note that Fedora 18 is using Gnome 3 as the default login desktop before you could switch to others, like my favorate MATE. Unfortunately, ‘yum history undo’ was unable to downgrade the libmesa (even in init 3 mode) for certain reasons. After a few days struggling, I find a workaround to bypass this issue before libmesa/Gnome could realize and fix it. NOTE again, this workaround  needs the other desktop instead of Gnome 3 (in my case, I have MATE installed).

1. Fedora 18, kernel 3.9.4, libmesa version…
[root@daveti daveti]# uname -a
Linux daveti.me 3.9.4-200.fc18.x86_64 #1 SMP Fri May 24 20:10:49 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@daveti daveti]# yum history info 142
Loaded plugins: auto-update-debuginfo, langpacks, presto, refresh-packagekit
Transaction ID : 142
Begin time     : Sat Jun  1 00:16:12 2013
Begin rpmdb    : 2779:e709b9f553182476eadaa5bdf69ad710af96301b
End time       :            00:17:28 2013 (76 seconds)
End rpmdb      : 2780:d845c48ab457707b0d33a46f18707a810d652f97
User           : root,DES 224,541-953-0921,541-953-0921 <root>
Return-Code    : Success
Command Line   : update
Transaction performed with:
Installed     rpm-4.10.3.1-1.fc18.x86_64                              @updates
Installed     yum-3.4.3-54.fc18.noarch                                @updates
Installed     yum-metadata-parser-1.1.4-7.fc18.x86_64                 @anaconda
Installed     yum-plugin-auto-update-debug-info-1.1.31-10.fc18.noarch @updates
Installed     yum-presto-0.9.0-1.fc18.noarch                          @anaconda
Packages Altered:
Updated     eclipse-changelog-2:2.8.0-4.fc18.noarch                     @updates
Update                        2:2.8.0-8.fc18.noarch                     @updates
Updated     eclipse-linuxtools-1.2.0-1.fc18.noarch                      @updates
Update                         1.2.0-7.fc18.noarch                      @updates
Updated     eclipse-oprofile-1.2.0-1.fc18.noarch                        @updates
Update                       1.2.0-7.fc18.noarch                        @updates
Updated     eclipse-rpm-editor-1.2.0-1.fc18.noarch                      @updates
Update                         1.2.0-7.fc18.noarch                      @updates
Updated     eclipse-rpmstubby-1.2.0-1.fc18.noarch                       @updates
Update                        1.2.0-7.fc18.noarch                       @updates
Updated     eclipse-valgrind-1.2.0-1.fc18.noarch                        @updates
Update                       1.2.0-7.fc18.noarch                        @updates
Updated     ibus-anthy-1.5.0-1.fc18.x86_64                              @updates
Update                 1.5.3-1.fc18.x86_64                              @updates
Updated     khrplatform-devel-9.1-3.fc18.noarch                         @updates
Update                        9.2-0.7.20130528.fc18.noarch              @updates
Updated     libtevent-0.9.17-1.fc18.x86_64                              @anaconda
Update                0.9.18-1.fc18.x86_64                              @updates
Updated     libxml2-2.9.1-1.fc18.i686                                   @updates
Updated     libxml2-2.9.1-1.fc18.x86_64                                 @updates
Update              2.9.1-1.fc18.1.i686                                 @updates
Update              2.9.1-1.fc18.1.x86_64                               @updates
Updated     libxml2-devel-2.9.1-1.fc18.x86_64                           @updates
Update                    2.9.1-1.fc18.1.x86_64                         @updates
Updated     libxml2-python-2.9.1-1.fc18.x86_64                          @updates
Update                     2.9.1-1.fc18.1.x86_64                        @updates
Updated     llvm-libs-3.2-2.fc18.x86_64                                 @updates
Update                3.3-0.4.rc2.fc18.x86_64                           @updates
Updated     mesa-dri-drivers-9.1-3.fc18.x86_64                          @updates
Update                       9.2-0.7.20130528.fc18.x86_64               @updates
Obsoleted   mesa-dri-filesystem-9.1-3.fc18.x86_64                       @updates
Obsoleting  mesa-filesystem-9.2-0.7.20130528.fc18.x86_64                @updates
Updated     mesa-libEGL-9.1-3.fc18.i686                                 @updates
Updated     mesa-libEGL-9.1-3.fc18.x86_64                               @updates
Update                  9.2-0.7.20130528.fc18.i686                      @updates
Update                  9.2-0.7.20130528.fc18.x86_64                    @updates
Updated     mesa-libEGL-devel-9.1-3.fc18.x86_64                         @updates
Update                        9.2-0.7.20130528.fc18.x86_64              @updates
Updated     mesa-libGL-9.1-3.fc18.i686                                  @updates
Updated     mesa-libGL-9.1-3.fc18.x86_64                                @updates
Update                 9.2-0.7.20130528.fc18.i686                       @updates
Update                 9.2-0.7.20130528.fc18.x86_64                     @updates
Updated     mesa-libGL-devel-9.1-3.fc18.x86_64                          @updates
Update                       9.2-0.7.20130528.fc18.x86_64               @updates
Updated     mesa-libgbm-9.1-3.fc18.i686                                 @updates
Updated     mesa-libgbm-9.1-3.fc18.x86_64                               @updates
Update                  9.2-0.7.20130528.fc18.i686                      @updates
Update                  9.2-0.7.20130528.fc18.x86_64                    @updates
Updated     mesa-libglapi-9.1-3.fc18.i686                               @updates
Updated     mesa-libglapi-9.1-3.fc18.x86_64                             @updates
Update                    9.2-0.7.20130528.fc18.i686                    @updates
Update                    9.2-0.7.20130528.fc18.x86_64                  @updates
Updated     mesa-libxatracker-9.1-3.fc18.x86_64                         @updates
Update                        9.2-0.7.20130528.fc18.x86_64              @updates
Updated     opencc-0.4.0-1.fc18.x86_64                                  @updates
Update             0.4.3-1.fc18.x86_64                                  @updates
Updated     selinux-policy-3.11.1-96.fc18.noarch                        @updates
Update                     3.11.1-97.fc18.noarch                        @updates
Updated     selinux-policy-devel-3.11.1-96.fc18.noarch                  @updates
Update                           3.11.1-97.fc18.noarch                  @updates
Updated     selinux-policy-doc-3.11.1-96.fc18.noarch                    @updates
Update                         3.11.1-97.fc18.noarch                    @updates
Updated     selinux-policy-targeted-3.11.1-96.fc18.noarch               @updates
Update                              3.11.1-97.fc18.noarch               @updates
Updated     xorg-x11-drv-ati-7.0.0-0.9.20121015gitbd9e2c064.fc18.x86_64 @updates
Update                       7.1.0-5.20130408git6e74aacc5.fc18.x86_64   @updates
Updated     xorg-x11-drv-intel-2.21.6-1.fc18.x86_64                     @updates
Update                         2.21.8-1.fc18.x86_64                     @updates
Dep-Install xorg-x11-glamor-0.5.0-5.20130401git81aadb8.fc18.x86_64      @updates
history info
[root@daveti daveti]#

2. Workaround – change the default desktop of ‘startx’ (from Gnome 3 to MATE)
a. Ctrl-Alt-F2: force into init3 mode
b. cd /etc/X11/xinit
c. Modify Xclients (with the changes below)
#daveti: make mate as the default
#GSESSION=”$(type -p gnome-session)”
GSESSION=”$(type -p mate-session)”
STARTKDE=”$(type -p startkde)”

# check to see if the user has a preferred desktop
PREFERRED=
if [ -f /etc/sysconfig/desktop ]; then
    . /etc/sysconfig/desktop
    if [ "$DESKTOP" = "GNOME" ]; then
        PREFERRED=”$GSESSION”
    elif [ "$DESKTOP" = "KDE" ]; then
        PREFERRED=”$STARTKDE”
    fi
fi

if [ -n "$PREFERRED" ]; then
    exec “$PREFERRED”
fi

# now if we can reach here, either no desktop file was present,
# or the desktop requested is not installed.

if [ -n "$GSESSION" ]; then
    # by default, we run GNOME.
    exec “$GSESSION”
elif [ -n "$STARTKDE" ]; then
    # if GNOME isn’t installed, try KDE.
    exec “$STARTKDE”
fi
d. startx!

Posted in OS | Tagged , , , , | 2 Comments