2013年3月15日 星期五

gdb: error while loading shared libraries: libexpat.so.0: cannot open shared object file: No such file or directory @ Ubuntu 12.04 Server 64Bit

原先以為安裝 libexpat1-dev 後即可解決,但有更多細節該留意,就順手記一下吧


$ sudo find / -name "libexpat.so*"
/lib/x86_64-linux-gnu/libexpat.so.1.5.2
/lib/x86_64-linux-gnu/libexpat.so.1
$ sudo ln -s /lib/x86_64-linux-gnu/libexpat.so.1 /lib/i386-linux-gnu/libexpat.so.0
$ sudo ldconfig
$ gdb
gdb: error while loading shared libraries: libexpat.so.0: wrong ELF class: ELFCLASS64
$ sudo apt-get install ia32-libs
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:


The following packages have unmet dependencies:
ia32-libs : Depends: ia32-libs-multiarch
E: Unable to correct problems, you have held broken packages.
$ dpkg --print-architecture
amd64
$ dpkg --print-foreign-architectures
i386
$ sudo unlink /lib/i386-linux-gnu/libexpat.so.0
$ sudo apt-get install libexpat1-dev:i386
$ sudo ln -s /lib/i386-linux-gnu/libexpat.so.1 /lib/i386-linux-gnu/libexpat.so.0
$ gdb

(gdb)


2013年3月9日 星期六

[C] XML parser using libroxml

複習一下 C 語言和 cmake 用法,這次用 C 來解 XML,至於為何要用 libroxml(LGPL) 嘛,只是單純碰到就用看看(且預設支援cmake),下次再改用 libxml2(MIT)。


處理一些 XML 時,會需要排版一下才方便人眼查看,這時就用到 Online XML Formatter 來格式化一下。


筆記:https://github.com/changyy/c-xml-parser-using-libroxml


$ git clone --recursive git://github.com/changyy/c-xml-parser-using-libroxml.git
$ cd c-xml-parser-using-libroxml
$ mkdir build
$ cd build
$ cmake ..
$ ./c-xml-parser


2013年3月3日 星期日

We Are Young!


這首歌的意境有很多的解釋方向,但此刻就不多說,享受那股年輕氣盛吧!最近花了兩個週末補齊了我錯估時程的工作 :P 真的,用說的都嘛比較快,不知不覺就說錯看錯估錯寫錯...


對這首歌歌詞有興趣的可以參考 fun.搖滾樂團-we-are-young-ft.-janelle-monáe-【中英歌詞】,翻的還不賴。


Tonight
We are young
So let's set the world on fire
We can burn brighter than the sun


最近周邊人的轉職、猶豫,都常讓我回顧自己去年的選擇方式,的確,就那幾個字罷了,我們還年輕,再衝動一點、再勇敢一點,再給自己多一點時間來驗證吧!


2013年3月1日 星期五

Redmine - 修正檔案上傳失敗

用 Redmine 附檔時只會看到 Internal Server Error 資訊,翻了 /var/log/apache2/error.log 後,看到了神祕句子:


Unexpected error in mod_passenger: An error occured while buffering HTTP upload data to a temporary file in /tmp/passenger.1.0.7336/generation-0/buffered_uploads. The current Apache worker process (which is running as XXX) doesn't have permissions to write to this directory. Please change the permissions for this directory (as well as all parent directories) so that it is writable by the Apache worker process, or set the 'PassengerUploadBufferDir' directive to a directory that Apache can write to.
Backtrace:
  in 'boost::shared_ptr<Passenger::BufferedUpload> Hooks::receiveRequestBody(request_rec*)' (Hooks.cpp:1321)
  in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:585)


這時我才想到,因為我在 Apache 設定時,透過 passenger 並指定 XXX 權限跑 redmine 的,因此會碰到 XXX 無法存取 /tmp 裡頭相關的位置,解法…那就是多建立一個目錄給 redmine 使用吧 :P


$ sudo su XXX
$ mkdir /path/redmine/PassengerUploadBufferDir
$ exit
$ sudo vim /etc/apache2/conf.d/redmine
Alias /redmine "/path/redmine/public"
RailsBaseURI /redmine
<Directory /path/redmine/public>
  AssignUserId XXX XXX
  PassengerUploadBufferDir /path/redmine/PassengerUploadBufferDir
  AllowOverride all
  Options -MultiViews
</Directory>


Redmine - 修正 attachments 資料

忘記是從哪個版本開始 XD 總之,現在將 Redmine 升到 2.3.0.devel 版本,請參考官方:http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade


後來發現,以前的 attachments 都不能下載,仔細確認後,發現這跟 db schema 有關,直接翻 db 後,發現多了個欄位 disk_directory,所以在 redmine/files 規劃已經改成 redmine/files/YEAR/MONTH 的結構,故只需建立對應的結構後,在把 db 資料更新一下即可,如:


$ mkdir -p /path/redmine/files/2013/01
$ mv /path/redmine/files/* /path/redmine/files/2013/01
$ cp /path/redmine/db/production.db /path/redmine/db/production.db-backup
$ sqlite3 /path/redmine/db/production.db
sqlite> SELECT * FROM attachments WHERE ifnull(disk_directory,'') = '';
sqlite> UPDATE attachments SET disk_directory = "2013/01" WHERE ifnull(disk_directory,'') = '';


收工