openEuler 知:iso镜像定制

原文:https://gitee.com/icanpool/shcanpool/blob/master/tools/oecustom/README.md

1. 前言

oecustom (openEuler customize) 是一套关于 openEuler iso 格式光盘映像的定制工具集。

工具用途
iso_custom用于定制 openEuler iso 镜像,可以定制 openEuler iso 镜像的系统名称和安装界面图标等
iso_cut用于裁剪 openEuler iso 镜像,参考 oemaker/isocut,可以裁剪iso大小及默认安装软件,还可以配置 kickstart 文件实现镜像自动安装等
iso_make用于制作 iso 镜像,参考 oemaker/isomaker,可以基于repo源重新制作镜像

2. iso_custom

帮助信息:

[root@localhost canpool]# bash shcanpool/tools/oecustom/iso_custom.sh -h
customize operating system from openeuler iso

usage:
    bash iso_custom.sh [-h] [-p PRODUCT] [-v VERSION] [-r RELEASE] [-i OLDISO] [-o NEWISO] [-g LOGO]

optional arguments:
    -p PRODUCT     product name, default is MyOS
    -v VERSION     version identifier, default is 1.0
    -r RELEASE     release information, default is null
    -i OLDISO      openeuler iso filepath
    -o NEWISO      new iso filename, default is PRODUCT-VERSION-RELEASE-ARCH-dvd.iso
    -g LOGO        directory of logos, directory structure is same as openEuler-logos.rpm
    -h             show the help message and exit

参数介绍:

  • -p PRODUCT:产品名称,如:openEuler,默认是 MyOS
  • -v VERSION:产品版本,如:24.03,默认是 1.0
  • -r RELEASE:产品发布号,如:LTS,默认无
  • -i OLDISO:老的iso文件路径,工具将基于该iso进行定制
  • -o NEWISO:新的iso文件名,定制后的iso文件,默认名为:PRODUCT-VERSION-RELEASE-ARCH-dvd.iso
  • -g LOGO:logo的目录,可以下载 openEuler-logos.rpm 解压,然后替换目录中相关图片,主要替换 sidebar-logo.png 和 morning.jpg

示例:

  • 将 openEuler-24.03-LTS-x86_64-dvd.iso 定制为 MyOS-1.0-x86_64-dvd.iso
bash shcanpool/tools/oecustom/iso_custom.sh -i /path/to/openEuler-24.03-LTS-x86_64-dvd.iso
  • 将 openEuler-24.03-LTS-x86_64-dvd.iso 定制为 MyOS-1.0-x86_64-dvd.iso,并且更换安装界面的logo
bash shcanpool/tools/oecustom/iso_custom.sh -i /path/to/openEuler-24.03-LTS-x86_64-dvd.iso -g shcanpool/tools/oecustom/logos/canpool

在这里插入图片描述
在这里插入图片描述

3. iso_cut

帮助信息:

[root@localhost canpool]# bash shcanpool/tools/oecustom/iso_cut.sh -h
cut operating system iso image

usage:
    bash iso_cut.sh [-h] [-i OLDISO] [-o NEWISO] [-s REPOSITORY] [-f FILE] [-e EXTFILE] [-k KSFILE]

optional arguments:
    -i OLDISO      openeuler iso filepath
    -o NEWISO      new iso filepath, default is new-ARCH-dvd-YYYYMMDD.iso in current dir
    -s REPOSITORY  source dnf repository address link (can be specified multiple times)
    -f FILE        package list file, contains extra packages (can be specified multiple times)
    -e EXTFILE     extra package list file, not installed by default
    -k KSFILE      kickstart filepath
    -a             perform a headless installation
    -h             show the help message and exit

参数介绍:

  • -i OLDISO:老的iso文件路径,工具将基于该iso进行裁剪
  • -o NEWISO:新的iso文件名,裁剪后的iso文件,默认名为:new-ARCH-dvd-YYYYMMDD.iso
  • -s REPOSITORY:dnf仓库源地址,可以指定多次-s来指定多个源。默认OLDISO会作为一个源,如果iso里面的软件不满足使用,可以通过-s指定其它源,比如:everything源,update源。
  • -f FILE:软件包列表文件,可以指定多次-f来指定多个文件。如果指定-f,新iso所包含的软件将由文件内软件决定;如果不指定-f,新iso直接拷贝老iso内的软件包。通过-f指定的软件包,在操作系统安装后将默认被安装。
  • -e EXTFILE:软件包列表文件,通过-e指定的软件包,在操作系统安装后不会默认安装。
  • -k KSFILE:kickstart配置文件
  • -a:指定后,配合-k,可实现安装操作系统时,自动选择第一个安装菜单,然后自动安装系统。

示例:

  • 裁剪 openEuler-24.03-LTS-x86_64-dvd.iso 添加 kickstart 配置文件
bash shcanpool/tools/oecustom/iso_cut.sh -i /path/to/openEuler-24.03-LTS-x86_64-dvd.iso -k shcanpool/tools/oecustom/config/ks/x86_64/ks_template.cfg -a
  • 将 openEuler-24.03-LTS-x86_64-dvd.iso 裁剪为按 minimal 方式安装的镜像
bash shcanpool/tools/oecustom/iso_cut.sh -i /path/to/openEuler-24.03-LTS-x86_64-dvd.iso -f shcanpool/tools/oecustom/config/rpmlist/rpmlist.template -f shcanpool/tools/oecustom/config/rpmlist/rpmlist.x86_64
  • 将 openEuler-24.03-LTS-x86_64-dvd.iso 裁剪为按 minimal 方式安装的镜像,并添加 kickstart 配置文件
bash shcanpool/tools/oecustom/iso_cut.sh -i /path/to/openEuler-24.03-LTS-x86_64-dvd.iso -f shcanpool/tools/oecustom/config/rpmlist/rpmlist.template -f shcanpool/tools/oecustom/config/rpmlist/rpmlist.x86_64 -k shcanpool/tools/oecustom/config/anaconda-ks.cfg -a

说明:shcanpool/tools/oecustom/config/anaconda-ks.cfg 是为裁剪准备的,默认安装环境组为 @^product,其它 iso 镜像中通常没有该环境组

4. iso_make

帮助信息:

[root@localhost canpool]# bash shcanpool/tools/oecustom/iso_make.sh -h
make iso image based on yum repository

usage:
    bash iso_make.sh [-h] [-t TYPE] [-p PRODUCT] [-v VERSION] [-r RELEASE] [-s REPOSITORY]
                     [-k KSFILE] [-b BASEOS] [-o OUTDIR] [-n NAME] [-c]

optional arguments:
    -t TYPE        ISO Type, default is standard, includes:
                       standard everything everything_debug everything_src
    -p PRODUCT     product name, such as: openEuler, default is MyOS
    -v VERSION     version identifier, default is 1.0
    -r RELEASE     release information, default is null
    -s REPOSITORY  source dnf repository address link (can be specified multiple times)
    -k KSFILE      kickstart filepath
    -b BASEOS      base os directory that contains normal.xml and rpmlist.xml, default is os/openEuler
    -o OUTDIR      iso output directory, default is work_dir
    -n NAME        field name in iso file, default is standard (only for standard iso)
    -c             keep the cache and continue the make, not recreate install image
    -h             show the help message and exit

参数介绍:

  • -t TYPE:iso 类型,参考 openEuler 的 iso 镜像类型
  • -p PRODUCT:产品名称,如:openEuler,默认是 MyOS
  • -v VERSION:产品版本,如:24.03,默认是 1.0
  • -r RELEASE:产品发布号,如:LTS,默认无
  • -s REPOSITORY:dnf仓库源地址,可以指定多次-s来指定多个源
  • -k KSFILE:kickstart配置文件
  • -b BASEOS:基线 os 目录,目录内包含 normal.xml 和 rpmlist.xml
  • -o OUTDIR:iso 输出目录
  • -n NAME:iso 文件名中的字段名,默认是 standard(当前只针对标准iso)
  • -c:保留缓存并继续制作镜像,可以不需要重新创建安装镜像,从而降低制作镜像的时间。有如下场景可能会使用:
    • lorax 已经将安装镜像制作成功,之后下载 rpm 失败(安装冲突、依赖不完整等导致的失败)。再次制作时,通过本参数可以跳过制作安装镜像的步骤,从而降低时间。
    • 连续制作多种类型的镜像,安装镜像不需要每次都制作。通过本参数可以只在第一个类型的镜像制作时制作安装镜像,之后类型的镜像复用安装镜像,从而降低时间。

示例:

  • 基于 openEuler-24.03-LTS 的 everything 源制作 iso
bash shcanpool/tools/oecustom/iso_make.sh -s https://mirrors.jxust.edu.cn/openeuler/openEuler-24.03-LTS/everything/x86_64/
  • 基于 openEuler-24.03-LTS 的 everything 和 update 源重新制作 iso
bash shcanpool/tools/oecustom/iso_make.sh -p openEuler -v 24.03 -r LTS -s https://mirrors.jxust.edu.cn/openeuler/openEuler-24.03-LTS/everything/x86_64/ -s https://mirrors.jxust.edu.cn/openeuler/openEuler-24.03-LTS/update/x86_64/
  • 基于 openEuler-24.03-LTS 的 everything 源制作标准 iso,但 iso 文件名中不带 standard 字段(相当于去掉 standard 字段)
bash shcanpool/tools/oecustom/iso_make.sh -n '' -s https://mirrors.jxust.edu.cn/openeuler/openEuler-24.03-LTS/everything/x86_64/
  • 基于 openEuler-24.03-LTS 的 everything 源制作桌面版 iso(需要准备桌面相关的 xml 文件)
bash shcanpool/tools/oecustom/iso_make.sh -n 'desktop' -b /path/to/DESKTOP_XML_DIR -s https://mirrors.jxust.edu.cn/openeuler/openEuler-24.03-LTS/everything/x86_64/

备注:

  • 默认 os/openEuler 目录内的 xml 来自 openEuler-24.03-LTS
  • 其它 openEuler 版本的 xml 文件可以访问 src-openeuler/oemaker 的版本分支获取,也可以访问 oecanpool/iso 获取

5. 后语

iso 的相关工具已经集成到 ola 工具中,通过 ola 的子命令 iso 可以快速使用相关工具:

[root@localhost canpool]# ola
Usage: ola [GLOBALOPTS] SUBCOMMAND [OPTS] [ARGS...]
or: ola help SUBCOMMAND

openEuler linux assistant
Type 'ola help <subcommand>' for help on a specific subcommand.

Commands:
    call (c)                Call the inner function
    checkenv (ce)           Check the enviroment about tools/commands
    debug (d)               debug the subcommad
    help (h)                Give detailed help on a specific sub-command
    init (ini)              Init ola environment
    setting (set)           Setting the config file
    obs                     Open Build Service command-line tool, base osc
    oec                     openEuler/src-openEuler command-line tool
    packageinit (pkginit)   Init package to gitee, including fork, clone, push, pr.
    pub                     A product publish tool
    ship                    A package ship query tool
    sig                     Analyze the SIG (Special Interest Group)
    sync                    Sync branch code of repo
    yumpkg (yump, ypm)      Verify rpm packages using yum
    cloc (cl)               Cloc to count lines of code
    nvd                     Get the CVE informations from NVD (csv format)
    patcher (pat)           Analyse patch files in source code
    repo                    The Multiple Git Repository Tool (git-repo)
    rpm                     RPM package tool
    uncompress (uc)         Uncompress commonly used compressed packages
    abi                     Analyze the Application Binary Interfaces (ABI)
    gec                     gitee command-line tool
    git                     git command-line tool
    spec                    Handle the spec file of rpm
    unittest (ut)           unit test
    build (b)               Build tool
    iso                     Custom iso image tool

Global Options:
    -h, --help          Show this help message and exit
    -v, --version       Get version of ola and exit

Notes:
    command-param: If the parameter of the command is plural, then this parameter can be a
        string list (space separated, as: "a b") or a list file (one per line or space separated).
        see the function "get_list" for more.
[root@localhost canpool]# ola iso
iso: Custom iso image tool

usage:
    ola iso subcmd [options] <args...>

subcmd:
    custom (cs)   customize operating system from openeuler iso
    cut (ct)      cut operating system iso image
    help (h)      Show the specific subcommand usage
    make (mk)     make iso image based on yum repository

notes:
    Type 'ola iso help <subcmd>' for help on a specific subcommand.

[root@localhost canpool]# ola iso cs
customize operating system from openeuler iso

usage:
    bash iso_custom.sh [-h] [-p PRODUCT] [-v VERSION] [-r RELEASE] [-i OLDISO] [-o NEWISO] [-g LOGO]

optional arguments:
    -p PRODUCT     product name, default is MyOS
    -v VERSION     version identifier, default is 1.0
    -r RELEASE     release information, default is null
    -i OLDISO      openeuler iso filepath
    -o NEWISO      new iso filename, default is PRODUCT-VERSION-RELEASE-ARCH-dvd.iso
    -g LOGO        directory of logos, directory structure is same as openEuler-logos.rpm
    -h             show the help message and exit

[root@localhost canpool]# ola iso ct
cut operating system iso image

usage:
    bash iso_cut.sh [-h] [-i OLDISO] [-o NEWISO] [-s REPOSITORY] [-f FILE] [-e EXTFILE] [-k KSFILE]

optional arguments:
    -i OLDISO      openeuler iso filepath
    -o NEWISO      new iso filepath, default is new-ARCH-dvd-YYYYMMDD.iso in current dir
    -s REPOSITORY  source dnf repository address link (can be specified multiple times)
    -f FILE        package list file, contains extra packages (can be specified multiple times)
    -e EXTFILE     extra package list file, not installed by default
    -k KSFILE      kickstart filepath
    -a             perform a headless installation
    -h             show the help message and exit
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值