组保留的标签 余下为需要删除的标签
unset($oldtag[$key]);
}
}
}
if (!empty($oldtag)) {
$tagids = array();
foreach ($oldtag as $tagid => $tagname) {
$tagids[] = $tagid;
}
well_oldtag_delete($tagids, $tid);
}
$r = well_tag_process($tid, $fid, $create_tag, $tagarr);
return $r;
}
// 删除标签和绑定的主题
function well_oldtag_delete($tagids, $tid)
{
$pagesize = count($tagids);
$arrlist = well_tag_find_by_tagids($tagids, 1, $pagesize);
$delete_tagids = array(); // 删除
$tagids = array();
$n = 0;
foreach ($arrlist as $val) {
++$n;
if (1 == $val['count']) {
// 只有一个主题
$delete_tagids[] = $val['tagid'];
} else {
$tagids[] = $val['tagid'];
}
}
!empty($delete_tagids) and well_tag_delete($delete_tagids);
$arlist = well_tag_thread_find_by_tid($tid, 1, $n);
if ($arlist) {
$ids = array();
foreach ($arlist as $val) $ids[] = $val['id'];
well_tag_thread_delete($ids);
}
!empty($tagids) and well_tag_update($tagids, array('count-' => 1));
}
// 标签数据处理 $arr=新提交的数组 $tagarr=保留的旧标签
function well_tag_process($tid, $fid, $new_tags = array(), $tagarr = array())
{
if (empty($tid)) return '';
// 新标签处理入库
if ($new_tags) {
$threadarr = array();
$tagids = array();
$i = 0;
$size = 5;
$n = count($tagarr);
$n = $n > $size ? $size : $size - $n;
foreach ($new_tags as $name) {
++$i;
$name = trim($name);
$name = stripslashes($name);
$name = strip_tags($name);
$name = str_replace(array(' ', '#', "@", "$", "%", "^", '&', '·', '<', '>', ';', '`', '~', '!', '¥', '……', ';', '?', '?', '-', '—', '_', '=', '+', '.', '{', '}', '|', ':', ':', '、', '/', '。', '[', ']', '【', '】', '‘', ' ', ' ', ' ', ' ', ' '), '', $name);
$name = htmlspecialchars($name, ENT_QUOTES);
if ($name && $i <= $n) {
// 查询标签
$read = well_tag_read_name($name);
if ($read) {
// 存在 count+1
$tagids[] = $read['tagid'];
} else {
// 入库
$arr = array('name' => $name, 'count' => 1);
$tagid = well_tag_create($arr);
FALSE === $tagid and message(-1, lang('create_failed'));
$read = array('tagid' => $tagid, 'name' => $name);
}
$tag_thread = array('tagid' => $read['tagid'], 'tid' => $tid);
$threadarr[] = $tag_thread;
$tagarr[$read['tagid']] = $read['name'];
}
}
!empty($threadarr) and tag_thread_big_insert($threadarr);
!empty($tagids) and well_tag_update($tagids, array('count+' => 1));
}
$json = empty($tagarr) ? '' : xn_json_encode($tagarr);
return $json;
}
?> $v = implode(",", $v);
$temp[] = $v;
}
// 去掉重复的字符串,也就是重复的一维数组
$temp = array_unique($temp);
// 再将拆开的数组重新组装
$output = array();
foreach ($temp as $k => $v) {
if ($stkeep) $k = $starr[$k];
if ($ndformat) {
$temparr = explode(",", $v);
foreach ($temparr as $ndkey => $ndval) $output[$k][$ndarr[$ndkey]] = $ndval;
} else $output[$k] = explode(",", $v);
}
return $output;
}
// 合并二维数组 如重复 值以第一个数组值为准
function array2_merge($array1, $array2, $key = '')
{
if (empty($array1) || empty($array2)) return NULL;
$arr = array();
foreach ($array1 as $k => $v) {
isset($v[$key]) ? $arr[$v[$key]] = array_merge($v, $array2[$k]) : $arr[] = array_merge($v, $array2[$k]);
}
return $arr;
}
/*
* 对二维数组排序 两个数组必须有一个相同的键值
* $array1 需要排序数组
* $array2 按照该数组key排序
* */
function array2_sort_key($array1, $array2, $key = '')
{
if (empty($array1) || empty($array2)) return NULL;
$arr = array();
foreach ($array2 as $k => $v) {
if (isset($v[$key]) && $v[$key] == $array1[$v[$key]][$key]) {
$arr[$v[$key]] = $array1[$v[$key]];
} else {
$arr[] = $v;
}
}
return $arr;
}
?>
【开源鸿蒙】下载 OpenHarmony 4.0 源代码和工具链编程频道|福州电脑网
【开源鸿蒙】下载 OpenHarmony 4.0 源代码和工具链
编程之家800
更新时间:2026-04-03 20:25:34
文章目录
- 一、准备命令工具
- 二、配置git和SSH公钥
- 三、下载OpenHarmony源码
- 3.1 使用ssh协议下载(推荐)
- 3.2 使用https协议下载
- 四、下载编译工具链
- 五、参考链接
本文介绍了如何下载开源鸿蒙(OpenHarmony)操作系统源码,该方法可以用于下载OpenHarmony最新开发版本(master分支)或者4.0 Release、3.2 Release等发布版本。
本文基于Ubuntu 22.04进行操作,Ubuntu其他版本也同样可行,包括 20.04, 18.04。
OpenHarmony架构图:
一、准备命令工具
本节介绍如何准备命令行工具,具体包括git/repo/python。
OpenHarmony代码托管在码云服务器上,下载单个代码仓通常使用git命令行工具,下载所有代码仓需要使用repo命令行工具。repo命令行工具是由Python开发的,因此开始之前,需要线安装git/git-lfs/python等命令行工具。
安装git/git-lfs/python/curl,执行如下命令:
sudo apt install git git-lfs python3-pip curl
安装repo命令,执行如下命令:
mkdir ~/bin
curl https://gitee/oschina/repo/raw/fork_flow/repo-py3 > ~/bin/repo
pip3 install -i https://repo.huaweicloud/repository/pypi/simple requests
二、配置git和SSH公钥
本节介绍如何配置本地git用户名和邮箱,以及码云SSH公钥(使用ssh协议下载必须配置):
-
注册码云gitee帐号。
-
注册码云SSH公钥,请参考码云帮助中心。
-
配置git用户信息,执行如下命令:
git config --global user.name "yourname"
git config --global user.email "your-email-address"
git config --global credential.helper store
-
创建目录,用于存放OpenHarmony源码,执行如下命令:
mkdir -p ~/ohos/openharmony
cd ~/ohos/openharmony
三、下载OpenHarmony源码
3.1 使用ssh协议下载(推荐)
通过repo + ssh 下载(需注册公钥,请参考码云帮助中心)。
-
从版本分支获取源码。可获取该版本分支的最新源码,包括版本发布后在该分支的合入。
repo init -u git@gitee:openharmony/manifest.git -b OpenHarmony-4.0-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
-
从版本发布Tag节点获取源码。可获取与版本发布时完全一致的源码。
repo init -u git@gitee:openharmony/manifest.git -b refs/tags/OpenHarmony-v4.0-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
3.2 使用https协议下载
通过repo + https 下载。
-
从版本分支获取源码。可获取该版本分支的最新源码,包括版本发布后在该分支的合入。
repo init -u https://gitee/openharmony/manifest -b OpenHarmony-4.0-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
-
从版本发布Tag节点获取源码。可获取与版本发布时完全一致的源码。
repo init -u https://gitee/openharmony/manifest -b refs/tags/OpenHarmony-v4.0-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
四、下载编译工具链
代码下载完成后,还需要执行prebuilts_download.sh脚本,下载编译工具链,执行如下命令:
bash build/prebuilts_download.sh
这个脚本会创建prebuilts目录,并将边回忆工具链下载、解压到这个目录下。
以上全部完成后,磁盘空间占用50G:
五、参考链接
本文主要参考了OpenHarmony文档仓,里面由其他版本的发布说明(Release Note),根据其他版本的发布说明,也可以下载其他版本的源代码。
- zh-cn/release-notes · OpenHarmony/docs - 码云 - 开源中国 (gitee)
- zh-cn/release-notes/OpenHarmony-v4.0-release.md · OpenHarmony/docs - Gitee
本文发布于:2025-08-04,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鸿蒙开源源代码工具OpenHarmony
发布评论