Thursday, February 14, 2013

Mosaic by `justMango

This is a colorful wallpaper I found on DeviantArt.com.

Mosaic wallpaper by justMango

Wednesday, October 17, 2012

To Install the Same Set of Packages as Another Debian Machine

I know this is a well-known trick with the Debian package system, but I'm going to sum it up here. Suppose that you want to install the same set of packages on box A as box B. At box B, type the following command to get the list of installed packages.



dpkg --get-selections > select.txt


Then, take select.txt to box A and run on box A:



apt-get update
dpkg --set-selections < select.txt
apt-get -u dselect-upgrade

Tuesday, October 16, 2012

Share your Linux desktop with x11vnc

x11vnc is a pretty useful program that you can use to share your Linux desktop with someone far away. To start x11vnc while using X11 windows, issue the following command:



x11vnc -display :0


This command will work in most cases, assuming there is only one instance of X11 Windows server running. However, the display number could be different. To be sure, type the following command:



xdpyinfo | head


x11vnc will output a lot of information, including the port number it runs on:



The VNC desktop is:      bootcd:2
PORT=5902


Subtracting 5900 from the port number (5902), you'll get the display number (2). Use this number to connect to your desktop remotely. I use gvncviewer.



gvncviewer 192.168.200.83:2


TightVNC viewer on Windows Vista




Administrator To Monitor Someone's Desktop with X11VNC



Let's assume that you are a system administrator with root privilege and want to monitor a user's X11 Windows desktop. You can't just run “x11vnc -display :0” because you are not the user currently using display :0. In that case, you need access to the X11 Windows' xauth file which is located at one of the following locations:




  • /var/lib/gdm
  • /var/lib/kdm
  • /var/lib/xdm/authdir/authfiles
  • /home/USER/.Xauthority


Once you locate the xauth file associated with the user's X11 desktop, you can use x11vnc to monitor his desktop activity.



x11vnc -display :0 -auth /var/lib/gdm/\:0.Xauth


Then, on your desktop as administrator, connect to the user's desktop with a vnc client.



gvncviewer 192.168.200.83:2


x11vnc with SSL



x11vnc supports various connection schemes, including SSL. On Debian and Ubuntu, type the following command to create a SSL certificate for use with x11vnc.



cat /etc/ssl/private/ssl-cert-snakeoil.key /etc/ssl/certs/ssl-cert-snakeoil.pem > /tmp/x11vnc.pem


Then, start x11vnc with -ssl option to run x11vnc in secure mode.



x11vnc -display :0 -auth /var/lib/gdm/\:0.Xauth -ssl /tmp/x11vnc.pem


ssvnc and gvncviewer can be used to connect to x11vnc via SSL connection. The following example command starts x11vnc in anonymous SSL mode that doesn't require X509 exchange.



x11vnc -display :0 -xauth /var/lib/xdm/authdir/authfiles/A\:0-R2x5Db -xkb -nopw -nc_cr -ssl /tmp/x11vnc.pem -vencrypt newdh:nox509:support

Setting Up XDM on Debian/Ubuntu Linux

XDM, short for X Display Manager, is my favorite login manager for its simplicity. Sure, gdm and kdm are visually pleasant, but why do I have to install all the dependencies if xdm provides the same functionality as them? After all, xdm can launch GNOME and KDE for you — you just need to fix your ~/.xsession file. This post will serve as my notes on installation, configuration and customization of xdm.



All configuration of xdm, except for distribution-specific settings, is done by modifying the files in the /etc/X11/xdm directory. For now, I'll just go over what I have in my xdm files.



/etc/X11/xdm/Xaccess



This file is used to tell xdm who can use xdm. Therefore, if you are happy to let anyone access the X-Windows desktop locally or remotely, then you would just put an asterisk (*) in Xaccess as I did.



*


If you are very keen on security, you would put only the following in Xaccess. This only allows local users to have access to xdm.



localhost
127.0.0.1


However, even if Xaccess is set up as above, remote xdm login may still be possible with SSH X11 forwarding.



/etc/X11/xdm/Xresources



Xresources file is used to fine-tune the behavior and appearance of XDM. Here is what I put in my Xresources file:



Xcursor.theme: redglass

xlogin*login.translations: #override \
Ctrl<Key>R: abort-display()\n\
<Key>F1: set-session-argument(failsafe) finish-field()\n\
<Key>Delete: delete-character()\n\
<Key>Left: move-backward-character()\n\
<Key>Right: move-forward-character()\n\
<Key>Home: move-to-begining()\n\
<Key>End: move-to-end()\n\
Ctrl<Key>KP_Enter: set-session-argument(failsafe) finish-field()\n\
<Key>KP_Enter: set-session-argument() finish-field()\n\
Ctrl<Key>Return: set-session-argument(failsafe) finish-field()\n\
<Key>Return: set-session-argument() finish-field()

xlogin*greeting: Welcome to CLIENTHOST
xlogin*namePrompt: Login:\040
xlogin*passwdPrompt: Password:\040
xlogin*fail: Login incorrect

xlogin*greetFace: Serif-21:bold:italic
xlogin*face: Sans-15
xlogin*promptFace: Sans-15:bold
xlogin*failFace: Sans-16:bold

xlogin*geometry: 600x400
xlogin*borderWidth: 1
xlogin*frameWidth: 5
xlogin*innerFramesWidth: 2
xlogin*shdColor: grey30
xlogin*hiColor: grey90
xlogin*background: grey
xlogin*greetColor: Blue3
xlogin*failColor: red
*Foreground: black
*Background: #fffff0

xlogin*logoFileName: /usr/share/X11/xdm/pixmaps/penguin_doll_200x300.xpm
xlogin*useShape: true
xlogin*logoPadding: 10


I think the settings are self-explanatory. This is how xdm would look with the above settings. The penguin image was taken from here.



xdm-screenshot

/etc/X11/xdm/Xresources



The Xresources file allows you to specify how many X servers to run and their command arguments. In my case, I run Xorg and Xvfb. Xorg is the standard X server, and Xvfb is a server that runs totally in memory without depending on the video hardware. To see what's going on with Xvfb, I use x11vnc and gvncviewer.



# Default X.org server
:0 local /usr/bin/Xorg :0 vt7 -br -dpi 96 -nolisten TCP

:1 local /usr/local/bin/Xvfb :1 -dpi 96 -screen 0 1024x768x16


/etc/X11/xdm/Xsetup



Xsetup allows you to write any command to run when xdm displays the login screen. In my case, I run gm to set up the background image and run x11vnc to remotely access Xvfb via VNC.



#!/bin/sh
#
# This script is run as root before showing login widget.

gm display -window root /usr/share/wallpapers/Board_Tile_Gray.jpg
xkbcomp -dflts -I/usr/share/X11/xkb /etc/X11/xkb/server-0.xkm $DISPLAY

PID_XVFB=$(pidof Xvfb)
PID_X11VNC=$(pidof x11vnc)
if [ -n "$PID_XVFB" -a -z "$PID_X11VNC" ]; then
x11vnc -display :1 -bg -xkb -nopw -nc_cr -forever -listen localhost -auth $(find /var/lib/xdm/authdir/authfiles -name \*:1\*) > /var/log/x11vnc.log 2>&1
fi


/etc/X11/xdm/xdm-config



In xdm-config, there is only one line that I bother to change. This line enables remote xdm logins.



! SECURITY: do not listen for XDMCP or Chooser requests
! Comment out this line if you want to manage X terminals with xdm
DisplayManager.requestPort: 177


/etc/X11/xdm/xdm-options



I think xdm-options is Debian specific. I don't think I made any change in this file.



# configuration options for xdm
# See xdm.options(5) for an explanation of the available options.

no-ignore-nologin
no-restart-on-upgrade
no-start-on-install
use-sessreg


Resetting XDM



There are other files in /etc/X11/xdm directory that you can safely leave as is. After you make any change with the files, have xdm reread the config files.



kill -1 $(pidof xdm)


If you want to force xdm to kill all running sessions and restart, enter the following command.



/etc/init.d/xdm restart


That's all I have to write about xdm for now. In summary, xdm is a simple, yet functional login manager that is easy to set up.

Monday, October 15, 2012

To Create SSL Certificates for Personal / Intranet Use

lock

I'm not a security guru, but I'm writing this as a personal note. Normally, I'll have to pay some company to have my SSL certificate digitally signed for commercial uses. That's because people and businesses won't acknowledge or recognize my SSL certificate in transactions unless it is signed by a reputable company. However, I can create SSL certificates myself for personal / intranet use.



On Debian and Ubuntu systems, after the ssl-cert package is installed, a SSL certificate is automatically created at /etc/ssl/certs/ssl-cert-snakeoil.pem, and the corresponding key is created at /etc/ssl/private/ssl-cert-snakeoil.key. You can just distribute ssl-cert-snakeoil.pem to other peer machines to set up SSL connections. To manually create your own SSL certificates, follow these steps. In this guide, we will use the arbitrary filenames: my-site.key, my-site.crt and my-site.pem.




  1. Generate a public/private key pair:

    openssl genrsa -out my-site.key 1024


  2. Generate a self signed certificate:

    openssl req -new -key my-site.key -x509 -days 3653 -out my-site.crt


  3. Generate the PEM file by just appending the key and certificate files:


    cat my-site.key my-site.crt > my-site.pem


  4. The private key should be kept secret, so change the file permission.


  5. chmod 600 my-site.key my-site.pem


    You can distribute the trust certificate server.crt to your SSL client hosts that will connect securely to the SSL-enabled server. The server may need *.crt files from clients for proper client authentication.





Read Also:



Linux: Transmitting a Bunch of Files using socat

computer

socat is a nifty, versatile tool for establishing a secure data channel between two computers. To install socat on Debian, use apt-get:



apt-get install socat


I was trying to use socat and tar to duplicate the contents of an entire filesystem securely between two computers. In this case, I copied all files in partition /dev/sda5 on box A to partition /dev/sdb6 on box B (IP 192.168.200.83).



Using the SCTP protocol



This method does not involve encryption, so it is relatively simple to follow.




  1. First, I opened a terminal at box B (192.168.200.83) and changed the current directory to /mnt/sdb6 where I will unpack the incoming stream of files.


    cd /mnt/sdb6

    Then, I typed the following command to have socat establish a SCTP connection listening on port 7749. tar would be expecting to receive incoming files.


    socat EXEC:"tar xzf -" SCTP4-LISTEN:7749

  2. Then, I opened a terminal at box A. Here I would transmit a bunch of files to box B (192.168.200.83). I changed directory to /mnt/sda5 containing files to send.


    cd /mnt/sda5

    Then, I typed the following command to transmit all the files in the current directory.


    socat EXEC:"tar czf - ." SCTP4-CONNECT:192.168.200.83:7749



Using the SSL connection



This method involves encrypted connection and requires SSL certicates on both sides of the link. Read this post to learn how to create self-signed SSL certificates if you don't already have one.




  1. Debian and Ubuntu automatically create a local SSL certificate at /etc/ssl/certs/ssl-cert-snakeoil.pem. Both parties of an SSL connection — box A and box B — should exchange each other's ssl-cert-snakeoil.pem in order to have SSL connections between them.



  2. On box B, I typed the following command to run socat in SSL listening mode at port 7749.

    cd /mnt/sdb6
    socat EXEC:"tar xzf -" OPENSSL-LISTEN:7749,reuseaddr,cert=/etc/ssl/certs/ssl-cert-snakeoil.pem,key=/etc/ssl/private/ssl-cert-snakeoil.key,cafile=box-A.pem


  3. On box A, I typed the following command to run socat in SSL mode while running tar to pack all the files and send them through the pipeline.

    cd /mnt/sda5
    socat EXEC:"tar czf - ." OPENSSL:192.168.200.83:7749,cert=/etc/ssl/certs/ssl-cert-snakeoil.pem,key=/etc/ssl/private/ssl-cert-snakeoil.key,cafile=box-B.pem




Thus I have duplicated the whole directory tree from Box A to Box B. Using socat and tar, I was able to mirror a filesystem over the network. As shown above, socat alone can be a good substitute in situations where ssh, scp and/or netcat are needed. socat has many other features I have yet to explore.

Thursday, October 11, 2012

How to Extract Boot Images from Acronis Bootable CD

Acronis Backup and Restore is a great software to purchase for any business that wants to protect and preserve their digital assets from natural or accidental loss. After you purchase Acronis software and deploy it on your computers, you have a chance to create a bootable CD for emergency purpose. The Acronis boot CD will prove useful when you need to restore backups on a compromised or corrupted system.



However, you may want to incorporate Acronis software into your own custom boot CD. The custom CD can be a live Linux CD or live Windows CD. In that case, your ideal CD will have a menu of choices to run Acronis in addition to booting Linux or Windows. To create such a disc, you need to extract boot images from Acronis Boot CD. This post illustrates the steps needed to creat a custom CD containing Acronis software.




  1. Bring your Acronis emergency CD and use the following command to create an ISO file. This assumes that you are using Linux. On Windows, you can use the readom program from my cdrkit build.



    readom dev=/dev/sr0 f=ABR11.5AWUR_en-US.iso speed=8 retries=16 -nocorr -noerror


  2. Acronis uses a special bootloader called BootWiz. To extract the boot image, you need to find the location of area that begins with BOOTWIZ0 string inside the ISO file. This is a hit-or-miss process. hexedit can be used here.



    hexedit ABR11.5AWUR_en-US.iso


  3. In hexedit, press Ctrl+S, then enter 424F4F5457495A30, which translates to BOOTWIZ0. Hit Enter.



    hexedit

  4. Hexedit will find the given string (BOOTWIZ0). Note the address of the line
    (0x1A000). The address (0x1A000) is equivalent to 106496 in decimal, and 208 sectors. After you write down the address, quit Hexedit by pressing Ctrl+C.



    hexedit

  5. Use dd to extract the FAT filesystem image.



    dd if=ABR11.5AWUR_en-US.iso of=abr11.bin skip=208


  6. Use WinImage to convert the image file (abr11.bin) — actually a FAT filesystem image — to a hard disk image format with MBR.



    winimage_export_to_image_mbr

    Normally, you can just put the hard disk image on the CD and boot it using isolinux & memdisk.



    LABEL abr11
    MENU LABEL Acronis Backup & Restore 11
    KERNEL memdisk
    INITRD abr11.bin


  7. Alternatively, you can mount the image file (abr11.bin) and extract only the kernel and initramfs.



    mount -t msdos -o loop,ro abr11.bin /mnt
    cd /mnt
    cp dat*.dat /boot


    The following is an example boot entry for isolinux that starts 64-bit Acronis Backup & Restore.



    LABEL abr11x
    MENU LABEL Acronis Backup & Restore 11 (64-bit)
    KERNEL dat5.dat
    INITRD dat4.dat
    APPEND video=vesa:mtrr vga=0x317 product=bootagent media_for_windows quiet


    The kernel parameters to put as APPEND string can be taken from the efi/boot/bootx64.xml.





Aria2 shell script and batch file

I wrote a BASH shell script and a DOS batch file that can be used to download files using aria2 — Aria2 is a command-line tool for downloading files. The script and the batch file take 2 arguments; the first one is for the bittorrent hash in 40-digit hexadecimal number and the second one is for arbitrary one-word description.





aria2.bat can be used on Windows, and aria2.sh can be used on Linux and *BSD. Make sure that aria2c is in PATH. For example, if you want to download an ISO file for the OpenSUSE DVD, you would type something like:



aria2.bat 198472f5217d843cceb1a4c82233f009ed6608af opensuse-dvd-586


To find the value of a bittorrent hash (that long hex number), you can cut it from a magnet link you find on a Web site — Magnet links allow you to download actual files without first having to download bittorrent files (*.torrent). When you see a magnet sign, right-click on it to display the shortcut menu and select Copy Link Location.



btih-demo1

Then, paste it somewhere, for example, inside the URL address bar. The hash value comes after the btih: string.



btih-demo2

After you find the bittorrent hash, use it as the first argument to the script and make up anything for the second argument, as shown in the example above.


Tuesday, October 9, 2012

isolinux.cfg for a live CD

isolinux is a bootloader included in the syslinux package and is used to boot a CD or DVD. isolinux is one of several popular bootloaders used to create a bootable CD for open-source operating systems, including Linux and FreeDOS. Another bootloader is GRUB, which I rarely use except for booting Windows 7 with BIOS emulation.



To create a bootable CD with isolinux, just copy the file isolinux.bin to a folder that will hold CD contents for ISO mastering. On Debian or Ubuntu, the file is located at the /usr/lib/syslinux folder.



ISOFS contents

A file named isolinux.cfg needs to be created in order to provide a menu or boot entries. A sample isolinux.cfg is shown below. It makes use of vesamenu.c32 which helps display a nice graphical menu with a background picture. Vesamenu.c32 is also located in /usr/lib/syslinux and needs to be copied too.





# isolinux.cfg
# Configuration for ISOLINUX

# Wait for 60 seconds before booting up the default entry.
TIMEOUT 600
F1 help.txt #ff702640

UI vesamenu.c32
MENU RESOLUTION 640 480
MENU BACKGROUND back642.jpg
MENU COLOR border 30;44 #40dfdfdf #00000000 std
MENU COLOR title 1;36;43 #e0fdff49 #804206ef none
MENU COLOR sel 7;37;40 #e0000000 #40ffffff all
MENU COLOR hotsel 1;7;37;40 #e0af0000 #40ffffff all
MENU COLOR disabled 1;30;44 #ffe4de6f #00000000 std
MENU COLOR scrollbar 30;44 #40000000 #e0af0000 std
MENU TITLE Boot Menu
MENU CLEAR

MENU ROWS 14
MENU TABMSGROW 20
MENU CMDLINEROW 20
MENU TIMEOUTROW 22
MENU HELPMSGROW 24
MENU VSHIFT 1

# The default is to boot the first hard drive.
DEFAULT hd0
ONERROR hd1

MENU BEGIN livecd_menu

MENU TITLE Linux Live CD Menu

LABEL livecd_heading
MENU LABEL Boot Linux live CD
MENU DISABLE

LABEL livecd_640x480
MENU LABEL 640x480 screen
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND root=/dev/sr0 edd=off vmode=640x480

LABEL livecd_800x600
MENU LABEL 800x600 screen
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND root=/dev/sr0 edd=off vmode=800x600

LABEL livecd_1024x768
MENU LABEL 1024x768 screen
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND root=/dev/sr0 edd=off vmode=1024x768

MENU SEPARATOR

LABEL livecd_console_heading
MENU LABEL Boot Linux live CD into text console
MENU DISABLE

LABEL livecd_console
MENU LABEL text-mode console
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND root=/dev/sr0 nox

LABEL livecd_console_old
MENU LABEL text-mode console for an old computer
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND root=/dev/sr0 acpi=off irqpoll nox

MENU SEPARATOR

LABEL exit0
MENU LABEL Return to the main menu.
MENU EXIT

MENU END

MENU BEGIN cdram_menu

MENU TITLE Linux on RAMdisk Menu

LABEL cdram_heading
MENU LABEL Boot Linux on RAMdisk
MENU DISABLE

LABEL cdram_640x480
MENU LABEL 640x480 screen
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND boot=cdrom root=/dev/ram ramdisk_size=573440 edd=off vmode=640x480

LABEL cdram_800x600
MENU LABEL 800x600 screen
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND boot=cdrom root=/dev/ram ramdisk_size=573440 edd=off vmode=800x600

LABEL cdram_1024x768
MENU LABEL 1024x768 screen
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND boot=cdrom root=/dev/ram ramdisk_size=573440 edd=off vmode=1024x768

MENU SEPARATOR

LABEL cdram_console_heading
MENU LABEL Boot Linux RAMdisk into text console
MENU DISABLE

LABEL cdram_console
MENU LABEL text-mode console
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND boot=cdrom root=/dev/ram ramdisk_size=573440 nox

LABEL cdram_console_old
MENU LABEL text-mode console for an old computer
MENU INDENT 1
KERNEL 360.lnx
INITRD initram.lzm
APPEND boot=cdrom root=/dev/ram ramdisk_size=573440 acpi=off irqpoll nox

MENU SEPARATOR

LABEL exit1
MENU LABEL Return to the main menu.
MENU EXIT

MENU END

LABEL hd0
MENU LABEL First Hard Drive
LOCALBOOT 0x80

LABEL hd1
MENU LABEL Second Hard Drive
KERNEL chain.c32
APPEND hd1 swap

MENU BEGIN hd0_menu

MENU TITLE Partition in First Hard Drive

LABEL hd0_part1
MENU LABEL 1st partition
KERNEL chain.c32
APPEND hd0 1

LABEL hd0_part2
MENU LABEL 2nd partition
KERNEL chain.c32
APPEND hd0 2

LABEL hd0_part3
MENU LABEL 3rd partition
KERNEL chain.c32
APPEND hd0 3

LABEL hd0_part4
MENU LABEL 4th partition
KERNEL chain.c32
APPEND hd0 4

LABEL hd0_part5
MENU LABEL 5th partition
KERNEL chain.c32
APPEND hd0 5

LABEL hd0_part6
MENU LABEL 6th partition
KERNEL chain.c32
APPEND hd0 6

LABEL hd0_part7
MENU LABEL 7th partition
KERNEL chain.c32
APPEND hd0 7

LABEL hd0_part8
MENU LABEL 8th partition
KERNEL chain.c32
APPEND hd0 8

LABEL hd0_part9
MENU LABEL 9th partition
KERNEL chain.c32
APPEND hd0 9

LABEL hd0_part10
MENU LABEL 10th partition
KERNEL chain.c32
APPEND hd0 10

MENU SEPARATOR

LABEL exit3
MENU LABEL Return to the main menu
MENU EXIT

MENU END

LABEL fd0
MENU LABEL Floppy Drive
LOCALBOOT 0x00

LABEL next
MENU LABEL Next in boot sequence
LOCALBOOT -1

LABEL memtest
MENU LABEL Test your computer memory
LINUX memtest.bin
TEXT HELP
Run Memtest86 to test your computer memory
ENDTEXT

LABEL help
MENU LABEL Help
MENU HELP help.txt #ff702640


isolinux boot menu

The example above is one that I use for my live CD, so some settings are specific to my situation. Thus, KERNEL and APPEND settings may have to be adapted for other users. However, all the keywords shown above is standard and acceptable.


Monday, October 8, 2012

Linux: Building X.org Kdrive Server Xfbdev on Debian Wheezy

Kdrive is a minimal X11 server that runs as a single executable with little dependencies. I use Kdrive for my Web-only/Rescue Linux systems. Before compiling Kdrive, I installed the following packages on my box running Debian Sid — which will be eventually rolled into Wheezy release:



  • bison

  • g++-4.7

  • libexpat1-dev

  • libpciaccess-dev

  • libpixman-1-dev

  • libssl-dev

  • libudev-dev
  • libxdamage-dev

  • libxfont-dev

  • libxi-dev

  • libxkbfile-dev

  • libxmu-dev

  • libxxf86vm-dev

  • make

  • pkg-config

  • x11proto-bigreqs-dev

  • x11proto-composite-dev

  • x11proto-randr-dev

  • x11proto-render-dev

  • x11proto-resource-dev

  • x11proto-scrnsaver-dev

  • x11proto-video-dev

  • x11proto-xcmisc-dev

  • x11proto-xf86dga-dev

  • x11proto-xinerama-dev

  • xkb-data



Installing X Protocol Headers



The current RandR protocol headers from Debian didn't meet the required version, so I had to download the latest one from freedesktop.org. I installed randrproto like this.



tar xjvf randrproto-1.4.0.tar.bz2
cd randrproto-1.4.0
./configure --prefix=/usr
make install


Compiling Xfbdev



I got the latest X.org release from freedesktop.org. The following commands will build Xfbdev:



tar xjf xorg-server_1.13.0.tar.bz2

cd xorg-server-1.13.0/

./configure --prefix=/usr --disable-xorg --enable-kdrive --enable-kdrive-evdev --enable-config-udev --disable-aiglx --disable-glx --disable-dri --disable-dri2 --disable-drm --disable-record --with-xkb-path=/usr/share/X11/xkb --with-xkb-output=/var/lib/xkb --with-xkb-bin-directory=/usr/bin --with-default-xkb-rules=xorg --with-default-xkb-model=pc105 --with-default-xkb-layout=us

make

make install


Installed Files



The following files are installed after successfully building a Kdrive server.


/usr/bin/Xfbdev

/usr/bin/Xnest

/usr/bin/Xvfb

/usr/lib/xorg/protocol.txt

/usr/share/man/man1/Xnest.1

/usr/share/man/man1/Xserver.1

/usr/share/man/man1/Xvfb.1

/var/lib/xkb/README.compiled


To Use Xfbdev



An executable file Xfbdev will be created in /usr/bin. To be able to use the Xfbdev server, framebuffer video must be enabled either in the kernel or as a module. If CONFIG_FB_VESA option was enabled in the kernel, you can use the syslinux bootloader in the following way to boot Linux into a framebuffer video mode:



LABEL minimal
KERNEL vmlinuz-2.6.31.5
INITRD initramfs.lzma
APPEND vga=0x314 video=vesafb:mtrr


Once the framebuffer video has been activated, Xfbdev can be started in the following way:



Xfbdev :0 vt7 dpms -ac -br +bs -dpi 96 -mouse evdev,5,device=/dev/input/event2 -2button -keybd evdev,,device=/dev/input/event3 -fp /usr/local/share/fonts,/usr/share/fonts/X11/Type1,/usr/share/fonts/truetype/ttf-dejavu -nolisten TCP


Download my X.org build 1.13.0



Download

Here you can obtain my compiled binaries Xfbdev, Xnest and Xvfb:





Also Read:



Saturday, October 6, 2012

My Live CD based on Debian Linux Sid

I created a Live CD from my Debian Linux installation. It is based on the unstable version (Sid). However, the live CD still lacks the capability to automatically configure X-Windows and the network, and uses IceWM for minimalist desktop. It can be downloaded from Google Drive. This Live CD has many uses, such as:



  • To troubleshoot and fix computer problems
  • To create backups and restore them
  • To partition a hard drive before installing Windows or Linux
  • To set up GRUB bootloader or enter boot commands
  • To install Debian, Ubuntu or Fedora
  • To access a Windows partition when it is unbootable
  • To survey and diagnose wireless and wired networks
  • To enjoy the Internet with the Web, IM, IRC and VoIP
  • To run a simple FTP or HTTP server
  • To participate in peer-to-peer networks
  • To do basic word processing and spreadsheet
  • To listen to music or watch movies
  • To rip CD's and DVD's


livecd-001

The snapshot above shows idesk icons on the desktop. Idesk is a neat application that displays icons on the desktop for you to quickly launch. Currently, I use IceWM instead of GNOME or KDE desktop to save space on the CD. So idesk is used to provide desktop icons for IceWM.





livecd-002

The snapshot above shows mlterm running. mlterm is my favorite terminal application. It allows me to use many languages.



livecd-003

Gparted is a cool application to have on a live CD. It lets you divide the hard drive into many partitions so you can run multiple operating systems.



livecd-004

IceWeasel is rebranded Firefox from Debian. Sorry, Chrome is not included.



livecd-005

LibreOffice is a fork of OpenOffice.org suite. I use it to create documents or read Microsoft Office documents.



Specifying the locale at boot time



To see your own language with the live CD, select an entry from the menu, click Tab and append LANG= option to the command line. For example, if you speak French, append LANG=fr_FR.UTF-8.

Friday, September 14, 2012

Thursday, September 13, 2012

Compile xz for Windows using MinGW

xz is the new popular compression format. To build xz tools and libraries, I issued the following commands.



./configure --prefix=/mingw --disable-shared --disable-nls --disable-lzma-links --disable-scripts
make
make install


I got the following files:



lzmadec.exe
lzmainfo.exe
unxz.exe
xz.exe
xzcat.exe
xzdec.exe


Note that xz can be used to create and decompress lzma files also.

Wednesday, September 12, 2012

Compile libcddb for Windows

libcddb is used to query for information about audio Compact Discs that has been loaded in media players and CD rippers. Compiling libcddb is not so hard with MinGW.




  1. First, I installed MinGW. I compiled zlib and libiconv.



  2. Then, I compiled libcdio. I downloaded the latest development source from its git web server.


    ./autogen.sh
    ./configure --prefix=/mingw
    make
    make install


  3. I compiled libcddb like this:


    ./configure --prefix=/mingw
    make
    make install


FLAC for Windows


FLAC File
FLAC, short for Free Lossless Audio Codec, is an audio format similar to MP3, but lossless. Thus, audio compressed in FLAC has no loss in quality. With digital storage getting cheaper everyday, it makes sense to copy or preserve sound in the near-perfect quality. I'm compiling FLAC with MinGW because it's needed by some programs I want to build.




  1. I installed MinGW, of course. I also instaled NASM because it was suggested during configure. I just downloaded yasm-1.2.0-win32.exe and renamed it as nasm.exe.



  2. I think it's not necessary, but I compiled zlib and libiconv.



  3. I built OGG.


    ./configure --prefix=/mingw
    make
    make install


  4. Then, I built FLAC.


    ./configure --prefix=/mingw --enable-sse


    The --enable-sse option is for SSE-capable CPU's which mean nearly all new desktop CPU's today. I began make.



    make


    I got errors about SIZE_T_MAX. To fix it, I just changed the line 38 in flac-1.2.1/include/share/alloc.h



    # if defined _MSC_VER || defined __MINGW32__


    I got another error compiling examples/cpp/encode/file/main.cpp. To fix it, I inserted the following line after <stdlib.h> on line 33.



    #include <string.h>


    I got no more error. I installed flac.



    make install



Tuesday, September 11, 2012

Kung Fu Hustle (2004) 功夫

Kung Fu Hustle is a funny but memorable movie from Hong Kong star Stephen Chow. If you haven't seen it yet, here's your chance to watch the movie.





And the one below is the original Chinese version with English subtitles.



Compile libRTMP with MinGW

streaming-video

The libRTMP library provides online multimedia streaming support for many open-source projects, such as ffmpeg and curl. I am building librtmp for use with ffmpeg and mplayer. I downloaded the latest release tarball from here.




  1. First, I compiled zlib as shown in this post.


    make -f win32/Makefile.gcc
    cp -iv zlib1.dll /mingw/bin
    cp -iv zconf.h zlib.h /mingw/include
    cp -iv libz.a /mingw/lib
    cp -iv libz.dll.a /mingw/lib


  2. Then, I built OpenSSL as shown in this post.


    ./Configure -DHAVE_STRUCT_TIMESPEC -L/mingw/lib -lz -lpthreadGC2 -lws2_32 --prefix=/mingw threads zlib mingw
    make
    make install


  3. Then, I built librtmp.


    make SYS=mingw
    cp -iv *.exe /mingw/bin

    To build the shared library, I typed:


    cd librtmp
    gcc -shared -o librtmp.dll -Wl,--out-implib,librtmp.dll.a rtmp.o log.o amf.o hashswf.o parseurl.o -lssl -lcrypto -lz -lws2_32 -lwinmm -lgdi32

    To install librtmp, I typed the following:


    cp -iv librtmp.dll /mingw/bin
    cp -iv amf.h http.h log.h rtmp.h /mingw/include/librtmp
    cp -iv librtmp*.a /mingw/lib
    cp -iv librtmp.pc /mingw/lib/pkgconfig


  4. Sometimes, librtmp.pc fails to be generated. In that case, make it yourself and copy it to /mingw/lib/pkgconfig.



    prefix=/mingw
    exec_prefix=${prefix}
    libdir=${exec_prefix}/lib
    incdir=${prefix}/include/librtmp

    Name: librtmp
    Description: RTMP implementation
    Version: 2.3
    Requires: openssl libcrypto
    URL: http://rtmpdump.mplayerhq.hu
    Libs: -L${libdir} -lrtmp -lz
    Libs.private: -lws2_32 -lwinmm -lgdi32 -lssl -lcrypto
    Cflags: -I${incdir}


Monday, September 10, 2012

Build OpenSSL with MinGW

lock

OpenSSL is an open-source library that provides cryptographic and network security functions. It is used by so many open-source software that require SSL/TLS support. To build OpenSSL for Windows, first install MinGW. There are two flavors of MinGW: mingw and mingw64. Just pick one of the following and set it up accordingly:





Then, download the latest source tarball from the OpenSSL website and unpack it with 7-zip. 7-zip should be used because MinGW/MSYS tar has trouble with tarballs containing symlinks. However, cygwin has no problem with tarballs containing symlinks.



7-zip openssl

OpenSSL optionally incorporates the following libraries when found.





Assuming that you compiled both zlib and pthread as shown in the above links, configure OpenSSL like this.



./Configure -DHAVE_STRUCT_TIMESPEC -DPTW32_STATIC_LIB -L/mingw/lib -lz -lpthreadGC2 -lws2_32 --prefix=/mingw threads zlib mingw


Then, run make.



make


If you run into errors compiling some test codes, just copy dummytest.c over. However, it doesn't happen under Cygwin.



cp -iv test/dummytest.c test/md2test.c
cp -iv test/dummytest.c test/rc5test.c
cp -iv test/dummytest.c test/jpaketest.c


Then, install OpenSSL.



make install

To Build the Live555 library with MinGW

The Live555 streaming media library is an open-source implementation of RTP/RTCP/RTSP/SIP multimedia streaming protocols. I mainly use it with MPlayer. To compile it with MinGW, download the source for live555 library and extract the tarball under /mingw/lib:



cd /mingw/lib
tar xzvf live555-latest.tar.gz
cd live


compile it like this:



./genMakefiles mingw
make


Live555 and MPlayer



Normally, mplayer will detect the live555 library automatically. If not, append --enable-live to the ./configure command.

After running ./configure, open config.mak in a text editor and make the following changes.




  • Append the following text to CXXFLAGS= line.
    -I/mingw/lib/live/liveMedia/include -I/mingw/lib/live/UsageEnvironment/include -I/mingw/lib/live/BasicUsageEnvironment/include -I/mingw/lib/live/groupsock/include

  • Append the following text to EXTRALIBS= line.
    /mingw/lib/live/liveMedia/libliveMedia.a /mingw/lib/live/UsageEnvironment/libUsageEnvironment.a /mingw/lib/live/BasicUsageEnvironment/libBasicUsageEnvironment.a /mingw/lib/live/groupsock/libgroupsock.a -lstdc++



Creating a Shared Library for live555


To create a shared library from the static live555 libraries, I ran the following command:


gcc -shared -o livemedia.dll -Wl,--out-implib,liblivemedia.dll.a -Wl,--whole-archive liveMedia/libliveMedia.a UsageEnvironment/libUsageEnvironment.a BasicUsageEnvironment/libBasicUsageEnvironment.a groupsock/libgroupsock.a -Wl,--no-whole-archive -lstdc++ -lws2_32

I got livemedia.dll and liblivemedia.dll.a. I copied these files under MinGW.


cp -iv livemedia.dll /mingw/bin
cp -iv liblivemedia.dll.a /mingw/lib

To use these files, I would define environment variables as follows:


CXXFLAGS='-I/mingw/lib/live/liveMedia/include -I/mingw/lib/live/UsageEnvironment/include -I/mingw/lib/live/BasicUsageEnvironment/include -I/mingw/lib/live/groupsock/include'



LIBS='-lstdc++ /mingw/lib/liblivemedia.dll.a'

Bonsai Rock Study #2 - Lake Tahoe, Nevada, USA by Rich Capture

A Tribute to Our Unknown Heroes - Bonsai Rock Study #2 - Lake Tahoe, Nevada, USA

What can I say? Simply hypnotic. Otherworldly. Nice presentation of light and darkness in a serene setting.

Bonsai by Rob Birchard

Bonsai

A wonderful picture of bonsai that presents a miniaturized view of evergreen pine tress over a cliff.

Bonsai Rock Lake Tahoe IV by Joe Y Jiang

Bonsai Rock Lake Tahoe IV

A serene scene of the Lake Tahoe with the nice natural blend of water, rock, distant forest and clear sky. Vivid blue and soft red present the viewer with pleasing contrast of color and the elliptical rocks on water are pleasant to watch.

Sunday, September 9, 2012

Hilariously Awesome Martial Arts Classic: The Story of Ricky (电影: 力王)

Do you like classic horror movies or a Chinese kung-fu movie? Then, you may like the Hong Kong movie, “Ricki Oh: the Story of Ricky.” It's got both: blood and gore, and awesome kung fu. The fight scenes are gross and brutal like Kill Bill, but otherwise have outrageously cool kung-fu moves. However, I warn that some viewer discretion is advised.





Here's the same movie in Mandarin Chinese.



Saturday, September 8, 2012

Building MPlayer and Mencoder for Windows

MPlayer logo

MPlayer is one of my favorite media players. It is used with a frontend like smplayer, gnome-mplayer and MPlayerGUI to provide a good alternative to Windows Media Player. Although there are already several Win32 builds of MPlayer on the net, I like to build MPlayer on my own using MinGW compiler because I want to optimize my build for my CPU. So I installed MinGW and compiled MPlayer as follows.





  1. Build ffmpeg statically or dynamically as shown in this post.



  2. (Optional) Compile the lzo library:

    ./configure --prefix=/mingw && make && make install


  3. (Optional) Fribidi is a rendering library for right-to-left scripts, such as Arabic and Hebrew. If you are a speaker of such right-to-left languages, compile fribidi statically as shown below:


    ./configure --prefix=/mingw --disable-shared --disable-debug
    make
    make install

    More information can be found here.



  4. Download JPEG source from ijg.org and complie JPEG:

    ./configure --prefix=/mingw --enable-static
    make
    make install


  5. Compile libPNG:

    ./configure --prefix=/mingw --disable-shared
    make
    make install


  6. Compile libiconv, Freetype, expat and fontconfig statically in that order:

    ./configure --prefix=/mingw --disable-shared
    make install


  7. Compile libdca:

    ./configure --prefix=/mingw
    make
    make install


  8. (Optional) Download DirectX headers from any of the following locations and unpack them in /mingw/include:



  9. Download the latest mplayer source (mplayer-export-snapshot.tar.bz2) and unpack it. (patch 1 and patch 2)

    tar xjvf mplayer-export-snapshot.tar.bz2
    cd mplayer-export-2010-02-07/

    Then, run ./configure:


    CPPFLAGS='-DFRIBIDI_ENTRY="" ' ./configure --prefix=/mingw --enable-runtime-cpudetection --enable-static --enable-theora --enable-fribidi --disable-ffmpeg_a --disable-gl --disable-vidix --yasm=/mingw/bin/yasm --extra-libs='-lfribidi'

    The CPPFLAGS value allows fribidi to be linked statically.



  10. Build Mplayer:

    make


    After successful build, strip the executables:


    strip m*.exe


    Optionally, compress the executables with upx:


    upx --best --strip-relocs=0 mplayer.exe
    upx --best --strip-relocs=0 mencoder.exe


  11. Download MPlayer codecs from here. The MPlayer codecs for Windows platform has a filename like windows-essential-20071007.zip. Extract the codecs package and you'll get a folder "windows-essential-20071007". Rename it as "codecs" and move the "codecs" folder inside where mplayer.exe file is located.



  12. Make sure that HOME environment variable is set to your personal folder(for example, C:\Users\Jocelyn). Upon the first run of mplayer, a new folder named mplayer will be created in your HOME folder. Copy codecs.conf to the mplayer folder. The "config" file stores default options for playing movie files. Open the "config" file and make changes as follows:


    # Write your default config options here!
    cdrom-device=D:
    dvd-device=D:
    ao=dsound
    vo=direct3d
    font=C:\WINDOWS\FONTS\MALGUN.TTF
    framedrop=yes
    subcp=cp949



My win32 build of mplayer can be downloaded from here. It is recommended that the zip archive should be extracted in C:\Program Files.



Running MPlayer


Now, let's try mplayer. First, get a movie file ready. In the Command Prompt, type a command in the following form:



mplayer mymoviefile.avi


Alternatively,



mplayer -vo direct3d -ao win32 -font C:\WINDOWS\FONTS\Tahoma.ttf -framedrop mymoviefile.avi


A new window will pop up with the movie playing inside it.



The next step is to get and set up SMPlayer.

Friday, September 7, 2012

Building cdrkit for Windows

K3b_Oxygen_800px.pngcdrkit is another CD/DVD burning tool that was spun off from the cdrtools project. Some say cdrkit is inferior to cdrtools, but I haven't found a problem with cdrkit yet. Although I prefer cdrtools to cdrkit, I'd like to give cdrkit a try. To build cdrkit with MinGW, I had to compile some libraries first.




  1. zlib

    First, I compiled zlib:


    tar xzvf zlib-1.2.7.tar.gz
    cd zlib-1.2.7
    make -f win32/Makefile.gcc
    cp -iv zlib1.dll /mingw/bin
    cp -iv zconf.h zlib.h /mingw/include
    cp -iv libz.a /mingw/lib
    cp -iv libz.dll.a /mingw/lib


  2. POSIX threads for Win32

    New genisoimage seems to use pthread for making checksums. I compiled pthread like this:


    make clean GC
    cp -iv pthreadGC2.dll /mingw/bin
    cp -iv pthread.h semaphore.h sched.h /mingw/include/
    cp -iv libpthreadGC2.a /mingw/lib
    cp -iv libpthreadGC2.a /mingw/lib/libpthread.a


  3. PCRE

    Then, I compile PCRE:



    ./configure --prefix=/mingw --enable-pcre16 --enable-unicode-properties
    make
    make install
    cp /mingw/include/pcreposix.h /mingw/include/regex.h
    cp /mingw/lib/libpcreposix.a /mingw/lib/libregex.a
    cp /mingw/lib/libpcreposix.dll.a /mingw/lib/libregex.dll.a


  4. libmagic

    I built the open-source file command. I configured it like this:



    ./configure --prefix=/mingw


    Then, I added the following lines to config.h:



    #define WIN32 1
    #define MAGIC "magic"


    Compile libmagic:



    make && make install


    I got an error trying to build file.exe, so I modified src/Makefile:


    file_LDADD = libmagic.la /mingw/lib/libpcreposix.dll.a


  5. libiconv

    I built libiconv like this:


    ./configure --prefix=/mingw
    make
    make install


  6. CMake

    Then, I built CMake.


    ./bootstrap --prefix=/mingw
    make
    make install


  7. cdrkit

    I unpacked the cdrkit source and applied the patch that I found at the mailing list. Here are the modified patches of mine.





    I used the command below to applied the patch.



    patch -p1 -l < ../cdrkit-1.1.9-mingw.patch


    Then, I compiled cdrkit:



    cmake -G "MSYS Makefiles"
    make

    After successful build, I copied the executable files (*.exe) to my folder.




Issues and Fixes



  1. I got an error linking genisoimage. I edited genisoimage/CMakeLists.txt to resolve the issue:



    IF(USE_MAGIC)
    ADD_DEFINITIONS(-DUSE_MAGIC)
    LIST(APPEND EXTRA_LIBS "shlwapi")
    SET(MAGICLIBS magic)
    ENDIF(USE_MAGIC)


  2. I got errors compiling sha256.* and sha512.*. I made the following changes.



    • I removed all lines that read #include <endian.h>.
    • Assume the target machine is little endian.
    • change all occurrences of __THROW to __attribute__ ((__nothrow__)).


  3. The code in genisoimage/checksum.c gave me errors linking with pthread-w32. To fix it, I replaced a->thread with (a->thread).p.



  4. I found that genisoimage and readom still used /dev/null. I changed it to NUL in genisoimage.c and readom.c.





Download my cdrkit Build


Here's my cdrkit build for Windows.




Related Links




Thursday, September 6, 2012

Building cdrtools under Cygwin


cdrtools is a powerful open-source CD/DVD/BD burning tool. It is used as backend software for free DVD-burning applications, such as Infrarecorder and cdrtfe. To build cdrtools for Windows, install Cygwin as shown in this post. Additionally, I installed the following Cygwin packages.




  • bison
  • gcc4-core
  • gcc4-g++
  • gettext-devel
  • libiconv
  • libtool
  • make
  • patch
  • pkg-config


I set up some environment variables before I started.


export CC=/usr/bin/gcc.exe
export CC_OPT="-O2"
export CFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields"
export LDFLAGS="-L/usr/lib -Wl,--enable-auto-image-base -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"


Then, I built smake.


cd smake-1.2
make
make INS_BASE=/usr install


Then, I built cdrtools.


smake
smake INS_BASE=/usr install


Using cdrtools


I tested my cdrtools build. To create an ISO file from a folder, I ran mkisofs:


mkisofs -J -R -hide-rr-moved ~/Downloads > dl.iso

To burn an ISO:


cdrecord -scanbus
cdrecord dev=0,0,0 speed=8 driveropts=burnfree dl.iso

To make a copy of a data CD:


readcd dev=0,0,0 f=dl2.iso speed=8 retries=16 -nocorr -noerror

To scan a music CD, I ran cdda2wav:


cdda2wav -scanbus
cdda2wav dev=0,0,0 cddb=1 -cddbp-server=freedb.freedb.org -cddbp-port=8880 -J -N

To rip the second track of the music CD:


cdda2wav dev=0,0,0 cddb=1 track=2 ~/Music/track2.wav



Download my cdrtools build for Windows


Here you can get my cdrtools build.




Free cdrtools Graphical Interfaces for Windows


If you don't want to deal with the command line, there are, of course, user-friendly GUI frontends for cdrtools.




Related Links



Wednesday, September 5, 2012

Compiling CMake with MinGW

CMake is a portable build system. CMake can be used to replace the traditional GNU build process, as in:



./configure

make

make install


Compiling CMake is fairly simple. After you install MinGW (as shown in this post), download and unpack the CMake source tarball. Run the following commands in order.



tar xzvf cmake-2.8.9.tar.gz
cd cmake-2.8.9
./bootstrap --prefix=/mingw
make
make install

To Compile ffmpeg with MinGW

ffmpeg is an important component of many open-source projects, such as MPlayer and VLC. I am compiling ffmpeg so that I can use it to transcode multimedia files. This guide shows how to use MinGW to compile ffmpeg either statically or dynamically. Installation of MinGW is explained in this post. The example commands below are meant to be entered into an MSYS window (not Command Prompt). I downloaded the FFmpeg source and unpacked it.



Preparing External Libraries for FFMpeg


FFMpeg can be linked with external libraries to add features to FFmpeg. I am adding most features to FFMpeg by compiling additional libraries. Most of these libraries are also covered in my posts on compiling MPlayer and Mencoder.




  1. Compression Libraries: Zlib and bzLib

    Get the zlib source (zlib127.zip), unzip and compile it:

    unzip zlib127.zip
    cd zlib-1.2.7/
    make -f win32/Makefile.gcc
    cp -iv zlib1.dll /mingw/bin
    cp -iv zconf.h zlib.h /mingw/include
    cp -iv libz.a /mingw/lib
    cp -iv libz.dll.a /mingw/lib


    Optionally, get bzip2 source from bzip.org and compile it like this:


    tar xzvf bzip2-1.0.6.tar.gz
    cd bzip2-1.0.6
    make
    cp bzlib.h /mingw/include/
    cp libbz2.a /mingw/lib


  2. libgsm

    Download gsm-1.0.13.tar.bz2, unpack and compile it as follows:

    tar xzvf gsm-1.0.13.tar.bz2
    cd gsm-1.0-pl13/
    make

    Just ignore the compile errors with fchmod and fchown when trying to build applications. Copy the header and static library to /mingw:


    mkdir /mingw/include/gsm
    cp inc/gsm.h /mingw/include/gsm
    cp lib/libgsm.a /mingw/lib


  3. LAME is an excellent MP3 encoder. LAME makes use of the nasm assembler if available. So download yasm and save it as /mingw/bin/nasm.exe. Then, download the LAME source from lame.sf.net and compile it like this.

    ./configure --prefix=/mingw --enable-expopt=full

    make

    make install


  4. OGG, Vorbis, Speex and Theora

    The source code for these libraries can be obtained from xiph.org. Compile them each like this:


    ./configure --prefix=/mingw
    make
    make install

    As for speex, use the version 1.2rc1 or later.



  5. FAAC

    FAAC is an MPEG-4 AAC audio encoder. Get the source (faac-1.28.tar.gz) and unpack the package. Then, edit Makefile.am:

    SUBDIRS = include libfaac

    Also, edit the line beginning with AC_OUTPUT in the file configure.in:

    AC_OUTPUT(libfaac/Makefile include/Makefile Makefile)

    Then, compile FAAC like this

    sh bootstrap
    ./configure --prefix=/mingw
    make
    make install


  6. XviD is a popular video encoder used to create movie files distributed in p2p networks. Xvid can use yasm assembler to build optimized binaries if found (/mingw/bin/yasm.exe). Get the XviD source from xvid.org and compile as follows:

    tar xzvf xvidcore-1.3.2.tar.gz
    cd xvidcore/build/generic
    ./configure --prefix=/mingw
    make
    make install


    If you encounter "unrecognized command-line option -mno-cygwin" errors, open the file platform.inc in a text editor and delete "-mno-cygwin". Then, run make and make install again.



    Copy the import library for xvidcore.dll:


    cp -iv \=build/xvidcore.dll.a /mingw/lib/libxvidcore.a


  7. x264 is yet another good video encoder. x264 requires YASM to build an optimized executable. So get yasm and save it as /mingw/bin/yasm.exe. Then, compile x264 like this:

    configure --prefix=/mingw --enable-win32thread --extra-cflags="-DX264_VERSION=20100422"

    make

    make install

    cp -iv x264.h x264_config.h /mingw/include

    cp -iv libx264.a /mingw/lib

    cp -iv x264.pc /mingw/lib/pkgconfig


  8. Compile librtmp as shown in this post.



Building FFMpeg Statically


You need pr.exe from MYS coreutils package (coreutils-5.97-3-msys-1.0.13-ext.tar.lzma). I configured ffmpeg with the following command:


CPPFLAGS='-DHAVE_INT32_T' ./configure --prefix=/mingw --enable-gpl --enable-nonfree --enable-postproc --enable-avfilter --enable-w32threads --enable-runtime-cpudetect --enable-memalign-hack --enable-bzlib --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --disable-debug

-DHAVE_INT32_T is used to allow static FAAC to be linked. Then, I began compilation and installation:


make
make install


Compiling FFmpeg Dynamically


Some Windows applications, such as Audacity, uses FFmpeg libraries when available. If you want to compile FFmpeg dynamically, append --enable-shared --disable-static to the ./configure command for FFmpeg.


./configure --prefix=/mingw --enable-gpl --enable-nonfree --enable-postproc --enable-avfilter --enable-w32threads --enable-runtime-cpudetect --enable-memalign-hack --enable-bzlib --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-zlib --enable-shared --disable-static --disable-debug


If you get "int32_t" error when compiling libfaac.o, open /mingw/include/faac.h and insert the following line:


#include <stdint.h>


When I built mplayer with --enable-static and --disable-ffmpeg_a options to force linking with shared ffmpeg libraries, I had to rename ffmpeg libraries so their names end in *.a.


cd /mingw/lib
cp -iv libavcodec.dll.a libavcodec.a
cp -iv libavformat.dll.a libavformat.a
cp -iv libavutil.dll.a libavutil.a
cp -iv libpostproc.dll.a libpostproc.a
cp -iv libswscale.dll.a libswscale.a

Tuesday, September 4, 2012

Using cdrtfe 1.5

cdrtfe is free CD/DVD/BD burning software for Windows. cdrtfe actually use the command-line program cdrtools as its burning engine. I have used cdrtools on Linux to create ISO images and burn or rip CD. I'd like to have cdrtools on Windows also. Fortunately, cdrtfe includes cdrtools Win32 binaries along with the nice-looking GUI application.



To install cdrtfe, I downloaded the cdrtfe zip archive (cdrtfe-1.5.zip) and unpacked the zip archive. Double-clicking on the cdrtfe file will start the cdrtfe program. (Warning: Running the Cygwin terminal and cdrtfe at the same time can cause a problem due to cygwin1.dll incompatibility, so close the Cygwin terminal before starting cdrtfe.)



So far, I have only tried ripping music CD's with cdrtfe. I will add more as I get to know more about cdrtfe.



Ripping Audio CD's


To rip a music CD, click on the DAE tab and click the Options button. Check to make sure the options are okay.


cdrtfe_dae_options_1
cdrtfe_dae_options_2

Back to the main window, click Read TOC to update the track list, check the Save tracks to folder, and click Start to begin ripping.


cdrtfe_dae

Sunday, September 2, 2012

Setting Up Cygwin For C/C++ Software Development on Windows

Cygwin provides a Unix-like environment for Windows users. Cygwin is useful for people who want to learn Unix or popular Linux without having to install Unix or Linux. Cygwin can also be used to port Linux applications to Windows or develop genuine Windows applications. To install Cygwin, download setup.exe from the Cygwin website and run it.



Cygwin Packages for Software Development


In addition to the default packages, select the following packages for common development environment:


  • bison
  • gettext-devel
  • libtool
  • make
  • patch
  • pkg-config


To select a package for installation, type the name of the package in the Search box, expand the categories by clicking a plus, and clicking on the package until its version number shows up.



cygwin_setup_mingw64

If you want to develop software applications that depend on cygwin1.dll (which emulates Unix on Windows), install one of the following packages. This is when you want to port Linux applications to Windows with little modification.


  • gcc-g++

    outdated version 3.4.4
  • gcc4-g++

    GCC 4.x that links applications with cygwin1.dll


If you want to develop pure Windows applications, install one of the following packages.


  • mingw-gcc-g++

    The original MinGW compiler from mingw.org can't build 64-bit applications.
  • mingw64-i686-gcc-g++

    New MinGW compiler from mingw-w64.sourceforge.net.
  • mingw64-x86_64-gcc-g++

    Install these to develop 64-bit Windows applications.


When you see the Resolving Dependencies window, just accept and click Next.


cygwin_setup_dependencies

Setting HOME Variable


Setting the environment variable %HOME% is useful for various reasons. First of all, it allows regular users to compile freely in their user folder without requiring access to C:\Cygwin. Secondly, it allows users to save user-specific configuration in their user folder. For example, user configuration files such as .profile, .gtkrc-2.0, .fonts.conf and .pango-aliases can be saved in the folder specified by %HOME%.


Set HOME environment variable for MinGW and Cygwin

Setting Up mingw* compiler for Cygwin


The file C:\Cygwin\etc\fstab is used to set up mount points in Cygwin. If you installed mingw64 packages, open the file C:\Cygwin\etc\fstab in a text editor and append the following line.


/usr/i686-w64-mingw32/sys-root/mingw /mingw none bind

Start the Cygwin terminal and type the following commands to set up Cygwin for Windows compilation.


ln -s /usr/bin/i686-w64-mingw32-g++.exe /usr/i686-w64-mingw32/bin/g++.exe
ln -s /usr/bin/i686-w64-mingw32-gcc.exe /usr/i686-w64-mingw32/bin/gcc.exe

Also, set up some environment variables.


export CFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
export CXXFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
export CPPFLAGS="-I/mingw/include"
export LDFLAGS="-L/mingw/lib -Wl,--enable-auto-image-base -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
export PATH=/mingw/bin:/usr/i686-w64-mingw32/bin:/usr/local/bin:/usr/bin
export PKG_CONFIG_PATH=/mingw/lib/pkgconfig


Setting Up gcc* Compiler for Cygwin


If you installed the gcc4 compiler (as opposed to mingw*), set up some environment variables to customize your build environment. I usually type the following commands:


CC="/usr/bin/gcc.exe"
CFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
CPPFLAGS="-I/usr/include"
CXXFLAGS="-march=pentium2 -mtune=i586 -mthreads -mms-bitfields -O2"
LDFLAGS="-L/usr/lib -Wl,--enable-auto-image-base -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc"
export CC CFLAGS CPPFLAGS CXXFLAGS LDFLAGS

Friday, August 31, 2012

To Create a Live Linux CD/DVD

A live CD is a bootable CD that contains the whole operating system and any applications you want to run from the CD. With the increasing popularity of DVD and Blu-ray drives, there is even a live DVD. A live CD is useful when you want to copy your existing Linux system to a CD and run it on multiple computers. In this post, I show how I normally create a live CD.



Rebuild a kernel with SquashFS and UnionFS patch


A new kernel should be built with SquashFS and UnionFS patches. The live CD will have a huge file that is actually a SquashFS image containing a copy of your existing Linux system. We will use UnionFS so that any changes to the read-only SquashFS will be saved to the volatile memory. Download the patches from the following locations.





After patching the kernel and rebuilding it, install the new kernel.



Make a SquashFS image of an existing Linux system


A SquashFS image needs to be created from an existing Linux system. Copy the contents of the Linux filesystem to an empty directory, assuming the filesystem is mounted at /mnt.



mkdir /tmp/livecd
cd /mnt
tar cf - . | (cd /tmp/livecd; tar xf -)


Empty the contents of fstab so that the live CD will not mount any hard disk partition, including the original root partition.



cp /dev/null /tmp/livecd/etc/fstab


Create a squashfs image.



mksquashfs /tmp/livecd /tmp/linuxfs.sqz -comp xz -b 262144 -Xdict-size 196608 -no-xattrs -e boot lost+found selinux srv


Create a Custom InitRamFS image


This is a tricky part of the job. Basically, the init script of the initramfs image will mount the CD-ROM, then mount the SquashFS image, and then mount a UnionFS. Refer to this post on building an initramfs image.



Create a Live CD structure.


Create an empty directory which will be the contents of live CD. The live CD will contain:




  • SquashFS image (named linuxfs.sqz, for example)
  • isolinux.bin and isolinux.cfg
  • kernel
  • initramfs image


Finally, create an ISO image for the live CD.



genisoimage -V LIVECD -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table /tmp/isofs > ~/livecd.iso


Burn the ISO image.



cdrskin -v dev=/dev/sr0 speed=8 driveropts=burnfree ~/livecd.iso

About This Blog

KBlog logo This blog seeks to provide a collection of interesting pictures found on the Web. Thanks for visiting the blog and posting your comments.

© Contents by KBlog

© Blogger template by Emporium Digital 2008

Followers

Total Pageviews

Powered By Blogger