jonEbird

December 29, 2011

Installing emacs v24 on Fedora

Filed under: adminstration,blogging,emacs,linux,usability — jonEbird @ 10:05 pm

I’ve been reading about other people giving the yet to be release version 24 of emacs for some time now. When I decided to upgrade my systems to use v24, I was a bit surprised to not find anything about configuring a Fedora system to use v24 of emacs. Guess I gotta do it myself…

This tutorial is part editorial and part instructional. I thought it would be helpful to include some of the techniques I used to get emacs up and running quickly without needing to pull my hair for other’s edification.

After realizing I wasn’t going to be able to just grab a pre-built binary, I went looking for the official sources. I ended up finding the pretest download location. First step first, let’s pull down the latest emacs-24 tarball and extract it.

PRETEST_URL="http://alpha.gnu.org/gnu/emacs/pretest/"
FILENAME=$(curl -s ${PRETEST_URL} | sed -n 's/^.*a href="\(emacs-24.[0-9\.]*tar.gz\)".*$/\1/p' )
curl -o ${FILENAME} ${PRETEST_URL}${FILENAME}
tar -xzof $FILENAME
cd ${FILENAME%.tar.gz}

If that worked, you are now sitting in the extracted directory of the latest emacs-24 pretest source. Now for some instructional information. Any significantly large project will need a decent amount of development packages installed for a successful compile and that can be a pain to identify. Earlier I claimed that I didn’t pull my hair out which means I cheated. I grabbed the latest Fedora source rpm. I didn’t actually want to install the src.rpm but rather extract the emacs.spec file which will act like a blueprint for my build. I’m going to give you the answer later but if you’d like to know how to extract the specfile, try this:
Note: You do not need to do this step. Instructional only.

SRCRPM=~/Download/emacs-23.3-7.fc16.src.rpm
# Your SRCRPM may differ depending on what you end up downloading.
mkdir tmp && cd tmp
rpm2cpio $SRCRPM | cpio -ivd
sed -n -e 's/,/ /g' -e 's/^BuildRequires: //p' emacs.spec | xargs sudo yum -y install

Note the last command in that section was a command to install the necessary development packages for our build. Since I”m not requiring you to do that above, here is the command for you:

sudo yum -y install atk-devel cairo-devel freetype-devel \
  fontconfig-devel dbus-devel giflib-devel glibc-devel gtk2-devel \
  libpng-devel libjpeg-devel libtiff-devel libX11-devel libXau-devel \
  libXdmcp-devel libXrender-devel libXt-devel libXpm-devel \
  ncurses-devel xorg-x11-proto-devel zlib-devel librsvg2-devel \
  m17n-lib-devel libotf-devel autoconf automake bzip2 cairo texinfo \
  gzip GConf2-devel alsa-lib-devel desktop-file-utils python2-devel \
  python3-devel util-linux

The other part of the specfile you’ll typically want to look at, if you’re cheating like me, is the %build section. That is where you’ll find the actual commands used to configure and build the binaries. There I found the configure switches used so I don’t have to pick out which ones I’ll need. Again, just like figuring out the development packages, figuring out configure options can also be a chore. Let’s get to configuring, building and installing it now.

./configure --prefix=/usr/local/emacs24 --with-dbus --with-gif --with-jpeg --with-png \
  --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk
make
./src/emacs --version # Look good? The INSTALL doc suggests testing: ./src/emacs -Q
sudo make install

Well, that worked for me and hopefully it worked for you too. If you noticed, I used the --prefix=/usr/local/emac24 option above on my configure line which means everything got cleanly installed down it’s own separate base directory of /usr/local/emacs24. Since you won’t want to use that path explicitly each time you launch emacs, we’ll have to inform Fedora of our new altenative.

sudo alternatives --install /usr/bin/emacs emacs /usr/local/emacs24/bin/emacs 20000
sudo alternatives --install /usr/bin/emacsclient emacsclient /usr/local/emacs24/bin/emacsclient 20000

And there, we’re done. Congratulations. You have installed emacs version 24 on your Fedora system. Let me know if you’ve had any problems or have a better recommendation.

Viewing 6 Comments

    • ^
    • v

    you are an excellent person. bzr branch to savannah is not working for me today. you have helped yet another addict get their emacs fix. All power to emacs, org-mode, babel, bbdb, and a few more.

    • ^
    • v

    Another informative post Mr. Miller. I to learned about yum-builddep as well, but it does not work for me. So, your sed handy work has saved me a lot of time (especially since my sed foo is not so stong.

    yum-builddep don't work for me because I am attempting to build a SPRM (same diff) that is from the next version of the OS, and as soon as yum-builddep cannot find a new library (from later OS), or there is requirement for a library to be greater than what's currently installed it aborts and does nothing--which for me means it don't do nothing.

    'rpm --nofiles -Vp http://somesrc.rpm' is one little command I discovered recently and thought it might be useful to you. It grabs the 'rpm header' which is basically the spec file I think. Using it you can avoid downloading and rpm2cpio. Of course your sed command would need to be updated.

    People who don't have the latest OS (like me) are going to have to deal with the Conflicts, Requires sections and complex BuildRequires entries as well. Here is an example from a Gtk2 spec file.
    BuildRequires: atk-devel >= %{atk_version}
    BuildRequires: pango-devel >= %{pango_version}
    BuildRequires: glib2-devel >= %{glib2_version}
    # Conflicts with packages containing theme engines
    # built against the 2.4.0 ABI
    Conflicts: gtk2-engines < 2.7.4-7
    Conflicts: libgnomeui < 2.15.1cvs20060505-2
    Conflicts: redhat-artwork < 0.243-1
    Requires(post): glib2 >= %{glib2_version}
    Requires(post): atk >= %{atk_version}
    Requires(post): pango >= %{pango_version}

    But your little sed ploughs through threw all the basic depends, and leaves me with the version requirements. Excellent!

    • ^
    • v

    I like the 
    'rpm --nofiles -Vp http://somesrc.rpm' invocation. I often forget that rpm will retrieve the package off the web for me and my habits are grounded in having the distribution packages readily available on a build server. I'll have to use that next time.

    • ^
    • v

    thanks..

    • ^
    • v

    From the INSTALL file in the emacs source, all you have to run is "yum-builddep emacs" - it will install all the build deps for you.  That worked for me.

    • ^
    • v

    I must have missed that from the INSTALL file and I hadn't known about "yum-builddep" before. Checking out the man page on it, it tells me that it will need access to the source RPM for the desired package from a repository. I have the source repo disabled, by default, so I'd have to enable that first. Thanks for the tip. That's going to save me time in the future. 

 
close Reblog this comment
blog comments powered by Disqus