修复数据库插入异常
This commit is contained in:
parent
4a6bfe4866
commit
caa7e580d2
|
@ -267,8 +267,10 @@ class Sqlite3Server(object):
|
||||||
return upgradeable_pkgs,upgradeable_groups
|
return upgradeable_pkgs,upgradeable_groups
|
||||||
|
|
||||||
# 接收更新列表与信息,生成数据并插入数据库中
|
# 接收更新列表与信息,生成数据并插入数据库中
|
||||||
def insert_info(self, success,matedata,error_code):
|
def insert_info(self, success,error_code):
|
||||||
try:
|
try:
|
||||||
|
output_config_name = '/var/cache/kylin-system-updater/json/kylin-update-desktop-system.json'
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
status = 'success'
|
status = 'success'
|
||||||
status_cn = '成功'
|
status_cn = '成功'
|
||||||
|
@ -276,9 +278,17 @@ class Sqlite3Server(object):
|
||||||
status = 'failed'
|
status = 'failed'
|
||||||
status_cn = '失败'
|
status_cn = '失败'
|
||||||
|
|
||||||
pkgappname = matedata.get("name",{}).get("zh_CN", "")
|
try:
|
||||||
|
with open(output_config_name,'r') as f:
|
||||||
|
matedata = json.load(f)
|
||||||
|
except Exception as exc:
|
||||||
|
matedata = {}
|
||||||
|
logging.error(exc)
|
||||||
|
|
||||||
|
pkgappname = matedata.get("update-name",{}).get("zh_CN", "")
|
||||||
|
logging.info(pkgappname)
|
||||||
pkgversion = matedata.get("version", "")
|
pkgversion = matedata.get("version", "")
|
||||||
pkgdescription = matedata.get("description", {}).get("zh_CN", "")
|
pkgdescription = matedata.get("description","")
|
||||||
pkgchangelog = matedata.get("changelog", "")
|
pkgchangelog = matedata.get("changelog", "")
|
||||||
|
|
||||||
pkgtimestr = datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%d %H:%M:%S")
|
pkgtimestr = datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%d %H:%M:%S")
|
||||||
|
|
|
@ -99,7 +99,7 @@ class UpdateManager():
|
||||||
def start_deploy(self,device_status):
|
def start_deploy(self,device_status):
|
||||||
try:
|
try:
|
||||||
def _deploy_finished(parent,trans):
|
def _deploy_finished(parent,trans):
|
||||||
self.dbus_send.DeployUpdatFinishedNext(parent.exit,[SYSTEM_UPDATE_GROUPS],trans.available_metadata,parent.error_code)
|
self.dbus_send.DeployUpdatFinishedNext(parent.exit,[SYSTEM_UPDATE_GROUPS],parent.error_code)
|
||||||
|
|
||||||
trans.deployable = False
|
trans.deployable = False
|
||||||
if parent.exit:
|
if parent.exit:
|
||||||
|
@ -158,6 +158,7 @@ class UpdateManager():
|
||||||
logging.info("Generate Jsonfile(%s) to complete... ",output_config_name)
|
logging.info("Generate Jsonfile(%s) to complete... ",output_config_name)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
|
|
||||||
def _check_conf_dir(self):
|
def _check_conf_dir(self):
|
||||||
# 检查var配置目录是否存在 不存在时进行创建
|
# 检查var配置目录是否存在 不存在时进行创建
|
||||||
VAR_CONFG_DIR = '/var/lib/kylin-system-updater'
|
VAR_CONFG_DIR = '/var/lib/kylin-system-updater'
|
||||||
|
|
|
@ -224,8 +224,8 @@ class UpdateManagerDbusController(dbus.service.Object):
|
||||||
logging.error(str(e))
|
logging.error(str(e))
|
||||||
return self.RETURN_UNKNOWN_CODE,str(e)
|
return self.RETURN_UNKNOWN_CODE,str(e)
|
||||||
|
|
||||||
def DeployUpdatFinishedNext(self,success,upgrade_group,metadata,error_code=''):
|
def DeployUpdatFinishedNext(self,success,upgrade_group,error_code=''):
|
||||||
self.database.insert_info(success,metadata,error_code)
|
self.database.insert_info(success,error_code)
|
||||||
self.DeployUpdatFinished(success,upgrade_group,error_code,get_error_description_from_enum(error_code))
|
self.DeployUpdatFinished(success,upgrade_group,error_code,get_error_description_from_enum(error_code))
|
||||||
|
|
||||||
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='basss')
|
@dbus.service.signal(UPDATER_DBUS_INTERFACE,signature='basss')
|
||||||
|
|
|
@ -21,7 +21,9 @@ deploy_finished_signal="DeployUpdatFinished"
|
||||||
CMD_PREFIX=""
|
CMD_PREFIX=""
|
||||||
test_tmpdir="/tmp/ostree-auto-test"
|
test_tmpdir="/tmp/ostree-auto-test"
|
||||||
|
|
||||||
|
BUILD_MASTER_BRACH="testos/buildmaster/newbranch"
|
||||||
|
|
||||||
http_port="8889"
|
http_port="8889"
|
||||||
process_name="python3 -m http.server "$http_port
|
process_name="python3 -m http.server "$http_port
|
||||||
|
|
||||||
metadata_string="--add-metadata=update-name={\"zh_CN\":\"系统更新\",\"en_US\":\"KylinOS\"} --add-metadata=description={\"zh_CN\":\"银河麒麟V10SP1-系统更新包\",\"en_US\":\"GalaxyKylinV10SP1SystemUpdate\"} --add-metadata-string=\"icon=/usr/share/kylin-update-desktop-config/icon/kylin-update-desktop-system.png\" --add-metadata-string=changelog=\"initialcommit\" --add-metadata-string=total_download_size=\"800MB\" --add-metadata-string=total_install_size=\"1.2GB\" --add-metadata-string=update-type=\"kylin-update-desktop-system\""
|
metadata_string="--add-metadata=update-name_zh_CN='系统更新' --add-metadata=update-name_en_US='dddddddddd' --add-metadata=description='GalaxyKylinV10SP1SystemUpdate' --add-metadata-string='icon=/usr/share/kylin-update-desktop-config/icon/kylin-update-desktop-system.png' --add-metadata-string=changelog='initialcommit' --add-metadata-string=total_download_size='800MB' --add-metadata-string=total_install_size='1.2GB' --add-metadata-string=update-type='kylin-update-desktop-system'"
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
if [ ! -d "$test_tmpdir" ]; then
|
if [ ! -d "$test_tmpdir" ]; then
|
||||||
mkdir -p "$test_tmpdir"
|
mkdir -p "$test_tmpdir"
|
||||||
echo "Test directory created: $test_tmpdir"
|
echo "创建测试目录: $test_tmpdir"
|
||||||
else
|
else
|
||||||
echo "Test directory exists and recreate: $test_tmpdir"
|
echo "创建测试目录: $test_tmpdir"
|
||||||
sudo chattr -R -i $test_tmpdir/* >/dev/null 2>&1 || true
|
sudo chattr -R -i $test_tmpdir/* >/dev/null 2>&1 || true
|
||||||
chmod -R 777 $test_tmpdir/* >/dev/null 2>&1 || true
|
chmod -R 777 $test_tmpdir/* >/dev/null 2>&1 || true
|
||||||
rm -rf $test_tmpdir
|
rm -rf $test_tmpdir
|
||||||
|
@ -16,7 +16,7 @@ os_repository_new_commit ()
|
||||||
{
|
{
|
||||||
boot_checksum_iteration=${1:-0}
|
boot_checksum_iteration=${1:-0}
|
||||||
content_iteration=${2:-0}
|
content_iteration=${2:-0}
|
||||||
branch=${3:-testos/buildmaster/x86_64-runtime}
|
branch=${3:-$BUILD_MASTER_BRACH}
|
||||||
export version=${4:-$(date "+%Y%m%d.${content_iteration}")}
|
export version=${4:-$(date "+%Y%m%d.${content_iteration}")}
|
||||||
# echo "BOOT ITERATION: $boot_checksum_iteration"
|
# echo "BOOT ITERATION: $boot_checksum_iteration"
|
||||||
cd ${test_tmpdir}/osdata
|
cd ${test_tmpdir}/osdata
|
||||||
|
@ -54,7 +54,7 @@ os_repository_new_commit ()
|
||||||
|
|
||||||
echo "content iteration ${content_iteration}" > usr/bin/content-iteration
|
echo "content iteration ${content_iteration}" > usr/bin/content-iteration
|
||||||
|
|
||||||
echo -n "Repo create new branch:$branch and commit revision:"
|
echo -n "创建新分支:$branch and commit revision:"
|
||||||
|
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit $metadata_string --add-metadata-string "version=${version}" -b $branch -s "Build"
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit $metadata_string --add-metadata-string "version=${version}" -b $branch -s "Build"
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
|
@ -90,6 +90,7 @@ setup_os_repository () {
|
||||||
oldpwd=`pwd`
|
oldpwd=`pwd`
|
||||||
|
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
|
echo "创建远程仓库 $test_tmpdir/test-repo"
|
||||||
mkdir testos-repo
|
mkdir testos-repo
|
||||||
if test -n "$mode"; then
|
if test -n "$mode"; then
|
||||||
ostree_repo_init testos-repo --mode=${mode}
|
ostree_repo_init testos-repo --mode=${mode}
|
||||||
|
@ -98,6 +99,7 @@ setup_os_repository () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
|
echo "模拟创建最小系统 $test_tmpdir/osdata"
|
||||||
mkdir osdata
|
mkdir osdata
|
||||||
cd osdata
|
cd osdata
|
||||||
kver=3.6.0
|
kver=3.6.0
|
||||||
|
@ -141,14 +143,14 @@ EOF
|
||||||
mkdir -p usr/etc/testdirectory
|
mkdir -p usr/etc/testdirectory
|
||||||
echo "a default daemon file" > usr/etc/testdirectory/test
|
echo "a default daemon file" > usr/etc/testdirectory/test
|
||||||
|
|
||||||
echo -n "First commit refs:testos/buildmaster/x86_64-runtime and revision:"
|
echo -n "第一次提交,分支:$BUILD_MASTER_BRACH and revision:"
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.9 -b testos/buildmaster/x86_64-runtime -s "Build"
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.9 -b $BUILD_MASTER_BRACH -s "Build"
|
||||||
|
|
||||||
# Ensure these commits have distinct second timestamps
|
# Ensure these commits have distinct second timestamps
|
||||||
sleep 2
|
sleep 2
|
||||||
echo "a new executable" > usr/bin/sh
|
echo "a new executable" > usr/bin/sh
|
||||||
echo -n "Second commit refs:testos/buildmaster/x86_64-runtime and revision:"
|
echo -n "第二次提交,分支:$BUILD_MASTER_BRACH and revision:"
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.10 -b testos/buildmaster/x86_64-runtime -s "Build"
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.10 -b $BUILD_MASTER_BRACH -s "Build"
|
||||||
|
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
rm -rf osdata-devel
|
rm -rf osdata-devel
|
||||||
|
@ -157,7 +159,7 @@ EOF
|
||||||
cd osdata-devel
|
cd osdata-devel
|
||||||
mkdir -p usr/include
|
mkdir -p usr/include
|
||||||
echo "a development header" > usr/include/foo.h
|
echo "a development header" > usr/include/foo.h
|
||||||
echo -n "Third commit new refs:testos/buildmaster/x86_64-devel and revision:"
|
echo -n "第三次提交,分支:testos/buildmaster/x86_64-devel and revision:"
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.9 -b testos/buildmaster/x86_64-devel -s "Build"
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string new_version=1.0.9 -b testos/buildmaster/x86_64-devel -s "Build"
|
||||||
|
|
||||||
# 更新summary文件
|
# 更新summary文件
|
||||||
|
@ -167,6 +169,7 @@ EOF
|
||||||
|
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
mkdir sysroot
|
mkdir sysroot
|
||||||
|
echo -n "初始化部署系统,位置$test_tmpdir/sysroot "
|
||||||
export OSTREE_SYSROOT=sysroot
|
export OSTREE_SYSROOT=sysroot
|
||||||
${CMD_PREFIX} ostree admin init-fs sysroot
|
${CMD_PREFIX} ostree admin init-fs sysroot
|
||||||
|
|
||||||
|
@ -187,6 +190,7 @@ EOF
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
echo "创建http服务链接到当前仓库 $test_tmpdir/test-repo"
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
mkdir ${test_tmpdir}/httpd
|
mkdir ${test_tmpdir}/httpd
|
||||||
cd httpd
|
cd httpd
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
# - 在osdata目录创建模拟一些系统文件 and 提交两次到testos-repo 仓库
|
# - 在osdata目录创建模拟一些系统文件 and 提交两次到testos-repo 仓库
|
||||||
# - 复制osdata数据到osdata-devel,做出修改然后再次提交
|
# - 复制osdata数据到osdata-devel,做出修改然后再次提交
|
||||||
# - 用init-fs创建sysroot 和 os-init 和 syslinux
|
# - 用init-fs创建sysroot 和 os-init 和 syslinux
|
||||||
# - 提交一个新的commit用空目录,标记初始分支(testos/buildmaster/x86_64-runtime)为EOL 重新定向到新分支(testos/buildmaster/newbranch)
|
# - 提交一个新的commit用空目录,标记初始分支($BUILD_MASTER_BRACH)为EOL 重新定向到新分支(testos/buildmaster/newbranch)
|
||||||
|
|
||||||
|
run_system=$(pwd)/../kylin-system-updater
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
@ -36,56 +38,61 @@ test_deploy_limit() {
|
||||||
if [ $y -eq 0 ]; then
|
if [ $y -eq 0 ]; then
|
||||||
y=""
|
y=""
|
||||||
fi
|
fi
|
||||||
os_repository_new_commit 1 1 testos/buildmaster/newbranch$i
|
echo ""
|
||||||
|
echo "测试:从当前分支切换到新分支部署升级"
|
||||||
|
|
||||||
|
new_brach="testos/buildmaster/newbranch$i"
|
||||||
|
os_repository_new_commit 1 1 $new_brach
|
||||||
|
|
||||||
mkdir empty$i
|
mkdir empty$i
|
||||||
echo -n "Refs:testos/buildmaster/x86_64-runtime and new commit revision:"
|
echo -n "当前系统分支:$BUILD_MASTER_BRACH,配置切换到新分支$new_brach revision:"
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=$(pwd)/empty$i --add-metadata-string "ostree.endoflife-rebase=testos/buildmaster/newbranch$i" -b testos/buildmaster/newbranch$y -s "EOL redirect to new branch"
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit --tree=dir=$(pwd)/empty$i --add-metadata-string "ostree.endoflife-rebase=testos/buildmaster/newbranch$i" -b testos/buildmaster/newbranch$y -s "EOL redirect to new branch"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Ostree test environment is deployed, Start System update Fuction tested"
|
echo "Ostree 测试环境创建成功, 开始系统更新功能测试"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# 检查更新
|
echo "检查更新"
|
||||||
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$update_method > /dev/null
|
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$update_method > /dev/null
|
||||||
moniter_signal_success $update_finished_signal
|
moniter_signal_success $update_finished_signal
|
||||||
|
|
||||||
# 下载过程
|
echo "部署下载"
|
||||||
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$download_method > /dev/null
|
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$download_method > /dev/null
|
||||||
moniter_signal_success $download_finished_signal
|
moniter_signal_success $download_finished_signal
|
||||||
|
|
||||||
# 部署
|
echo "部署内容"
|
||||||
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$deploy_method > /dev/null
|
sudo gdbus call --system --dest $bus_name --object-path $object_path --method $interface_name.$deploy_method > /dev/null
|
||||||
moniter_signal_success $deploy_finished_signal
|
moniter_signal_success $deploy_finished_signal
|
||||||
|
|
||||||
|
# 部署完成后的检查
|
||||||
|
assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf "${bootcsum}"
|
||||||
|
rev=$(${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse $new_brach)
|
||||||
|
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/usr/bin/content-iteration "1"
|
||||||
|
|
||||||
|
assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0.origin "newbranch"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# 创建仓库 仓库类型 and boot类型
|
# 创建ostree仓库 仓库类型 and boot类型 包括默认开启一个远程
|
||||||
setup_os_repository "archive" "syslinux"
|
setup_os_repository "archive" "syslinux"
|
||||||
|
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo
|
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos $(cat httpd-address)/ostree/testos-repo
|
||||||
|
|
||||||
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime > /dev/null
|
${CMD_PREFIX} ostree --repo=sysroot/ostree/repo pull testos $BUILD_MASTER_BRACH > /dev/null
|
||||||
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse testos/buildmaster/x86_64-runtime)
|
rev=$(${CMD_PREFIX} ostree --repo=sysroot/ostree/repo rev-parse $BUILD_MASTER_BRACH)
|
||||||
echo "Pull a branch(testos/buildmaster/x86_64-runtime) from remote repo and revision=${rev}"
|
echo "拉取分支:$BUILD_MASTER_BRACH 从远程仓库testos-repo and revision=${rev}"
|
||||||
|
|
||||||
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime > /dev/null
|
echo "部署分支:$BUILD_MASTER_BRACH"
|
||||||
|
${CMD_PREFIX} ostree admin deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:$BUILD_MASTER_BRACH > /dev/null
|
||||||
assert_has_dir sysroot/boot/ostree/testos-${bootcsum}
|
assert_has_dir sysroot/boot/ostree/testos-${bootcsum}
|
||||||
|
|
||||||
echo "Frist deploy refs:testos/buildmaster/x86_64-runtime to success"
|
exec 3< <($run_system -r -d --sysroot=$test_tmpdir/sysroot --os=testos 2>&1)
|
||||||
|
|
||||||
exec 3< <(/home/x/share/ostree/kylin-system-updater/backend/kylin-system-updater -r -d --sysroot=$test_tmpdir/sysroot --os=testos 2>&1)
|
|
||||||
# 等待dbus服务启动
|
# 等待dbus服务启动
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
||||||
test_deploy_limit 1
|
test_deploy_limit 1
|
||||||
|
|
||||||
# 部署完成后的检查
|
|
||||||
# assert_file_has_content sysroot/boot/loader/entries/ostree-2-testos.conf "${bootcsum}"
|
|
||||||
# rev=$(${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo rev-parse testos/buildmaster/newbranch)
|
|
||||||
# assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0/usr/bin/content-iteration "1"
|
|
||||||
|
|
||||||
# assert_file_has_content sysroot/ostree/deploy/testos/deploy/${rev}.0.origin "newbranch"
|
|
||||||
|
|
||||||
echo "ok update and redirect"
|
echo "ok update and redirect"
|
Loading…
Reference in New Issue