星期六, 9月 24, 2016

Open Build Service 實作練習 Workshop 101 小記

Open Build Service 實作練習 Workshop 101

OS: openSUSE Leap 42.1

預先準備
  • 安裝 osc 套件
    • #zypper   install   osc
  • 有 OBS 帳號

首先設定 API 的 URL
# osc    -A   https://api.opensuse.org

Your user account / password are not configured yet.
You will be asked for them below, and they will be stored in
/root/.oscrc for future use.

Creating osc configuration file /root/.oscrc ...
Username: 輸入帳號
Password: 輸入密碼

建立完之後家目錄會產生  .oscrc  以及 .osc_cookiejar
  • ~/.oscrc 為相關apiurl 以及帳號資訊, 檔案權限為 600, 後續可以用 ring 來處理


使用 osc 指令進行 check out 專案  osc  co   home:使用者帳號
# osc  co  home:sakana

觀察目錄就會出現專案的資料夾
# ls
.bash_history  .dbus        inst-sys        .oscrc    .Xauthority bin            .gnupg       .local          .rnd
.config        home:sakana  .osc_cookiejar  .viminfo

切換到專案目錄
# cd   home\:sakana/

使用 osc mkpac 指令建立 package, 這次workshop 使用的是  ctris
# osc  mkpac   ctris
A    ctris

再次觀察
# ls
ctris  gmchess  Helloworld-test  jUploadr  .osc  owncloud
進入 套件工作目錄
# cd   ctris/

修改 .spec 檔案, 可以參考講師提供的  http://paste.opensuse.org/8035d628
# vi  ctris.spec

Name:           ctris
Summary:        Console based Tetris clone
URL:            http://www.hackl.dhs.org/ctris/
License:        GPL-2.0
Group:          Amusements/Games/Action/Arcade
Version:        0.42
Release:        1
Source:         %{name}-%{version}.tar.bz2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  ncurses-devel
Requires:       ncurses

%description
An ASCII version of the well known game Tetris

%prep
%setup -q

%build
make

%install
%make_install
%debug_package

%clean
rm -rf $RPM_BUILD_ROOT;

%files
%defattr(-,root,root)
%doc AUTHORS COPYING README TODO
%doc %{_mandir}/man6/ctris.6.gz
/usr/games/ctris

%changelog

Notes
  • 在 openSUSE 環境內 #vi  xxxx.spec 會自動套入 .spec 格式
  • BuildRequires 為編譯過程中需要的套件
  • Requires 則為執行需要的套件

抓取套件  source code
# wget  http://goo.gl/zWJXyd -O ctris-0.42.tar.bz2

觀察目錄
# ls
ctris-0.42.tar.bz2  ctris.spec  .osc

觀察.osc 目錄
# ls   .osc/
_apiurl  _files  _osclib_version  _package  _project

使用 osc   vc 指令填寫 chang log
# osc  vc

填入 change log
-------------------------------------------------------------------
Sat Sep 24 07:11:09 UTC 2016 -

- OBS workshop

# ls
ctris-0.42.tar.bz2  ctris.changes  ctris.spec  .osc

觀察目錄
# ls .osc/
_apiurl  _files  _osclib_version  _package  _project

標記要新增或是移除的檔案
# osc   addremove
A    ctris.spec
A    ctris.changes
A    ctris-0.42.tar.bz2

觀察目錄, 多了 _to_be_added
# ls .osc/
_apiurl  _files  _osclib_version  _package  _project  _to_be_added

# cat  .osc/_to_be_added
ctris.spec
ctris.changes
ctris-0.42.tar.bz2

到目前為止都是在 local

接下來進行 commit ( -ci ) 以及上傳到 build.opensuse.org
# osc   ci    -m  "Ya! I am a packager"
Sending meta data...
Done.
Sending    ctris
Sending    ctris/ctris.spec
Sending    ctris/ctris.changes
Sending    ctris/ctris-0.42.tar.bz2
Transmitting file data ..
Committed revision 1.
觀察目錄
# ls .osc/
_apiurl  ctris-0.42.tar.bz2  ctris.changes  ctris.spec  _files  _meta  _osclib_version  _package  _project

接下來要設定套件要編譯的 Repositories ( OS )

到 Web UI
點選  Repositories
點選  Add repositories

螢幕快照 2016-09-24 下午3.18.41.png


針對要加入的 repo 勾選
勾選完之後就會自動 build

螢幕快照 2016-09-24 下午3.24.30.png


到此, 就可以在 OBS 上面享受用一個原始碼編譯出不同平台的便利性
也可以到 http://software.opensuse.org/search 搜尋一下自己的套件觀察 :)
2016-09-24 22-16-56 的螢幕擷圖.png


剛剛是在  build.opensuse.org 上面編譯
那如果要在本機編譯呢?

本地端 編譯  ( 要配合自己有裝的 repo )
可以使用 osc  build 指令 後面加上 repo 以及架構 還有 .spec 檔案
# osc  build  openSUSE_Leap_42.1   x86_64   ctris.spec
Building ctris.spec for openSUSE_Leap_42.1/x86_64
Getting buildinfo from server and store to /root/home:sakana/ctris/.osc/_buildinfo-openSUSE_Leap_42.1-x86_64.xml
Getting buildconfig from server and store to /root/home:sakana/ctris/.osc/_buildconfig-openSUSE_Leap_42.1-x86_64
Updating cache of required packages

The build root needs packages from project 'openSUSE:Leap:42.1'.
Note that malicious packages can compromise the build result or even your system.
Would you like to ...
0 - quit (default)
1 - always trust packages from 'openSUSE:Leap:42.1'
2 - trust packages just this time
? 1
adding 'openSUSE:Leap:42.1' to ~/.oscrc: ['https://api.opensuse.org']['trusted_prj']
100.0% cache miss. 0/100 dependencies cached.

[   34s] RPMLINT report:
[   34s] ===============
[   35s] ctris.x86_64: W: incorrect-fsf-address /usr/share/doc/packages/ctris/COPYING
[   35s] The Free Software Foundation address in this file seems to be outdated or
[   35s] misspelled.  Ask upstream to update the address, or if this is a license file,
[   35s] possibly the entire file with a new copy available from the FSF.
[   35s]
[   35s] ctris.x86_64: W: file-contains-current-date /usr/games/ctris
[   35s] Your file contains the current date, this may cause the package to rebuild in
[   35s] excess.
[   35s]
[   35s] 2 packages and 0 specfiles checked; 0 errors, 2 warnings.
[   35s]
[   35s]
[   35s] template finished "build ctris.spec" at Sat Sep 24 07:38:00 UTC 2016.
[   35s]

/var/tmp/build-root/openSUSE_Leap_42.1-x86_64/home/abuild/rpmbuild/SRPMS/ctris-0.42-1.src.rpm

/var/tmp/build-root/openSUSE_Leap_42.1-x86_64/home/abuild/rpmbuild/RPMS/x86_64/ctris-0.42-1.x86_64.rpm
/var/tmp/build-root/openSUSE_Leap_42.1-x86_64/home/abuild/rpmbuild/RPMS/x86_64/ctris-debuginfo-0.42-1.x86_64.rpm

這邊會看到, 編譯完成之後會放到 /var/tmp 下面的目錄


Lab: 共同協作

那如果想要跟其他人共同維護套件呢?

範例 使用現有的套件

使用 osc  branch 指令建立分支, 這邊是使用講師的 套件
# osc   branch   home:gary_lin   ctris

# cd

切換到工作目錄
# osc   co   home:sakana:branches:home:gary_lin/ctris
A    home:sakana:branches:home:gary_lin
A    home:sakana:branches:home:gary_lin/ctris
A    home:sakana:branches:home:gary_lin/ctris/ctris-0.42.tar.bz2
A    home:sakana:branches:home:gary_lin/ctris/ctris.changes
A    home:sakana:branches:home:gary_lin/ctris/ctris.spec
At revision e1fa18eaa16d59e32af37e7b02af3130.

觀察目錄
# ls
.bash_history  bin  .config  .dbus  .gnupg  home:sakana  home:sakana:branches:home:gary_lin  inst-sys  .local  .osc_cookiejar  .oscrc  .rnd  .viminfo

由於只是 workshop 所以先切換到該套件的工作目錄
# cd   home\:sakana\:branches\:home\:gary_lin/ctris/

測試改動 .spec 內容 ( 這邊我改了 release 版本 )
# vim  ctris.spec

填入 change log
# osc   vc

標記新增或是移除檔案
# osc  addremove

進行 build 動作
$ osc  build  openSUSE_Leap_42.1   x86_64

進行  commit, 此時都是在自己的 home project 上面
$ osc   ci   -m   “another change”

可以到 Subprojects 查詢
螢幕快照 2016-09-24 下午4.23.20.png


透過  osc  submitreq 送出更動請求 ( 像是git 的 pull request )
# osc   submitreq
created request id 429914

這樣就可以完成 協同工作

今天的  workshop 真是收穫良多
謝謝 Gary

~ enjoy it

星期日, 9月 18, 2016

SUSE Beta program 申請小記

SUSE Beta Program

自己在不同的用途會使用不同的 OS
目前桌面環境是 openSUSE Leap 42.1 來進行日常作業
公司的測試環境也是 openSUSE Leap 42.1, 配合一些專案, 有可能伺服器的環境是 CentOS,  RHEL 或是 SUSE Linux Enterprise Server ( SLES ).

但如果要使用 SUSE 企業版Linux的環境來測試有兩種方式

1. 申請 60天免費測試( 針對穩定發行版 )

到 https://www.suse.com/products/server/download
使用自己的 e-mail 來申請 60 天的測試


這樣的方式主要是針對已經發行的穩定版來進行測試

但如果針對一些新功能想要嘗鮮或是針對功能修改想進行測試, 
例如 SUSE 的 Yast docker 模組的功能 ( 註: SLES 12 SP1 已經有 yast2 docker 模組了 )

那就要嘗試第2種方式

2. SUSE Beta Program

SUSE Beat Program 可以讓使用者測試目前還在開發中的企業版 SUSE Linux 功能

申請方式
至 SUSE Beta Program 頁面

點選右上方 login 登入 suse 帳號
這個部份可能自己要有 SUSE 帳號來登入 :) 

2016-06-15 13-25-07 的螢幕擷圖.png

登入帳號之後
這個部份可以看到主要有 3 種

  • SLES 新的 SP 測試
  • SLED 新的 SP 測試
  • SLES HA 新的 SP 測試

準備好要參加測試計劃了嗎? :)
接下來點選 畫面下方的 click here to join


2016-06-15 13-27-20 的螢幕擷圖.png

在 SUSE Beta Program Code of Conduct 頁面
點選 I Accept

接下來在 Beta Program 中就可以看見 Download Links

2016-06-15 13-30-51 的螢幕擷圖.png
就可以針對自己平台架構下載 ISO 進行相關測試了

另外針對一些額外的模組是要申請 Subscription Code 的, 可以參考頁面內 "Beta Test Subscription and Registration Code" 那段的說明.

Beta Test Subscription and Registration Code
Note: Regular product subscription and registration code will not work with the beta products!
Thus we will not provide a beta product subscription or beta product registration code by default for the SLE 12 SP2 Beta Program. You might request one via beta-programs@lists.suse.com, but we reserve the right to review your case and eventually provide one for your personal beta test.
Without a beta registration code for SLES or SLED you won’t be able to access the online SLE 12 Modules on SLES/SLED 12 SP2 Beta.

簡單來說就是要寄封信給 beta-programs@lists.suse.com 說明想要測試額外的模組
讓自己可以在 # yast2 repositories 新增那些額外模組的訂閱 :)

先記下來

~ enjoy it

星期四, 9月 01, 2016

DHCP Server with openSUSE Leap 42.1 in 4 Steps

DHCP Server with openSUSE Leap 42.1 in 4 Steps

最近在整理實驗環境, 不想手動設定 IP 所以就在實驗環境內建立 DHCP Server 來發放 IP 啦 :)

既然要 4 個步驟完成 DHCP Server 的設定, 當然就是 YasT 啦

先安裝相關套件

# zypper  install  -n  yast2-dhcp-server  dhcp-server

安裝完畢之後就是呼叫可愛的 yast2  dhcp-server 啦

#yast2  dhcp-server

首先步驟 1 就是選取要發放 dhcp 的網卡, 以我的例子是 eth1
點選 eth1 -- > 點選 Seletct -- > 點選 Next

2016-08-30 19-57-44 的螢幕擷圖.png


接下來是DHCP 給的相關資訊, 填入環境的相關資訊, 例如
填入 DNS / Default Gateway -- > 點選 Next
2016-08-30 19-58-29 的螢幕擷圖.png

接下來是要發放的 IP 範圍
以我來說, 我設定由 192.168.100.100 開始發放, 到 192.168.100.199 為止 -- > 點選 Next


2016-08-30 19-59-12 的螢幕擷圖.png


最後就是 設定開機是否啟動
我這邊設定 開機自動啟動 ( When Booting )  -- > 點選 Finish
2016-08-30 19-59-27 的螢幕擷圖.png

就這樣簡簡單單完成 DHCP Server 架設

先記下來

~ enjoy it