Tutorials

Wednesday, October 31, 2012

Fedora 17 - Custom Spins, Continued

This is a continuation of my previous post regarding creating custom live media.  The previous post dealt with specifying software only from Fedora's repositories.  This installment furthers the live media effort to include software from third party repositories, as well as some custom tweaking

Note that if you choose to distribute this media, you should be aware of any licensing issues from the third party repositories.

Let's get on with it!

Create Your Kickstart File


Next, create your kickstart file.  I'll call mine giltner-livedvd-kde-multimedia.ks

~/spin/giltner-livedvd-kde-multimedia.ks


# giltner-livedvd-kde-multimedia.ks
#
# Description:
# - Fedora Livecd Spin with the K Desktop Environment (KDE)
#
# Maintainer(s):
# - Giltner Tech <giltnertech@gmail.com>


%include fedora-livecd-kde.ks


repo --name="rpmfusion-nonfree" --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-$releasever&arch=$basearch
repo --name="rpmfusion-nonfree-updates" --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-updates-released-$releasever&arch=$basearch
repo --name="rpmfusion-free" --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-$releasever&arch=$basearch
repo --name="rpmfusion-free-updates" --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-updates-released-$releasever&arch=$basearch

repo --name=local --baseurl=file:///home/giltner/spin/repo
repo --name="adobe-linux-i686" --baseurl=http://linuxdownload.adobe.com/linux/i386/

#repo --name="fedora-chromium-stable" --baseurl=http://repos.fedorapeople.org/repos/spot/chromium-stable/fedora-$releasever/$basearch/
#repo --name="virtualbox" --baseurl=http://download.virtualbox.org/virtualbox/rpm/fedora/$releasever/$basearch
#repo --name="livna" --mirrorlist=http://rpm.livna.org/mirrorlist




%packages

#######################################
# Repo RPMs
# Installs repositories on the target system from the repos listed above
#######################################

rpmfusion-free-release
rpmfusion-nonfree-release
adobe-release-i386
#livna-release



#######################################
# Software from "local" repo, i.e., --basefile=file:///path/to/rpm/files
# This is a great spot to put your own RPM files, or downloaded RPM files
#######################################

autoplus
libdvdcss2
opera


#######################################
# Adobe - http://fedoraproject.org/wiki/Flash
#######################################

AdobeReader_enu
flash-plugin



#######################################
# Livna - The home of libdvdcss, that which allows DVD playback
# This repo suffers intermittent troubles. Install from local repo instead
#######################################

#libdvdcss




#######################################
# RPM Fusion
# Install multimed software and codecs
#######################################

gstreamer-plugins-ugly
gstreamer-plugins-bad
gstreamer-plugins-bad-extras
gstreamer-ffmpeg
totem
totem-mozplugin
totem-pl-parser
####totem-xine -- cannot find for some reason.
mozplugger
gecko-mediaplayer
xmms
xmms-faad2
libmad
libid3tag
libdvdread
libdvdnav
libquicktime
vlc
ffmpeg
xine-ui
imagination
dvdrip
k9copy
dvd95


#######################################
# Prepare for nVidia driver compilation
# Install now, to save downloading later
#######################################

gcc
binutils
rpm-build


%end




%post --nochroot

#######################################
# MPlayer Multimedia Codecs
# Additional codecs. You can never have too many!
#######################################

wget http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20110131.tar.bz2
tar -jxvf all-20110131.tar.bz2
mkdir -p $INSTALL_ROOT/usr/local/lib/codecs
cp all-20110131/* $INSTALL_ROOT/usr/local/lib/codecs
ln -sf $INSTALL_ROOT/usr/local/lib/codecs $INSTALL_ROOT/usr/lib/codecs && ln -sf $INSTALL_ROOT/usr/local/lib/codecs $INSTALL_ROOT/usr/local/lib/win32 && ln -sf $INSTALL_ROOT/usr/local/lib/codecs $INSTALL_ROOT/usr/lib/win32
rm -f all-20100303.tar.bz2
rm -rf all-20100303




#######################################
# nVidia Driver Scripts
# Handy scripts to install drivers after OS installation
#######################################

mkdir $INSTALL_ROOT/root/GiltnerTech

cat << --nVidia1-- >> $INSTALL_ROOT/root/GiltnerTech/nVidia_driver_1
#!/bin/bash
clear
echo The nVidia driver scripts will install the proprietary nVidia drivers.
echo
echo This first script will update selinux, and install the PAE kernel.
echo
echo Press Enter to continue, or Ctlr-C to exit.
read $Dummy
yum -y update selinux-policy\*
yum -y install kernel-PAE
echo You must now reboot your system to activate the new kernel
echo before continuing with the next stage.
--nVidia1--

cat << --nVidia2-- >> $INSTALL_ROOT/root/GiltnerTech/nVidia_driver_2
#!/bin/bash
clear
echo The nVidia driver scripts will install the proprietary nVidia drivers.
echo
echo This second script will install kernel headers, nVidia drivers, backup
echo the existing initramfs image, and create a new initram image.
echo
echo Press Enter to continue, or Ctlr-C to exit.
read $Dummy

yum install kernel-PAE-devel akmod-nvidia xorg-x11-drv-nvidia-libs.i686
mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r)-nouveau.img
dracut /boot/initramfs-$(uname -r).img $(uname -r)
echo You must now reboot your system.  The driver should be installed and working.
--nVidia2--

chmod 755 $INSTALL_ROOT/root/GiltnerTech/nVidia_driver_1
chmod 755 $INSTALL_ROOT/root/GiltnerTech/nVidia_driver_2



#######################################
# Virtualbox
# Need to install VirtualBox after OS is installed on target
#######################################


cat << --virtualBox-- >> $INSTALL_ROOT/root/GiltnerTech/installVirtualbox_4.1
#!/bin/bash
echo This script will download the VirtualBox repo file, GPG key, and install VirtualBox.
echo
echo Press Enter to continue, or Ctlr-C to exit.
read $Dummy

rpm --import  http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc
wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
mv virtualbox.repo /etc/yum.repos.d/
chmod 644 /etc/yum.repos.d/virtualbox.repo
echo Repository installed.  Continuing with installation.
yum -y install VirtualBox-4.1
--virtualBox--

chmod 755 $INSTALL_ROOT/root/GiltnerTech/installVirtualbox_4.1





#######################################
# Chromium Fedora People Repo
#######################################


cat << --fedoraChromium-- >> $INSTALL_ROOT/root/GiltnerTech/installChromium
#!/bin/bash
echo This script will install the FedoraPeople Chromium repo, and install the Chromium browser
echo
echo Press Enter to continue, or Ctlr-C to exit.
read $Dummy

wget http://repos.fedorapeople.org/repos/spot/chromium-stable/fedora-chromium-stable.repo
mv fedora-chromium-stable.repo /etc/yum.repos.d/
chmod 644 /etc/yum.repos.d/fedora-chromium-stable.repo
echo Repository installed.  Continuing with installation.
yum -y install chromium.i686 chromium-ffmpegsumo.i686

--fedoraChromium--

chmod 755 $INSTALL_ROOT/root/GiltnerTech/installChromium




#######################################
# Google Earth Repo
#######################################

cat << --googleEarth-- >> $INSTALL_ROOT/root/GiltnerTech/installGoogleEarth
#!/bin/bash
echo This script will install the Google signing key, Earth repo, and install Earth with dependencies
echo
echo Press Enter to continue, or Ctlr-C to exit.
read $Dummy

rpm --import https://dl-ssl.google.com/linux/linux_signing_key.pub

cat << --googleEarthRepo-- >> /etc/yum.repos.d/google-earth.repo
[google-earth]
name=google-earth
baseurl=http://dl.google.com/linux/earth/rpm/stable/i386
enabled=1
gpgcheck=1
--googleEarthRepo--

chmod 644 /etc/yum.repos.d/google-earth.repo
echo Repository installed.  Continuing with installation.
yum -y install google-earth-stable mesa-libGL.i686 bitstream-vera-fonts-common libxml2.i686 gtk2.i686 libSM.i686 qt-x11 redhat-lsb-desktop.i686 redhat-lsb-printing.i686 redhat-lsb.i686

--googleEarth--

chmod 755 $INSTALL_ROOT/root/GiltnerTech/installGoogleEarth





#######################################
# Google Music Manager Repo
#######################################


cat << --googleMusic-- >> $INSTALL_ROOT/root/GiltnerTech/installGoogleMusic
#!/bin/bash
echo This script will install the Google signing key, Music repo, and install Music Manager
echo
echo Press Enter to continue, or Ctlr-C to exit.
read $Dummy

rpm --import https://dl-ssl.google.com/linux/linux_signing_key.pub

cat << --googleMusicRepo-- >> /etc/yum.repos.d/google-musicmanager.repo
[google-musicmanager]
name=google-musicmanager
baseurl=http://dl.google.com/linux/musicmanager/rpm/stable/i386
enabled=1
gpgcheck=1
--googleMusicRepo--

chmod 644 /etc/yum.repos.d/google-musicmanager.repo
echo Repository installed.  Continuing with installation.
yum -y install google-musicmanager

--googleMusic--

chmod 755 $INSTALL_ROOT/root/GiltnerTech/installGoogleMusic


%end





Place any RPM files you wish to include inside of the repo folder.  In my example above, I placed Autoplus, libdvdcss2, and Opera RPM files inside my local folder.

Now, let's build the image

As root, do

setenforce 0
createrepo /home/giltner/spin/repo
livecd-creator --config=/home/giltner/spin/giltner-livedvd-kde-multimedia.ks.ks --fslabel=GiltnerMultimedia --cache=/var/cache/live 



Let's take a look at the above example one section at a time.

The first several lines are comments.  You can freely modify this to suit your needs.

%include
This line pulls in all data from the specified file.  Multiple include declarations are acceptable.  The above kickstart basically adds multimedia support on top of the Fedora KDE spin.

I happen to have a separate kickstart file that adds additional software from the official Fedora repos, called giltner-livedvd-kde.ks.  If I want to combine the two, I can change the %include line to point to my other kickstart file, which includes fedora-livecd-kde.ks.  This keeps things separate.

clearpart and part
These lines clear the partition table of the media, and resets the root partition size to that of a DVD.  It throws an error when creating the image, but appears to work just fine.


repo
The repo lines add a repository that will be used to create the media.  Note that this does not install the repository on the live media (thus, installed system).  This merely tells livecd-tools where to pull software from for the installation.

Note the repo line named "local".  This points to a local directory from which to install RPM files from.  Here, you can create your own RPM's, or download them from the Internet and place them here manually.


packages
This section is rather straightforward.  The only thing I did here is group software according to which repo they were installed from.

post --nochroot
This section issues commands just as you would at a terminal, and does so inside the live image, and gets transferred to the build system.  Customizations can be made here to the target system, for example, by using sed to edit existing files.

The first thing I've done in my example is to download and install additional multimedia codecs. 

The rest of this section creates bash scripts, inside a folder called GiltnerTech in root's home, to install additional software after the target system is installed.

Creation of the bash scripts is fairly simple.  Take for example the following lines.


cat << --fileExample-- >> /root/test.sh
#!/bin/bash
echo Hello World!
--fileExample--

chmod 755 $INSTALL_ROOT/root/test.sh



What happens here is cat places the everything that follows the cat line, up to but not including the --fileExample-- label, into a file called /root/test.sh.  Then, the file is marked as executable.

The file created will look like this:

/root/test.sh

#!/bin/bash
echo Hello World!



This will create a nicely loaded KDE DVD with plenty of multimedia add-ons, repos configured, and some custom scripts to install more software.

More Info
Fedora, How to create and use a Live CD



Friday, October 26, 2012

Fedora 17 - Custom Spins

If you have multiple computers that you install Fedora on, custom live CD's or DVD's can be a wonderful time saver for multiple installations.  You can build upon an existing spin, or start from scratch and build your own Fedora spin from the ground up.

If you build upon an existing Fedora spin, when the next version of Fedora is released you'll be armed with a kickstart file from the old release.  The benefit here is that the list software you've installed into your live media can be easily transferred to the next Fedora release.

Note that you will need plenty of space in /var for this to complete.  For a CD, you'll need about 700MB for the install packages, 5.5 gigs for the install target, and 700mb for the ISO image.

Let's get going!


Install Software

As root,

yum -y install livecd-tools spin-kickstarts


livecd-tools contains the necessary software to create the images.

spin-kickstarts contains the official Fedora spins kickstart files.  This will be a big time saver, and give you a foundation with which to build your live CD from.  It can also be used as a reference for building your own independant kickstart files from scratch

Overview

Now that everything, including reference materials, has been installed, let's start looking at what we have

/usr/share/spin-kickstarts is where the kickstart files for Fedora spins are located.  Let's take a look at a few of the lines in the fedora-livecd-kde.ks file, which is used to build the Fedora Live KDE CD that is downloaded from the Fedora website.

fedora-livecd-kde.ks

%include fedora-live-kde-base.ks
%include fedora-live-minimization.ks

%packages

-desktop-backgrounds-basic
-scribus

calligra-words
fuse
%end

%post
%end


The first thing this kickstart file does is load two other kickstart files, using %include.  This is how I will be building my own KDE spin, by reading in the official kickstart file, and adding on from there.

Then follows the packages section located within the %packages and subsequent %end lines.  Adding packages is as simple as specifying the package name.  Remove a package my preceding the name with a dash.

The post section, located within the %post and subsequent %end lines, is for issuing commands after "installation" to the live media image is complete. 

Setup Your Build Environment, and Test

Create a directory in which to build your live media, and copy the kickstart files to this directory


mkdir ~/spin
cp /usr/share/spin-kickstarts/*ks ~/fedora_spin



Next, create your kickstart file.  I'll call mine test-livedvd-kde.ks

~/spin/test-livedvd-kde.ks

# test-livedvd.ks
#
# Description:
# - Giltner Fedora Remix
#
# Maintainer(s):
# - Giltner Tech <giltnertech@gmail.com>


%include fedora-livecd-kde.ks

clearpart --all
part / --size=4096 # Sets filesystem limit to a DVD, instead of CD

%packages
-calligra            #Remove Calligra
-calligra-words
-calligra-sheets
-calligra-stage

libreoffice
libreoffice-kde
kate                 # Include text editor


%end

%post
%end


Let's take a look at the above example.
  • The first several lines beginning with a hash (#) are comments.  They are there for reference.
  • Under that, is the clearpart and part lines. This clears any partitions setup inside any included file (and must come after all include lines) and sets the filesystem to a single layer DVD
  • Next is the packages section.  Here, we remove all of Calligra, and include Kate.
  • Nothing exists in the post section for this example.
Let's build the media!  (Note that SELinux must be turned off.)

As root, do

setenforce 0
livecd-creator --config=/home/giltner/spin/test-livecd-kde.ks --fslabel=Test --cache=/var/cache/live 


This process, depending on the speed of your Internet connection, can take some time.  The build process, minus download time, on my system is about an hour.  The first time I ran a small test, I didn't expect it to take as long as it did.  To that point, here is an unofficial rundown of the build process, based on my watching of the filesystem.

When the terminal is blank, or a few error lines
  1. All necessary RPM packages are downloaded to /var/cache/live.
  2. /var/tmp/imgcreate-*/install_root is prepared 
The terminal appears to be installing software
  1. The packages are installed to /var/tmp/imgcreate*/install_root.
  2. Install_root is cleaned, and moved to /var/tmp/imgcreate*/tmp-*
When the terminal pauses at 99%
  1. Contents of the ISO image are created in /var/tmp/imgcreate*/iso-*
When  percentages scroll on the screen, with estimated finish time
  1. The ISO image is created in /var/tmp/imgcreate-*/out
 And finally, when a summary is output to the terminal
  1. The ISO image is moved and renamed to /home/giltner/spin/Test.iso
  2. The /var/tmp/imgcreate* directory is removed
Note that the downloaded RPM packages are not deleted from /var/cache/live, so they can be used for the next build.

If you either burn and boot the ISO image, or boot it up in a virtual machine, you will have a Fedora KDE desktop, without Calligra, and with Kate.

Using the above, you can easily customize the installed software that resides on the live media, and thus gets installed from that media.  If you take a look at the existing kickstart files, you'll see that there's lots more that can be done!

And I'll be addressing a slightly more advanced kickstart file in my next post!



Monday, October 15, 2012

Fedora 17 - Install Scanner

Fedora's live KDE disk does not ship with any scanning software.  There are two very useful programs that I use for scanning, depending on what I am scanning.

Xsane
The most flexible scanning software available.  Xsane gives you fine grain control over scanning.  One very handy feature is the ability to batch scan multiple areas of your scanner, which is great for scanning photos using time-consuming high resolution settings.

Simple-scan
Just as the name indicates.  A very simple scanner.  Place document, hit scan, and go.  The one very nice feature of simple-scan is the ability to batch scan several sheets into a single PDF file, provided you have the hardware to do so.  Many multifunction printers have an automatic document feeder feature

Sane

Before any scanning software can be used, the backend that controls the scanner must be installed.  Sane, an acronym for Scanner Access Now Easy, is just that.  Install it, and go.  Any sane compatible scanner will work.  I've had success with HP MFC printers, and I have a Canon scanner.  Both work with no issues, including the wireless HP MFC printer!

As root,

yum -y install sane-backends-drivers-scanners
sane-find-scanner


You may find it necessary to unplug and re-plug in the USB cable to your scanner before trying one of the below scanning programs.

Xsane


As root, with your USB scanner attached and powered up

yum -y install xsane



Simple Scan

As root,

yum -y install simple-scan



Tuesday, September 18, 2012

Fedora 17 - Install Java

There are two ways to install Java. The simplest is to install the open source variant from the Fedora repository.  It's easy to install, and most importantly it keeps itself up to date.

The second way is to install the official Sun Java binaries manually. The benefit is you'll be working with the official libraries.  The downside is updates are done manually, instead of automatically through the Fedora repos.

I would highly recommend using the open source Java.  Simply install it, and forget it!  I've yet to have an issue with it.

Open Source Java

As root,

yum -y install java-1.7.0-openjdk icedtea-web



Official Java Binaries

32-bit Java binaries

As root,

yum -y install wget
wget -O jre-7u06-linux-i586.rpm http://javadl.sun.com/webapps/download/AutoDL?BundleId=67385
yum -y localinstall jre-7u06-linux-i586.rpm
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000
alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 20000
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/lib/i386/libnpjp2.so 20000
rm -f jre-7u06-linux-i586.rpm




64-bit Java binaries

As root,

yum -y install wget
wget -O jre-7u06-linux-x86_64.rpm http://javadl.sun.com/webapps/download/AutoDL?BundleId=67387
yum -y localinstall jre-7u06-linux-
x86_64.rpm
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000
alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 20000
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.
x86_64  /usr/java/latest/lib/amd64/libnpjp2.so 20000
rm -f jre-7u06-linux-
x86_64.rpm



Fedora 17 - Adobe Flash

Fedora does not come shipped with the Adobe Flash player.  The following directions install the Adobe software repository, and install the Flash Player.  Please note that the instructions are different for 32 and 64 bit systems.


32-bit systems

As root,


yum -y install --nogpgcheck http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
yum -y install flash-plugin


64-bit systems

As root,


yum -y install --nogpgcheck http://linuxdownload.adobe.com/adobe-release/adobe-release-x86_64-1.0-1.noarch.rpm
yum -y install flash-plugin


If you had Firefox open at the time of install, you will need to close Firefox and reopen it in order to use the Flash player

Fedora 17 - Multimedia Add-ons

Fedora ships with no closed source or proprietary multimedia codecs.  As such, Fedora is not equipped to play MP3's or many video clips out-of-the-box.  Here's how to install most of what you'll need for a rich multimedia experience.

What we will be doing is installing the RPM Fusion repository and installing several packages from there.  Afterwards, we'll download a codec tarball from Mplayer, and install that as well.  Then, the Livna repository will be installed (then disabled by default), and from there libdvdcss will be installed so as to play DVDs.

Upon completion, your Fedora installation will be well equipped for multimedia!

As root:

yum install -y --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

yum -y install xine-ui gstreamer-plugins-bad-extras gstreamer-ffmpeg gstreamer-plugins-ugly gstreamer-plugins-bad totem totem-mozplugin totem-nautilus totem-pl-parser totem-xine mozplugger gecko-mediaplayer xmms xmms-faad2 libmad libid3tag libdvdread libdvdnav libquicktime vlc ffmpeg wget xine-lib-extras-freeworld xmms-mp3 lame

wget http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20110131.tar.bz2
tar -jxvf all-20110131.tar.bz2
mkdir -p /usr/local/lib/codecs
cp all-20110131/* /usr/local/lib/codecs
ln -sf /usr/local/lib/codecs /usr/lib/codecs && ln -sf /usr/local/lib/codecs /usr/local/lib/win32 && ln -sf /usr/local/lib/codecs /usr/lib/win32
rm -f all-20100303.tar.bz2
rm -rf all-20100303

yum -y install --nogpgcheck http://rpm.livna.org/livna-release.rpm
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/livna.repo
yum --enablerepo=livna -y install libdvdcss



Enjoy!

Fedora 17 - Customize Gnome

After installation, there’s a number of things I like to tweak for a comfortable working environment, as well as modify what software is installed. Please note that this is Gnome specific.

Tweak User Interface with gnome-tweak-tool

gnome-tweak-tool can be used to modify several settings. Before we can use it, we have to install it.

As root,

yum install gnome-tweak-tool


Open gnome-tweak-tool, found in Activities -> Applications -> Advanced Settings, and let’s start changing things!

Desktop

  • Turn Have file manager handle the desktop on
    • This turns the desktop back on, including Computer, Trash, and other such icons
Files

  • Turn Always show location entry, instead of the pathbar on
    • In the Nautilus file manager, this allows you to type in the path to display, instead of clicking.
Shell

  • Turn Show date in clock on
    • This displays the date on the top of the screen, along with the clock
  • Change Arrangement of buttons on the titlebar to All
    • This brings back the maximize and minimize buttons. 
Theme

  • Turn Menus Have Icons on
    • This shows icons next to menu items. I prefer them.
  • Turn Buttons Have Icons on
    • This shows icons next to buttons. These two options make the user interface slightly more efficient, in my humble opinion.
Windows
  • Chage Action on title bar middle click to Toggle shade
    • When the title bar of a window is middle clicked, it will shade the window. Shading will remove the contents from view, leaving just the menu bar. Similar to rolling up a window shade to see outside.