結合git server的opkg update server === 我透過yocto建立了一套自用的disto。因為後續想要新增功能,於是在建置disto有將opkg套件管理建置進去。 然而,我建置的環境是透過效能較好的PC,但更新伺服器並不想開放這台PC給其他人使用。所以,我會將建置好的檔案(IPK檔),放到單板機上(raspberry pi),透過單板機提供服務。 本篇就是紀錄這個系統的建置過程。 git主要用來上傳更新好的ipk檔案,並且記錄版本資訊。 --- ### 環境 * Update Server: Raspberry pi + Ubuntu * Compile and Push Server: PC + Ubuntu * Client: Raspberry pi + Own disto --- ### GIT Server設定1 [簡易git server架設教學 (用Ubuntu linux)](https://www.bruceli.net/tw/2011/02/04/install-git-server-on-ubuntu-linux.html) 1. 安裝GIT Server: ```bash= sudo apt-get install git-core ``` 2. 建立好檔案目錄 ```bash= cd /var sudo mkdir git cd git sudo mkdir opkg_update_server.git cd opkg_update_server.git sudo git --bare init ``` 3. 新增一個名為git的用戶並建立權限 ```bash= sudo groupadd git sudo usermod -a -G git your_login sudo chgrp -R git /var/git sudo chmod g+rwx -R /var/git ``` :::info your_login 為自己的系統登入帳號 ::: --- ### 推送端設定(之前建立的那台PC) 本章節目標將所有的ipk資料夾加入git。 我的ipk資料夾位於 ```text= $workspace/tmp/deploy/ipk ``` 1. 初始化git: ```bash= cd $workspace/tmp/deploy/ipk git init ``` 2. 加入所有ipk檔案 ```bash= git add . ``` 3. 新增commit ```bash= git commit -m "commit body" ``` 4. 新增remote server ```bash= git remote add origin ssh://your_login@host:port/var/git/opkg_update_server.git ``` 5. 推上Server: ```bash= git push -u origin master ``` --- ### GIT Server設定2 GIT會用object紀錄所有推上來檔案 然而,opkg是透過直接下載ipk檔案的方式提供服務,因此要在Server端建立local repo。 local repo在每次更新推上來後,需要pull git server內容。 1. 建立repo資料夾 ```bash= mkdir repo cd repo ``` 2. 初始化repo,並加入remote server ```bash= git init git remote add origin ssh://your_login@127.0.0.1:port/var/git/opkg_update_server.git ``` 3. 同步套件 ```bash= git pull ``` :::info 每次伺服器推送上來,都必須重新同步套件 ::: 4. 將資料夾推上HTTP ```bash= python3 -m http.server ``` --- ### opkg客戶端設定 [OpenWRT介紹opkg參考](https://openwrt.org/docs/guide-user/additional-software/opkg) 1. 建立設定檔案(檔案名稱只要是附檔名conf就可以了,主檔名沒有規範): ```bash= touch /etc/opkg/customfeeds.conf ``` 2. 輸入設定: ```text= src/gz packagesDirectory file:///path/to/packagesDirectory src/gz packagesDirectory1 file:///path/to/packagesDirectory1 ... ``` :::info packagesDirectory 為資料夾名稱 file:///path/to/packagesDirectory為資料夾路徑,例如: http://127.0.0.1/all ::: 3. 更新套件清單: ```bash= opkg update ``` :::info 到此設定完畢 :::