FreeBSD ports system
dv
許邱翔
@ NCTU
前情提要
有來上次社課的話
應該已經裝好一個自己的 FreeBSD 了
前情提要 (cont'd)
沒有自己的 FreeBSD 可以用的話
馬上舉手 0.0/
(我們有備好虛擬機可以用)
前情提要 (cont'd)
現在請先開好自己的 FreeBSD
說明
以下投影片中
# 開頭的都是指令
說明 (cont'd)
在修改系統設定檔、安裝軟體時
需要 root 權限
社課正式開始/
一般軟體安裝
Click, Click, Click
FreeBSD 軟體安裝
use command !!!
ports tree
ports tree 是 FreeBSD 上的 軟體列表
而且是有經過檢驗的
而放在裡面的軟體就被稱為 ports
ports tree (cont'd)
接下來將教你如何藉由 ports tree 來安裝軟體
ports tree (cont'd)
Ports tree is what you need before installing
ports
Path: /usr/ports/
ports tree (cont'd)
請先 cd 進去 /usr/ports/ 看看裡面是不是空的
如果你安裝時沒有勾選 ports 的話
應該是空的
現在來教如何抓 ports tree ~
portsnap
更新、管理 ports tree 的工具
portsnap (cont'd)
First time
# edit /etc/portsnap.conf
SERVERNAME=portsnap.FreeBSD.org

SERVERNAME=portsnap.tw.FreeBSD.org
portsnap (cont'd)
First time
# portsnap fetch
# portsnap extract
merge => # portsnap fetch extract
portsnap (cont'd)
After the first use
# portsnap fetch
# portsnap update
merge => # portsnap fetch update
Search - whereis
# whereis NAME
# whereis rsync
rsync: /usr/ports/net/rsync
Search - echo
(using wildcard)
# echo /usr/ports/*/NAME
# echo /usr/ports/*/rsync
/usr/ports/net/rsync
# echo /usr/ports/*...
INDEX
# make fetchindex
(the files are INDEX-*)
For make search & make quicksearch
Search - make search
# cd /usr/ports/
# make search name=NAME
# make search key=KEYWORD
If names or keywords have multiple...
Search - make search (cont'd)
Port: rsync-3.0.9_3
Path: /usr/ports/net/rsync
Info: Network file distribution/synchronizati...
B-deps
B-deps means Build dependencies
R-deps
R-deps means Run dependencies
Search - make quicksearch
# cd /usr/ports/
# make quicksearch name=NAME

Port: rsync-3.0.9_3
Path: /usr/ports/net/rsync
In...
Search - psearch
ports-mgmt/psearch
# psearch NAME

# psearch rsync
net/rsync Network file distribution...
in the ports
請先 cd 到 /usr/ports/security/sudo
in the ports (cont'd)
● Makefile
● distinfo - info about files and checksums
● files/ - some patches and files
● pkg-descr...
in the ports (cont'd)
other files
● pkg-message - msg to user (after installed)
Before getting the source
# edit /etc/make.conf
MASTER_SITE_BACKUP?= 
http://freebsd.cs.nctu.edu.tw/distfiles/${DIST_SUBDI...
make
# cd /path/to/your/ports
# make
# make install
# make clean
merge => # make install clean
make (cont'd)
# make deinstall
delete software anyway even if it is required by
other packages
make (cont'd)
change config again
# make config
make your make faster
# edit /etc/make.conf
FORCE_MAKE_JOBS=yes
MAKE_JOBS_NUMBER=6
portmaster
ports-mgmt/portmaster
# portmaster PORTS_PATH
ex:
# portmaster security/sudo
portmaster (cont'd)
check upgrade (all installed software)
# portmaster -a
portmaster (cont'd)
● -a 確認所有的ports有沒有可以升級的
● -d 升級或移除ports的時候自動將用不到的
distfiles砍掉
● -B 升級時,不將舊的套件備份起來
● -f 強制編譯升級ports
ex:...
portmaster (cont'd)
●
●
●
●
●

-G 不跳出 make config 選擇視窗
-y 對所有問題都回答yes
--clean-distfiles 移除不需要的distfiles
--clean-packages 移...
ports & package
ports
● Build from source
● Install slower than
package, but run
faster
● more flexibility
● easier to mod...
pkg_add, pkg_delete
# pkg_add LOCAL_PACKAGE_FILES
# pkg_add -r PACKAGE_NAME

(remote)
pkg_add, pkg_delete (cont'd)
# pkg_delete NAME-VERSION
pkg_delete need specific version
pkg_add, pkg_delete (cont'd)
# pkg_delete NAME*
pkg_add, pkg_delete (cont'd)
# pkg_delete -r -v PACKAGE_NAME
● -r : Recursive removal
● -v : Turn on verbose output
● -f :...
pkgng
ports-mgmt/pkg
a replacement for pkg_* tools
convert the package database
# pkg2ng
(This step is not reversible)
pkgng (cont'd)
# pkg install NAME
# pkg delete NAME
pkgng (cont'd)
earlier than FreeBSD 10.X require this line in
/etc/make.conf
WITH_PKGNG = YES
pkgng notice
不要在使用 pkg2ng 來轉成使用 pkgng 前
在 make.conf 加入 WITH_PKGNG = YES
Other command
list and describe installed packages
# pkg_info
# pkg info (pkgng)
Other command (cont'd)
compares the package version to the
current version found in the ports tree
# pkg_verson
# pkg vers...
Rehash
# rehash
Updating
check /usr/ports/UPDATING
it documents some of the problems you may
encounter when upgrading your ports
Updating (cont'd)
# pkg_updating
# pkg updating (pkgng)
# pkg_updating NAME_OF_SOFTWARE
# pkg updating NAME_OF_SOFTWARE
(p...
Updating (cont'd)
list installed software and search for updates
# portmaster -L
upgrade all ports that can be upgraded
# ...
Portaudit
ports-mgmt/portaudit
check if installed ports are listed in a
database of published security vulnerabilities
Portaudit (cont'd)
# portaudit -Fda
# portaudit
● -F Fetch the current database
● -d Print the creation date of the databa...
pkg audit
Fetch the database before checking
# pkg audit -F
# pkg audit
● -F Fetch the database
Task Today
install below software
●
●
●
●
●
●

screen
vim-lite
sudo
subversion
git
python
Reference
●
●
●
●
●
●
●

FreeBSD handbook
NCTU SA - Install Applications
FreeBSD Ports - pellaeon
FreeBSD wiki - pkgng
Fre...
This is the end of today's course
Thanks for everyone
More things
PKGSITE
如果想改用其他 FreeBSD Packages Mirror
就得設定此環境變數
# setenv PKGSITE PACKAGES_MIRROR_URL
PKGSITE (cont'd)
如果之後想移除此環境變數時
可下此指令
# unsetenv PKGSITE
portconf
一次設定好編譯參數
以後裝新機就不用重新勾選
portconf (cont'd)
/usr/local/etc/ports.conf
net/rsync: WITH_ICONV

Wildcard can be used.
ports tree (cont'd)
● distfiles/
預設會把安裝軟體時所需要下載的檔案
存到 /usr/ports/distfiles/ 底下
ports tree (cont'd)
● CHANGES
major changes to ports and the ports
infrastructure (for ports committers,
maintainers and o...
ports tree (cont'd)
● MOVED
A list of (recently) moved or removed ports
Upcoming SlideShare
Loading in...5
×

FreeBSD ports

766

Published on

FreeBSD ports @NCTU

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
766
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

FreeBSD ports

  1. 1. FreeBSD ports system dv 許邱翔 @ NCTU
  2. 2. 前情提要 有來上次社課的話 應該已經裝好一個自己的 FreeBSD 了
  3. 3. 前情提要 (cont'd) 沒有自己的 FreeBSD 可以用的話 馬上舉手 0.0/ (我們有備好虛擬機可以用)
  4. 4. 前情提要 (cont'd) 現在請先開好自己的 FreeBSD
  5. 5. 說明 以下投影片中 # 開頭的都是指令
  6. 6. 說明 (cont'd) 在修改系統設定檔、安裝軟體時 需要 root 權限
  7. 7. 社課正式開始/
  8. 8. 一般軟體安裝 Click, Click, Click
  9. 9. FreeBSD 軟體安裝 use command !!!
  10. 10. ports tree ports tree 是 FreeBSD 上的 軟體列表 而且是有經過檢驗的 而放在裡面的軟體就被稱為 ports
  11. 11. ports tree (cont'd) 接下來將教你如何藉由 ports tree 來安裝軟體
  12. 12. ports tree (cont'd) Ports tree is what you need before installing ports Path: /usr/ports/
  13. 13. ports tree (cont'd) 請先 cd 進去 /usr/ports/ 看看裡面是不是空的 如果你安裝時沒有勾選 ports 的話 應該是空的 現在來教如何抓 ports tree ~
  14. 14. portsnap 更新、管理 ports tree 的工具
  15. 15. portsnap (cont'd) First time # edit /etc/portsnap.conf SERVERNAME=portsnap.FreeBSD.org SERVERNAME=portsnap.tw.FreeBSD.org
  16. 16. portsnap (cont'd) First time # portsnap fetch # portsnap extract merge => # portsnap fetch extract
  17. 17. portsnap (cont'd) After the first use # portsnap fetch # portsnap update merge => # portsnap fetch update
  18. 18. Search - whereis # whereis NAME # whereis rsync rsync: /usr/ports/net/rsync
  19. 19. Search - echo (using wildcard) # echo /usr/ports/*/NAME # echo /usr/ports/*/rsync /usr/ports/net/rsync # echo /usr/ports/*/*NAME*
  20. 20. INDEX # make fetchindex (the files are INDEX-*) For make search & make quicksearch
  21. 21. Search - make search # cd /usr/ports/ # make search name=NAME # make search key=KEYWORD If names or keywords have multiple words, use ' ' or " "
  22. 22. Search - make search (cont'd) Port: rsync-3.0.9_3 Path: /usr/ports/net/rsync Info: Network file distribution/synchronization utility Maint: ehaupt@FreeBSD.org B-deps: R-deps: WWW: http://rsync.samba.org/
  23. 23. B-deps B-deps means Build dependencies
  24. 24. R-deps R-deps means Run dependencies
  25. 25. Search - make quicksearch # cd /usr/ports/ # make quicksearch name=NAME Port: rsync-3.0.9_3 Path: /usr/ports/net/rsync Info: Network file distribution/synchronization utility
  26. 26. Search - psearch ports-mgmt/psearch # psearch NAME # psearch rsync net/rsync Network file distribution...
  27. 27. in the ports 請先 cd 到 /usr/ports/security/sudo
  28. 28. in the ports (cont'd) ● Makefile ● distinfo - info about files and checksums ● files/ - some patches and files ● pkg-descr - more descriptions ● pkg-plist - all files that port will install
  29. 29. in the ports (cont'd) other files ● pkg-message - msg to user (after installed)
  30. 30. Before getting the source # edit /etc/make.conf MASTER_SITE_BACKUP?= http://freebsd.cs.nctu.edu.tw/distfiles/${DIST_SUBDIR}/ MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
  31. 31. make # cd /path/to/your/ports # make # make install # make clean merge => # make install clean
  32. 32. make (cont'd) # make deinstall delete software anyway even if it is required by other packages
  33. 33. make (cont'd) change config again # make config
  34. 34. make your make faster # edit /etc/make.conf FORCE_MAKE_JOBS=yes MAKE_JOBS_NUMBER=6
  35. 35. portmaster ports-mgmt/portmaster # portmaster PORTS_PATH ex: # portmaster security/sudo
  36. 36. portmaster (cont'd) check upgrade (all installed software) # portmaster -a
  37. 37. portmaster (cont'd) ● -a 確認所有的ports有沒有可以升級的 ● -d 升級或移除ports的時候自動將用不到的 distfiles砍掉 ● -B 升級時,不將舊的套件備份起來 ● -f 強制編譯升級ports ex: # portmaster -dB security/sudo
  38. 38. portmaster (cont'd) ● ● ● ● ● -G 不跳出 make config 選擇視窗 -y 對所有問題都回答yes --clean-distfiles 移除不需要的distfiles --clean-packages 移除不需要的packages --check-depends 確認目前所有的ports相 依性
  39. 39. ports & package ports ● Build from source ● Install slower than package, but run faster ● more flexibility ● easier to modify code package ● Install faster, but run slower (binary) ● less flexibility ● save the time building from source
  40. 40. pkg_add, pkg_delete # pkg_add LOCAL_PACKAGE_FILES # pkg_add -r PACKAGE_NAME (remote)
  41. 41. pkg_add, pkg_delete (cont'd) # pkg_delete NAME-VERSION pkg_delete need specific version
  42. 42. pkg_add, pkg_delete (cont'd) # pkg_delete NAME*
  43. 43. pkg_add, pkg_delete (cont'd) # pkg_delete -r -v PACKAGE_NAME ● -r : Recursive removal ● -v : Turn on verbose output ● -f : force
  44. 44. pkgng ports-mgmt/pkg a replacement for pkg_* tools convert the package database # pkg2ng (This step is not reversible)
  45. 45. pkgng (cont'd) # pkg install NAME # pkg delete NAME
  46. 46. pkgng (cont'd) earlier than FreeBSD 10.X require this line in /etc/make.conf WITH_PKGNG = YES
  47. 47. pkgng notice 不要在使用 pkg2ng 來轉成使用 pkgng 前 在 make.conf 加入 WITH_PKGNG = YES
  48. 48. Other command list and describe installed packages # pkg_info # pkg info (pkgng)
  49. 49. Other command (cont'd) compares the package version to the current version found in the ports tree # pkg_verson # pkg version (pkgng)
  50. 50. Rehash # rehash
  51. 51. Updating check /usr/ports/UPDATING it documents some of the problems you may encounter when upgrading your ports
  52. 52. Updating (cont'd) # pkg_updating # pkg updating (pkgng) # pkg_updating NAME_OF_SOFTWARE # pkg updating NAME_OF_SOFTWARE (pkgng) print the ${PORTSDIR}/UPDATING entries that concern your installed packages
  53. 53. Updating (cont'd) list installed software and search for updates # portmaster -L upgrade all ports that can be upgraded # portmaster -a
  54. 54. Portaudit ports-mgmt/portaudit check if installed ports are listed in a database of published security vulnerabilities
  55. 55. Portaudit (cont'd) # portaudit -Fda # portaudit ● -F Fetch the current database ● -d Print the creation date of the database ● -a Print a vulnerability report for all installed packages
  56. 56. pkg audit Fetch the database before checking # pkg audit -F # pkg audit ● -F Fetch the database
  57. 57. Task Today install below software ● ● ● ● ● ● screen vim-lite sudo subversion git python
  58. 58. Reference ● ● ● ● ● ● ● FreeBSD handbook NCTU SA - Install Applications FreeBSD Ports - pellaeon FreeBSD wiki - pkgng FreeBSD wiki - Pkg Primer portmaster - Hsian Studio command manual
  59. 59. This is the end of today's course Thanks for everyone
  60. 60. More things
  61. 61. PKGSITE 如果想改用其他 FreeBSD Packages Mirror 就得設定此環境變數 # setenv PKGSITE PACKAGES_MIRROR_URL
  62. 62. PKGSITE (cont'd) 如果之後想移除此環境變數時 可下此指令 # unsetenv PKGSITE
  63. 63. portconf 一次設定好編譯參數 以後裝新機就不用重新勾選
  64. 64. portconf (cont'd) /usr/local/etc/ports.conf net/rsync: WITH_ICONV Wildcard can be used.
  65. 65. ports tree (cont'd) ● distfiles/ 預設會把安裝軟體時所需要下載的檔案 存到 /usr/ports/distfiles/ 底下
  66. 66. ports tree (cont'd) ● CHANGES major changes to ports and the ports infrastructure (for ports committers, maintainers and other developers)
  67. 67. ports tree (cont'd) ● MOVED A list of (recently) moved or removed ports

×