前边有转发过来自chef 团队的一篇omnibus-ctl 介绍文章,以下尝试进行项目试用

就是简单的集成,没有多少复杂的操作

环境准备

  • ruby
    ruby 使用2.6.3 使用 rbenv 安装,可以参考rbenv mac&&linux 安装简单说明
  • bundle
    bundler 的安装可以直接使用gem,其他途径存在版本的问题,安装方法
gem install bundler
  • 可选配置gem source
gem source -r https://rubygems.org/
gem source -a https://gems.ruby-china.com/
  • 安装omnibus

    脚手架模式

gem install omnibus

简单项目集成omnibus-ctl

项目是一个简单的模拟gitlab 的软件包,没有多少操作

  • 初始化项目
omnibus new gitlab
  • 项目结构
├── Berksfile
├── Gemfile
├── Gemfile.lock
├── README.md
├── config
│ ├── projects
│ │ └── gitlab.rb
│ └── software
│ ├── gitlab-ctl.rb
│ └── preparation.rb
├── files
│ └── gitlab-ctl-commands
│ └── config.rb
├── omnibus.rb
└── package-scripts
    └── gitlab
        ├── postinst
        ├── postrm
        ├── preinst
        └── prerm
  • 说明
    以上config/software/gitlab-ctl.rbfiles/gitlab-ctl-commands 是添加的文件
  • 代码说明
    Gemfile 因为需要集成omnibus-ctl 所以需要引用gem 包,我修改了source 为国内的
source 'https://gems.ruby-china.com/'
# Install omnibus
gem 'omnibus', '~> 6.0'
# gem 'omnibus-ctl', '~> 0.6.0'
gem 'omnibus-software', git: 'https://github.com/chef/omnibus-software.git'
# Use Chef's software definitions. It is recommended that you write your own
# software definitions, but you can clone/fork Chef's to get you started.
# gem 'omnibus-software', github: 'chef/omnibus-software'
# This development group is installed by default when you run `bundle install`,
# but if you are using Omnibus in a CI-based infrastructure, you do not need
# the Test Kitchen-based build lab. You can skip these unnecessary dependencies
# by running `bundle install --without development` to speed up build times.
group :development do
  # Use Berkshelf for resolving cookbook dependencies
  gem 'berkshelf'
  # Use Test Kitchen with Vagrant for converging the build environment
  gem 'test-kitchen'
  gem 'kitchen-vagrant'
end
 

config/project/gitlab.rb 项目包信息描述,包含依赖以及项目信息

#
# Copyright 2019 YOUR NAME
#
# All Rights Reserved.
#
name "gitlab"
maintainer "rongfengliang"
homepage "https://github.com/rongfengliang"
# Defaults to C:/my on Windows
# and /opt/my on all other platforms
install_dir "#{default_root}/#{name}"
build_version Omnibus::BuildVersion.semver
build_iteration 1
# Creates required build directories
dependency "preparation"
dependency "gitlab-ctl"  # 我们需要依赖的soft 定义
# my dependencies/components
# dependency "somedep"
exclude "**/.git"
exclude "**/bundler/git"
 

config/software/gitlab-ctl.rb 我们的包软件定义:
这个实际上就是对omnibus-ctl 的一个包装

name "gitlab-ctl"
dependency "omnibus-ctl"
source :path => File.expand_path("files/gitlab-ctl-commands", RbConfig::CONFIG['project_root'])
build do
  block do
    open("#{install_dir}/embedded/bin/gitlab-ctl", "w") do |file|
      file.print <<-EOH
#!/bin/bash
# Ruby environment if gitlab-ctl is called from a Ruby script.
for ruby_env_var in RUBYOPT \\
                    BUNDLE_BIN_PATH \\
                    BUNDLE_GEMFILE \\
                    GEM_PATH \\
                    GEM_HOME
do
  unset $ruby_env_var
done
#{install_dir}/embedded/bin/omnibus-ctl gitlab #{install_dir}/embedded/service/omnibus-ctl $@
       EOH
    end
  end
  command "chmod 755 #{install_dir}/embedded/bin/gitlab-ctl"
  # additional omnibus-ctl commands
  sync "#{project_dir}/", "#{install_dir}/embedded/service/omnibus-ctl/"
end
 

files/gitlab-ctl-commands 自定义命令:

add_command 'config', 'reconfig for gitlab server', 1 do |cmd_name|
      puts 'run config'
      reconfigure
  end

运行&&测试

  • 初始化依赖
bundle install --binstubs
  • 构建
sudo bin/omnibus build gitlab
  • 效果
tree pkg/
pkg/
├── gitlab-0.0.0+20190701053352-1.el7.x86_64.rpm
├── gitlab-0.0.0+20190701053352-1.el7.x86_64.rpm.metadata.json
├── gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm
├── gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm.metadata.json
└── version-manifest.json
  • 安装软件包
yum install gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm
已加载插件:fastestmirror
正在检查 gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm: gitlab-0.0.0+20190701062746-1.el7.x86_64
gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 gitlab.x86_64.0.0.0.0+20190701062746-1.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===============================================================================================================
 Package 架构 版本 源 大小
===============================================================================================================
正在安装:
 gitlab x86_64 0.0.0+20190701062746-1.el7 /gitlab-0.0.0+20190701062746-1.el7.x86_64 46 M
事务概要
========================================
  • 生成的软件包目录结构
tree -L 3 /opt/gitlab/
/opt/gitlab/
├── bin
├── embedded
│ ├── bin
│ │ ├── bundle
│ │ ├── bundler
│ │ ├── c_rehash
│ │ ├── erb
│ │ ├── gem
│ │ ├── gitlab-ctl
│ │ ├── irb
│ │ ├── libtool
│ │ ├── libtoolize
│ │ ├── makedepend
│ │ ├── omnibus-ctl
│ │ ├── openssl
│ │ ├── pkg-config
│ │ ├── rake
│ │ ├── rdoc
│ │ ├── ri
│ │ ├── ruby
│ │ └── update_rubygems
│ ├── include
│ │ ├── ffi.h
│ │ ├── ffitarget.h
│ │ ├── libltdl
│ │ ├── ltdl.h
│ │ ├── openssl
│ │ ├── ruby-2.6.0
│ │ ├── X11
│ │ ├── yaml.h
│ │ ├── zconf.h
│ │ └── zlib.h
│ ├── lib
│ │ ├── config_guess
│ │ ├── engines
│ │ ├── libcrypto.a
│ │ ├── libcrypto.so -> libcrypto.so.1.0.0
│ │ ├── libcrypto.so.1.0.0
│ │ ├── libffi-3.2.1
│ │ ├── libffi.a
│ │ ├── libffi.la
│ │ ├── libffi.so -> libffi.so.6.0.4
│ │ ├── libffi.so.6 -> libffi.so.6.0.4
│ │ ├── libffi.so.6.0.4
│ │ ├── libltdl.a
│ │ ├── libltdl.la
│ │ ├── libltdl.so -> libltdl.so.7.3.0
│ │ ├── libltdl.so.7 -> libltdl.so.7.3.0
│ │ ├── libltdl.so.7.3.0
│ │ ├── libruby.so -> libruby.so.2.6.3
│ │ ├── libruby.so.2.6 -> libruby.so.2.6.3
│ │ ├── libruby.so.2.6.3
│ │ ├── libssl.a
│ │ ├── libssl.so -> libssl.so.1.0.0
│ │ ├── libssl.so.1.0.0
│ │ ├── libyaml-0.so.2 -> libyaml-0.so.2.0.5
│ │ ├── libyaml-0.so.2.0.5
│ │ ├── libyaml.a
│ │ ├── libyaml.la
│ │ ├── libyaml.so -> libyaml-0.so.2.0.5
│ │ ├── libz.a
│ │ ├── libz.so -> libz.so.1.2.11
│ │ ├── libz.so.1 -> libz.so.1.2.11
│ │ ├── libz.so.1.2.11
│ │ ├── pkgconfig
│ │ └── ruby
│ ├── service
│ │ └── omnibus-ctl
│ ├── share
│ │ ├── aclocal
│ │ ├── doc
│ │ ├── info
│ │ ├── libtool
│ │ ├── man
│ │ ├── pkgconfig
│ │ └── util-macros
│ └── ssl
│ ├── cert.pem -> certs/cacert.pem
│ ├── certs
│ ├── misc
│ └── openssl.cnf
├── LICENSE
├── LICENSES
│ ├── bundler-LICENSE.md
│ ├── cacerts-index.815ca599c9df.txt
│ ├── config_guess-config.guess
│ ├── config_guess-config.sub
│ ├── libffi-LICENSE
│ ├── libtool-COPYING
│ ├── libyaml-LICENSE
│ ├── makedepend-COPYING
│ ├── omnibus-ctl-LICENSE
│ ├── openssl-LICENSE
│ ├── pkg-config-lite-COPYING
│ ├── ruby-BSDL
│ ├── ruby-COPYING
│ ├── rubygems-LICENSE.txt
│ ├── ruby-LEGAL
│ ├── util-macros-COPYING
│ ├── xproto-COPYING
│ └── zlib-README
├── version-manifest.json
└── version-manifest.txt
 
 
  • 使用gitlab-ctl
    因为打包制作的比较简单,配置path 路径我们就可以直接使用gitlab-ctl
export PATH=$PATH:/opt/gitlab/embedded

使用命令:

gitlab-ctl
I don't know that command.
/opt/gitlab/embedded/bin/omnibus-ctl: command (subcommand)
config
  reconfig for gitlab server
General Commands:
  cleanse
    Delete *all* my data, and start from scratch.
  help
    Print this help message.
  reconfigure
    Reconfigure the application.
  show-config
    Show the configuration that would be generated by reconfigure.
  uninstall
    Kill all processes and uninstall the process supervisor (data will be preserved).
Service Management Commands:
  graceful-kill
    Attempt a graceful stop, then SIGKILL the entire process group.
  hup
    Send the services a HUP.
  int
    Send the services an INT.
  kill
    Send the services a KILL.
  once
    Start the services if they are down. Do not restart them if they stop.
  restart
    Stop the services if they are running, then start them again.
  service-list
    List all the services (enabled services appear with a *.)
  start
    Start services if they are down, and restart them if they stop.
  status
    Show the status of all the services.
  stop
    Stop the services, and do not restart them.
  tail
    Watch the service logs of all enabled services.
  term
    Send the services a TERM.
 
  • 说明
    可以看出我们这样就搞出来了一个和gitlab安装包类似的ctl 了,实际上gitlab 安装包也是集成的omnibus-ctl,只是里面功能更复杂而已。
    通过项目omnibus-gitlab 我们可以了解到更多关于omnibus-ctl 的用法

参考资料

https://github.com/gitlabhq/omnibus-gitlab
https://blog.chef.io/2015/05/26/omnibus-ctl-what-is-it-and-what-can-it-do-for-you/
https://github.com/rongfengliang/omnibus-ctl-demo

集成omnibus-ctl 开发一个专业的软件包管理工具的更多相关文章

  1. iOS开发一个制作Live Photo的工具

    代码地址如下:http://www.demodashi.com/demo/13339.html 1.livePhoto简介 livePhoto是iOS 9.0 之后系统相机提供的拍摄动态照片的功能,但 ...

  2. RPM是RedHat Package Manager(RedHat软件包管理工具)

    RPM是RedHat Package Manager(RedHat软件包管理工具)类似Windows里面的“添加/删除程序” rpm 执行安装包二进制包(Binary)以及源代码包(Source)两种 ...

  3. 【one day one linux】linux下的软件包管理工具

    Linux 下的软件包管理工具 linux下的软件安装可以通过两种方式,一种是直接使用自带的软件包管理工具安装,另外一种通过编译源码安装. 1.软件包的种类 Red Hat和Fedora:redhat ...

  4. Mac OSX上的软件包管理工具,brew 即 Homebrew

    brew 即 Homebrew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件, 只需要一个命令, 非常方便. brew类似ubuntu系统下的apt-get的功能. 安装 ...

  5. Mac Pro 安装 Homebrew 软件包管理工具

    Linux系统有个让人蛋疼的通病,软件包依赖,好在当前主流的两大发行版本都自带了解决方案,Red hat有 yum,Ubuntu有 apt-get. Mac os 中没有类似的东东,不过有第三方库支持 ...

  6. Mac安装软件包管理工具Homebrew

    PS:最近开始学习groovy,打算去官网下载SDK Bundle,可是官网半天加载不出来,而且莫名其妙就是下载不下来,Folx一直提示 "无效的HTTP相应:禁止",可能是插件和 ...

  7. 3. 上网调查一下目前流行的源程序版本管理软件和项目管理软件都有哪些, 各有什么优缺点? (提示:搜索一下Microsoft TFS、GitHub、Trac、Bugzilla、Rationale,Apple XCode),请用一个实际的源代码管理工具来建立源代码仓库,并签入/签出代码。

    上网调查一下目前流行的源程序版本管理软件和项目管理软件都有哪些, 各有什么优缺点? ---------------答题者:徐潇瑞 (1)Microsoft TFS的优缺点: 优点:是对敏捷,msf,c ...

  8. 利用chocolatey软件包管理工具安装yarn,比npm更快更稳定

    Chocolatey 是一个 Windows 专用的软件包管理工具. Yarn 对你的代码来说是一个包管理器, 你可以通过它使用全世界开发者的代码, 或者分享自己的代码.Yarn 做这些快捷.安全.可 ...

  9. pip软件包管理工具介绍及基本使用

    pip软件包管理工具介绍及基本使用 一分耕耘,一分收获,要收获得好,必须耕耘得好.-- 徐特立 一.pip软件包管理工具介绍: 定义:pip是Python包管理工具 作用:对Python包的查找.下载 ...

随机推荐

  1. 2. Spark GraphX解析

    2.1 存储模式 2.1.1 图存储模式 巨型图的存储总体上有边分割和点分割两种存储方式 1)边分割(Edge-Cut):每个顶点都存储一次,但有的边会被打断分到两台机器上.这样做的好处是节省存储空间 ...

  2. pytest_pytest-html生成html报告

    前言 pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告.兼容Python 2.7,3.6 pytest-html 1.github上源码地址[https://github. ...

  3. highcharts离线导出图表

    到了这里,其实还没有结束,导出图片时,仍会发出两个请求 此时找到offline-exporting.js文件修改其中的libURL 修改为请求自己的网站

  4. MVC视图中 TextBoxFor 数据格式化

    @Html.TextBoxFor(m => m.Birthday,"{0:yyyy-MM-dd}", new { @class = "m-wrap small&qu ...

  5. 学习操作系统和Linux内核的新体会

    算起来是第三次看内核了吧,要从源码的细节中爬出来: (1)先拎清楚主要的数据结构,就把握住了骨架: (2)再看每个系统调用的功能的流程是如何围绕上述数据结构展开.举个栗子,块设备驱动层的主要数据结构有 ...

  6. Linux 磁盘配额(XFS & EXT4)

    若是在Linux中搭建了FTP服务器,为了安全性,就要考虑磁盘配额,以防服务器磁盘空间被恶意占满. 磁盘配额概述 1.作用范围:只在指定的分区有效. 2.限制对象:主要针对用户.组进行限制,对组账号限 ...

  7. 树莓派3b安装opencv

    前言:最近买了一个CSI接口的摄像头,最准用树莓派做人脸识别项目.树莓派上本身已经安装了python2.python3,最开始通过sudo apt-get install python3-opencv ...

  8. Python_math模块

    1.math模块常用方法: import math #π的值 print(math.pi) #计算90度的正弦值 print(math.sin(math.pi/2)) #幂运算,2的十次方 print ...

  9. 浅谈Linux下傻瓜式磁盘分区工具cfdisk的使用

    对于新手来说,Linux环境下的磁盘分区可能还会存在一些困难.对于熟悉Linux的朋友来说,我们还有fdisk.parted(2TB以上的磁盘分区使用)等磁盘分区工具可以使用.在我们新增磁盘或者在原来 ...

  10. Linux操作系统的进程管理

    Linux操作系统的进程管理 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.进程相关概念 1>.进程概述 内核的功用: 进程管理.文件系统.网络功能.内存管理.驱动程序. ...