Howto: Compile the latest Midori web browser

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

Howto: Compile the latest Midori web browser

Postby johnnyj on Mon Sep 28, 2009 1:39 pm

Midori is a lightning-fast web browser based on WebKit. Unfortunately, the version in the repos is really old and it segfaults a lot.


These webpages give you all the info you need to compile Midori:

http://www.twotoasts.de/index.php?/pages/midori_summary.html
http://brainwreckedtech.wordpress.com/2009/05/21/howto-compile-midori-from-source-in-ubuntu/


Also, I've made a shell script that tries to do all those steps for you. I don't know what distros this script works on but it should work on Linux Mint 7.

Code: Select all
#!/bin/sh

# This shell script is placed into the public domain.

# The name of this shell script is compile-midori.sh
# It compiles the latest version of the Midori web browser.

# I don't know what distros this script works on, but it should work on an Ubuntu Jaunty-based distro.


# Special thanks to the following web pages:
#
# http://www.twotoasts.de/index.php?/pages/midori_summary.html
# http://brainwreckedtech.wordpress.com/2009/05/21/howto-compile-midori-from-source-in-ubuntu/
#
# for giving me the information I needed to create this script.


SOURCES_LIST="/etc/apt/sources.list"
ENTER_PASSWORD="You may need to enter your password because I'm using sudo for this."


cd "$HOME"

clear


echo "This shell script will compile the latest version of the Midori web browser."
printf "Press enter to continue:   "
read PAUSE


clear
echo "
Backing up your "$SOURCES_LIST" file to "$SOURCES_LIST".bak
"$ENTER_PASSWORD"

"

sudo cp -f "$SOURCES_LIST" "$SOURCES_LIST".bak


for i in "deb http://ppa.launchpad.net/webkit-team/ppa/ubuntu jaunty main" "deb-src http://ppa.launchpad.net/webkit-team/ppa/ubuntu jaunty main"
do
   if [ "`grep "$i" <"$SOURCES_LIST"`" != "$i" ]
   then
      clear
      sudo echo "" | sudo tee -a "$SOURCES_LIST" # Append a blank line to "$SOURCES_LIST" because I think "$SOURCES_LIST" looks better that way.
      echo "
      Adding repository
      "$i"
      to your "$SOURCES_LIST" file.
      "$ENTER_PASSWORD"
      " | sed 's_      __' # Yes, I WILL waste a process to keep my code pretty. This gets rid of the 2 tabs that echo would otherwise output.
      
      sudo echo "$i" | sudo tee -a "$SOURCES_LIST" # Append repo's name to "$SOURCES_LIST"
   fi
done


sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 612d9fe65c733a79bb2ab07d991e6cf92d9a3c5b
sudo apt-get update


# The function "check_for_package" installs or removes a package if it is found (or not found).
# See the uses of it below for examples.

check_for_package () {
   
   for PACKAGE in $1
   do
      if [ "`dpkg --get-selections | sed -n -e "s_^\($PACKAGE   \).*_\1_p"`" "$2" ""$i"   " ]
      then
         clear
         echo "
         
         Hang on while I "$3" the package '"$PACKAGE"'...
         "$ENTER_PASSWORD"
         
         " | sed 's_         __'
         sleep 4
         sudo apt-get "$3" "$i"
      fi
   done

}


clear
echo "
Checking if the package 'midori' is installed and removing it if it is.
I'm doing this because the package 'midori' provides an obsolete version of Midori.
"

check_for_package "midori" "=" "remove"


echo "
I need the following packages:

   git-core librsvg2-bin intltool libgtk2.0-dev libglib2.0-dev libidn11-dev libsqlite3-dev libunique-dev libwebkit-dev

to compile the latest Midori,
so I'm going to install these packages.
"

sudo apt-get install git-core librsvg2-bin intltool libgtk2.0-dev libglib2.0-dev libidn11-dev libsqlite3-dev libunique-dev libwebkit-dev


clear
echo "Downloading the latest Midori..."
sleep 3

git clone git://git.xfce.org/apps/midori


clear
echo "Compiling Midori..."
sleep 2

cd midori/
./waf configure --prefix=/usr # This ensures Midori is installed to /usr/bin/midori
./waf build

"$ENTER_PASSWORD"
sudo ./waf install


echo "

Deleting the source code directory...

"
sleep 1

cd ../
sudo rm -rf midori/


clear


if [ "`which midori`" != "" ]
then
   echo "
   
   Done! Midori has been successfully installed.
   You can run it by typing 'midori' in a terminal.
   
   
   Please close your browser.
   " | sed 's_   __'
   
   
   ask_to_make_default_browser () {
      
      printf "Make Midori the system's default browser? (This affects all users.) [y/n]   "
      read REPLY
      
      case "$REPLY" in
         "y")
            # Midori does not provide x-www-browser,
            # i.e., it doesn't appear when you type 'sudo update-alternatives --config x-www-browser'
            # So, if you want it to be your default browser, you have to symlink it to x-www-browser
            
            echo "$ENTER_PASSWORD"
            sudo rm -f /etc/alternatives/x-www-browser.1.gz
            sudo ln -sf /usr/bin/midori /etc/alternatives/x-www-browser # This script installed midori in /usr/bin/midori
            
            echo
            echo "Done."
            ;;
         "n")
            # Do nothing.
            ;;
         *)
            echo "Please enter y or n, then enter."
            ask_to_make_default_browser # Call the function recursively in case of invalid input.
            ;;
      esac
      
   }
   
   echo
   ask_to_make_default_browser
   
   
   ask_to_create_desktop_shortcut () {
      
      printf "Create a desktop shortcut for Midori? [y/n]   "
      read REPLY
      
      case "$REPLY" in
         "y")
            echo "
            [Desktop Entry]
            Version=1.0
            Encoding=UTF-8
            Type=Application
            Name=Midori
            Comment=Lightweight web browser
            Categories=Application;
            Exec=midori %u
            Icon=midori
            Terminal=false
            StartupNotify=true
            " | sed 's_            __' > "$HOME"/Desktop/Midori.desktop
            
            echo "Done."
            ;;
         "n")
            # Do nothing.
            ;;
         *)
            echo "Please enter y or n, then enter."
            ask_to_create_desktop_shortcut # Call the function recursively in case of invalid input.
            ;;
      esac
      
   }
   
   echo
   ask_to_create_desktop_shortcut
   
else
   echo
   echo "There was a problem compiling Midori..."
fi


exit

johnnyj
Level 1
Level 1
 
Posts: 13
Joined: Wed Jul 08, 2009 2:39 pm

Linux Mint is funded by ads and donations.
 

Re: Howto: Compile the latest Midori web browser

Postby beauvin on Tue Sep 29, 2009 4:19 am

Thank you! that script works just fine, i am posting this with midori :)

Edit: the ad blocker doesn't work though it needs WebKitGTK+ 1.1.14 :(
User avatar
beauvin
Level 2
Level 2
 
Posts: 51
Joined: Fri Oct 31, 2008 11:33 am
Location: Bucureşti, Romania

Re: Howto: Compile the latest Midori web browser

Postby johnnyj on Tue Sep 29, 2009 2:25 pm

beauvin wrote:Thank you! that script works just fine, i am posting this with midori :)

Edit: the ad blocker doesn't work though it needs WebKitGTK+ 1.1.14 :(


I guess the WebKit version in the PPA's isn't recent enough. I was going to compile WebKit, but it became too much work.
johnnyj
Level 1
Level 1
 
Posts: 13
Joined: Wed Jul 08, 2009 2:39 pm

Re: Howto: Compile the latest Midori web browser

Postby piratesmack on Tue Sep 29, 2009 3:20 pm

You could build a deb with something like
Code: Select all
build_deb() {
   PROGRAM="midori"
   PKG="/tmp/package-$PROGRAM"
   VERSION="git`date +%Y%m%d`"
   ARCH="i386"
   # ARCH="amd64" # Uncomment on 64-bit system

   if [ -d $PKG ]; then
      "$ENTER_PASSWORD"
      sudo rm -rf $PKG
   fi

   mkdir -p $PKG

   ./waf install DESTDIR=$PKG

   mkdir -p $PKG/DEBIAN
   cat > $PKG/DEBIAN/control <<EOF
   Package: $PROGRAM
   Version: $VERSION
   Maintainer: `id -un` <`id -un`@`hostname`>
   Architecture: $ARCH
   Description: Lightweight GTK web browser
   EOF

   "$ENTER_PASSWORD"
   sudo chown -R root:root $PKG
   sudo dpkg --build $PKG /tmp/$PROGRAM-$VERSION-$ARCH.deb
   sudo dpkg -i /tmp/$PROGRAM-$VERSION-$ARCH.deb
}


Would make it easier to uninstall
piratesmack
Level 5
Level 5
 
Posts: 710
Joined: Mon May 26, 2008 3:08 pm


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 9 guests