2009年11月20日 星期五

[Linux] Eclipse & Subclipse Plugin (SVN Client) - Change/Clear SVN User/Password @ Ubuntu 9.10

在 Ubuntun 9.10 i386 Desktop 環境,安裝 Eclipse 3.5.1 with Sublcipse 1.0.0 版。


製作一份共用的 VMWare Image 檔互傳使用,並使用 Eclipse 與 Svn 管理案子,因此碰到如何移除 SVN 所紀錄的 User & Password 問題,找了很久並未發現 Eclipse 或 Subclipse 介面上有無去除密碼的方式,最後選擇直接砍掉儲存密碼的檔案,如此一來,把 VMWare Image 傳給其他人時,第一次使用就會詢問帳號密碼,以此讓使用者以自己的帳號進行專案的管理。


Subclipse 儲存密碼的資訊:



  • 檔名:.keyring

  • 位置:$HOME/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.core.runtime/.keyring

  • 動作:# rm $HOME/.eclipse/org.eclipse.platform_3.5.0_155965261/configuration/org.eclipse.core.runtime/.keyring
     (記得先備份,以免出事)


另外,如果有用到 Subversion 時,可能也會有一樣的問題,這時也可以移除紀錄帳密的檔案來達到一樣效果:



  • 目錄:auth

  • 位置:$HOME/.subversion/auth

  • 動作:# rm -r $HOME/.subversion/auth (記得先備份,以免出事)


參考資料



[Linux] Update Manager : An error occurred during the signature verification (Hash Sum mismatch) @ Ubuntu 9.10

前陣子安裝 Ubuntu 9.10 i386 Desktop ,印象中當時作系統更新時還算正常,但之後改過 /etc/hostname ,也不知何時開始,更新作業系統就無法成功,出現的訊息大多是 Hash Sum mismatch ,後來試了這篇 [ubuntu] Update Manager Problem... Invalid signature? - Page 2 - Ubuntu Forums ,看到許多人說 Aearenda 提到的更新 /etc/hostname 與 /etc/hosts 的修正,就可以更新成功囉!可惜的,我仍沒有解決這個問題,或採用下面指令也是如此。



  • # sudo apt-get update -o Acquire::http::No-Cache=True


但我發現,我有一台主機 Ubuntu 9.04 的,使用上述的方式的確有效,但 Ubuntu 9.10 依舊沒有解決。慶幸的最後仍有找到方式,以下是相關的執行樣貌,最後我是使用 Bug #24234 in apt (Ubuntu): “apt-get update failing with bad signature.” finjay 提到的解法,解決了 Ubuntu 9.10 的更新問題!



  • sudo apt-get clean

  • cd /var/lib/apt

  • sudo mv lists lists.old

  • sudo mkdir -p lists/partial

  • sudo apt-get clean

  • sudo apt-get update


我嘗試的流程:



  1. 使用 sudo apt-get update -o Acquire::http::No-Cache=True ,但仍無解決

  2. 使用修正 /etc/hosts 與 /etc/hostname 的關係,仍無解決

  3. 最後使用 finjay 提到的解法,就更新成功囉



以下是一些相關的錯誤訊息,也忘了到底是在那個階段出現的 :P 畢竟兩種是接續著試,有無相依性也不確定,再說問題解決後環境也不再,無法再測試,僅留下來當作參考囉。


user@Ubuntu910:~$ sudo apt-get update
Hit http://tw.archive.ubuntu.com karmic Release.gpg
Ign http://tw.archive.ubuntu.com karmic/main Translation-en_US
Ign http://tw.archive.ubuntu.com karmic/restricted Translation-en_US
Ign http://tw.archive.ubuntu.com karmic/universe Translation-en_US
Ign http://tw.archive.ubuntu.com karmic/multiverse Translation-en_US
Get:1 http://tw.archive.ubuntu.com karmic-updates Release.gpg [189B]
Ign http://tw.archive.ubuntu.com karmic-updates/main Translation-en_US
Ign http://tw.archive.ubuntu.com karmic-updates/restricted Translation-en_US
Ign http://tw.archive.ubuntu.com karmic-updates/universe Translation-en_US
Ign http://tw.archive.ubuntu.com karmic-updates/multiverse Translation-en_US
Hit http://tw.archive.ubuntu.com karmic Release
Get:2 http://tw.archive.ubuntu.com karmic-updates Release [44.1kB]
Hit http://tw.archive.ubuntu.com karmic/main Packages
Err http://tw.archive.ubuntu.com karmic-updates Release

Hit http://tw.archive.ubuntu.com karmic/restricted Packages
Hit http://tw.archive.ubuntu.com karmic/main Sources
Hit http://tw.archive.ubuntu.com karmic/restricted Sources
Hit http://tw.archive.ubuntu.com karmic/universe Packages
Hit http://tw.archive.ubuntu.com karmic/universe Sources
Hit http://tw.archive.ubuntu.com karmic/multiverse Packages
Hit http://tw.archive.ubuntu.com karmic/multiverse Sources
Hit http://security.ubuntu.com karmic-security Release.gpg
Ign http://security.ubuntu.com karmic-security/main Translation-en_US
Ign http://security.ubuntu.com karmic-security/restricted Translation-en_US
Ign http://security.ubuntu.com karmic-security/universe Translation-en_US
Ign http://tw.archive.ubuntu.com karmic-updates/multiverse Translation-en_US
Hit http://tw.archive.ubuntu.com karmic Release
Get:2 http://tw.archive.ubuntu.com karmic-updates Release [44.1kB]
Hit http://tw.archive.ubuntu.com karmic/main Packages
Err http://tw.archive.ubuntu.com karmic-updates Release

Hit http://tw.archive.ubuntu.com karmic/restricted Packages
Hit http://tw.archive.ubuntu.com karmic/main Sources
Hit http://tw.archive.ubuntu.com karmic/restricted Sources
Hit http://tw.archive.ubuntu.com karmic/universe Packages
Hit http://tw.archive.ubuntu.com karmic/universe Sources
Hit http://tw.archive.ubuntu.com karmic/multiverse Packages
Hit http://tw.archive.ubuntu.com karmic/multiverse Sources
Hit http://security.ubuntu.com karmic-security Release.gpg
Ign http://security.ubuntu.com karmic-security/main Translation-en_US
Ign http://security.ubuntu.com karmic-security/restricted Translation-en_US
Ign http://security.ubuntu.com karmic-security/universe Translation-en_US
Ign http://security.ubuntu.com karmic-security/multiverse Translation-en_US
Hit http://security.ubuntu.com karmic-security Release
Hit http://security.ubuntu.com karmic-security/main Packages
Hit http://security.ubuntu.com karmic-security/restricted Packages
Hit http://security.ubuntu.com karmic-security/main Sources
Hit http://security.ubuntu.com karmic-security/restricted Sources
Hit http://security.ubuntu.com karmic-security/universe Packages
Hit http://security.ubuntu.com karmic-security/universe Sources
Hit http://security.ubuntu.com karmic-security/multiverse Packages
Hit http://security.ubuntu.com karmic-security/multiverse Sources
Fetched 190B in 11s (16B/s)
Reading package lists... Done
W: A error occurred during the signature verification. The repository is not updated and the previous index files will be used.GPG error: http://tw.archive.ubuntu.com karmic-updates Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>

W: Failed to fetch http://tw.archive.ubuntu.com/ubuntu/dists/karmic-updates/Release

W: Some index files failed to download, they have been ignored, or old ones used instead.


2009年11月17日 星期二

[Linux] 設定 Objective-C 開發環境及教學資料 @ Ubuntu 9.10

差不多該學學 Objective-C 了,手邊也有 iphone 及相關的環境可開發,剩下只有懶散的心情要整頓。至於什麼是 Objective-C ,可以先看看維基百科的介紹,我覺得還滿詳盡的,甚至英文版還有介紹從 C/C++ 跨到 Objective-C 的範例程式,真的就乾心哩,看程式比看英文快上十倍啊。



跟 iphone 開發相關的網頁介紹:



其他相關的教學



接著,就只剩環境架設的部分,


在 Ubuntu 9.10 最簡化版:



  1. 安裝相關套件

    • # sudo apt-get install gnustep-devel

    • The following extra packages will be installed:
        gnustep-back-common gnustep-back0.16 gnustep-back0.16-art gnustep-base-doc gnustep-core-devel gnustep-core-doc gnustep-gpbs gnustep-gui-common
        gnustep-gui-doc gnustep-gui-runtime gnustep-make-doc gorm.app libaspell-dev libaudiofile-dev libgif-dev libgnustep-gui-dev libgnustep-gui0.16
        libjpeg62-dev libpng12-dev librenaissance0 librenaissance0-dev libtiff4-dev libtiffxx0c2 projectcenter.app projectmanager.app zlib1g-dev



  2. 安裝完就能用 gcc 進行編譯囉

    • # gcc -lgnustep-base -lpthread -lobjc -lm -I/usr/local/include/GNUstep -I/usr/include/GNUstep source.m -o source_run



  3. 參考資料



使用 Makefile 的教學:



  1. 建立 GNUmakefile

    • GNUSTEP_MAKEFILES = /usr/share/GNUstep/Makefiles/

      include $(GNUSTEP_MAKEFILES)/common.make
      TOOL_NAME = LogTest
      LogTest_OBJC_FILES = source.m
      include $(GNUSTEP_MAKEFILES)/tool.make

    • 最上頭那段是我自己加的,網路上大部分的文件都是使用 shell 來設置環境變數

      • C shell

        • # source <GNUstep root>/System/Library/Makefiles/GNUstep.csh



      • Bourne shell

        • # . <GNUstep root>/System/Library/Makefiles/GNUstep.sh







  2. 建立 source.m


    • #include <stdio.h>

      /*
      * The next #include line is generally present in all Objective-C
      * source files that use GNUstep.  The Foundation.h header file
      * includes all the other standard header files you need.
      */
      #include <Foundation/Foundation.h>  

      /*
      * Declare the Test class that implements the class method (classStringValue).
      */
      @interface Test
      + (const char *) classStringValue;
      @end

      /*
      * Define the Test class and the class method (classStringValue).
      */
      @implementation Test
      + (const char *) classStringValue;
      {
        return "This is the string value of the Test class";
      }
      @end

      /*
      * The main() function: pass a message to the Test class
      * and print the returned string.
      */
      int main(void)
      {
        printf("%s\n", [Test classStringValue]);
        return 0;
      }



  3. 編譯與測試

    • # mkdir test ; cd test ;

    • # vim GNUmakefile (內容如上)

    • # vim source.m (內容如上)

    • # make ;

    • # ./obj/LogTest


      • 輸出結果:This is the string value of the Test class





  4. 參考資料



 



Learn Objective-C on Ubuntu



2009年11月13日 星期五

[Linux] 安裝 Eclipse & Subclipse Plugin (SVN Client) @ Ubuntu 9.10

最近剛重灌電腦,上次安裝失敗,這次就好好順便紀錄一下安裝過程。


安裝環境:Ubuntu 9.10 Desktop i386



  1. 安裝 Eclipse

    • # sudo apt-get install eclipse



  2. 安裝 Subclipse

    • 開起 eclipse

    • [Help] -> [Install New Software] 點選 Add


      • Name : subclipse

      • Locatioon : http://subclipse.tigris.org/update



    • 點選 Subclipse Plugin -> Subclipse

    • 接著就 Next 進行囉 (記得版權那邊要勾一下才能按 Finish 安裝喔)



  3. 設定 Eclipse

    • [Window]->[Preferences]->[Team]->[SVN]

    • 此時會蹦出錯誤訊號窗

      • Failed to load JavaHL Library.
        There are the errors that were encountered:
        no libsunjavahl-1 in java.library.path
        no svnjavahl-1 in java.library.path
        no svnjavahl in java.library.path
        java.library.path = /usr/lib/jvm/java-6-openjdk/jre/lib/i386/cclient:/usr/lib/lib/jvm/java-6-openjdk/jre/lib/i386:......:/usr/lib/jni:/usr/lib

      • 這是因為一開始預設是用 JavaHL 關係



    • 解決方式有兩種

      • 第一種:在剛剛的頁面上,有 SVN interface 選項,有 JavaHL(JNI) 跟 JavaSVN(Pure  Java) 兩種可選,切換成 JavaSVN 就行了!

      • 第二種:安裝 JavaHL

        • # sudo apt-get install libsvn-java

        • 只是我安裝完仍有看到錯誤訊息

          • Failed to load JavaHL Library.
            There are ther errors that were encountered:
            no libsvnjavahl-1 in java.library.path
            Incompatible JavaHL library loaded, 1.3.x or later required.



        • 然而自己就很懶得再繼續解下去,就略過這個解法,改用 JavaSVN(Pure  Java) 啦







  4. 測試

    • [File]->[New]->[Other]->[SVN]->[Checkout Projects from SVN]->[Create a new repository location]

      • 若預設就在這個選項,但又不能按 Next ,就先選另一個選項再切回來就可以選 Next 啦



    • 剩下的就只是選你要 checkout 的目錄囉,選完按 Finish 就能跑了




以上純粹只是在 Linux 上使用安裝 Subclipse plugin for Eclipse 而已,並不是要開發 Java 類的程式,因此僅利用預設的環境。


2009年11月6日 星期五

使用 find regex 與 xargs 將特定檔案打包壓縮

通常使用 find . -name "*.txt" 已經很夠用了,但如果要多個附檔名時卻又有點困擾。


這時可以使用 find . -regex 的方式,它是接受正規表示法的。但須留意用法,原先 find . -name "*.txt" 需更新成 find . -regex ".*\.txt",原理部份請參考 regular expression 。


處理多個副檔名的範例:


# find . -regex ".*\.jpg\|.*\.txt"


如果要順便打包壓縮:


# find. -regex ".*\.jpg\|.*\.txt" | xargs tar -rvf test.tgz