安装软件包
SuSe 的安装请参照相应文档,本文主要针对 RHEL/CentOS 5, GTES 11 版本。
软件包地址:
配置
mysql
mysql root
如果mysql还未使用,即没有设置root密码,可以这样:
# /etc/init.d/mysqld start 启动 MySQL: [确定] # mysqladmin -u root password 'turbolinux'
如果 mysqladmin 命令失败,请查找相关原因,一定要成功!
创建数据库
我们需要为 obs 的 api 模块配置一个数据库,至于数据库的名字,请参考 1.7 版本 obs 的 /srv/www/obs/frontend/config/database.yml 文件,如果没有 database.yml 文件,请拷贝 database.yml.example 为 database.yml ,修改该 文件中的 production 字段,其中 database 选项指定数据库的名字,下面是 database.yml.example 的示例,我们使用 api_production 为数据库名字:
production: adapter: mysql database: api_production username: root password: turbolinux
现在创建 api_production 数据库:
# mysql -u root -p ... mysql> create database api_production; Query OK, 1 row affected (0.00 sec)
使用指定角色访问数据库
我们可以简单地用 root 角色访问数据库,如果是这样,只要创建必要的数 据库即可。
如果我们的数据库还有其他用处,用一个单独的角色访问会更科学点,我们创建 一个 obs 用户,设置密码为 turbolinux :
mysql> GRANT all privileges
-> ON api_production.*
-> TO 'obs'@'%', 'obs'@'localhost'
-> IDENTIFIED BY 'turbolinux';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
初始化数据库
# pwd /srv/www/obs/api # chown -R lighttpd.lighttpd db/ # sudo -u lighttpd RAILS_ENV="production" rake db:migrate ...
lighttpd
OBS 使用 lighttpd 启动 api 和 webui 服务(1.7 以前, api 称为 frontend , webui 称为 webclient)。
/etc/lighttpd/vhosts.d/obs.conf
obs.conf 配置虚拟主机:
$HTTP["host"] =~ "build.turbolinux.com.cn" {
rails_app = "webui"
rails_root = "/srv/www/obs/webui"
rails_procs = 5
# production/development are typical values here
rails_mode = "production"
log_root = "/srv/www/obs/webui/log"
include "vhosts.d/rails.inc"
}
$HTTP["host"] =~ "api.turbolinux.com.cn" {
rails_app = "api"
rails_root = "/srv/www/obs/api"
rails_procs = 5
# production/development are typical values here
rails_mode = "production"
log_root = "/srv/www/obs/api/log"
include "vhosts.d/rails.inc"
}
$HTTP["host"] =~ "download.turbolinux.com.cn" {
server.name = "download.turbolinux.com.cn"
server.document-root = "/srv/obs/repos/"
}
注意: build.turbolinux.com.cn, api.turbolinux.com.cn, download.turbolinux.com.cn 三个域名可以任选。如果任选,dns 解析不一定正 确,这时候可以在 /etc/hosts 里写好规则:
# cat /etc/hosts 127.0.0.1 localhost.localdomain localhost 172.16.70.33 build.turbolinux.com.cn 172.16.70.33 api.turbolinux.com.cn 172.16.70.33 download.turbolinux.com.cn
访问的时候也要直接访问这些域名,不能直接使用 http://172.16.70.33 这样的 方式。这时还是可以在性client段设置好这些域名解析。
/etc/lighttpd/lighttpd.conf
激活 obs.conf 配置,要在 lighttpd.conf 文件中添加
var.conf_dir = "/etc/lighttpd/" include "vhosts.d/obs.conf"
同时, "mod_magnet" , "mod_rewrite" 和 fastcgi 模块也要激活 :
14 server.modules = ( 15 "mod_rewrite", 16 "mod_magnet", ... 25 "mod_fastcgi", ...
如果想配置 fastcgi 或者 magnet ,可以进一步用下面方法定制,这里略过:
## mod_magnet include "conf.d/magnet.conf" ## FastCGI (mod_fastcgi) include "conf.d/fastcgi.conf"
如果配置文件中默认没有的,请查看 /usr/lib64/lighttpd/ (x86_64 arch) 下 是否有对应模块,如果有,添加就可以,如果没有,需要查找原因。比如 mod_magnet 配置文件中默认没有,lib64下有 (/usr/lib64/lighttpd/mod_magnet.so),添加即可。
/srv/www/obs/webui/config/environments/production.rb
如果定制了 /etc/lighttpd/vhosts.d/obs.conf 文件,修要相应地修改 /srv/www/obs/webui/config/environments/production.rb 文件!
FRONTEND_HOST = "api.turbolinux.com.cn" FRONTEND_PORT = 80 DOWNLOAD_URL = "http://download.turbolinux.com.cn"
backend
/usr/lib/obs/server/BSConfig.pm
这个是最主要的配置部分,主要配置 $hostname 部分:
my $hostname = '172.16.70.33';
注意, $hostname 是字符串!
/etc/sysconfig/obs-server
如果没有这个文件请找一份模板,如果用 rpm 方式安装 obs-server,这个文件 应该安装了,/var/adm/fillup-templates/sysconfig.obs-server,可以用做模 板。
主要是 bs_sched 依据这里的配置知道需要监视哪些架构。
| OBS_SCHEDULER_ARCHITECTURES | 指定监视那些架构 |
OBS_SCHEDULER_ARCHITECTURES="i586 x86_64"
worker
/etc/sysconfig/obs-worker
GTES 定制
使用 i386 架构
如果是服务器版本通常需要编译针对 i386 架构的软件包,而 OBS 默认支持 i586 及以上的架构,需要修改一些地方才能编译 i386 。
api
默认 OBS 使用 i586 架构,不支持 i386 架构编译,我们需要修改 api 应用里 的数据库初始化部分,添加 i386 数据记录!
api 的 migrate 部分有很多地方可以向数据库添加 i386 架构记录,我在这里添 加 : api/db/migrate/004_add_repositories.rb 。
Architecture.create :name => "i386"
Architecture.create :name => "i586"
Architecture.create :name => "x86_64"
初始化数据库后,就有 i386 支持记录了:
# pwd /srv/www/obs/api # chown -R lighttpd.lighttpd db/ # sudo -u lighttpd RAILS_ENV="production" rake db:migrate ...
/usr/lib/obs/server/bs_dispatch
出来修改 api 在数据库里面添加 i386 支持记录,另外一个需要修改的就是 dispatcher 。 dispatcher 决定怎么分配任务,修改 /usr/lib/obs/server/bs_dispatch 里面的 %cando :
'x86_64' => ['x86_64', 'i386', 'i586', 'i686', 'armv4l', 'armv5el', 'armv7el','sh4'],
%cando hash 的 key 表示 worker 的架构, value 表示此种worker架构可以编译哪些架构。通常我们的 worker 都运行在 x86_64 架构上,所以一般只要在这里添加 i386 架构即可。如果想要在 i386 机器上执行 worker (现在基本用不到了),可添加一行:
'i386' => ['i386','armv4l', 'armv5el', 'armv7el','sh4'],
/usr/lib/obs/server/bs_worker
worker 也需要修改能编译 i386 才行,修改 server 上的 /usr/lib/obs/server/bs_worker 里的 %cando hash:
'x86_64' => ['x86_64', 'i386:linux32', 'i586:linux32', 'i686:linux32', 'armv4l', 'armv5el', 'armv7el', 'sh4' ],
/etc/sysconfig/obs-server
OBS_SCHEDULER_ARCHITECTURES 决定 /etc/init.d/obsscheduler 会启动几个监 视进程。
OBS_SCHEDULER_ARCHITECTURES="i386 x86_64 ia64"
取消 success relsync
默认 OBS 对所有软件包进行 relsync 编译,我们想在 success 时不 relsync 编译。这需要修改 /usr/lib/obs/server/bs_sched 里的一个 "while (@cpacks) {...}" 循环里面的内容。
3863 while (@cpacks) {
3864 my $packid = shift @cpacks;
3865 my $incycle = 0;
3866 if ($cychash{$packid}) {
...
修改要点:
- 此循环里每个软件包都要设置 status , 不然就会出现 "unknown" 状态软件包
- 此循环处理很多种类事件,需要单独对待
最好还是使用 relsync
下面修改都是在 "while (@cpacks) {...}" 循环内部。
忽略 "meta change"
4248 my @diff = diffsortedmd5(0, \@meta, \@new_meta);
4249 # 在 meta change 之前也来设置判断一下,如果是 success ,就不管了它
4250 if (grep {$packid eq $_} ls("$reporoot/$prp/$myarch/:logfiles.success")) {
4251 #print " - $packid ($packtype)\n";
4252 #print " meta change, but don't rebuild on tbs!";
4253 $packstatus{$packid} = 'done'; # 不设置就成unknown了!
4254 next;
4255 } # 修改结束
4256 print " - $packid ($packtype)\n";
4257 print " $_\n" for @diff;
4258 print " meta change, start build\n";
4259 $reason = { 'explain' => 'meta change', 'packagechange' => sortedmd5toreason(@diff) };
4260 }
使用 repoview 创建美观 repodata
要使用 repoview ,在 createrepo 时需添加 -d 参数时长 sqlite 数据。可以 修改 /usr/lib/obs/server/bs_publish 。查看 /srv/obs/log/publisher.log 可以看到日志信息。
禁用 gpgcheck
修改 /usr/lib/obs/server/bs_publish ,让 bs_publish 生成 XXX.repo 文件 时候不加入 "gpgcheck=1" 设置。
#print FILE "gpgcheck=1\n";
定制 webui
从 1.7 开始 webclient 命名为 webui ,而且更容易定制自己的部分。 在 webui/config/options.yml 提供一个参数 theme 定义主题的名字,默认是 neutral ,这里改为 turbolinux :
#theme: neutral theme: turbolinux
让后仿照 webui/app/views/vendor/neutral/ 和 webui/public/vendor/neutral/ 两个目录在同级目录建立 turbolinux 目录,定 制就可以开始了。
application.html.erb
application.html.erb 可能是最主要的定义,这里定义 web 界面的基本架构。 拷贝一份到 app/views/vendor/turbolinux/layouts/application.html.erb , 就可以定制。
注意, 应该是 1.7 使用 cache ,所以如果修改没有起作用,请重启 lighttpd 。
用户图标
修改 app/helpers/application_helper.rb 文件:
bugzilla 链接
修改 app/helpers/application_helper.rb
121 def gravatar_image(email)
122 hash = MD5::md5(email.downcase)
123 #return image_tag "https://secure.gravatar.com/avatar/#{hash}?s=20&d=" + image_url('vendor/turbolinux/images/local/default_face.png'
), :alt => '', :width => 20, :height => 20
124 return image_tag "/vendor/turbolinux/images/local/#{hash}.png", :alt => '', :width => 20, :height => 20
125 end
拷贝 png 图片到 public/vendor/turbolinux/images/local/下,名字为 email 的hash值+png。
问题解决
webui
我第一次启动 lighttpd ,api 访问正常, webui 访问在 /var/log/lighttpd/error.log 可以看到 500 错误日志:
connect failed: Connection refused on unix:/srv/www/obs/webui/tmp/sockets/fcgi.socket-4
这个问题通常表明 publick/dispatch.fcgi 启动不了,试着手动启动 dispatch.fcgi ,查看信息:
# cd /srv/www/obs/webui/ # ./public/dispatch.fcgi
然后一一解决即可。
perl-BSSolv 问题
1.7 使用 perl-BSSolv
looking at low prio GTES:11.3/standard (0/0/2/0/3)
- GTES:11.3/standard
scanning repo GTES:11.3/standard...
/usr/bin/perl: symbol lookup error: /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/BSSolv/BSSolv.so: undefined symbol: qsort_r
这个原因是 GTES11 (包括CentOS/RHEL 5) 的 glibc 版本是 2.5, 没有 qsort_r 这个库函数,我从 glibc-2.9 的 stdlib 下找到 qsort 函数,复制过 来了。
x86_64 依赖
如果在 x86_64 架构上提示 "nothing provides libgcc_s.so.1 needed by gcc" (在 /srv/obs/log/scheduler_x86_64.log 里查看日志),如下:
expansion errors:
nothing provides libgcc_s.so.1 needed by gcc
可以从 fedora 的 koji 系统下载 glibc32 srpm 软件包修改 spec ,添加 "Provides: libgcc_s.so.1" ,编译完成后添加到 x86_64 标准库中,重新启动 obs 即可包含此依赖关系。
Goto Repository 返回错误
默认 obs 使用 repoview 发布 html 格式的 repodata ,但是如果没有安装 repoview ,就只能开启 lighttpd 的 dir-listing.activate (列目录) 功能 查看仓库,修改 /etc/lighttpd/vhosts.d/obs.conf :
$HTTP["host"] =~ "download.turbolinux.com.cn" {
server.name = "download.turbolinux.com.cn"
dir-listing.activate = "enable"
server.document-root = "/srv/obs/repos/"
}
Expansion errors
"have choice for"
参考: http://en.opensuse.org/Build_Service/Tips_and_Tricks
错误信息示例:
have choice for smtpdaemon: sendmail postfix
根据 Tips_and_Tricks 方法, osc meta -e prjconf <Project> and add the line: Prefer: sendmail
openSUSE Webclient Error
Interrupted system call
openSUSE Webclient Error: Error Details: Errorcode: unknown Message: Interrupted system call
修改 lib/common/activexml/transport.rb 文件 ,如果 opt[:timeout] 没有 值,就设置为 60:
482 @http = Net::HTTP.new(url.host, url.port) 483 # FIXME: we should get the protocol here instead of depending on the port 484 @http.use_ssl = true if url.port == 443 485 @http.start 486 end 487 if opt[:timeout] 488 @http.read_timeout = opt[:timeout] 489 else 490 @http.read_timeout = 60 491 end
编译错误
"C compiler cannot create executables"
这个问题要查看 CFLAGES ,可能是 worker 没有设置正确。比如在默认的 worker 上编译 i386 架构就会出现这个错误。如果依据上面修改 bs_worker 文 件的方式就会解决问题。
"Couldn't exec XXX: Permission denied"
这个是因为 OBS 准备 chroot 环境时,拷贝文件没有保留执行权限,所以执行时 会出错。错误信息示例:
+ cp -pr examples/autofs examples/LDAP examples/libsmbclient examples/misc examples/printer-accounting /var/tmp/samba-3.0.33-root/usr/share/doc/samba-3.0.33 + cp -pr examples/printing /var/tmp/samba-3.0.33-root/usr/share/doc/samba-3.0.33 + exit 0 error: Couldn't exec /usr/src/turbo/SOURCES/filter-requires-samba.sh: Permission denied getOutputFrom(): Broken pipe
可以修改 /usr/lib/obs/server/build/build 解决:
1535 chmod 755 $BUILD_ROOT/.build.command 1536 # Jian Lee: add the exec premission to all files 1537 chmod a+x $BUILD_ROOT/$TOPDIR/SOURCES/* 1538 chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true 1539 fi
编译架构: —target
如果想编译 i586 的软件包,使用 rpmbuild 命令时候添加 "—target=i586" 即 可。在 "/usr/lib/build/build" 中添加 933-936 行即可:
927 if [ -z "$RUNNING_IN_VM" ]; then
928 echo Using BUILD_ROOT=$BUILD_ROOT
929 test -n "$BUILD_RPMS" && echo Using BUILD_RPMS=$BUILD_RPMS
930 echo Using BUILD_ARCH=$BUILD_ARCH
931 test -n "$VM_TYPE" && echo "Doing $VM_TYPE build in $VM_IMAGE"
932 echo
933 if test "$BUILD_ARCH" != "${BUILD_ARCH#i586}"; then
934 ABUILD_TARGET_ARCH=i586
935 echo "Change arch to i586."
936 fi
937 fi
