apt-get แล้วเกือบเจ๊ง
www.tanabutr.co.th/photobook
เคยเขียนเรื่องเกี่ยวกับ apt-get ที่เกี่ยวกับเรื่องไม่ให้ apt-get อัปเกรดบางแพ็กเกจ. คราวนี้คล้ายๆกัีนจนจำไม่ได้ว่าเคยเขียนไปหรือยัง.
ปัญหาคือมีอยู่ว่าวันนี้ติดตั้ง Debian stable ไปแล้วอยากจะใช้แพ็กเกจบางอย่างของ testing หรือ unstable. ตรงนี้ทำได้โดยแก้ไฟล์ /etc/apt/sources.list เช่นเดิมมีอยู่ว่า
deb http://http.us.debian.org/debian stable main contrib non-free deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free deb http://security.debian.org stable/updates main contrib non-free
ก็อาจจะเพิ่มหนึ่งบรรทัดเป็น
deb http://http.us.debian.org/debian stable main contrib non-free
deb http://http.us.debian.org/debian testing main contrib non-free
deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
deb http://security.debian.org stable/updates main contrib non-free
แล้วก็ apt-get update ครั้งหนึ่ง. ทีนี้แหละบางทีอาจจะเจอปัญหา
... Get:6 http://http.us.debian.org testing/non-free Release [85B] Fetched 3923kB in 38s (101kB/s) Reading Package Lists... E: Dynamic MMap ran out of room E: Error occured while processing gimp-help-it (NewVersion1) E: Problem with MergeList /var/lib/apt/lists/http.us.debian.org_debian_dists_testing_main_binary-i386_Packages E: The package lists or status file could not be parsed or opened.
มี error ว่า "Dynamic MMap ran out of room". MMap เกี่ยวกับการจัดการหน่วยความจำ. ลองค้นหา google ก็มีคนเจอปัญหานี้เยอะ. สรุปว่า cache ไม่พอ, ต้องเพิ่มขีดจำกัดของ cache ให้มากขึ้นโดยการสร้างไฟล์ /etc/apt/apt.conf โดยมีเนื้อหาแบบนี้
APT::Cache-Limit "10000000";
ก็ไม่รู้เหมือนกันว่าค่าปริยายมันเท่าไร แต่ในตอนนี้ตั้งไว้ 10000000 ไบต์ (ประมาณ 10MB) ไปก่อน. ถ้าลองดูตั้งเป็น 1000000 ก็ยังมีปัญหาก็เลยตั้งค่าให้เยอะๆ. Cache-Limit จาก manpage ของ apt.conf เขาบอกว่า APT ใช้ fixed size memory mapped cache file เพื่อที่จะเก็บข้อมูลที่ available. ปัญหา "Dynamic MMap ran out of room" ก็คือที่ไม่พอ, ก็เลยต้องมาแก้ที่นี่แล้วก็จะ apt-get update ได้.
ทีนี้พอ apt-get install PACKAGE_NAME มันก็จะพยายามเอาแพ็กเกจของ testing มาโดยปริยาย. ผมชอบจะอยู่แบบ stable มากกว่าก็เลยต้องแก้ไฟล์ /etc/apt/apt.conf เป็นแบบนี้
APT::Cache-Limit "10000000";
APT::Default-Release "stable";
เวลา apt-get ก็จะได้แพ็กเกจจาก stable. แต่ถ้าอยากได้แพ็กเกจจาก testing ก็ใช้ตัวเลือก -t testing ร่วมกับ apt-get.
# apt-get -s install mysql-server
Reading Package Lists...
Building Dependency Tree...
Sorry, mysql-server is already the newest version.
0 packages upgraded, 0 newly installed, 0 to remove and 77 not upgraded.
www:/etc/apt# apt-get -s -t testing install mysql-server
Reading Package Lists...
Building Dependency Tree...
The following extra packages will be installed:
coreutils debianutils e2fslibs e2fsprogs gcc-4.0-base initscripts libacl1
libattr1 libblkid1 libc6 libgcc1 libmysqlclient15 libncurses5 libreadline5
libselinux1 libsepol1 libss2 libstdc++6 libuuid1 lsb-base mount mysql-client
mysql-client-5.0 mysql-common mysql-server-5.0 readline-common sysv-rc
sysvinit
The following packages will be REMOVED:
libreadline4
The following NEW packages will be installed:
coreutils e2fslibs gcc-4.0-base initscripts libacl1 libattr1 libblkid1
libmysqlclient15 libreadline5 libselinux1 libsepol1 libss2 libstdc++6
libuuid1 lsb-base mysql-client-5.0 mysql-server-5.0 readline-common sysv-rc
10 packages upgraded, 19 newly installed, 1 to remove and 112 not upgraded.
E: This installation run will require temporarily removing the essential package
e2fsprogs due to a Conflicts/Pre-Depends loop. This is often bad, but if you
really want to do it, activate the APT::Force-LoopBreak option.
E: Internal Error, Could not early remove e2fsprogs
มี error บอกด้วยว่าไม่ได้. ให้ไปใส่ APT::Force-LoopBreak ในไฟล์ apt.conf ก็เลยลองดู (เครื่องเจ๊งได้).
# echo 'APT::Force-LoopBreak "true";' >> /etc/apt/apt.conf
อ่านดูใน man apt.conf แล้วบอกว่า Force-LoopBreak นี่ไม่ควรใช้แ่ต่ผมก็ว่าลองดูแล้วกัน.
# apt-get -t testing install mysql-server
ติดตั้งโน่นนี่จนสุดท้ายไม่รอด. มี hint ให้ลอง apt-get -f install ไม่ต้องมีชื่อแพ็กเกจ. แก้ได้พอควรแต่ปรากฏว่า update-rc.d หายไป! โดนลบไปตั้งแต่เมื่อไรไม่รู้. เกือบจะเลิกแล้ว, ก็เลยลองเอา update-rc.d ของเครื่องอื่นมาใส่ให้แทน.
คราวนี้เอา APT::Force-LoopBreak ออก. แล้ว apt-get -f install. เสร็จแล้ว apt-get -t testing install mysql-server ก็ใช้ได้.
สรุปว่าไม่ควรใช้ APT::Force-LoopBreak เลย. และก็ไม่แนะนำผสม Debian ถ้าไม่จำเป็นจริงๆ. ครั้งนี้ไม่เป็นไร, ลองได้.