dpkg error: trying to overwrite X, which is also in package Y

今天ubuntu9.10 alpha4 升级出现了点问题:

Preparing to replace language-pack-zh 1:9.10 (using .../language-pack-zh_1%3a9.10+20090805_all.deb) ...
Unpacking replacement language-pack-zh ...
Preparing to replace language-pack-zh-base 1:9.10 (using .../language-pack-zh-base_1%3a9.10+20090805_all.deb) ...
Unpacking replacement language-pack-zh-base ...
dpkg: error processing /var/cache/apt/archives/language-pack-zh-base_1%3a9.10+20090805_all.deb (--unpack):
 trying to overwrite `/usr/share/locale-langpack/zh_TW/LC_MESSAGES/sed.mo', which is also in package language-pack-zh-hant-base
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Preparing to replace language-pack-gnome-zh 1:9.10 (using .../language-pack-gnome-zh_1%3a9.10+20090805_all.deb) ...
Unpacking replacement language-pack-gnome-zh ...
Preparing to replace language-pack-gnome-zh-base 1:9.10 (using .../language-pack-gnome-zh-base_1%3a9.10+20090805_all.deb) ...
Unpacking replacement language-pack-gnome-zh-base ...
dpkg: error processing /var/cache/apt/archives/language-pack-gnome-zh-base_1%3a9.10+20090805_all.deb (--unpack):
 trying to overwrite `/usr/share/locale-langpack/zh_TW/LC_MESSAGES/gnome-settings-daemon.mo', which is also in package language-pack-gnome-zh-hant-base

中文的显示是这样:

(正在读取数据库 ... 系统当前总共安装有 123909 个文件和目录。)
正在解压缩 language-pack-gnome-zh-hans-base (从 .../language-pack-gnome-zh-hans-base_1%3a9.10+20090819_all.deb) ...
dpkg:处理 /var/cache/apt/archives/language-pack-gnome-zh-hans-base_1%3a9.10+20090819_all.deb (--unpack)时出错:
 正试图覆盖“/usr/share/locale-langpack/zh_CN/LC_MESSAGES/gnome-settings-daemon.mo”,它属于软件包 language-pack-gnome-zh-base
dpkg-deb: 子进程 粘贴 被信号(Broken pipe)终止了
正在解压缩 language-pack-gnome-zh-hant-base (从 .../language-pack-gnome-zh-hant-base_1%3a9.10+20090819_all.deb) ...
dpkg:处理 /var/cache/apt/archives/language-pack-gnome-zh-hant-base_1%3a9.10+20090819_all.deb (--unpack)时出错:
 正试图覆盖“/usr/share/locale-langpack/zh_TW/LC_MESSAGES/gnome-settings-daemon.mo”,它属于软件包 language-pack-gnome-zh-base
dpkg-deb: 子进程 粘贴 被信号(Broken pipe)终止了
在处理时有错误发生:
 /var/cache/apt/archives/language-pack-gnome-zh-hans-base_1%3a9.10+20090819_all.deb
 /var/cache/apt/archives/language-pack-gnome-zh-hant-base_1%3a9.10+20090819_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

类似这样的错误:

dpkg: error processing /var/cache/apt/archives/AAA (–unpack):
trying to overwrite `/usr/lib/BBB', which is also in package CCC
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
AAA
E: Sub-process /usr/bin/dpkg returned an error code (1)
解决方法:

sudo dpkg -i –force-overwrite AAA

(give full path of AAA), and then run

sudo apt-get -f install

again.

[via(翻墙的需要..)]

php写的cet成绩批量查询

![php写的cet成绩批量查询][1]

一直都关注cnbeta的动态,没想到20号的时候登录尽然有这条新闻:“2009年6月CET6成绩于今天2009年8月20号早上9点公布” ,cnbeta现在是嘛新闻都出啊。于是乎就拿出了俺的“证件夹”,掏出了准考证开始查成绩,我对这个网上cet查分的网站的认识和评价基本上和"另一个角度看CET查分"一文一样,这次6级得到437分,感觉还是差不多了,因为还重来没有认认真真的停下来背单词、作题,除了考四级的时候作了一张模拟卷。

![php写的cet成绩批量查询][2]

这个查询网站通过ajax来查询,需要等待15秒的时间,每次限查询一人成绩,听说08年的时候还要安装activex控件才能查询,对于linux用户就恼火了。通过分析一下http://cet.99sushe.com/这个页面发现没有表单(form),而是这样一句:

调用了一个js函数submit_search(); 网页引用了一个js文件:http://cet.99sushe.com/res/js/cet0908.js 。内容如下。

var testid = "";
var score = "";
var contenthtml = "";
var sec = 15;  //默认等待15秒钟
String.prototype.trim  =  function(){
return  this.replace(/(^\s*)|(\s*$)/g,  ""); //javascrip没有自带trim函数,用来消除空白符
}
function gid(id) {return document.getElementById(id);} //返回表单输入的准考证号的值
function assertFormat(tid){   //检查准考证号格式
    var reg = /^\d{1,}$/;  //regexp 表示全部为数字
    if (!reg.test(tid) || tid.length != 15 || tid.substr(6, 3) != "091" || get_testtype(tid) == "") { //第6位其的三位数不是091的不准查,意思就是只能查09年上半年的成绩,而后用curl发现根本就没有其他几次考试的数据
    alert("准考证号格式不正确");
    return false;
}
else {
    for (var i = 1; i  0) { //15秒没有到
        gid("time").innerHTML = waitsec;
        waitsec--;
        setTimeout("wait_time(" + waitsec + ")", 1000);   //难道这就是传说的中递归调用函数?!
}
    else{
        showscore(score); //时间到了也该显示分数得了
    }
}
function showscore(tscore){
var name = "";
var school = "";
var sarray=new Array();
if(tscore != ""){
    sarray = tscore.split(',');//根据不同的考试类型来给sarray数列赋值
if (sarray.length >= 7) {
    name = sarray[6];
    school = sarray[5];
}
else {
    name = sarray[2];
    school = sarray[1];
}
}
var resulthtml = "
2009年6月考试成绩查询结果:
";
resulthtml += "  考生姓名: "+name+"";
resulthtml += "
学校: " + school + "";
resulthtml += "
考试类别: ";
resulthtml += get_testtype(testid);
resulthtml += "  ";
resulthtml += "
准考证号: ";
resulthtml += testid;
resulthtml += "
";
if(tscore == "") resulthtml += "无法找到对应准考证号的分数,请确认你输入的准考证号无误";
else {
if (sarray.length >= 7) {
resulthtml += "
您的成绩总分:
" + sarray[4] + "
";
resulthtml += "
听力:
" + sarray[0] + "
";
resulthtml += "
阅读:
" + sarray1 + "
";
resulthtml += "
综合:
" + sarray2 + "
";
resulthtml += "
写作:
" + sarray[3] + "
";
}
else {
resulthtml += "
您的成绩总分:
" + sarray[0] + "
";
}
}
resulthtml += "
姓名中的生僻字可能无法正常显示,以成绩单为准
";
resulthtml += "
";
resulthtml += "
";
gid("content").innerHTML = resulthtml; //通过js写html到dom上,用IE,firefox默认的源代码查看工具都没有发现源代码的变化,但是firefox扩展firebug就能看到,看来还是firebug牛逼。
}
function re_search() { //清空数据
var testid = "";
var score = "";
gid("content").innerHTML = contenthtml;
}
function get_testtype(tid) { //根据考号得到考试类型
switch (tid.substr(9, 1)) {
case "1": return "英语四级";
case "2": return "英语六级";
case "3": return "日语四级";
case "4": return "日语六级";
case "5": return "德语四级";
case "7": return "俄语四级";
case "9": return "法语四级";
default: return "";
}
}
function search(tid){ //通过ajax post数据"id="+xxxxxxxxxxxxxxx
var ajax = new Ajax();
ajax.Post("/getscore.html", "id="+tid, search_callback); //这个就是关键,通过post发送数据到getscore.html来完成查询。
}
function search_callback(success, responsetext) {
if (success) {
score = responsetext;
//showscore(score);
}
else {
search(testid);
}
}

总结起来就是向getscore.html post一个数据"id="+xxxxxxxxxxxx

可以通过curl向指定的服务器发送数据包,具体方法此文 “斗智斗勇续 四六级查分技巧” 有介绍,需要注意的一点是查询的服务器有referer验证,referer验证一般用来防盗链,防止数据从非本站的提交上去,不过自定义referer并不是什么好难的事情,此为的作者还做了一个c#的gui前端,基本上就是把cmd的输出放在gui界面上,没有多大的意义。这个 “CET在线连续查分程序” 是别人用c#弄的一个在线查询,可以指定准考证号的起始号码和结束号码,就可以连续查询了。

然后我受到这样的启发,做了一个php版本的,演示地址:http://tunpishuang.iamspace.com/cet.php , 和c#那个略有不同的是并不是指定起始和结束地址,而是直接输入前6位,最多输出6000人的成绩,我贴一下源代码:

2009年上半年CET院校成绩批量查询 by tunpishuang
#description{
    border:solid 4px 4px 10px 4px #828282;
    color:#8B0000;
    width:420px;
}
#form{
    border:solid 4px #828282;
    color:#8B0000;
    width:520px;
}
2009年上半年CET院校成绩批量查询 by tunpishuang
A.前6位是地区号.(可以问与你同一城市报名的任何一人)
B.然后是071 (表示07年的第1次,即07年6月份的)
C.然后是1或2 (1代表四级,2代表6级)
D.然后的三位是你的考场号,多为0**或1**
E.最后两位是你的座位
单人成绩查询(输入准考证号)
院校成绩查询(输入准考证号前六位)
这个查询程序草草完工,有待完善的地方,但是我不想弄了,弄老一天,人都矿鸟
有空到我博客来耍哈,http://tunps.com

cet_query.php

本博升级到wordpress 2.8.4

wordpress程序的更新确实很快,有时候升级起来都觉得麻烦,担心出现兼容性的问题,记得最后一次升级是升级到2.7.1解决了一个WordPress2.7.1升级超时问题。

我的方法是:

首先一定要做好的工作就是备份,要是没有备份就升级,要是出了问题就完蛋了。我把备份的sql导入本地搭建的wordpress2.8.4,首先查看本地的wordpress升级后运行有没有问题。具体的做法是:

  • cn.wordpress.com下载最新中文版的wordpress。
  • 使用wordpress database backup插件导出sql
  • 本地安装phpnow之类的amp套件,登录自带的phpmyadmin,然后建立一个数据库,比如叫做wordpress。
  • 修改下载下来的wordpress2.8.4-zh_CN根目录下载wp-config-sample.php 改名为wp-config.php 然后打开wp-config.php添加上自己的数据库名,用户名和密码。
  • 用ultrastudio打开sql文件,批量替换http://tunps.com 为http://localhost/wordpress 保存
  • 在phpmysql导入sql文件,打开http://localhost/wordpress/wp-admin/ 应该可以看到升级数据库结构的网页,点升级。
  • 浏览网页是否正常,我浏览自己的主页正常,但是进入单个页面就自动转入主页,或者显示404错误,解决的方法是:打开apache2的配置文件httpd.conf 确认
  • LoadModule rewrite_module modules/mod_rewrite.so 这句前面没有#符号,

    Options FollowSymLinks
    AllowOverride No  //改为AllowOverride All
    Order deny,allow  //改为Order allow,deny
    Deny from all  //改为Allow from all


     

    重启动apache2,再次浏览就没有问题了。

  • 确认本地的没有问题后,在后台,禁用所有插件,使用wordpress默认主题,移除所有小工具。然后直接点“自动升级”,等待4-5分钟,升级完成了,然后进自己的页面看看有没有错误,将出错的插件禁用,然后升级插件或者琢磨其他的方法。

  • 最后将自己的主题还原,小工具都添加上,搞定。

此文是2.8.4升级后的第一文,给我的感觉布局没有太大的变化,后台看稍加的清爽了一下,后台的配色我喜欢,估计是因为之前那个灰色有点审美疲劳了,其他的还在挖掘中。

用gpg(Gnu 隐私卫士)来生成自己的密钥

root@ubuntu:/mirrors/debian# gpg -bao dists/karmic/Release.gpg dists/karmic/Release
gpg: directory `/home/tun/.gnupg' created
gpg: new configuration file `/home/tun/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/tun/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/tun/.gnupg/secring.gpg' created
gpg: keyring `/home/tun/.gnupg/pubring.gpg' created
gpg: no default secret key: secret key not available
gpg: signing failed: secret key not available

当执行以上蓝色字体的命令的时候出错了。这个命令功能是生成Release文件的gpg密钥。从字面意思来理解应该是gpg没有默认的gpg密钥, 参照这个minihowto: Gnu 隐私卫士 (GnuPG) 袖珍 HOWTO (中文版) 发现可以用gpg –gen-key来生成自己的密钥:(蓝色字体是我输入的)

root@ubuntu:/mirrors/debian# gpg –gen-key
gpg (GnuPG) 1.4.9; Copyright (C) 2008 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) (直接回车)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
  = key expires in n days
w = key expires in n weeks
m = key expires in n months
y = key expires in n years
Key is valid for? (0) (直接回车)
Key does not expire at all
Is this correct? (y/N) y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
“Heinrich Heine (Der Dichter) heinrichh@duesseldorf.de

Real name: tunpishuang
Email address: tunpishuang@gmail.com
Comment: just 4 fun.
You selected this USER-ID:
“tunpishuang (just 4 fun.) tunpishuang@gmail.com

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
You need a Passphrase to protect your secret key.

gpg: gpg-agent is not available in this session
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
++++++++++++++++++++++++++++++.+++++.++++++++++++++++++++++++++++++.++++++++++++++++++++++++++++++.+++++++++++++++++++++++++.+++++.+++++>+++++.+++++……………..>+++++…+++++
ds
Not enough random bytes available.  Please do some other work to give
the OS a chance to collect more entropy! (Need 283 more bytes)
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
+++++…++++++++++..++++++++++.++++++++++..+++++++++++++++..+++++…++++++++++++++++++++.+++++++++++++++++++++++++.+++++..++++++++++++++++++++++++++++++…+++++..+++++>…++++++++++>+++++.>.+++++……<.+++++……………..<+++++>..+++++…………………………………………………………………………………………………………………………………………..<+++++…>+++++…………………………………..+++++^^^^^^^^^

(上面这一砣蓝字的主要意思是通过移动鼠标和写入/输出硬盘数据来生成随机数字,我一般使用du / 命令)
gpg: key EDA38ECC marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   1024D/EDA38ECC 2009-08-20
Key fingerprint = 8B43 BB97 2716 0124 83C5  D73B DEE3 732F EDA3 8ECC
uid                  tunpishuang (just 4 fun.) tunpishuang@gmail.com
sub   2048g/15197563 2009-08-20

root@ubuntu:/mirrors/debian# gpg –list-keys    (生成成功了)
/home/tun/.gnupg/pubring.gpg
-—————————
pub   1024D/EDA38ECC 2009-08-20
uid                  tunpishuang (just 4 fun.) tunpishuang@gmail.com
sub   2048g/15197563 2009-08-20

root@ubuntu:/mirrors/debian# apt-key list (通过这个我们发现改gpg的key和apt的key不是一个库的,但是可以通过gpg导入到apt-key中)
/etc/apt/trusted.gpg
——————–
pub   1024D/437D05B5 2004-09-12
uid                  Ubuntu Archive Automatic Signing Key ftpmaster@ubuntu.com
sub   2048g/79164387 2004-09-12

pub   1024D/FBB75451 2004-12-30
uid                  Ubuntu CD Image Automatic Signing Key cdimage@ubuntu.com

root@ubuntu:/mirrors/debian# gpg -bao dists/karmic/Release.gpg dists/karmic/Release (执行成功)

You need a passphrase to unlock the secret key for (这点输入私人密钥就ok)
user: “tunpishuang (just 4 fun.) tunpishuang@gmail.com
1024-bit DSA key, ID EDA38ECC, created 2009-08-20

gpg: gpg-agent is not available in this session

iceweasel(firefox)的kde4主题:KFirefox

才安装好kde4.3,发现iceweasel(也就是firefox)的默认主题十分的丑陋,或许是因为我用的是kde桌面环境,而firefox for linux是用gtk+开发,于是乎发现了个仿kde4的主题:KFirefox , 主页和下载地址:http://ramonantonio.net/kde-firefox/

对比一下安装。安装前:

安装后:

debian amd64安装flashplayer

7/30/09之前64位的机子一直都是用nspluginwrapper来模拟运行32位的浏览器插件,不过7/30/09那天,adobe发布了flashplayer 64bit for linux alpha, 可以从这个页面下载:http://labs.adobe.com/downloads/flashplayer10.html 。直接下载(最新版本是10.0.32.18)。

Download 64-bit Plugin for Linux (TAR.GZ, 3.64 MB)

下载下来后

tar zxvf libflashplayer-10.0.32.18.linux-x86_64.so.tar.gz
mkdir /usr/bin/iceweasel/plugins/
cp libflashplayer.so /usr/bin/iceweasel/plugins/

重启iceweasel,搞定。在youku, tudou , vimeo上溜达了一圈没有任何问题。

trying to overwrite `/usr/bin/keditfiletype’, which is also in package kcontrol

因为前几天硬盘出现故障,老是进不了windows,没办法,开始不知道,傻傻的以为是系统问题,就安装了debian 5.02,也就是最新的debian/linux稳定版lenny。结果安装的时候也提示install failed , 昨天跑到街上买了根sata数据线,结果机子尽然可以用了,难道真的是数据线的问题? 不过可以用就行了,不怕找不到娱乐工具了。我安装的是debian 5.02 amd64的基本系统,以前一直用gnome,现在想换换胃口就安装了kde,主要是被kde4的华丽丽的界面给征服鸟。找任意一个编辑器把一下内容写入/etc/apt/sources.list ,我电信的,这个源是中国科大的,贼快哦。

deb http://211.86.156.210/debian/ unstable main non-free contrib
deb http://211.86.156.210/debian-multimedia/ unstable main
deb http://211.86.156.210/debian-security/ testing/updates main

debian 和 debian-multimedia 库都是用的unstable版本,因为只有unstable的kde版本才是最新的4.3 ,debian-security用来打安全补丁。

运行

apt-get update
apt-get install x-window-system kde
apt-get dist-upgrade

直接startx kde4.3就安装好了。

--------------------华丽丽分割现---------------

其实本来安装是没有这样的顺利的,本来开始用的是mirrors.163.com这个源,但是在apt-get dist-upgrade后,出现了下面的错误:

Preparing to replace kdebase-runtime 4:4.2.4-2 (using …/kdebase-runtime_4%3a4.3.0-1_amd64.deb) …
Unpacking replacement kdebase-runtime …
dpkg: error processing /var/cache/apt/archives/kdebase-runtime_4%3a4.3.0-1_i386.deb (–unpack):
trying to overwrite `/usr/bin/keditfiletype’, which is also in package kcontrol

看字面意思来解释,应该是kdebase-runtime_4:4.3.0-1_amd64.deb这个包和之前安装的kcontrol发生了冲突。google了半天,发现这个是个bug:http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=540009

修复的方法是:

cd /var/lib/dpkg/info
rm -rf kdebase-runtime.*
rm -rf kcontrol.*
apt-get -f install

然后换成科大的源,重新下载安装。 查看了kdebase-runtime_4.3.0-2的changlog,这个bug已经修正了:

+++ Changes by Modestas Vainius:

  • Merge kdebase-runtime-data-common to kdebase-runtime-data.
  • Merge kdebase-runtime-bin-kde4 to kdebase-runtime.
  • kdebase-runtime conflicts with kcontrol. (Closes: <a class="buglink" href="http://bugs.debian.org/540009">#540009</a>).
  • Urgency medium due to RC bugfix.
  • Add build depend on libslp-dev.

我后来查看了mirrors.163.com的套件库,已经修正的包是存在的:

kdebase-runtime_4.3.0-2_amd64.deb 06-Aug-2009 00:03 2466466

但是我们用apt-get update 下载下来163的包索引文件:

Packages.bz2 05-Aug-2009 16:15 6028664

并没有及时的更新,日期是8月5日生成不信可以抓下来bzip2 -d -v Packages.bz2 然后 less Packages 搜索Filename: pool/main/k/kdebase-runtime 发现版本还是4.3.0-1。

Packages.bz2 11-Aug-2009 22:27 5.8M

上面这个是科大的,8月11日生成,这个:Wed, 05 Aug 2009 13:30:30 +0200 是bug修复的日期,可见及时更新Packages包索引是多么的重要啊。