Monday, June 29, 2015

How to dist-upgrade BOSS GNU/Linux?

I am user of BOSS GNU/Linux version 5.0(code name: anokha) since a few years and i am content with it.  It's been about a year that the next version 6.0 (code name: anoop) is out there for public usage, I am bit afraid to upgrade my machine.  There are two reasons for my hesitation,

1.  I am completely adapted(/addicted) to BOSS 5.0, and pretty much comfortable with it.  I don't want to lose my comfortableness.

2.  I afraid to dist-upgrade, which many a time leads to -> at minimum inconsistency & at maximum machine crash.

So, what made me to upgrade my linux box?
It's been about 2 years since my last bug-fix to LibreOffice office suite.  And that FOSS contribution itch starts now again.  So, I decide to download & compile the source code LibreOffice in my Linux box.  But, Unfortunately when I to do so I end up with the error

"libo/sal/qa/rtl/strings/test_oustring_stringliterals.cxx: In member function ‘void test::oustring::StringLiterals::checkOUStringLiteral1()"
libo/sal/qa/rtl/strings/test_oustring_stringliterals.cxx:195:48: internal compiler error: Segmentation fault

As the reason pointed out by the LibreOffice developers, I have to use gcc-4.8 or higher version to compile the LibreOffice source.  But, It's not available with BOSS 5.0 (which derived from Debian release wheezy) and the same is with debian also (even backports also don't have gcc-4.8).  This leads to only one solution i.e upgrading the machine.
BOSS GNU/Linux Logo

Now, The steps to dist-upgrade your BOSS GNU/Linux machine.
(Note: 
* First backup all your (important)data, configuration files before proceeding the upgrade your machine.
* Ensure you have active internet connection throughout the following process.
* The process data consuming, it needs about 2.0 GB of data transfer) 

Steps to do in current version with the current repository (in our case BOSS 5.0 anokha)
1.  update the machine
     $sudo apt-get update 
2.  upgrade the machine
     $sudo apt-get upgrade
3.  dist-upgrade the machine
     $sudo apt-get dist-upgrade
     The steps 2 & 3 must be finished successfully without any errors.  If you end-up with errors first fix it, without you can't proceed.  And importantly
check each time what are the packages going to be removed.  If you find anything important shown as going to be removed, be ensure twice with double cautions is it ok to you and then proceed.

Steps to do in current version with the target repository (in our case BOSS 6.0 anoop)
1.  Modify the "/etc/apt/sources.list" to point to the new version's repository.  For our case open & edit the file "/etc/apt/sources.list" file as follows.

$sudo gedit /etc/apt/sources.list

existing:
deb http://packages.bosslinux.in/boss anokha main contrib non-free
deb-src http://packages.bosslinux.in/boss anokha main contrib non-free


After modification:
deb http://packages.bosslinux.in/boss anoop main contrib non-free
deb-src http://packages.bosslinux.in/boss anoop main contrib non-free


save and exit.

2. update the machine
   $sudo apt-get update

3. Upgrade the machine
   $sudo apt-get upgrade

4.  Upgrade the machine
   $sudo apt-get dist-upgrade

  In the 3 & 4 th steps be in & around your machine, as the new versions of the packages installed it will prompt for configuration file changes.  For example let's take "postgresql" configuration file.  You may be modified it for your previous needs.  As the newer version going to be installed you will be prompted with options to keep older configuration file, replace with new etc., give your option accordingly (default & recommended is keeping your old configuration file).  Once you crossed all the said steps successfully, machine will prompt for "reboot", after which you could be landed into newer version of BOSS GNU/Linux.

How to check the upgraded version?
$hostnamectl
output will be something like

    Static hostname: boss
              Icon name: computer-desktop
                  Chassis: desktop
            Machine ID: 62c6fd7923f0953d60
                  Boot ID: 5449ccd6794947cc8309fdff20546b0b
Operating System: BOSS GNU/Linux 6 (anoop)
                   Kernel: Linux 3.2.0-4-686-pae

Kernel Upgrade:
From the above output we are sure that the machine is i686 arch so we have to install the newer kernel of same architecture.  So, we will find the newer/latest linux kernel available in our repository and install.  First let us check the available linux kernels using
$apt-cache search linux-image  - outputs something like follows
linux-image-3.16.0-4-586 - Linux 3.16 for older PCs
linux-image-3.16.0-4-686-pae - Linux 3.16 for modern PCs
linux-image-3.16.0-4-686-pae-dbg - Debugging symbols for Linux  \ 3.16.0-4-686-pae
linux-image-3.16.0-4-amd64 - Linux 3.16 for 64-bit PCs
linux-image-486 - Linux for older PCs (dummy package)
linux-image-586 - Linux for older PCs (meta-package)
linux-image-686-pae - Linux for modern PCs (meta-package)
linux-image-686-pae-dbg - Debugging symbols for Linux 686-pae configuration (meta-package)
linux-image-amd64 - Linux for 64-bit PCs (meta-package)
linux-image-3.2.0-4-686-pae - Linux 3.2 for modern PCs
linux-headers-3.2.0-4-686-pae - Header files for Linux 3.2.0-4-686-pae

The existing kernle is linux-3.2 and we have linux-3.16 in our repository for i686 architecture.  So, we could proceed with installation of new kernel
$sudo apt-get install linux-image-3.16.0-4-686-pae

Now, your machine will prompt you for rebooting.  Before rebooting you may consider purging removed packages(optional but recommended).


Purging removed packages:
Purge = (In Linux) Complete removal of a package including configuration files.  Many a time a package removed but its configuration files may stay with the machine.  To remove those unnecessary configuration files we purging.

$ dpkg -l | awk '/^rc/ { print $2 }'  - Lists all the removed packages
$sudo apt-get purge $(dpkg -l | awk '/^rc/ { print $2 }') - purge the removed packages.


 

Monday, June 22, 2015

How to print the current line and the file name in a c program?

'C' compilers usually define preprocessor macros along with our header file inclusion macro.  There are many different useful preprocessor macros available, two of them are __FILE__ & __LINE__. 

__FILE__ -> will be replaced by the executing filename.

__LINE__ -> will be replaced by the current line of execution.

Example program - test.c:

1 #include

3 int main()
4 {
5  printf("\n%s\t%d",__FILE__, __LINE__);
6  return 0;
7 }

while running the above program outputs:
tst.c        5