發表文章

如何在 SVN 新增/刪除大量的檔案

感謝 Wolfer 大大提供教學,在此記錄一下: 最近遭遇一個問題,就是廠商提供的SDK,在套用了patch之後, 除了修改檔案之外,還可能會新增/刪除檔案。 而這些新增/刪除的檔案,可能數量不少,而且散在目錄結構的各處, 使得手動新增/刪除也既方便也容易造成錯誤。 因此從網路上找到了方法,說明如下: 1. svn status svn status 這個指令,可以列出目前目錄下的檔案狀態。 它會把所有被 修改/新增/刪除 的檔案列出來。 畫面最左邊會列出這個檔案的狀況: M:此檔案被修改過 ?:此檔案不在 SVN 的管控下(通常是新增檔案) !:檔案遺失(通常是被刪除) A:新增(透過 SVN add 指令加入) D:刪除(透過 SVN del 指令刪除) 2. grep 使用 grep ^? (或 grep ^!)來找出 新增 (或刪除)的檔案 3. sed 使用 sed ‘s/?//g’ (或 sed ‘s/!//g’) 來把 ‘?’ (或 ‘!’)移除 4. svn add (或 svn del) 使用 svn add (或 svn del) 來 新增/刪除 檔案 把四個步驟整合在一起就變成: 新增用 svn status | grep ^? | sed 's/?//g' | xargs svn add $1 刪除則用 svn status | grep ^! | sed 's/!//g' | xargs svn del $1

[Iperf] Iperf Porting and Testing Bandwidth Commands

這篇主要介紹的是 Iperf 要如何透過 cross-compile 來 porting 到不同的平台上。 Iperf 下載網址: http://iperf.fr/ 第一個範例是 Porting 到 Cavium 的 ECONA 平台上,第二個是 Porting 到 Ti 的系列平台上, 在文章最後並會介紹 Iperf 的簡單用法,現介紹如下: == Porting == ** ECONA Platform ** 1. get iperf-2.0.5.tar.gz from http://sourceforge.net/projects/iperf/ 2. tar zxvf iperf-2.0.5.tar.gz 3. cd iperf-2.0.5$ 4. export PATH=$PATH:/opt/cnstools/arm-linux-le-uclibc-gcc-4.3.3-2010.05/usr/bin 5. chmod 777 configure 6. chmod 777 config.h 7. ./configure –host=arm-linux CC=arm-linux-gcc” 8. comment “#define malloc rpl_malloc” in config.h (if you have ac_cv_func_malloc_0_nonnull=yes in previous line, you don’t need to do this) 9. make 10. you can find binary “iperf” in directory “src” ** Ti Platform ** 1. Download and un-pack the source code. 2. ./configure --host=arm-arago-linux-gnueabi CC=arm-arago-linux-gnueabi-gcc CXX=arm-arago-linux-gnueabi-g++ CXXCPP="arm-arago-linux-gnueabi-g++ -E" 3. make 4. comment “#define malloc rpl_malloc” in config.h ...

[iOS] iTunes 無法備份 iPhone,因為無法以 iPhone 來啟始同步階段

最近在透過 iTunes 來備份 / 回覆我的 iPhone 時,常常會出現這個字眼: 「iTunes 無法備份 iPhone,因為無法以 iPhone 來啟始同步階段」 原因不明,但 Apple 也知道這個情況,並在官網上提供了解決辦法: http://support.apple.com/kb/TS2529?viewlocale=zh_TW&locale=zh_TW 如果無法以新使用者的身分進行備份,請嘗試重置 Lockdown 檔案夾。重置 Lockdown 檔案夾後,您也許就可以啟動或儲存備份。 1. 從電腦拔下所有 iOS 裝置,然後結束 iTunes。 2. 重置(刪除、更名) Lockdown 檔案夾。 3. 重新開機 4. 插入 iOS 裝置。 5. 打開 iTunes 並嘗試進行備份。 Lockdown 資料夾的位置: 1. Vista / Win 7 / Win 8 的位置在: C: \p rogramdata \a pple \l ockdown  2. XP 的位置在: C: \D ocuments and Settings \A ll Users \A pplication Data \A pple \l ockdown 如果找不到資料夾的位置,可以這樣做: 1. 選擇 開始 -> 執行 -> 輸入 %ProgramData% 並按一下執行 -> 連按兩下 Apple 檔案夾 -> 即可找到 Lockdown 檔案夾。 2. 由於 ProgramData 是隱藏資料夾,因此先在檔案總管的工具列的「工具」>「 資料夾選項」中的「檢視」頁籤,將「隱藏檔案和資料夾」改為「顯示隱藏的檔案、資料夾及磁碟機」,這樣就能找到了。 參考資料: 1.  http://allennotebook.blogspot.tw/2013/10/itunes-iphone-iphone.html 2.  http://www.mobile01.com/topicdetail.php?f=383&t=3554867&p=1

設定 Git 的環境變數 - Git config

這裡記錄一下目前會用到的 git config 設定 # 設定使用者資訊 git config --global user.name "Steven" git config --global user.email "steven@helloworld.com" # 設定顏色顯示 git config --global color.ui auto git config --global color.diff auto git config --global color.status auto git config --global color.branch auto git config --global color.log auto # 設定 alias git config --global alias.st status git config --global alias.co checkout # 如要忽略空白的比對,可增加以下這個 git config --global apply.whitespace nowarn 設定完之後,在個人的家目錄底下去 cat .gitconfig ,即會看到此資訊 [ push ] default = matching [ alias ] st = status # 設定 status 縮寫 co = checkout # 設定 checkout 縮寫 [ color ] ui = auto # 設定 ut 的顏色為 auto diff = auto # diff status = auto # status branch = auto # branch log = auto # log, 以上這幾種都會自動標色 [ user ] name = Steven Wu email = steven@helloworld.com 參考資料: http://gogojimmy.net...

在舊版 Ubuntu 底下安裝新版 git 套件 (以 Ubuntu 8.04 hardy 為例)

最近由於工作需求,需要在舊版的 Ubuntu 上面安裝 git 套件, 但由於舊版的 Ubuntu 版本已不支援「直接」透過 apt-get update 來更新 source list, 於是用了另一種方法來直接安裝 git,方法如下: 下載目前最新版的 git-1.8.4.1 版本,並且解壓縮並安裝 wget http://www.kernel.org/pub/software/scm/git/git-1.8.4.1.tar.gz tar zxvf git-1.8.4.1.tar.gz cd git-1.8.4.1 ./configure make make install 之後就可以開心的建立 Git repository 了! 參考資料: http://serengetisunset.blogspot.tw/2009/02/installing-git-1613-on-ubuntu-804.html

在 Linux 底下,如何讓 CPU 使用率達到 100% (使用 md5sum 與 gzip)

在工作上,由於 HW 要做溫度的相關測試, 因此要想辦法讓 CPU 使用率拉到 100%,藉此來提高整體溫度。 這邊有個很簡單的方法,分享給大家: 簡單。好用,提供給大家做參考!

建立 git repository 時,要如何找出空目錄,以避免 build code 失敗?

在過去的經驗裡,使用 git 管理 project source code 最討厭遇到空目錄 (empty directory),偏偏我們在 build firmware image 時,常常會需要這樣的目錄,例如 root filesystem 的 /etc, /var, /dev 等等這些目錄。 假如 Makefile 沒有寫好的話,會假設這些目錄是存在的,但是因為 git 並不會儲存空的目錄,這會導致當我們將 project 從 git server clone 下來後,空目錄消失,然後 compile 就 fail 了。 多半這時候的解法就是透過 directory comparison 的工具,例如 Araxis Merge, Beyond Compare,或是 meld 等等,找出空目錄,touch 一個檔案,把檔案加入 git 管理,這樣就可以避免這樣的問題了。 過去我是這樣解決的: 在 project 目錄下,我會執行以下的指令: find 這個指令大家多少都用過,就不多做解釋 -type d 就是找出目錄,man page 說明如下: -empty 就是空檔案或是空目錄的,man page說明如下: -exec find 指令產生的 output,可以有幾種針對 output 做後續處理的方法,其中一種比較直覺的就是透過 exec,將 output 作為新指令的輸入,有點類似 pipeline ( | ) 的概念;exec 的參數必須以 " ; " 結尾,又因為在 shell 下,這個符號有其他用途,所以必須用反斜線標記 (\),然後 " { } " 是代表前面 find 指令的 output string。man page 說明如下: 最後, .gitignore 是 open source community 中,滿常被用來解決這問題的空檔案,而且同時又是 git 本身會 check 的特殊檔案,所以我都是拿這個檔案作為保留空目錄使用。 附註:在搜尋的過程中,也有人建議:如果在空目錄內新增一個 README 之類的檔案,藉以說明這個目錄是用來做什麼的,也是一個不錯的好選擇。