Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

2010-10-08

approx

打包时经常需要反复下载一些包, 如果你的网速不够快,建议安装 approx 透明代理, 可以缓存大部分包。

1. 如何安装 approx
安装方法: "sudo apt-get install approx", 然后修改配置文件 /etc/approx/approx.conf 为
ubuntu http://cn.archive.ubuntu.com/ubuntu
debian http://mirrors.163.com/debian
修改 /etc/apt/sources.list, 修改为如下的内容
deb http://127.0.0.1:9999/ubuntu lucid main restricted universe multiverse
deb http://127.0.0.1:9999/ubuntu lucid-security main restricted universe multiverse
deb http://127.0.0.1:9999/ubuntu lucid-updates main restricted universe multiverse

2. approx 的优点
2.1 可以在局域网内共享, approx 缺省绑定在 0.0.0.0, 所以一个局域网内用户可以共享这个源,互相加速, 如果使用安装法部署大量机器时也非常快速
2.2 i386 和 amd64 系统可以互相加速(因为可以互相共享架构无关的包),karmic 和 lucid 也可以互相共享包 (某些包在这两个版本是一致的), 但 debian 和 ubuntu 之间不能共享包
2.3 即使单人使用, approx 也很有帮助,比如可以快速重建 linux chroot, pbuilder, 或者在虚拟机内重装一份debian/ubunu
2.4 可以模拟多线程下载,比如你要同时安装 vim 和 emacs, 可以先运行 "sudo apt-get install vim", 然后在下载时按 Ctrl+C 终端,然后运行 "sudo apt-get install emacs23", 这时候 approx 会在后台帮你下载 vim 所需的包 (一般会帮你下载前面5个)
2.5 智能cache, debian/ubuntu 仓库有逐级签名, approx 能快速判定一个文件,是不是完整的,是不是最新的, 也可以定时清理掉不再被使用的文件。

2010-10-02

在 Ubuntu 构建 Debian 打包环境

0. 原因
尽管你是在 Ubuntu 下工作,但由于种种原因[1],你还是需要给 Debian 做打包工作,如果你不想你做的包因为一些简单的错误被退回,比如无法在 Debian 下编译,没有处理好 lintian 警告,那么最好在 Ubuntu 下给 Debian 打包的环境,步骤如下所示:

1. 安装 approx
打包时经常需要反复下载一些包, 如果你的网速不够快,建议安装 approx 透明代理, 可以缓存大部分包。安装方法: "sudo apt-get install approx", 然后修改配置文件 /etc/approx/approx.conf 为
ubuntu http://cn.archive.ubuntu.com/ubuntu
debian http://mirrors.163.com/debian

2. 修改 /etc/apt/sources.list, 修改为如下的内容
deb http://127.0.0.1:9999/ubuntu lucid main restricted universe multiverse
deb http://127.0.0.1:9999/ubuntu lucid-security main restricted universe multiverse
deb http://127.0.0.1:9999/ubuntu lucid-updates main restricted universe multiverse

3. 安装工具包, 运行 "sudo apt-get install ubuntu-dev-tools cowbuilder"

4. 准备 cowbuilder-sid
$ sudo cp /usr/bin/pbuilder-dist /usr/bin/cowbuilder-sid
$ sudo sed -ie 's,ftp://ftp.debian.org/debian,http://127.0.0.1:9999/debian,' /usr/bin/cowbuilder-sid

5. 准备开发环境
$ sudo mkdir /var/cache/pbuilder-dist/sid_result
$ cowbuilder-sid create

6. 开始开发
$ dget http://ftp.debian.org/debian/pool/main/h/hello/hello_2.6-1.dsc
$ dpkg-source -x hello_2.6-1.dsc
$ cd hello-2.6
$ # 修改 debian 包,版本改为 2.6-2
$ debuild -S -sa
$ cd ..
$ cowbuilder-sid hello_2.6-2.dsc # 使用 sid 环境进行编译

7. 检查
7.1 安装最新版的 lintian
Ubuntu 自带的 lintian 版本不够新,需要从 Debian 安装最新版本
$ # 到 http://ftp.us.debian.org/debian/pool/main/l/lintian/ 下载最新版本的 lintian
$ wget http://ftp.us.debian.org/debian/pool/main/l/lintian/lintian_2.4.3_all.deb
$ sudo dpkg -i lintian_2.4.3_all.deb
$ sudo apt-get -f install

7.2 对包做最后的检查
$ cd /var/cache/pbuilder-dist/sid_result
$ lintian -i hello_2.6-2_amd64.changes
$ #如果上一步出现错误,则继续修正
$ debsign hello_2.6-2_amd64.changes #签名

8. 上传
根据 http://mentors.debian.net/cgi-bin/maintainer-intro 的介绍准备好 mentors.debian.net 的上传的环境, 然后用如下的命令上传
$ dput mentors hello_2.6-2_amd64.changes

9. 召唤 Debian Developer (DD)
到 mentors.debian.net, 登录后可以找到一份模板邮件, 把模板邮件中的内容填好,然后发到 debian-mentors@lists.debian.org
如果你有相熟的 DD, 也可以直接发信给他让他帮忙检查。

2009-05-01

debian/control: switch between debian and ubuntu format


#!/usr/bin/env python

import logging
import sys

log = logging.getLogger(__name__)

def main():
lines = file('debian/control').readlines()

l1 = None
l2 = None

for idx, x in enumerate(lines):
if x.startswith('Maintainer:'):
l1 = idx
elif x.startswith('XSBC-Original-Maintainer:'):
l2 = idx

if l1 is None:
log.error("can't find maintainer line")
sys.exit(1)

isUbuntu = l2 is not None

if isUbuntu:
maintainer = lines[l2].lstrip('XSBC-Original-Maintainer:').strip()
else:
maintainer = lines[l1].lstrip('Maintainer:').strip()

if isUbuntu:
lines[l1] = 'Maintainer: %s\n' % maintainer
del lines[l2]
else:
lines[l1] = 'Maintainer: Ubuntu MOTU Developers <ubuntu-motu@lists.ubuntu.com>\n' \
+ 'XSBC-Original-Maintainer: %s\n' % maintainer

file('debian/control', 'w').writelines(lines)

if __name__ == '__main__':
main()

2009-02-14

tegaki 0.1 is ready for ubuntu 8.10 (a handwriting input method)

Hello,

tegaki 0.1 is ready for ubuntu 8.10 in my ppa. (need more refinement before submit it to the Debian/Ubuntu official repos)

tegaki provide a handwriting input method for scim, support japanese and simplified chinese.

INSTALL:


  1. add the following line to your /etc/apt/sources.list:

    deb http://ppa.launchpad.net/lidaobing/ppa/ubuntu intrepid main

  2. run "sudo apt-get update"

  3. run "sudo apt-get install scim-tegaki"

  4. if you want to recognize Simplified Chinese, run "sudo apt-get install tegaki-zinnia-simplified-chinese"

  5. if you want to recognize Japanese, run "sudo apt-get install tegaki-zinnia-japanese"



这个情人节过得很充实

ibus 0.1.1 for ubuntu 8.10 is ready

Hello,

I have add ibus 0.1.1 to my ppa (ubuntu 8.10), you can install this by add the following line to your /etc/apt/sources.list:

deb http://ppa.launchpad.net/lidaobing/ppa/ubuntu intrepid main


all packages are in this site except two:
1. ibus-chewing: have some packaging issue not resolved.
2. ibus-table-zengma: law issue

this site is slow in China (also slow for me), if anyone want to setup (or already have setup) a mirror for this site, leave me a information, thanks.

2009-02-07

dell inspiron 1420 打开 mic 的方法

启动 gnome-volume-control 后

1. Device 选择 HDA Intel (Alsa mixer)
2. 选择 Options Tab
3. Digital Input Source 改为 Digitial Mic 1

2008-12-28

sprintf/snprintf 陷阱

最近 ubuntu/debian 正在讨论 sprintf/snprintf 的问题,我在这描述一遍。

sprintf 的原型为:
int sprintf(char *restrict s, const char *restrict format, ...);

其中 char* restrict s 的含义为通过s 指向的内存空间不得与其他指针参数指向的内存的空间重叠。比如如下的语句就是错误的用法, 因为参数1与参数3指向的内存重叠了。但这种做法作为增强版的 strcat 已被广泛使用。

sprintf(buf, "%s foo %d %d", buf, var1, var2);

在 ubuntu 8.10 所带的 gcc 中,如果编译时加入了优化选项(比如 -O1, -O2), 那么sprinf 会首先将 s 清空,比如如下的程序会输出 "fail", 而不是 "not fail"。

#include
char buf[80] = "not ";
int main()
{
sprintf(buf, "%sfail", buf);
puts(buf);
return 0;
}






作为补救方案,可以使用如下的语句来代替:

sprintf(buf+strlen(buf), " foo %d %d", var1, var2);

snprintf 有类似的 bug.

很多 Debian/Ubuntu 包都有此 bug,可以参见如下两个 thread 中的具体内容

[1] https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/305901
[2] http://groups.google.com/group/linux.debian.devel/browse_thread/thread/c5bbda39f1a01bd4