本文介绍使用Open Build Service(OBS)
构建Ubuntu deb包
介绍
- Open Build Service (OBS) 构建工具,构建的软件包,以及 SUSE Linux Enterprise、Arch、Debian、Fedora、Scientific Linux、RHEL、CentOS、Ubuntu 甚至更多发行版的部分软件包。官网
OBS
是 C/S
模式
client
用户可以通过 Web UI(官网)
或 命令行(osc
)配置
server
有很多主机提供服务
- ubuntu 打包文档
- 其他部署
obs 页面操作:
- Overview 工程简介
- Repositories 包列表
- Monitor 包的构建状况
- Requests 用户请求,类似于 github 的 mr
- Users 工程的所有用户
- Subprojects 子工程
- Project Config 配置文件
- Repotype
- Presinstall
- Prefer
- Attributes
- Meta 一些参数信息
- Status
- 子目录:Branch package 派生包
安装 osc 客户端
- 支持本地部署 Open Build Service 参考
- osc 客户端安装参考
CentOS
cd /etc/yum.repo.d
wget https://download.opensuse.org/repositories/openSUSE:/Tools/CentOS_7/openSUSE:Tools.repo
yum makecache
yum install osc -y
Ubuntu
# sudo apt install osc
# wget https://download.opensuse.org/repositories/openSUSE:/Tools/Debian_8.0/all/obs-build_20230808-1_all.deb
# wget https://download.opensuse.org/repositories/openSUSE:/Tools/xUbuntu_20.04/amd64/osc_1.4.3-0_amd64.deb
dpkg -i osc_1.4.3-0_amd64.deb
osc 使用
help
$ osc --help
usage: osc [global opts] <command> [--help] [opts] [args]
optional arguments:
-h, --help show this help message and exit
-v, --verbose increase verbosity
-q, --quiet be quiet, not verbose
--debug print info useful for debugging
--debugger jump into the debugger before executing anything
--post-mortem jump into the debugger in case of errors
--traceback print call trace in case of errors
-H, --http-debug debug HTTP traffic (filters some headers)
--http-full-debug debug HTTP traffic (filters no headers)
-A URL, --apiurl URL Open Build Service API URL or a configured alias
--config FILE specify alternate configuration file
--setopt KEY=VALUE set a config option for the current program run
--no-keyring disable usage of desktop keyring system
commands:
add Mark files to be added upon the next commit
addchannels Add channels to project
addcontainers Add maintained containers for a give package
addremove (ar) Adds new files, removes disappeared files
aggregatepac "Aggregate" a package to another package
api Issue an arbitrary request to the API
branch (getpac, bco, branchco)
Branch a package
browse Opens browser
build (wipe, shell, chroot)
Build a package on your local machine
buildconfig Shows the build config
buildhistory (buildhist)
Shows the build history of a package
buildinfo Shows the build info
buildlog (buildlogtail, blt, bl)
Shows the build log of a package
cat (less, blame) Output the content of a file to standard output
changedevelrequest (changedevelreq, cr)
Create request to change the devel package definition
checkconstraints Check the constraints and view compliant workers
checkout (co) Check out content from the repository
clean Removes all untracked files from the package working copy
cleanassets (ca) Clean all previous downloaded assets
comment List / create / delete comments
commit (checkin, ci) Upload content to the repository server
config Get/set a config option
copypac Copy a package
create-pbuild-config (cpc)
This command is creating the necessary files to build using pbuild tool.
createincident Create a maintenance incident
createrequest (creq) Create multiple requests with a single command
delete (remove, del, rm)
Mark files or package directories to be deleted upon the next 'checkin'
deleterequest (deletereq, droprequest, dropreq, dr)
Request to delete (or 'drop') a package or project
dependson Dependson shows the build dependencies inside of a project, valid for a given repository and architecture
detachbranch Replace a link with its expanded sources
develproject (dp, bsdevelproject)
Print the devel project / package of a package
diff (di, ldiff, linkdiff)
Generates a diff
distributions (dists)
Shows all available distributions
downloadassets (da) Download all assets referenced in the build descriptions
enablechannels (enablechannel)
Enables channels
getbinaries Download binaries to a local directory
help (?) Give detailed help on a specific sub-command
importsrcpkg Import a new package from a src.rpm
info Print information about a working copy
init Initialize a directory as working copy
jobhistory (jobhist) Shows the job history of a project
linkpac "Link" a package to another package
linktobranch Convert a package containing a classic link with patch to a branch
list (LL, lL, ll, ls)
List sources or binaries on the server
localbuildlog (lbl) Shows the build log of a local buildchroot
lock Locks a project or package
log Shows the commit log of a package
maintainer (bugowner)
Show maintainers according to server side configuration
maintenancerequest (mr)
Create a request for starting a maintenance incident
mbranch (maintained, sm)
Search or branch multiple instances of a package
meta Show meta information, or edit it
mkpac Create a new package under version control
mv Move SOURCE file to DEST and keep it under version control
my Show waiting work, packages, projects or requests involving yourself
patchinfo Generate and edit a patchinfo file
pdiff Quick alias to diff the content of a package with its parent
prdiff (projdiff, projectdiff)
Server-side diff of two projects
prjresults (pr) Shows project-wide build results
pull Merge the changes of the link target into your working copy
rdelete Delete a project or packages on the server
rdiff Server-side "pretty" diff of two packages
rebuild (rebuildpac) Trigger package rebuilds
release Release sources and binaries
releaserequest Create a release request
remotebuildlog (remotebuildlogtail, rbuildlogtail, rblt, rbuildlog, rbl)
Shows the build log of a package
repairlink Repair a broken source link
repairwc Try to repair an inconsistent working copy
repo Manage repositories in project meta
repositories (platforms, repos)
Shows repositories configured for a project
repourls Shows URLs of .repo files
request (review, rq) Show or modify requests and reviews
requestmaintainership (reqbs, reqms, reqmaintainership, requestbugownership, reqbugownership)
Requests to add user as maintainer or bugowner
resolved Remove 'conflicted' state on working copy files
restartbuild (abortbuild)
Restart the build of a certain project or package
results (r) Shows the build results of a package or project
revert Restore changed files or the entire working copy
rpmlintlog (lint, rpmlint)
Shows the rpmlint logfile
rremove Remove source files from selected package
search (bse, se) Search for a project and/or package
sendsysrq Trigger a sysrq in a running build
service Handle source services
setdevelproject (sdp)
Set the devel project / package of a package
setlinkrev Updates a revision number in a source link
showlinked Show all packages linking to a given one
signkey Manage Project Signing Key
status (st) Show status of files in working copy
submitrequest (submitpac, submitreq, sr)
Create request to submit source into another Project
token Show and manage authentication token
triggerreason (tr) Show reason why a package got triggered to build
undelete Restores a deleted project or package on the server
unlock Unlocks a project or package
update (up) Update a working copy
updatepacmetafromspec (updatepkgmetafromspec, metafromspec)
Update package meta information from a specfile
vc Edit the changes file
version Give version of osc binary
whatdependson Show the packages that require the specified package during the build
whois (user, who) Show fullname and email of a buildservice user
wipebinaries (unpublish)
Delete all binary packages of a certain project/package
workerinfo Gets the information to a worker from the server
配置认证信息
- 使用
osc token
生成配置文件,需要数据用户名和密码
$ osc token
Your user account / password are not configured yet.
You will be asked for them below, and they will be stored in
/root/.config/osc/oscrc for future use.
Creating osc configuration file /root/.config/osc/oscrc ...
Username [api.opensuse.org]: xiexianbin
Password [xiexianbin@api.opensuse.org]:
NUM NAME DESCRIPTION
1 Secret Service Store password in Secret Service (GNOME Keyring backend) [secure, persistent]
2 Transient Do not store the password and always ask for it [secure, in-memory]
3 Obfuscated config Store the password in obfuscated form in the osc config file [insecure, persistent]
4 Config Store the password in plain text in the osc config file [insecure, persistent]
Select credentials manager [default=1]: 4
done
<directory count="0"/>
$ cat ~/.config/osc/oscrc
# see oscrc(5) man page for the full list of available options
[general]
# Default URL to the API server.
# Credentials and other `apiurl` specific settings must be configured in a `[$apiurl]` config section.
apiurl=https://api.opensuse.org
[https://api.opensuse.org]
# aliases=
# user=
# pass=
# credentials_mgr_class=osc.credentials...
user=xiexianbin
pass=******
credentials_mgr_class=osc.credentials.PlaintextConfigFileCredentialsManager
osc 示例
# 查看当前登录的用户
$ osc whois
xiexianbin: "xie xianbin" <me@xiexianbin.cn>
# 打开浏览器
$ obs browe
# 查看sources or binaries
osc list home:xiexianbin
osc list home:xiexianbin:xxx
# 下载获取远程项目的某一个包
$ osc co home:<user name>/<project name>
$ osc checkout home:xiexianbin
A home:xiexianbin
A home:xiexianbin/containers-skopeo
A home:xiexianbin/containers-skopeo/skopeo_1.13.3-1.debian.tar.xz
A home:xiexianbin/containers-skopeo/skopeo_1.13.3-1.dsc
...
$ osc co home:xiexianbin/containers-skopeo
$ cd home:xiexianbin/containers-skopeo
# 查看状态
$ osc status .
# 查看仓库信息
osc repos
# 提交重命名后的修改
osc addremove
# 更新本地代码
osc update
# 直接推送修改后的内容到远程OBS仓库中去
osc ci -m1
# 添加文件到打包项目
osc add *
osc add https://github.com/xiexianbin/xxx/xxx.tar.gz
# 提交到远程OBS仓库
osc commit
# 查看提交日志
osc log
# 查看打包结果
osc results
新建包
cd [project名]
# 新建Package
osc mkpac [package名]
# 添加文件
osc add *
# 上传服务器
osc commit
# 更新包
osc up
# 打包
osc build
osc build openSUSE_Tumbleweed x86_64
# 本地打包
Debian/Ubuntu deb 包打包
相关文件:
<?xml version="1.0"?>
<services>
<service name="obs_scm">
<param name="versionformat">@PARENT_TAG@</param>
<param name="url">https://github.com/jane/my_package.git</param>
<param name="scm">git</param>
<param name="revision">@PARENT_TAG@</param>
<param name="extract">my_package.spec</param>
</service>
<service name="set_version"/>
<service name="tar" mode="buildtime"/>
</services>
PACKAGE.dsc
文件,Debian source control files
是构建二进制包的控制文件 参考
*.orig.tar.xz|gz
源码包
*.debian.tar.xz|gz
debian 打包的文件压缩包,加压后的结果
debian/
changelog
control
rules
- …
本地打包
- 参考
- 可以删除
_service
文件,防止网上下载源码文件
apt install obs-build build-essential devscripts equivs
osc add xxx
# use one of: Debian_10, Debian_11, Debian_12, RHEL_7, xUbuntu_20.04, xUbuntu_22.04, xUbuntu_23.04
osc build --local-package xUbuntu_23.04 x86_64
osc build --local-package --trust-all-projects -d xUbuntu_23.04 x86_64 *.dsc
# osc build --vm-type=qemu --vm-memory=MB REPOSITORY ARCHITECTURE
# osc shell --vm-type=VM
# osc wipe --vm-type=VM
dpkg -c /var/tmp/build-root/xxx_x86_64/usr/src/packages/DEBS/*.deb
sudo apt install -y debhelper sbuild
sudo sbuild --arch=x86_64 -c sid-x86_64-sbuild
F&Q
sudo update-binfmts --enable
Can’t locate Build.pm in @INC (you may need to install the Build module)
apt-get install libmodule-build-perl
cpan Module::Build