Compare commits

...

11 Commits

Author SHA1 Message Date
openeuler-ci-bot
4f4642f86e !22 [sync] PR-21: KubeOS:add arm architecture support to the OS image
Merge pull request !22 from openeuler-sync-bot/sync-pr21-master-to-openEuler-20.03-LTS-SP3
2021-12-18 03:41:27 +00:00
liyuanr
56c02b7e2f KubeOS:add arm architecture support to the OS image
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
(cherry picked from commit 230b157db00cd15d21ccb6edff7cd38e72bd426b)
2021-12-18 11:28:01 +08:00
openeuler-ci-bot
33877c2bf1 !19 [sync] PR-18: change generate argument from isopath to repopath
Merge pull request !19 from openeuler-sync-bot/sync-pr18-master-to-openEuler-20.03-LTS-SP3
2021-12-13 07:09:09 +00:00
linxiaoxu
e0ffbbc8cc change generate argument from isopath to repopath
(cherry picked from commit 34799ba67450f5ad7914574ce62db2675efda8e4)
2021-12-13 15:03:08 +08:00
openeuler-ci-bot
16135f48ff !17 [sync] PR-16: KubeOS:fix bugs of checks in generate.sh and change module path
From: @openeuler-sync-bot
Reviewed-by: @duguhaotian
Signed-off-by: @duguhaotian
2021-11-22 06:35:36 +00:00
liyuanr
75df3bb729 KubeOS:fix bugs of checks in generate.sh and change module path
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
(cherry picked from commit 5753d7f7bf8f63bfb0ae32df4f447b56b388bdb4)
2021-11-16 10:18:59 +08:00
openeuler-ci-bot
0f9b377b26 !14 update version to v1.0.1
From: @li-yuanrong
Reviewed-by: @jianminw
Signed-off-by: @jianminw
2021-11-01 03:03:23 +00:00
liyuanr
e3b47f8db3 update compressed package
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
2021-10-30 09:29:21 +00:00
openeuler-ci-bot
e0b505cab9 !9 update version to v1.0.1
From: @linxiaoxu131415
Reviewed-by: @caihaomin
Signed-off-by: @caihaomin
2021-10-29 07:04:07 +00:00
linxiaoxu
75f919d393 update version to v1.0.1 2021-10-29 06:34:04 +00:00
openeuler-ci-bot
c1c94707f5 !7 change generate argument check range
From: @linxiaoxu131415
Reviewed-by: @jianminw
Signed-off-by: @jianminw
2021-10-20 04:17:44 +00:00
7 changed files with 722 additions and 37 deletions

View File

@ -0,0 +1,264 @@
From 0ccbd9d7eba9d600746420d2dd363065f487be17 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Sat, 30 Oct 2021 02:50:37 +0000
Subject: [PATCH] KubeOS:modify checks in generate.sh and change module path
The previous disk space check did not consider the case where
the disk capacity was TB. In addition,if a path containing
/mnt exists,the mount check consider that /mnt has been mounted.
Add the processing when the disk capacity is TB during disk check,
modify mount check and changes module path to openeuler.org/KubeOS.
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
VERSION | 2 +-
cmd/agent/main.go | 6 ++--
cmd/agent/server/server.go | 2 +-
cmd/operator/controllers/os_controller.go | 6 ++--
cmd/operator/main.go | 8 +++---
cmd/proxy/controllers/os_controller.go | 14 ++++-----
cmd/proxy/main.go | 12 ++++----
go.mod | 2 +-
hack/releasenote.sh | 35 +++++++++++++++++++++++
pkg/agentclient/connection.go | 2 +-
scripts/generate.sh | 16 ++++++-----
11 files changed, 71 insertions(+), 34 deletions(-)
create mode 100755 hack/releasenote.sh
diff --git a/VERSION b/VERSION
index 3eefcb9..7dea76e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.0
+1.0.1
diff --git a/cmd/agent/main.go b/cmd/agent/main.go
index 8f9485a..aef9e47 100644
--- a/cmd/agent/main.go
+++ b/cmd/agent/main.go
@@ -17,9 +17,9 @@ import (
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
- pb "openeuler.org/saiyan/cmd/agent/api"
- "openeuler.org/saiyan/cmd/agent/server"
- "openeuler.org/saiyan/pkg/version"
+ pb "openeuler.org/KubeOS/cmd/agent/api"
+ "openeuler.org/KubeOS/cmd/agent/server"
+ "openeuler.org/KubeOS/pkg/version"
)
func main() {
diff --git a/cmd/agent/server/server.go b/cmd/agent/server/server.go
index ef8630b..711e0c8 100644
--- a/cmd/agent/server/server.go
+++ b/cmd/agent/server/server.go
@@ -29,7 +29,7 @@ import (
"time"
"github.com/sirupsen/logrus"
- pb "openeuler.org/saiyan/cmd/agent/api"
+ pb "openeuler.org/KubeOS/cmd/agent/api"
)
const (
diff --git a/cmd/operator/controllers/os_controller.go b/cmd/operator/controllers/os_controller.go
index 5c572fd..a040ef4 100644
--- a/cmd/operator/controllers/os_controller.go
+++ b/cmd/operator/controllers/os_controller.go
@@ -25,9 +25,9 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
- "openeuler.org/saiyan/pkg/common"
- "openeuler.org/saiyan/pkg/values"
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
+ "openeuler.org/KubeOS/pkg/common"
+ "openeuler.org/KubeOS/pkg/values"
)
// OSReconciler reconciles an OS object
diff --git a/cmd/operator/main.go b/cmd/operator/main.go
index c8c0530..17b74e1 100644
--- a/cmd/operator/main.go
+++ b/cmd/operator/main.go
@@ -21,10 +21,10 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"
ctrl "sigs.k8s.io/controller-runtime"
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
- "openeuler.org/saiyan/cmd/operator/controllers"
- "openeuler.org/saiyan/pkg/common"
- "openeuler.org/saiyan/pkg/version"
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
+ "openeuler.org/KubeOS/cmd/operator/controllers"
+ "openeuler.org/KubeOS/pkg/common"
+ "openeuler.org/KubeOS/pkg/version"
//+kubebuilder:scaffold:imports
)
diff --git a/cmd/proxy/controllers/os_controller.go b/cmd/proxy/controllers/os_controller.go
index 04aed8f..ab9a411 100644
--- a/cmd/proxy/controllers/os_controller.go
+++ b/cmd/proxy/controllers/os_controller.go
@@ -26,10 +26,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
- "openeuler.org/saiyan/pkg/agentclient"
- "openeuler.org/saiyan/pkg/common"
- "openeuler.org/saiyan/pkg/values"
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
+ "openeuler.org/KubeOS/pkg/agentclient"
+ "openeuler.org/KubeOS/pkg/common"
+ "openeuler.org/KubeOS/pkg/values"
)
// OSReconciler reconciles a OS object
@@ -137,9 +137,9 @@ func evictNode(drainer *drain.Helper, node *corev1.Node) error {
}
if err := drain.RunNodeDrain(drainer, node.Name); err != nil {
log.Error(err, "unable to drain node")
- if err := drain.RunCordonOrUncordon(drainer, node, false); err != nil {
- log.Error(err, "unable to uncordon node when an error occurs in draining node")
- return err
+ if terr := drain.RunCordonOrUncordon(drainer, node, false); terr != nil {
+ log.Error(terr, "unable to uncordon node when an error occurs in draining node")
+ return terr
}
return err
}
diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go
index 921bd95..ce1f58d 100644
--- a/cmd/proxy/main.go
+++ b/cmd/proxy/main.go
@@ -22,12 +22,12 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"
ctrl "sigs.k8s.io/controller-runtime"
- upgradev1 "openeuler.org/saiyan/api/v1alpha1"
- "openeuler.org/saiyan/cmd/agent/server"
- "openeuler.org/saiyan/cmd/proxy/controllers"
- "openeuler.org/saiyan/pkg/agentclient"
- "openeuler.org/saiyan/pkg/common"
- "openeuler.org/saiyan/pkg/version"
+ upgradev1 "openeuler.org/KubeOS/api/v1alpha1"
+ "openeuler.org/KubeOS/cmd/agent/server"
+ "openeuler.org/KubeOS/cmd/proxy/controllers"
+ "openeuler.org/KubeOS/pkg/agentclient"
+ "openeuler.org/KubeOS/pkg/common"
+ "openeuler.org/KubeOS/pkg/version"
//+kubebuilder:scaffold:imports
)
diff --git a/go.mod b/go.mod
index cdf8ff6..736e6bd 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module openeuler.org/saiyan
+module openeuler.org/KubeOS
go 1.15
diff --git a/hack/releasenote.sh b/hack/releasenote.sh
new file mode 100755
index 0000000..71049a2
--- /dev/null
+++ b/hack/releasenote.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+#######################################################################
+##- @Copyright (C) Huawei Technologies., Ltd. 2021. All rights reserved.
+# - KubeOS licensed under the Mulan PSL v2.
+# - You can use this software according to the terms and conditions of the Mulan PSL v2.
+# - You may obtain a copy of Mulan PSL v2 at:
+# - http://license.coscl.org.cn/MulanPSL2
+# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
+# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
+# - PURPOSE.
+# - See the Mulan PSL v2 for more details.
+#######################################################################
+
+#!/bin/bash
+
+function get_release_notes()
+{
+ LAST_RELEASE=$(git describe --tags --abbrev=0)
+ # Prepare proposed delease notes
+ echo "$(date "+%Y-%m-%d") $USER release $1"
+ git log --first-parent --oneline $LAST_RELEASE.. | cut -d' ' -f 2- | sed 's/^/ - /'
+ echo ""
+ echo " dev stats:"
+ echo " -$(git diff --shortstat $LAST_RELEASE)"
+ echo -n " - contributors: "
+ git shortlog -ns --no-merges $LAST_RELEASE..HEAD | cut -d$'\t' -f 2 | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/, /g'
+ echo ""
+}
+
+if [ $# -ne 1 ];then
+ echo "Usage:"
+ echo "./hack/releasenote.sh v1.0.0"
+ exit 0
+fi
+get_release_notes $1
diff --git a/pkg/agentclient/connection.go b/pkg/agentclient/connection.go
index 1f28ee4..7d16019 100644
--- a/pkg/agentclient/connection.go
+++ b/pkg/agentclient/connection.go
@@ -21,7 +21,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
- pb "openeuler.org/saiyan/cmd/agent/api"
+ pb "openeuler.org/KubeOS/cmd/agent/api"
)
// Client defines the client stub for OS service
diff --git a/scripts/generate.sh b/scripts/generate.sh
index 7a57b05..1374894 100644
--- a/scripts/generate.sh
+++ b/scripts/generate.sh
@@ -145,7 +145,7 @@ function check_path() {
exit 5
fi
- if mount 2>/dev/null | grep -q "${ISO_PATH}"; then
+ if mount 2>/dev/null | grep -w -q "${ISO_PATH}"; then
echo "$ISO_PATH has already been mounted."
exit 4
fi
@@ -153,11 +153,13 @@ function check_path() {
function check_disk_space() {
local disk_ava="$(df ${PWD} -h | awk 'NR==2{print}' | awk '{print $4}')"
- if echo "${disk_ava}" | grep -q G$; then
- disk_ava="$(echo ${disk_ava} | awk -F G '{print $1}' | awk -F . '{print $1}')"
- if [ "${disk_ava}" -lt 25 ]; then
- echo "The available disk space is not enough, at least 25GB."
- exit 6
+ if echo "${disk_ava}" | grep -q [GT]$; then
+ if echo "${disk_ava}" | grep -q G$; then
+ disk_ava="$(echo ${disk_ava} | awk -F G '{print $1}' | awk -F . '{print $1}')"
+ if [ "${disk_ava}" -lt 25 ]; then
+ echo "The available disk space is not enough, at least 25GB."
+ exit 6
+ fi
fi
else
echo "The available disk space is not enough, at least 25G."
@@ -293,7 +295,7 @@ fi
set +eE
for i in $1 $2 $3
do
- echo "$i" | grep -v -E ${CHECK_REGEX}
+ echo "$i" | grep -v -E -q ${CHECK_REGEX}
filterParam=$(echo "$i" | grep -v -E ${CHECK_REGEX})
if [[ "${filterParam}" != "$i" ]]; then
echo "error: params $i is invalid, please check it."
--
2.30.0

View File

@ -1,29 +0,0 @@
From 377a5a9a81a3063ab56e2916575d46c0ec984f52 Mon Sep 17 00:00:00 2001
From: linxiaoxu131415 <linxiaoxu@huawei.com>
Date: Wed, 13 Oct 2021 07:54:55 +0000
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E6=95=B0=E6=A0=A1?=
=?UTF-8?q?=E9=AA=8C=E8=8C=83=E5=9B=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
scripts/generate.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/generate.sh b/scripts/generate.sh
index c181221..7a57b05 100644
--- a/scripts/generate.sh
+++ b/scripts/generate.sh
@@ -291,7 +291,7 @@ if [ $# != 4 ];then
fi
set +eE
-for i in $*
+for i in $1 $2 $3
do
echo "$i" | grep -v -E ${CHECK_REGEX}
filterParam=$(echo "$i" | grep -v -E ${CHECK_REGEX})
--
2.23.0

View File

@ -0,0 +1,119 @@
From c652bb6f46ce2e434bd098552abebbba8909a9c0 Mon Sep 17 00:00:00 2001
From: linxiaoxu <linxiaoxu@huawei.com>
Date: Wed, 8 Dec 2021 02:01:18 +0000
Subject: [PATCH] change generate argument from isopath to repopath
---
docs/quick-start.md | 4 ++--
scripts/generate.sh | 30 ++++++------------------------
2 files changed, 8 insertions(+), 26 deletions(-)
diff --git a/docs/quick-start.md b/docs/quick-start.md
index 098c839..ceb81e5 100644
--- a/docs/quick-start.md
+++ b/docs/quick-start.md
@@ -56,10 +56,10 @@
进入scripts目录执行脚本
```
cd scripts
- bash generate.sh ISO_PATH VERSION AGENT_PATH ENCRYPTED_PASSWD
+ bash generate.sh REPO_PATH VERSION AGENT_PATH ENCRYPTED_PASSWD
```
- 参数说明:
- - ISO_PATH 全量iso的路径
+ - REPO_PATH 全量repo的路径
- VERSION 制作的容器OS镜像的版本
- AGENT_PATH构建出来的os-agent的路径
- ENCRYPTED_PASSWD镜像的root用户密码加密后的带盐值的密码。可以用openssl、kiwi等命令生成
diff --git a/scripts/generate.sh b/scripts/generate.sh
index 1374894..d5111f1 100644
--- a/scripts/generate.sh
+++ b/scripts/generate.sh
@@ -12,8 +12,7 @@
set -e
NAME=KubeOS
-ISO_PATH="/mnt"
-ISO=""
+REPO=""
VERSION=""
AGENT_PATH=""
PASSWD=""
@@ -27,7 +26,7 @@ CHECK_REGEX='\||;|&|&&|\|\||>|>>|<|,|#|!|\$'
function show_options() {
cat << EOF
-usage example: sh generate.sh isopath osversion agentpath passwd(encrypted)
+usage example: sh generate.sh repopath osversion agentpath passwd(encrypted)
options:
-h,--help show help information
@@ -114,7 +113,6 @@ function delete_file() {
function clean_space() {
delete_dir "${RPM_ROOT}"
delete_dir "${TMP_MOUNT_PATH}"
- unmount_dir "${ISO_PATH}"
delete_file os.tar
rm -rf "${LOCK}"
}
@@ -135,8 +133,8 @@ function test_lock() {
}
function check_path() {
- if [ ! -f "${ISO}" ];then
- echo "ISO path is invalid."
+ if [ ! -f "${REPO}" ];then
+ echo "REPO path is invalid."
exit 3
fi
@@ -144,11 +142,6 @@ function check_path() {
echo "there is a rootfs folder. please confirm if rootfs is being used, if not, please remove ${RPM_ROOT} first."
exit 5
fi
-
- if mount 2>/dev/null | grep -w -q "${ISO_PATH}"; then
- echo "$ISO_PATH has already been mounted."
- exit 4
- fi
}
function check_disk_space() {
@@ -168,24 +161,13 @@ function check_disk_space() {
}
function prepare_yum() {
- mount "${ISO}" "${ISO_PATH}"
- if [ ! -d "/mnt/Packages" ]; then
- echo "please use ISO file path as ${ISO}."
- exit 2
- fi
-
# init rpmdb
rpm --root "${RPM_ROOT}" --initdb
mkdir -p "${RPM_ROOT}"{/etc/yum.repos.d,/persist,/proc,/dev/pts,/sys}
mount_proc_dev_sys "${RPM_ROOT}"
# init yum repo
local iso_repo="${RPM_ROOT}/etc/yum.repos.d/iso.repo"
- echo "[base]" >"${iso_repo}"
- {
- echo "name=ISO base"
- echo "baseurl=file://${ISO_PATH}"
- echo "enabled=1"
- } >>"${iso_repo}"
+ cat ${REPO} > ${RPM_ROOT}/etc/yum.repos.d/iso.repo
}
function install_packages() {
@@ -304,7 +286,7 @@ do
done
set -eE
-ISO=$1
+REPO=$1
VERSION=$2
AGENT_PATH=$3
PASSWD=$4
--
2.30.0

View File

@ -0,0 +1,298 @@
From a19218ad25eac323ead61ec5ff1fbb04a6dc2539 Mon Sep 17 00:00:00 2001
From: liyuanr <liyuanrong1@huawei.com>
Date: Fri, 3 Dec 2021 11:16:22 +0800
Subject: [PATCH] KubeOS:add arm architecture support to the OS image
Signed-off-by: liyuanr <liyuanrong1@huawei.com>
---
cmd/agent/server/server.go | 5 +-
files/{boot-grub2.mount => boot.mount} | 6 +-
scripts/bootloader.sh | 40 +++++++++++++
scripts/generate.sh | 83 +++++++++++++++-----------
scripts/grub.cfg | 16 ++---
scripts/rpmlist | 3 +-
scripts/set_in_chroot.sh | 2 +-
7 files changed, 107 insertions(+), 48 deletions(-)
rename files/{boot-grub2.mount => boot.mount} (92%)
create mode 100644 scripts/bootloader.sh
diff --git a/cmd/agent/server/server.go b/cmd/agent/server/server.go
index 711e0c8..e4db02e 100644
--- a/cmd/agent/server/server.go
+++ b/cmd/agent/server/server.go
@@ -174,7 +174,10 @@ func install(imagePath string, mainPart string, partB string) error {
if side != partB {
next = "A"
}
- return runCommand("grub2-set-default", next)
+ if err := runCommand("grub2-set-default", next); err != nil {
+ return err
+ }
+ return runCommand("cp", "/boot/grub2/grubenv", "/boot/efi/EFI/openEuler")
}
func (s *Server) reboot() error {
diff --git a/files/boot-grub2.mount b/files/boot.mount
similarity index 92%
rename from files/boot-grub2.mount
rename to files/boot.mount
index a53fff7..a228aae 100644
--- a/files/boot-grub2.mount
+++ b/files/boot.mount
@@ -15,9 +15,9 @@ Conflicts=umount.target
Before=local-fs.target umount.target
[Mount]
-What=/dev/disk/by-label/GRUB2
-Where=/boot/grub2
-Type=ext4
+What=/dev/disk/by-label/BOOT
+Where=/boot
+Type=vfat
Options=defaults
[Install]
diff --git a/scripts/bootloader.sh b/scripts/bootloader.sh
new file mode 100644
index 0000000..b93c314
--- /dev/null
+++ b/scripts/bootloader.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+set -eu
+set -o pipefail
+set -x
+ARCH=`arch`
+
+function install_grub2_x86 ()
+{
+ # make boot.img/core.img and setup, to support legacy boot mode
+ GRUBNAME=$(which grub2-install)
+ echo "Installing GRUB2..."
+ GRUB_OPTS=${GRUB_OPTS:-"--force"}
+ GRUB_OPTS="$GRUB_OPTS --target=i386-pc"
+
+ $GRUBNAME --modules="biosdisk part_msdos" $GRUB_OPTS $DEVICE
+
+ # make efi file, and save in FAT16 partition, to support UEFI boot mode
+ cp -r /usr/lib/grub/x86_64-efi boot/efi/EFI/openEuler
+ eval "grub2-mkimage -d /usr/lib/grub/x86_64-efi -O x86_64-efi --output=/boot/efi/EFI/openEuler/grubx64.efi '--prefix=(,msdos1)/efi/EFI/openEuler' fat part_gpt part_msdos linux"
+
+ mkdir -p /boot/EFI/BOOT/
+ cp -f /boot/efi/EFI/openEuler/grubx64.efi /boot/EFI/BOOT/BOOTX64.EFI
+}
+
+function install_grub2_efi ()
+{
+ cp -r /usr/lib/grub/arm64-efi /boot/efi/EFI/openEuler/
+ eval "grub2-mkimage -d /usr/lib/grub/arm64-efi -O arm64-efi --output=/boot/efi/EFI/openEuler/grubaa64.efi '--prefix=(,msdos1)/efi/EFI/openEuler' fat part_gpt part_msdos linux"
+
+ mkdir -p /boot/EFI/BOOT/
+ cp -f /boot/efi/EFI/openEuler/grubaa64.efi /boot/EFI/BOOT/BOOTAA64.EFI
+}
+
+if [ $ARCH == "x86_64" ]; then
+ install_grub2_x86
+fi
+
+if [ $ARCH == "aarch64" ]; then
+ install_grub2_efi
+fi
diff --git a/scripts/generate.sh b/scripts/generate.sh
index 73830ea..c481e30 100644
--- a/scripts/generate.sh
+++ b/scripts/generate.sh
@@ -22,6 +22,7 @@ TMP_MOUNT_PATH="${PWD}/mnt"
RPM_ROOT="${PWD}/rootfs"
LOCK=./test.lock
CHECK_REGEX='\||;|&|&&|\|\||>|>>|<|,|#|!|\$'
+ARCH=$(arch)
function show_options() {
cat << EOF
@@ -76,9 +77,14 @@ function init_part() {
offset=$(echo "${offset}*512" | bc)
local loop=$(losetup -f)
losetup -o "${offset}" --sizelimit "${sizelimit}" "${loop}" system.img
- mkfs.ext4 -L "$2" "${loop}"
- mount -t ext4 "${loop}" "$3"
- rm -rf "$3/lost+found"
+ if [ $2 == "BOOT" ];then
+ mkfs.vfat -n "$2" "${loop}"
+ mount -t vfat "${loop}" "$3"
+ else
+ mkfs.ext4 -L "$2" "${loop}"
+ mount -t ext4 "${loop}" "$3"
+ rm -rf "$3/lost+found"
+ fi
}
function delete_dir() {
@@ -183,12 +189,15 @@ function install_packages() {
fi
local rpms=$(cat ./rpmlist | tr "\n" " ")
- yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms}
- yum -y --installroot="${RPM_ROOT}" clean all
+ if [ "${ARCH}" == "x86_64" ]; then
+ yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms} grub2 grub2-efi-x64-modules grub2-pc-modules
+ elif [ "${ARCH}" == "aarch64" ]; then
+ yum -y --installroot="${RPM_ROOT}" install --nogpgcheck --setopt install_weak_deps=False ${rpms} grub2-efi-aa64-modules
+ fi
+ yum -y --installroot="${RPM_ROOT}" clean all
}
function install_misc() {
- cp grub.cfg "${RPM_ROOT}/boot/grub2/"
cp ../files/*mount ../files/os-agent.service "${RPM_ROOT}/usr/lib/systemd/system/"
cp ../files/os-release "${RPM_ROOT}/usr/lib/"
cp "${AGENT_PATH}" "${RPM_ROOT}/usr/bin"
@@ -204,38 +213,46 @@ EOF
mv "${RPM_ROOT}"/boot/initramfs* "${RPM_ROOT}/boot/initramfs.img"
cp set_in_chroot.sh "${RPM_ROOT}"
- ROOT_PWD="${PASSWD}" chroot "$RPM_ROOT" bash /set_in_chroot.sh
+ ROOT_PWD="${PASSWD}" chroot "${RPM_ROOT}" bash /set_in_chroot.sh
rm "${RPM_ROOT}/set_in_chroot.sh"
}
function create_img() {
rm -f system.img update.img
qemu-img create system.img ${IMG_SIZE}G
- parted system.img -- mklabel msdos
- parted system.img -- mkpart primary ext4 1MiB 20MiB
- parted system.img -- mkpart primary ext4 20MiB 2120MiB
- parted system.img -- mkpart primary ext4 2120MiB 4220MiB
- parted system.img -- mkpart primary ext4 4220MiB 100%
-
- local device=$(losetup -f)
- losetup "${device}" system.img
-
- mkdir -p "${TMP_MOUNT_PATH}"
-
- init_part system.img2 ROOT-A "${TMP_MOUNT_PATH}"
- local grub2_path="${TMP_MOUNT_PATH}/boot/grub2"
- mkdir -p "${grub2_path}"
- init_part system.img1 GRUB2 "${grub2_path}"
-
- tar -x -C "${TMP_MOUNT_PATH}" -f os.tar
- sync
-
- dd if=/dev/disk/by-label/ROOT-A of=update.img bs=8M
- mount_proc_dev_sys "${TMP_MOUNT_PATH}"
- chroot "${TMP_MOUNT_PATH}" grub2-install --modules="biosdisk part_msdos" "${device}"
- sync
- unmount_dir "${TMP_MOUNT_PATH}"
-
+ parted system.img -- mklabel msdos
+ parted system.img -- mkpart primary fat16 1MiB 60MiB
+ parted system.img -- mkpart primary ext4 60MiB 2160MiB
+ parted system.img -- mkpart primary ext4 2160MiB 4260MiB
+ parted system.img -- mkpart primary ext4 4260MiB 100%
+
+ local device=$(losetup -f)
+ losetup "${device}" system.img
+
+ mkdir -p "${TMP_MOUNT_PATH}"
+
+ init_part system.img2 ROOT-A "${TMP_MOUNT_PATH}"
+ local BOOT_PATH=${TMP_MOUNT_PATH}/boot
+ mkdir -p ${BOOT_PATH}
+ chmod 755 ${BOOT_PATH}
+ init_part system.img1 BOOT "${BOOT_PATH}"
+
+ mv -f ${RPM_ROOT}/boot/* ${BOOT_PATH} || true
+ [ -d ${RPM_ROOT}/boot/ ] && rm -rf ${RPM_ROOT}/boot/
+ sudo mv -t ${TMP_MOUNT_PATH} ${RPM_ROOT}/* || true
+ cp bootloader.sh "${TMP_MOUNT_PATH}"
+ mount_proc_dev_sys "${TMP_MOUNT_PATH}"
+ DEVICE="${device}" chroot "${TMP_MOUNT_PATH}" bash bootloader.sh
+ cp grub.cfg ${TMP_MOUNT_PATH}/boot/grub2
+ cp grub.cfg ${TMP_MOUNT_PATH}/boot/efi/EFI/openEuler
+ rm -rf "${TMP_MOUNT_PATH}/bootloader.sh"
+ sync
+
+ dd if=/dev/disk/by-label/ROOT-A of=update.img bs=8M
+ sync
+ unmount_dir "${TMP_MOUNT_PATH}"
+
+
init_part system.img3 ROOT-B "${TMP_MOUNT_PATH}"
umount "${TMP_MOUNT_PATH}"
@@ -251,8 +268,6 @@ function create_os_tar() {
install_packages
install_misc
unmount_dir "${RPM_ROOT}"
-
- tar -C "${RPM_ROOT}" -cf ./os.tar .
}
test_lock
diff --git a/scripts/grub.cfg b/scripts/grub.cfg
index d10e4cf..90507c4 100644
--- a/scripts/grub.cfg
+++ b/scripts/grub.cfg
@@ -92,12 +92,12 @@ menuentry 'A' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
insmod ext2
set root='hd0,msdos2'
if [ x$feature_platform_search_hint = xy ]; then
- search --no-floppy --file --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 /boot/vmlinuz
+ search --no-floppy --file --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 /vmlinuz
else
- search --no-floppy --file --set=root /boot/vmlinuz
+ search --no-floppy --file --set=root /vmlinuz
fi
- linux /boot/vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
- initrd /boot/initramfs.img
+ linux /vmlinuz root=/dev/sda2 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
+ initrd /initramfs.img
}
menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'KubeOS-B' {
@@ -108,12 +108,12 @@ menuentry 'B' --class KubeOS --class gnu-linux --class gnu --class os --unrestri
insmod ext2
set root='hd0,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
- search --no-floppy --file --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 /boot/vmlinuz
+ search --no-floppy --file --set=root --hint-bios=hd0,msdos3 --hint-efi=hd0,msdos3 --hint-baremetal=ahci0,msdos3 /vmlinuz
else
- search --no-floppy --file --set=root /boot/vmlinuz
+ search --no-floppy --file --set=root /vmlinuz
fi
- linux /boot/vmlinuz root=/dev/sda3 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
- initrd /boot/initramfs.img
+ linux /vmlinuz root=/dev/sda3 ro rootfstype=ext4 nomodeset quiet oops=panic softlockup_panic=1 nmi_watchdog=1 rd.shell=0 selinux=0 crashkernel=256M panic=3
+ initrd /initramfs.img
}
### END /etc/grub.d/10_linux ###
diff --git a/scripts/rpmlist b/scripts/rpmlist
index 93c277c..7a9adfa 100644
--- a/scripts/rpmlist
+++ b/scripts/rpmlist
@@ -1,6 +1,7 @@
kernel
passwd
-grub2
+grub2-efi
+grub2-tools
dhcp
NetworkManager
openssh-server
diff --git a/scripts/set_in_chroot.sh b/scripts/set_in_chroot.sh
index 3b8313f..49e3894 100644
--- a/scripts/set_in_chroot.sh
+++ b/scripts/set_in_chroot.sh
@@ -1,7 +1,7 @@
#!/bin/bash
ln -s /usr/lib/systemd/system/os-agent.service /usr/lib/systemd/system/multi-user.target.wants/os-agent.service
ln -s /usr/lib/systemd/system/kubelet.service /usr/lib/systemd/system/multi-user.target.wants/kubelet.service
-ln -s /usr/lib/systemd/system/boot-grub2.mount /lib/systemd/system/local-fs.target.wants/boot-grub2.mount
+ln -s /usr/lib/systemd/system/boot.mount /lib/systemd/system/local-fs.target.wants/boot.mount
ln -s /usr/lib/systemd/system/etc.mount /lib/systemd/system/local-fs.target.wants/etc.mount
str=`sed -n '/^root:/p' /etc/shadow | awk -F "root:" '{print $2}'`
--
2.30.0

View File

@ -1,14 +1,15 @@
# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved.
Name: KubeOS
Version: 1.0.0
Release: 4
Version: 1.0.1
Release: 5
Summary: O&M platform used to update the whole OS as an entirety
License: Mulan PSL v2
Source0: https://gitee.com/openeuler/isula-build/repository/archive/v%{version}.tar.gz
ExclusiveArch: x86_64
Source0: https://gitee.com/openeuler/KubeOS/repository/archive/v%{version}.tar.gz
Patch1: 0001-KubeOS-modify-checks-in-generate.sh-and-change-modul.patch
Patch2: 0002-change-generate-argument-from-isopath-to-repopath.patch
Patch3: 0003-KubeOS-add-arm-architecture-support-to-the-OS-image.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Patch1: 0001-argumentchange.patch
BuildRequires: make
BuildRequires: golang >= 1.13
%description
@ -20,7 +21,7 @@ it should be running in kubernetes environment.
%package scripts
Summary: Scripts to build the os image and binaries of os-proxy and os-operator
Requires: qemu-img, parted, bc, tar, docker
Requires: qemu-img, parted, bc, tar, docker, dosfstools
%description scripts
The scripts package includes scripts which could build the os image and binaries of os-proxy and os-operator
@ -46,9 +47,10 @@ install -p -m 0600 ./scripts/rpmlist %{buildroot}/opt/kubeOS/scripts
install -p -m 0500 ./scripts/generate.sh %{buildroot}/opt/kubeOS/scripts
install -p -m 0500 ./scripts/set_in_chroot.sh %{buildroot}/opt/kubeOS/scripts
install -p -m 0600 ./scripts/grub.cfg %{buildroot}/opt/kubeOS/scripts
install -p -m 0500 ./scripts/bootloader.sh %{buildroot}/opt/kubeOS/scripts
install -d -m 0740 %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/boot-grub2.mount %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/boot.mount %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/etc.mount %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/persist.mount %{buildroot}/opt/kubeOS/files
install -p -m 0600 ./files/var.mount %{buildroot}/opt/kubeOS/files
@ -58,7 +60,7 @@ install -p -m 0600 ./files/os-release %{buildroot}/opt/kubeOS/files
%files
%attr(0500,root,root) /opt/kubeOS/bin/os-agent
%defattr(-,root,root,0500)
%attr(0600,root,root) /opt/kubeOS/files/boot-grub2.mount
%attr(0600,root,root) /opt/kubeOS/files/boot.mount
%attr(0600,root,root) /opt/kubeOS/files/etc.mount
%attr(0600,root,root) /opt/kubeOS/files/persist.mount
%attr(0600,root,root) /opt/kubeOS/files/var.mount
@ -73,11 +75,42 @@ install -p -m 0600 ./files/os-release %{buildroot}/opt/kubeOS/files
%attr(0500,root,root) /opt/kubeOS/scripts/generate.sh
%attr(0500,root,root) /opt/kubeOS/scripts/set_in_chroot.sh
%attr(0600,root,root) /opt/kubeOS/scripts/grub.cfg
%attr(0500,root,root) /opt/kubeOS/scripts/bootloader.sh
%clean
rm -rfv %{buildroot}
%changelog
* Fri Dec 17 2021 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-5
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:add arm architecture support to the OS image
* Wed Dec 08 2021 linxiaoxu<linxiaoxu@huawei.com> - 1.0.1-4
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:fix bugs of change generate argument from isopath to repopath
* Thu Nov 11 2021 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-3
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:fix bugs of checks in generate.sh and change module path
* Fri Oct 30 2021 liyuanrong<liyuanrong1@huawei.com> - 1.0.1-2
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:update compressed package
* Fri Oct 29 2021 linxiaoxu<linxiaoxu@huawei.com> - 1.0.1-1
- Type:requirement
- CVE:NA
- SUG:restart
- DESC:update version to v1.0.1
* Tue Oct 19 2021 linxiaoxu<linxiaoxu@huawei.com> - 1.0.0-4
- Type:requirement
- CVE:NA

Binary file not shown.

BIN
v1.0.1.tar.gz Normal file

Binary file not shown.