openEuler 20.03上部署OBS客户端osc,并通过openeuler-build进行编译

----------------------------------------------------------------------------------------------

一 操作系统版本

openEuler  20.03


# cat /etc/openEuler-release 
openEuler release 20.03 (LTS)
[root@openeuler-test ~]# uname -a
Linux openeuler-test 4.19.90-2003.4.0.0036.oe1.x86_64 #1 SMP Mon Mar 23 19:10:41 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

二 设置yum源


# mount -oloop openEuler-20.03-LTS-everything-x86_64-dvd.iso /mnt
# vim  /etc/yum.repos.d/openEuler_x86_64.repo
[iso]
name=iso
baseurl=file:///mnt
gpgcheck=0
enable=1

三 安装osc rpm

下载
# wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/p/python3-lxml-4.4.0-1.fc31.x86_64.rpm
# wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/aarch64/os/Packages/o/osc-0.165.1-255.1.2.fc31.1.noarch.rpm
# wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/aarch64/os/Packages/o/osc-source_validator-0.10-5.fc31.noarch.rpm
# wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/o/obs-build-20190321-314.1.1.fc31.1.noarch.rpm
# wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/o/obs-build-mkbaselibs-20190321-314.1.1.fc31.1.noarch.rpm
# wget https://download-ib01.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/o/obs-build-mkdrpms-20190321-314.1.1.fc31.1.noarch.rpm

安装
# dnf install -y python3-lxml-4.4.0-1.fc31.x86_64.rpm
# dnf install -y osc-0.165.1-255.1.2.fc31.1.noarch.rpm
# dnf install -y obs-build-20190321-314.1.1.fc31.1.noarch.rpm obs-build-mkbaselibs-20190321-314.1.1.fc31.1.noarch.rpm obs-build-mkdrpms-20190321-314.1.1.fc31.1.noarch.rpm
# dnf install -y osc-source_validator-0.10-5.fc31.noarch.rpm

 

四 创建新project并checkout到本地

1)登录华为的obs注册用户
http://openeuler-build.huawei.com
记录用户名和密码(本文中用户名为test)

2)web界面obs创建自己的项目,名称为test_project,也就是home:test:test_project

3)checkout project到本地

# mkdir ~/obs
# cd ~/obs
# osc checkout home:test:test_project

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: test  # 注册用户
Password:          # 注册用户口令
done
Server returned an error: HTTP Error 401: Unauthorized  # 提示认证失败信息


修改位于osc配置文件:

编辑 ~/.oscrc(建议普通用户)或者/root/.config/osc/oscrc

# vi /root/.config/osc/oscrc

编辑以下内容:

[general]
apiurl = http://openeuler-build.huawei.com/

[http://openeuler-build.huawei.com/]
user = test     #注册用户
pass = 密码   # 注册用户口令


再次checkout
# osc checkout home:test:test_project
WARNING: SSL certificate checks disabled. Connection is insecure!

A    home:test;test_project

 

五 创建project的meta信息

设置project meta信息使用(建议通过web界面,设置repositories以及arch等):

# osc meta prj -e home:test:test_project

六 新建package


1) 进入project目录
# cd home\:test\:test_project

2) 新建Package

以zsh包为示例: 

第一种方法:
# osc mkpac zsh
# cd zsh
将源码放入到该目录,主要是以【tar包、所有patch、spec文件、其他source文件】格式放置,不能是src.rpm包
(或者通过src.rpm包:rpm2cpio /tmp/src/
zsh-5.7.1-4.oe1.src.rpm | cpio -iudm)

第二种方法:

# osc importsrcpkg --name=zsh /tmp/src/zsh-5.7.1-4.oe1.src.rpm
创建package meta信息以及zsh目录,并将zsh-5.7.1-4.oe1.src.rpm解压到zsh目录
# cd zsh

3) 向新创建的package中添加以上文件 
# osc add *
4) 将更改上传至服务器: 
# osc commit -m"Init  2020-02-01"

5) 更新包
进入project文件夹:
# cd [project名]
更新本地代码为最新代码:
# osc up

6) 如果仓库中已有包,可以如下: 
# osc checkout home\:test\:test_project/zsh
或者
# osc checkout home\:test\:test_project zsh
(适用于项目中存在大量package,通过checkout一个package,将整个项目meta信息拉取到本地)

八 问题

1)执行osc importsrcpkg提示信息如下

# osc importsrcpkg kronosnet-1.15-1.el7.src.rpm              
WARNING: SSL certificate checks disabled. Connection is insecure!

Traceback (most recent call last):
  File "/usr/bin/osc", line 41, in
    r = babysitter.run(osccli)
  File "/usr/lib/python3.7/site-packages/osc/babysitter.py", line 61, in run
    return prg.main(argv)
  File "/usr/lib/python3.7/site-packages/osc/cmdln.py", line 344, in main
    return self.cmd(args)
  File "/usr/lib/python3.7/site-packages/osc/cmdln.py", line 367, in cmd
    retval = self.onecmd(argv)
  File "/usr/lib/python3.7/site-packages/osc/cmdln.py", line 501, in onecmd
    return self._dispatch_cmd(handler, argv)
  File "/usr/lib/python3.7/site-packages/osc/cmdln.py", line 1232, in _dispatch_cmd
    return handler(argv[0], opts, *args)
  File "/usr/lib/python3.7/site-packages/osc/commandline.py", line 7881, in do_importsrcpkg
    createPackageDir(os.path.join(project.dir, pac), project)
  File "/usr/lib64/python3.7/posixpath.py", line 94, in join
    genericpath._check_arg_types('join', a, *p)
  File "/usr/lib64/python3.7/genericpath.py", line 151, in _check_arg_types
    raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components

正确用法:
# osc importsrcpkg --name kronosnet  /tmp/src/kronosnet-1.15-1.el7.src.rpm

 

2)openeuler-build从gitee获取src源码进行编译

https://openeuler.org/zh/blog/2020/03/26/2020-03-26-OBS-with-Git.html

openeuler-build中创建package,进入package中Add file

Filename输入:ioprocess

File URL输入:https://gitee.com/openkylin/ioprocess.git

点击Save后报错

继续进入ioprocess包的界面

编辑_service内容,其他内容不变,只改标注的地方内容

 
    git
    ioprocess  # 改为自己的需要从gitee上取得的包名
    https://gitee.com/openkylin/ioprocess.git  #改为包在gitee上的url地址
 

 
    *.*
    */*
 

然后可以正常从gitee拉取源码并自动编译(这种方式目前是无法通过openeuler-build界面修改源码文件,需要在gitee中提交修改,合并到master,obs中点击该包界面中的 Trigger services自动获取最新master代码进行编译)。

 

 

 

 

你可能感兴趣的:(openEuler)