2015年3月23日 星期一

Debian套件 安裝

 

Debian 套件 安裝

1.

pi@raspberrypi ~ $ dpkg --help
用法:dpkg [<;選項> ...] <命令>
 
指令:
  -i|--install       <;.deb 檔> ... | -R|--recursive <目錄> ...
  --unpack           <;.deb 檔> ... | -R|--recursive <目錄> ...
  -A|--record-avail  <;.deb 檔> ... | -R|--recursive <目錄> ...
  --configure        <;套件> ...    | -a|--pending
  --triggers-only    <;套件> ...    | -a|--pending
  -r|--remove        <;套件> ...    | -a|--pending
  -P|--purge         <;套件> ...    | -a|--pending
  --get-selections [<;表達式> ...]  將選擇清單,列印到標準輸出。
  --set-selections                 從標準輸入,取得套件選擇清單。
  --clear-selections               取消所有的非核心套件。
  --update-avail <;Packages 檔>     取代可用套件資訊。
  --merge-avail <;Packages 檔>      由檔案合併可用套件資訊。
  --clear-avail                    清除可用套件資訊。
  --forget-old-unavail             清除已移除且無法再安裝的套件。
  -s|--status <;套件> ...           顯示套件詳情。
  -p|--print-avail <;套件> ...      顯示可用版本詳情。
  -L|--listfiles <;套件> ...        列出 `屬於' 套件的檔案。
  -l|--list [<;表達式> ...]         簡要列出套件。
  -S|--search <;表達式> ...         搜尋擁有該檔案的套件。
  -C|--audit                       檢查有沒有損毀的套件。
  --add-architecture <;硬體平台>    把 <硬體平台> 加到硬體平台清單中。
  --remove-architecture <;硬體平台> 由硬體平台清單移除 <硬體平台>。
  --print-architecture             顯示 dpkg 的硬體平台。
  --print-foreign-architectures    顯示可用的異質硬體平台。
  --compare-versions <;a> <op> <b>  比較版本 - 請參閱下文。
  --force-help                     顯示強制選項的說明。
  -Dh|--debug=help                 顯示偵錯模式的說明。
 
  -?, --help                       顯示這個說明訊息。
      --version                    顯示版本資訊。
 
使用 dpkg -b|--build|-c|--contents|-e|--control|-I|--info|-f|--field|
 -x|--extract|-X|--vextract|--fsys-tarfile 於套件檔上(鍵入 dpkg-deb --help)。
 
內部使用:dpkg --assert-support-predepends | --predep-package |
  --assert-working-epoch | --assert-long-filenames | --assert-multi-conrep |
  --assert-multi-arch。
 
選項:
  --admindir=<;目錄>          使用 <目錄> 代替 /var/lib/dpkg。
  --root=<;目錄>              安裝在另一個 root 目錄。
  --instdir=<;目錄>           變更安裝路徑,不變更 admin dir。
  --path-exclude=<;表達式>    不安裝符合 shell 表達式的檔案。
  --path-include=<;表達式>    前項選項排除後,再加上符合表達式的檔案。
  -O|--selected-only         略過未選擇為要安裝/升級的套件。
  -E|--skip-same-version     略過相同版本已安裝的套件。
  -G|--refuse-downgrade      略過比已安裝版本舊的套件。
  -B|--auto-deconfigure      即使會損毀其它套件也要安裝。
  --[no-]triggers            略過或強制接下來的觸發程式。
  --no-debsig                不試著去驗証套件簽章。
  --no-act|--dry-run|--simulate
                             只顯示接下來的動作 - 不實際執行。
  -D|--debug=<;八進制數字>    啟用除錯(參閱 -Dhelp 或 --debug=help)。
  --status-fd <;n>            傳送狀態異動至檔案敘述 <n>。
  --status-logger=<;指令>     傳送狀態異動 <指令> 的標準輸入。
  --log=<;檔名>               記錄狀態異動及動作至 <檔名>。
  --ignore-depends=<;套件>,...
                             忽略 <;套件> 的相依關係。
  --force-...                無視問題(參閱 --force-help)。
  --no-force-...|--refuse-...
                             當發生問題時中止。
  --abort-after <;n>          碰到 <n> 個錯誤後中止。
 
--compare-versions 的比較運算子:
  lt le eq ne ge gt       (無版號時,視為最舊版);
  lt-nl le-nl ge-nl gt-nl (無版號時,視為最新版);
  <; << <= = >= >> >       (相容於控制檔的語法專用)。
 
使用 `dselect' 或 `aptitude' 等介面親和的套件管理程式。

2. man dpkg


 


以zsh 為例.


A.是否已被安裝 dpgk –l



$dpkg -l zsh


B.若在A中,"no packages found matching zsh"則去檢查是否可在套件中找到



sudo apt-cache serach zsh


zsh - A shell with lots of features
zsh-dbg - A shell with lots of features (debugging symbols)
zsh-dev - A shell with lots of features (development files)
zsh-doc - zsh documentation - info/HTML format
csh - Shell with C-like syntax, standard login shell on BSD systems
draai - A command-line music player for MPD
fatrat-czshare - fatrat plugin allowing download and upload to czshare
grml-shlib - Generic shell library used in grml scripts
tucan - Download and upload manager for 1-Click Hosters
viewglob - A graphical display of directories referenced at the shell prompt
zsh-beta - A shell with lots of features (dev tree)
zsh-beta-doc - zsh beta documentation - info/HTML format
zsh-lovers - tips, tricks and examples for the zsh
zsh-static - A shell with lots of features (static link)
zshdb - debugger for Z-Shell scripts

C. 若有找到時,則可以使用APT安裝



apt-get install zsh

D.檢查其zsh是否已正確安裝



dpkg -s zsh



Package: zsh
Status: install ok installed
Priority: optional
Section: shells
Installed-Size: 13732
Maintainer: Ubuntu Developers (ubuntu-devel-discuss@lists.ubuntu.com)
Architecture: amd64
Version: 4.3.11-4ubuntu2.is.3ubuntu1
Depends: libc6 (>;= 2.4), libcap2 (>= 2.10), libncursesw5 (>= 5.6+20070908)
Recommends: libc6 (>;= 2.11), libpcre3 (>= 8.10)
Suggests: zsh-doc
Conffiles:
 /etc/zsh/zlogin 48032df2ace0977f2491b016e3c421a3
 /etc/zsh/zlogout b73789c3e790b855302ce10ca076037a
 /etc/zsh/zprofile 58c4f65d775c055b5d80b67c1bd12838
 /etc/zsh/zshenv 5a8a0ff4f6ff945a5aa6ba7f6f1e8c97
 /etc/zsh/zshrc e069ba51ba293da1aeddd5779324df19
 /etc/zsh/newuser.zshrc.recommended dac3563a2ddd13e8027b1861d415f3d4
Description: A shell with lots of features
 Zsh is a UNIX command interpreter (shell) usable as an
 interactive login shell and as a shell script command
 processor. Of the standard shells, zsh most closely resembles
 ksh but includes many enhancements. Zsh has command-line editing,
 built-in spelling correction, programmable command completion,
 shell functions (with autoloading), a history mechanism, and a
 host of other features.
Homepage: http://www.zsh.org/
Original-Maintainer: Debian Zsh Maintainers (pkg-zsh-devel@lists.alioth.debian.org)

E.列出相關文件 (可以去找出confi)



dpkg -L zsh


F.



apt-get remove zsh


sudo dpkg -P(R) zsh
#P : remove all soft and config
#R : remain config

实践:Debian 软件包管理


http://www.ibm.com/developerworks/cn/linux/l-setup-debpkg-pr/index.html

2015年3月21日 星期六

mbed 介紹

 

前言:

ARM 推出了全面性的物聯網(IoT: Internet of Things)運用平台,該平台包括了 mbed OS 與 mbed 伺服器設備.

keyword:

iot,mbed ,nordic 51422

 

年前,ARM正式推出mbed IDE(整合開發平台) , 其介紹可見what is mbed.

內容有致有

1.MBED MCU

2.MBED compiler

3.MBED SDK

而其中,MBED compiler及SDK都是在線上完成的.

這邊我把手上一個nrf51422 (nordic dongle)為範例操作.

image image

1.去mbed 註冊

https://mbed.org/

image

2.進入右上方的develop site

image

3.再進入右上方的compiler

image

4.select device

image

5.new a project(select device)

image 

6.new a file(main) and lib(mbed)

(Click the right button on the mouse at the project name,example "blink"))

image 

(the file must *.cpp),it use the c++

7.program (you should reference the mbed lib (or other lib))

select the mbed lib and export it to click the DigitalOut

image

write follow in main.cpp

#include "mbed.h"
DigitalOut led(LED1);
int main()
{
    while(1){
        wait(1);
        led=!led;
        }
}

 


8.compiler and download


(the loader ,the brower will download the bin file)


image


9.loader (by your develop board,put the into loader mode)


10.reboot your device ,should be work.



MBED 的用途

MBED 是专为实验及反覆操作而设计的,主要是测验某种东西或方法而不是优化解决方案。因此,它适合专业嵌入式工程师,也适合想初次尝试的门外汉


最後,這讓我感覺這個像是另一個"arduino". 然而這個應是現階段的部份.


而在之後在在mbed OS出來後.一定會變成下一個arduino.(只是在只是AVR平台而已)


而且也可以跟著不同板子有不同的功能.如nrf5144有radio(ble 'ant and proprotal)


 


image


 


image


ref:


https://github.com/mbedmicro/nRF51822


http://developer.mbed.org/cookbook/mbed-application-board


https://mbed.org/technology/os/


http://www.chinatimes.com/realtimenews/20141008004930-260412


ARM發表物聯網專用作業系統MBED,正式版將在2015年釋出


http://www.techbang.com/posts/20319-king-of-computers-arm-to-launch-the-operating-system-for-internet-use-mbed-accelerated-the-development-of-internet-applications


https://developer.mbed.org/


https://www.nordicsemi.com/eng/Products/ANT/nRF51422

2015年3月7日 星期六

samba

前言:

目前,我已經有一個NAS(個人雲端伺服器,TOGOBOX) ,這是在外面時方便分享或不同設備上的存取資料時使用.而它也可以當作Soft AP來使用; 所以它的角色和我的Ras Pi的部份重複了.

因此,我得需想在宿舍時.如何時存取及如何可以讓不同的設備共同去存取TOGOBOX.

keyword:

RasPi, network, samba and ios

分為二個部份,

1.在RasPi 上,安裝samba並去掛載TOTOBOX.也可以讓它去充電

2.在client(PC)

   mac ,

   windows

   ipad(寫app,samba client)

 
sudo apt-get -y install samba samba-common-bin
#create the mount point
sudo mkdir /autofs/togobox/sd
udo chmod 777 /autofs/togobox/sd
udo mount /dev/sda1 /autofs/togobox/sd

$samba config file



[global]
 netbios name  = TOGOBOX
 workgroup     = WORKGROUP
 security      = user
 map to guest  = bad user
share]
 path       = /autofs/togobox/sd
 read only  = no
 browseable = yes
 guest ok   = yes

image


sudo apt-get install autofs



#etc/auto.master
+auto.master
/autofs/togobox /etc/auto.ext-usb --timeout=10,defaults,user,exec,uid=1000
#create a auto.ext-usb
#to mount the device
sd      -fstype=auto    :/dev/sda1

image


ps.


Q:


原本,想使得在使用時.去自己去mount togobox device.


而在未使用/長時間沒使用時也去umount togobox device.


而這是因為,若沒有umount togobox時,它會從第一個sda1 ,變成sdb1 ....依序


直到你close the samba/autofs,並umount它.它成會回到sda1.


但因為samba/autofs可能相互鍞定該目錄,因此有衝突.變得無法umount(在沒有samba時可以在autofs中timeout umount)


A.


未解決它,因此現在在掛上togobox時必需先reset Ras Pi


app:


在ios 上,已經有不少的app for smb.我目前是使這二個針對File manager 及觀看video


Remote File Explorer


VidOn Player – Free HD Movie and Streaming


http://appcrawlr.com/ios-apps/best-apps-smb-shares?q=smb+shares&query=best-apps-smb-shares&deviceSeo=iphone%2Cipad&prefix=top-apps&action=seoProcess&controller=app&&_rv=1


ref:


togobox


http://www.aximcom.com/zh-hant/TOGOBOX


samba


https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/


http://www.simonthepiman.com/how_to_setup_windows_file_server.php/


http://linux.die.net/man/8/automount




http://linuxconfig.org/automatically-mount-usb-external-drive-with-autofs