Sunday, 15 March 2009

Creating a FEDORA 10 CHROOT Environment in DEBIAN SID

Fedora is a linux distribution supported by a community: fedoraproject.org and by Red Hat enterprise.
Fedora (Wikipedia)

Current release name is Fedora 10.


Fedora packages are provided in rpm format. We can manage these packages using rpm tool, and use yum to deal with repositories.

Debian sid provides the rpm tool so our first task will be installing it in our Debian system:
#aptitude install rpm

This tool will allow us to install fedora packages in our debian system using a separate database and a different directory than / .


We create the directory to place our Fedora chroot environment:
$mkdir Fedora
$cd Fedora
$mkdir Distro


We are going to download the minimal amount of rpm packages required for our Fedora distro.

Navigating through fedora project web page we can find some mirrors, e.g:
http://glup.uv.es/mirror/fedora/linux/
http://ftp.uni-kl.de/pub/linux/fedora/linux/
Choose one near you.

Within those mirrors we find where packages are:
http://glup.uv.es/mirror/fedora/linux/releases/10/Fedora/i386/os/Packages/
http://ftp.uni-kl.de/pub/linux/fedora/linux/releases/10/Fedora/i386/os/Packages/


We can download every package we need using wget tool.
Although we only show the installing rpm command, you will have to download every rpm package prior to install it.
NOTE: Package version may not coincide, but the same package name and same installing order are mandatory.

If we need some file to satisfy a dependency, but don't know which package contains it, this web page can help us:
http://rpmfind.net


Our goal is to install a minimal working Fedora distro. Some important packages are needed to acomplish that: bash, rpm and yum.

Bash will provide us a shell, rpm is needed to manage rpm packages, and yum will allow us to continue installing packages in our chroot enviroment using some rpm repositories and solving dependency problems.


We begin installing the packages:
/home/foo/Fedora/Distro is the directory where our chroot environment will be placed.

#export FEDORA_DISTRO_DIR="/home/foo/Fedora/Distro"
rpm --root $FEDORA_DISTRO_DIR/ -i setup-2.7.4-1.fc10.noarch.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i filesystem-2.4.19-1.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i basesystem-10.0-1.noarch.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libgcc-4.3.2-7.i386.rpm


"--nodeps" option is needed because glibc package has cross dependencies.
rpm --root $FEDORA_DISTRO_DIR/ -i glibc-2.9-2.i686.rpm --nodeps

rpm --root $FEDORA_DISTRO_DIR/ -i ncurses-base-5.6-20.20080927.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i ncurses-libs-5.6-20.20080927.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i bash-3.2-29.fc10.i386.rpm

Bash is now installed so we could execute chroot if we would want.

rpm --root $FEDORA_DISTRO_DIR/ -i tzdata-2008h-1.fc10.noarch.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i glibc-common-2.9-2.i386.rpm


rpm --root $FEDORA_DISTRO_DIR/ -i ncurses-5.6-20.20080927.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libsepol-2.0.33-1.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libselinux-2.0.73-1.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libstdc++-4.3.2-7.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i pcre-7.8-1.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i zlib-1.2.3-18.fc9.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i info-4.12-4.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i grep-2.5.1a-61.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libattr-2.4.43-1.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libacl-2.2.47-3.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libcap-2.10-2.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i audit-libs-1.7.8-6.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i cracklib-2.8.12-2.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i cracklib-dicts-2.8.12-2.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i db4-4.7.25-5.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i coreutils-6.12-17.fc10.i386.rpm -nodeps
rpm --root $FEDORA_DISTRO_DIR/ -i pam-1.0.2-2.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i popt-1.13-4.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i logrotate-3.7.7-1.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i bzip2-libs-1.0.5-3.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i compat-db45-4.5.20-5.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i elfutils-libelf-0.137-3.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i readline-5.2-13.fc9.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i lua-5.1.4-1.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i file-libs-4.26-3.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i nspr-4.7.2-2.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i sqlite-3.5.9-2.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i nss-3.12.2.0-3.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i crontabs-1.10-23.fc10.noarch.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i e2fsprogs-libs-1.41.3-2.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i keyutils-libs-1.2-3.fc9.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i krb5-libs-1.6.3-16.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libidn-0.6.14-8.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i ca-certificates-2008-7.noarch.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i openssl-0.9.8g-11.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i cyrus-sasl-lib-2.1.22-19.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i openldap-2.4.12-1.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libssh2-0.18-7.fc9.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i libcurl-7.18.2-7.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i curl-7.18.2-7.fc10.i386.rpm
rpm --root $FEDORA_DISTRO_DIR/ -i rpm-libs-4.6.0-0.rc1.7.i386.rpm --nodeps
rpm --root $FEDORA_DISTRO_DIR/ -i rpm-4.6.0-0.rc1.7.i386.rpm


RPM ACOMPLISHED!! We would be able to enter the chroot environment an install packages with rpm.


Packages needed to create new users and change their passwords:
rpm -i shadow-utils-4.1.2-8.fc10.i386.rpm
rpm -i gamin-0.1.9-6.fc10.i386.rpm --nodeps
rpm -i glib2-2.18.2-3.fc10.i386.rpm
rpm -i libuser-0.56.9-1.i386.rpm
rpm -i passwd-0.75-2.fc9.i386.rpm


Terminal to login in the system: (actually we will use agetty instead)
rpm -i mingetty-1.08-2.fc9.i386.rpm


Packages needed to install YUM tool.
rpm -i expat-2.0.1-5.i386.rpm
rpm -i gdbm-1.8.0-29.fc10.i386.rpm
rpm -i python-libs-2.5.2-1.fc10.i386.rpm --nodeps
rpm -i python-2.5.2-1.fc10.i386.rpm
rpm -i libgpg-error-1.6-2.i386.rpm
rpm -i libgcrypt-1.4.3-2.fc10.i386.rpm
rpm -i libksba-1.0.4-1.fc10.i386.rpm
rpm -i pth-2.0.7-7.i386.rpm
rpm -i dirmngr-1.0.2-1.fc10.i386.rpm
rpm -i libusb-0.1.12-20.fc10.i386.rpm
rpm -i chkconfig-1.3.38-1.i386.rpm
rpm -i pinentry-0.7.4-5.fc9.i386.rpm
rpm -i gnupg2-2.0.9-3.fc10.i386.rpm
rpm -i gpgme-1.1.7-1.fc10.i386.rpm
rpm -i pygpgme-0.1-8.fc9.i386.rpm
rpm -i python-iniparse-0.2.3-3.fc9.noarch.rpm
rpm -i rpm-python-4.6.0-0.rc1.7.i386.rpm
rpm -i python-urlgrabber-3.0.0-10.fc10.noarch.rpm
rpm -i libxml2-2.7.2-1.fc10.i386.rpm
rpm -i yum-metadata-parser-1.1.2-10.fc10.i386.rpm
rpm -i yum-3.2.20-3.fc10.noarch.rpm


Yum is now installed in our system. So we add a repository.

We edit and add this into $FEDORA_DISTRO_DIR/etc/yum.conf file:
Change baseurl to the mirror url you choose.

[Fedora10]
name=Fedora 10
baseurl=http://ftp.uni-kl.de/pub/linux/fedora/linux/releases/10/Fedora/i386/os


NOTE: We will need to run: #yum update to take into account this new repository, when our chroot environment will be working.


MOUNTING DIRECTORIES
Lets mount the directories needed for our chroot environment:

# cd $FEDORA_DISTRO_DIR
# mount --bind /proc proc
# mount --bind /sys sys
# mount --bind /proc/bus/usb proc/bus/usb
# mount --bind /dev dev
# mount --bind /dev/shm dev/shm
# mount --bind /dev/pts dev/pts
# mount --bind /tmp tmp # to use X-Windows
# mkdir -p lib/init/rw
# mount --bind /lib/init/rw lib/init/rw



We copy these files to be able to resolve localhost and dns
# cp /etc/hosts $FEDORA_DISTRO_DIR/etc/
# cp /etc/resolv.conf $FEDORA_DISTRO_DIR/etc/


Create a working /etc/mtab file:
# cp /etc/mtab $FEDORA_DISTRO_DIR/etc #edit this file to correct values. e.g:
proc /proc proc rw,noexec,nosuid,nodev 0 0
sysfs /sys sysfs rw,noexec,nosuid,nodev 0 0
udev /dev tmpfs rw,mode=0755 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0


NOTE: You can left proc and sysfs only, if you want.

ENTER INTO THE CHROOT JAIL:
Sid:# chroot $FEDORA_DISTRO_DIR

We are now in the Fedora 10 environment!!


Now we import the repository key:
Fedora:# wget http://ftp.uni-kl.de/pub/linux/fedora/linux/releases/10/Fedora/i386/os/RPM-GPG-KEY-fedora-i386
Fedora:# rpm --import RPM-GPG-KEY-fedora-i386
Fedora:# yum update



We can install new packages. e.g:
Fedora:# yum install man-pages
Fedora:# yum install man


Fedora:# yum install iputils #ping utility.



Before login in the standar way we need to CREATE A NEW USER AND CHANGE PASSWORDS:

To solve password changing problem: "passwd: User not known to the underlying authentication module"
Fedora:# yum install shadow-utils
Fedora:# pwconv #to create /etc/shadow file.


We create fedoraUser:
Fedora:# adduser fedoraUser

Fedora:# passwd # change root password.
Fedora:# passwd fedoraUser # change fedoraUser password.





To ENTER INTO THE CHROOT JAIL IN THE STANDARD WAY, without CONTROLLING TTY error, we will use agetty command:

Fedora:# yum install util-linux-ng #to obtain agetty command.
Sid:$ su -c "chroot ChDistro /sbin/agetty 38400 $(tty)"

We can login as fedoraUser.




USING SID X-Windows:

Sid:$xhost +local:`hostname` # Allow connections from local machine.

Fedora:$ export DISPLAY=:0.0 if you are using 0.0 display in Sid distro.
Fedora:$ xclock





INSTALLING EMACS

Fedora:# yum install emacs

We get this error, to solve it we will install some fonts e.g dejavu ones:

# Emacs fonts problems it is solved installing some fonts:
"Pango-CRITICAL **: No fonts found:
This probably means that the fontconfig
library is not correctly configured. You may need to
edit the fonts.conf configuration file. More information
about fontconfig can be found in the fontconfig(3) manual
page and on http://fontconfig.org"


Fedora:# yum install dejavu-fonts




INSTALLING FIREFOX

Fedora:# yum install firefox


Some errors occur:

D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory

solved with:
#dbus-uuidgen --ensure


GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://www.gnome.org/projects/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to execute dbus-launch to autolaunch D-Bus session)

solved installing:
#yum install dbus-x11 so /usr/bin/dbus-launch will be available.




SOUND SUPPORT IN OUR CHROOT

Fedora:# ls -l /dev/snd/*
We see a group number, 29 in my system. This is audio group in my Sid distro.
Fedora:# groupadd -g 29 audio
Fedora:# ls -l /dev/snd*
Fedora:# usermod -a -G audio fedoraUser

we can check if audio group was added:
Fedora:# groups fedoraUser

I use alsa in my system so:
Fedora:# yum install alsa-lib

Now we can use sound applications in our Fedora chroot environment.

Saturday, 31 January 2009

Calculating Prime Numbers using python

This blog article shows a python exercise which consists on calculating some prime numbers using division tests.

You can copy this code in a script and then execute it!


#!/usr/bin/env python

#Prime numbers
import sys
import math

print "Prime numbers"

#Asks user how many numbers he wants to calculate.
top = int(raw_input("How many prime numbers do you want to calculate?: "))

if (top <1 ) :
print "Error: Invalid number. It must be greater than one"
sys.exit

#Initializing some variables
a = 11 # first number to test if it is prime
statea = 0
stateb = 0
result = [7] # result list begins with prime number 7
num = 1 # number of calculated primes.
print 1, 3, 5, 7,

while num < top : # main loop
cont = 0

#Calculates the integer square root of a
low = 1
upper = a
while (upper - low) > 1 :
med = (low + upper)/2
temp = med * med
if temp > a :
upper = med
else:
low = med
if temp == a :
break

# Performs the division test
while 1 :
divisor = result[cont]
if (a % divisor) :
if divisor <= low :
cont += 1
else:
result.append(a)
print a, # number a is a prime
num += 1
break
else:
break # number a is not a prime

# Calculates next number to test if it is a prime.
if (stateb == 4) or (stateb == 6) :
a += 6
stateb += 1
elif statea :
a += 4
statea = 0
if stateb == 7 :
stateb = 0
else :
stateb += 1
else :
a += 2
statea = 1
stateb +=1

Friday, 26 December 2008

Installing Adobe Flash Player Plugin in GNU/Debian Sid

There are several available installation versions: tar.gz, deb and rpm.

I try deb package version because it solved me all unsatisfied dependencies that made iceweasel(firefox) crash.

First we download .deb package.
$wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.deb

Now we install the package.
#dpkg -i install_flash_player_10_linux.deb

Solving dependencies problems
#apt-get -f install

You can now run iceweasel with adobe flash plugin support.




NOTE:Another way of installing this plugin is the Debian installation way:

supposing you have non-free repositories added in your sources.list file.

#aptitude install flashplugin-nonfree

It automatically installs tar.gz version from adobe page


However dependencies are not the same as .deb package and my iceweasel crashed.




REFERENCE URLs

http://get.adobe.com/es/flashplayer/

http://www.adobe.com/es/products/flashplayer/productinfo/instructions/

Sunday, 21 September 2008

Installing GNU/Debian Sid in Ubuntu Hardy using debootstrap and chroot

This article explains how to install GNU/Debian Sid in a previously installed Ubuntu Hardy System. We will use debootstrap and chroot tools to accomplish that. This how-to is not focused on security, it does not tell how to create a restricted chroot environment to improve security.

Ubuntu is a GNU/Debian based distro. Every six months they take GNU/Debian Unstable packages and make a new Ubuntu distribution.
Debian Sid provides more and newer packages. Ubuntu is configured for easiness. Debian has less preconfiguration instead.

chroot runs a command with a special root directory.
chroot comes as part of coreutils package.
$sudo aptitude install coreutils

debootstrap command bootstraps a basic Debian system (it can also bootstrap other systems).
$sudo aptitude install debootstrap

$ls /usr/share/debootstrap/scripts/ #shows which distros and versions you can install with debootstrap:

breezy  edgy  etch-m68k  gutsy  hoary  lenny  sarge  sarge.fakechroot  warty  woody 
dapper etch feisty hardy hoary.buildd potato sarge.buildd sid warty.buildd woody.buildd


INSTALLATION BEGINNING

First of all we create the directory where Debian Sid will be installed.
$mkdir DebianSid


CREATING A LOOPBACK IMAGE TO STORE DEBIAN SID

This step is only necessary if you plan to boot your system from your Debian Sid chroot environment.

$sudo dd if=/dev/zero of=DebianSidFile bs=1048576 count=10000 #We create DebianSidFile with 10 gigabyte capacity.

$sudo mkfs.ext3 -b 4096 -L DSid DebianSidFile #Ext3 filesystem creation.

$sudo mount DebianSidFile DebianSid -t ext3 -o loop #mounting it on DebianSid directory.


INSTALLING A MINIMAL SYSTEM

$sudo debootstrap --variant=minbase --verbose sid DebianSid http://ftp.debian.org

it downloads, unpacks and installs a minimal Debian base system.


MOUNTING IMPORTANT FILESYSTEMS

$sudo mount --bind /proc DebianSid/proc

$sudo mount --bind /sys DebianSid/sys

$sudo mount --bind /tmp DebianSid/tmp

$sudo mount --bind /dev DebianSid/dev

$sudo mount --bind /dev/pts DebianSid/dev/pts


NOTE: if you wanna share your user application configurations between Ubuntu and Debian you can mount home directory.

$sudo mount --bind /home DebianSid/home



Copying the static lookup table for host names:

$sudo cp /etc/hosts DebianSid/etc/


To resolve dns:

$sudo cp /etc/resolv.conf DebianSid/etc/


ENTERING INTO THE CHROOT ENVIRONMENT

$sudo chroot DebianSid

If we execute: #cat /etc/issue it will show:

Debian GNU/Linux lenny/sid \n \l

so we are in Debian Sid!!


NOTE: Setting the hostname also changes the original system hostname, better not to change it: e.g: #hostname DebianChrootSid


ADDING SEVERAL TOOLS TO OUR SYSTEM

Updating the package system database:
#apt-get update

Dialog interface to show messages:
#apt-get install dialog

To obtaing ping utility: #apt-get install inetutils-ping
We can test the network: #ping www.google.com

Installing less:
#apt-get install less

Small vi editor:
#apt-get install vim-tiny

apt-file: #apt-get install apt-file #to search for files and packages.
apt-file configuration: #apt-file update #This will take some time.

Installing man to read man pages: #apt-get install man-db


ADDING NEW USERS

#apt-get install adduser

adding user foo: #adduser foo

becoming that user: #su foo



INSTALLING AND CONFIGURING LOCALE SUPPORT

installing locales: #apt-get install locales


The easier way to configure locales is, using dialog interface, executing:
#dpkg-reconfigure locales


The hard way to configure locales is editing some configuration files:

we edit locale.gen file: #vi /etc/locale.gen

and uncomment the locale we want to generate:
e.g: #es_ES.UTF-8 UTF-8 for Spain

generate locales with: #locale-gen


After locales have been configured we can execute:

show available locales: #locale -a

selecting a locale: e.g: spanish locale: #export LANG="es_ES.UTF-8"

showing current locale: #locale



WAYS OF LAUNCHING OUR CHROOT ENVIRONMENT

STANDARD WAY

$sudo chroot DebianSid /bin/bash

This method maintains a lot of variables from the original environment, I dont like it.


LOGGING IN WAY

NOTE: To use this method you need to previously create a new user (with adduser) and assign a password to root (with passwd) because is not possible to log in as root user. You will have to login as a standard user and then execute su command to become root.


tty command tells which terminal is standard output attached to: eg: /dev/pts/3

$sudo chroot DebianSid /sbin/getty 38400 `tty`

after you type sudo password you are offered a login prompt to enter in the chroot environment.



INSTALLING X-WINDOWS

Installing x-windows: #apt-get install xorg

Copying xorg configuration file from Ubuntu:

$sudo mv /etc/X11/xorg.conf DebianSid/etc/X11/


window manager: #apt-get install ion2

starting X: #startx /usr/bin/ion2 -- :1


NOTE: if you cannot start the X server as a normal user change in /etc/X11/Xwrapper.config

allowed_users=console to allowed_users=anybody



SHOWING X APPLICATIONS IN THE UBUNTU DISPLAY

On ubuntu to allow connections from anyone:

$xhost +


Better open only local connections: (in Ubuntu)

$hostname #shows the hostname

$xhost +local:`hostname`


now in the chroot environtment:

$export DISPLAY=:0.0 # X display in Ubuntu.

$xclock # an x window clock will show on the Ubuntu desktop screen.

this will work because we have shared X11 socket through /tmp dir with Ubuntu.



INSTALLING MPLAYER TO TEST VIDEO AND SOUND

After installing mplayer, video and sound should work fine:

Installing mplayer: #apt-get install mplayer



INSTALLING GNOME

Installing gnome: #apt-get install gnome

Starting gdm: #/etc/init.d/gdm start

NOTE: There is a problem with some gnome-applets because their configuration are shared with Ubuntu.



BOOTING FROM YOUR CHROOT ENVIRONMENT USING GRUB

At booting time you will be able to choose between booting from Ubuntu or from your chrooted Debian Sid.


You will have to add some lines to /boot/grub/menu.lst file to boot from your chroot environment.
Best idea is copying the lines at /boot/grub/menu.lst which ubuntu uses to boot Ubuntu and adapt them.

These are from my system. You will have to change 2.6.24-21 to your linux kernel version, loop=/usr/local/DebianSidFile to your DebianSidFile location, and your root device identifier.

title           kernel 2.6.24-21-generic DebianSid Loop
root (hd0,0)
kernel /boot/vmlinuz-2.6.24-21-generic root=UUID=a31628c8-5402-4319-b9cd-6a6183d43bc5 loop=/usr/local/DebianSidFile ro
initrd /boot/initrd.img-2.6.24-21-generic
quiet


NOTE: You have to use an ubuntu initrd.img file in order to understand the loop option.

Copy the necessary kernel modules into our chroot environment:
$sudo cp -a /lib/modules/2.6.24-21-generic DebianSid/lib/modules


And reinstall grub: $sudo grub-install /dev/sda #supposing master boot record is in /dev/sda device.

Now you can reboot your system into your chroot environment.


REFERENCE: http://ubuntuforums.org/showthread.php?t=24575

Wednesday, 20 August 2008

Joining two AVI files with MENCODER

It is usual having an avi film split into two cdrom sized files of 700 megabytes each.

mencoder utility allows us to concatenate these two parts into a new reintegrate file.

mencoder (MPlayer's Movie Encoder) is a tool MPlayer provides to encode multimedia contents into files.
It supports among others, MPEG-4 video, libavcodec codecs, and PCM/MP3/VBRMP3 audio formats.
mencoder also possesses stream copying abilities and a powerful filter system (crop, expand, flip, ....).


So we have a film split into two files e.g: foo1.avi and foo2.avi, both with the same encoding characteristics (window size, codecs, bitrate...),

We execute this command that produces an output file called foo.avi which is the result of concatenating foo1.avi and foo2.avi files.
$mencoder -oac copy -ovc copy -forceidx foo1.avi foo2.avi -o foo.avi

The command options mean:
* -oac output audio codec
* -ovc output video codec
* -o output file name
* -forceidx forces creation of a new index.
copy means copying the original stream and do not change the codec it is encoded into (because of that it is very fast).


more info executing: $man mencoder

INSTALLING MENCODER