ubuntu上面无网络的情况上安装 emacs

ubuntu下面无网络的情况下安装 emacs

因为有朋友问我这个问题,所以我就实践一下,写了下来.

 

 

1, 在其它能上网的电脑上面下载 emacs :

   http://www.gnu.org/software/emacs/emacs.html 

   wget -c http://ftp.gnu.org/pub/gnu/emacs/emacs-23.2.tar.gz

 

 

    82% [===============================>       ] 38,794,237   438K/s  ETA 23s     

 

2, 解压

     tar -xf emacs-23.2.tar.gz

     cd emacs-23.2

 

 

3,看 README , 再看 INSTALL

 

 

INSTALL 里面写着:

 

 

  1. Make sure your system has at least 120 MB of free disk space.

  2a. `cd' to the directory where you unpacked Emacs and invoke the
      `configure' script:

		 ./configure

  2b. Alternatively, create a separate directory, outside the source
      directory, where you want to build Emacs, and invoke `configure'
      from there:

		 SOURCE-DIR/configure

      where SOURCE-DIR is the top-level Emacs source directory.  This
      may not work unless you use GNU make.

  3. When `configure' finishes, it prints several lines of details
     about the system configuration.  Read those details carefully
     looking for anything suspicious, such as wrong CPU and operating
     system names, wrong places for headers or libraries, missing
     libraries that you know are installed on your system, etc.

     If you find anything wrong, you will have to pass to `configure'
     explicit machine configuration name, and one or more options
     which tell it where to find various headers and libraries; refer
     to DETAILED BUILDING AND INSTALLATION section below.

     If `configure' didn't find some image support libraries, such as
     Xpm, jpeg, etc., and you want to use them refer to the subsection
     "Image support libraries", below.

     If the details printed by `configure' don't make any sense to
     you, assume that `configure' did its job and proceed.

  4. If you need to run the `configure' script more than once (e.g.,
     with some non-default options), always clean the source
     directories before running `configure' again:

		make distclean
		./configure

  5. Invoke the `make' program:

		 make

  6. If `make' succeeds, it will build an executable program `emacs'
     in the `src' directory.  You can try this program, to make sure
     it works:

		 src/emacs -q

  7. Assuming that the program `src/emacs' starts and displays its
     opening screen, you can install the program and its auxiliary
     files into their installation directories:

		 make install

  You are now ready to use Emacs.  If you wish to conserve disk space,
  you may remove the program binaries and object files from the
  directory where you built Emacs:

		 make clean

  You can also save some space by compressing (with `gzip') Info files
  and installed Lisp source (.el) files which have corresponding .elc
  versions.


 

 

4, 那就按他说的做吧:

 

 

kk@kk-laptop:~/down/emacs-23.2$ ./configure 

 

提示错误:

 

 

configure: error: The following required libraries were not found:
     libjpeg libpng libgif/libungif libtiff
Maybe some development libraries/packages are missing?
If you don't want to link with them give
     --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no
as options to configure

 

 

 

说是这几个库没找到:      libjpeg libpng libgif/libungif libtiff
也说可以跳过这几个库:  ./configure --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no

 

我是直接跳过了.

安装这几个库:   用 aptitude search 命令查找 libjpeg : 
kk@kk-laptop:~/down/emacs-23.2$ as libjpeg
v   libjpeg-dbg                     -                                           
v   libjpeg-dev                     -                                           
p   libjpeg-progs                   - Programs for manipulating JPEG files      
i   libjpeg62                       - The Independent JPEG Group's JPEG runtime 
p   libjpeg62-dbg                   - Development files for the IJG JPEG library
p   libjpeg62-dev                   - Development files for the IJG JPEG library
 

 

得到答案: 要安装 libjpeg-dev , 于是在其它电脑上面下载这个包, 命令 :

 

 

aptitude install -d libjpeg-dev

 

 

读取:1 http://cn.archive.ubuntu.com/ubuntu/ lucid/main libjpeg62-dev 6b-15ubuntu1 [188kB]

已下载 188kB,耗时 0秒 (284kB/s)



cd /var/cache/apt/archives

kk@kk-laptop:/var/cache/apt/archives$ ls libjpeg*
libjpeg62-dev_6b-15ubuntu1_i386.deb
 

得到 libjpeg62-dev_6b-15ubuntu1_i386.deb

 

担心这个包还有其它依赖,于是: 

kk@kk-laptop:~/down/emacs-23.2$ aw libjpeg-dev
未发现 libjpeg-dev 的已安装或候选版本
软件包: libjpeg-dev
状态: 不是一个真实的软件包
提供者:: libjpeg62-dev
kk@kk-laptop:~/down/emacs-23.2$ aw libjpeg62-dev
软件包: libjpeg62-dev
状态: 已安装
自动安装: 否
版本号: 6b-15ubuntu1
优先级: 可选
部分: libdevel
维护者: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
未压缩尺寸: 434k
依赖于: libjpeg62 (= 6b-15ubuntu1), libc-dev
提供: libjpeg-dev

需要把 libjpeg62 libc-dev 也装上.
其实把  build-essential 这个包装上,基本上就很全了. 

再搞定 其它几个.

... 我是直接跳过的.  ./configure --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no

 

 

 

 

然后:

 

                make distclean

                ./configure


 

configure: creating ./config.status
config.status: creating Makefile
config.status: creating lib-src/Makefile.c
config.status: creating oldXMenu/Makefile
config.status: creating doc/emacs/Makefile
config.status: creating doc/misc/Makefile
config.status: creating doc/lispintro/Makefile
config.status: creating doc/lispref/Makefile
config.status: creating src/Makefile.c
config.status: creating lwlib/Makefile
config.status: creating lisp/Makefile
config.status: creating leim/Makefile
config.status: creating src/config.h
config.status: executing default commands
creating src/epaths.h
creating lib-src/Makefile
creating src/Makefile

 

 

OK没报错.

 

 

 

直接执行 make 

看看也没什么错误,

 

然后执行                  src/emacs -q

成功了, emacs 的普通界面跳出来了. 爽的.

c-x,c-c 退出. 

按照 INSTALL 里的第7步,还要          sudo        make install

debian 系统要加 sudo  不然会提示权限不足.
看看也没什么错误,

然后执行 emacs 
成功了,  emacs 的标准界面跳出来了, 很好很强大.

kk@kk-laptop:~/down/emacs-23.2$ type emacs
emacs 已经被散列 (/usr/local/bin/emacs)

kk@kk-laptop:~/down/emacs-23.2$ file /usr/local/bin/emacs
/usr/local/bin/emacs: sticky ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
kk@kk-laptop:~/down/emacs-23.2$ ls -l /usr/local/bin/emacs
-rwxr-xr-t 2 root root 10479250 2010-11-17 19:09 /usr/local/bin/emacs
 


需要 rm /usr/local/bin/ctags , 这个是emacs 自带的, 要删. 因为我平时用的是另一个 ctags + vim . 汗. 删了这个. 

 

牛.



有兴趣的朋友可以把源码打包成 deb 格式: http://www.debian.org/doc/maint-guide/index.zh-cn.html