fix build error

This commit is contained in:
KevinDuan 2023-12-08 11:09:50 +08:00
parent 12d48c15e5
commit 228231b369
12 changed files with 1236 additions and 63 deletions

View File

@ -60,6 +60,7 @@
<file>resource/debian/copyright</file>
<file>resource/debian/source/format</file>
<file>resource/debian/postinst</file>
<file>resource/debian/postrm</file>
<file>resource/background/homepage-boot.png</file>
<file>resource/background/openKylin.svg</file>
<file>resource/background/grub-listview.png</file>
@ -115,6 +116,10 @@
<file>resource/time-cursor/watch_9.png</file>
<file>resource/time-cursor/watch_10.png</file>
<file>resource/background/kylin.gif</file>
<file>resource/plymouth/logo.script</file>
<file>resource/plymouth/uk.png</file>
<file>resource/plymouth/password_field.png</file>
<file>resource/plymouth/progress_dot_off.png</file>
<file>resource/plymouth/104.png</file>
<file>resource/plymouth/103.png</file>
<file>resource/plymouth/102.png</file>

View File

@ -1,6 +1,5 @@
[generic]
Name[zh_CN]=寻光
Name[bo_CN]=འོད་ཟེར་འཚོལ་བ།
[color-schemes]
supportLightDarkMode=true

View File

@ -3,14 +3,6 @@ set -e
case "$1" in
configure)
update-alternatives \
--install /usr/share/plymouth/themes/default.plymouth default.plymouth \
/usr/share/plymouth/themes/openkylin-logo/openkylin-logo.plymouth 150
update-alternatives \
--install /usr/share/plymouth/themes/text.plymouth text.plymouth \
/usr/share/plymouth/themes/openkylin-text/openkylin-text.plymouth 150
if [ -e /boot/grub/grub.cfg ]; then
# Will break Live CD generation, LP #1228462
update-grub || true
@ -33,8 +25,3 @@ case "$1" in
esac
#DEBHELPER#
update-alternatives --install /usr/share/icons/default/index.theme \
x-cursor-theme /usr/share/icons/dark-sense/cursor.theme 110
update-alternatives --install /usr/share/icons/default/index.theme \
x-cursor-theme /usr/share/icons/blue-crystal/cursor.theme 45

42
resource/debian/postrm Normal file
View File

@ -0,0 +1,42 @@
#!/bin/sh
set -e
case "$1" in
remove)
if [ -e /boot/grub/grub.cfg ]; then
# Will break Live CD generation, LP #1228462
update-grub || true
fi
if which update-initramfs >/dev/null 2>&1
then
update-initramfs -u
fi
;;
purge)
;;
upgrade|failed-upgrade|disappear)
;;
abort-install|abort-upgrade)
;;
*)
echo "$0 called with unknown argument \`$1'" 1>&2
exit 1
;;
esac
#DEBHELPER#
update-alternatives --remove-all default.plymouth
update-alternatives --install /usr/share/plymouth/themes/default.plymouth default.plymouth /usr/share/plymouth/themes/openkylin-logo/openkylin-logo.plymouth 150
file_path='/usr/share/grub/themes/UKUI/theme.txt'
line_number=$(grep -n 'desktop-image:' $file_path | cut -d ':' -f 1)
if [ -n $line_number ]; then
sed -i '/^desktop-image:/s|".*"|"'background.png'"|' "$file_path"
fi

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

BIN
resource/plymouth/uk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -12,6 +12,7 @@ void buildCheckWidget::buildCopy(){
m_debRules = ":/resource/debian/rules";
m_debCopyRight = ":/resource/debian/copyright";
m_debCopyPostinst = ":/resource/debian/postinst";
m_debCopyPostrm = ":/resource/debian/postrm";
QString m_debPath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src";
QDir m_debSource = m_debPath +"/debian/source";
@ -21,30 +22,97 @@ void buildCheckWidget::buildCopy(){
if (QFile::copy(m_debSourceFormat,m_debPath+"/debian/source/format") &&
QFile::copy(m_debRules,m_debPath+"/debian/rules") &&
QFile::copy(m_debCopyRight,m_debPath+"/debian/copyright") &&
QFile::copy(m_debCopyPostinst,m_debPath+"/debian/postinst")){
QFile::copy(m_debCopyPostinst,m_debPath+"/debian/postinst") &&
QFile::copy(m_debCopyPostrm,m_debPath+"/debian/postrm")){
qDebug()<<"COPY SUCCESS";
} else {
qDebug()<<"COPY Failed";
qDebug()<<QFile::copy(m_debSourceFormat,m_debPath+"/debian/source/format") ;
qDebug()<<QFile::copy(m_debRules,m_debPath+"/debian/rules") ;
qDebug()<<QFile::copy(m_debCopyRight,m_debPath+"/debian/copyright");
qDebug()<<QFile::copy(m_debCopyPostinst,m_debPath+"/debian/postinst");
qDebug()<<QFile::copy(m_debCopyPostrm,m_debPath+"/debian/postrm");
}
}
//全局主题打包
void buildCheckWidget::buildForGlobal(){
buildForIcon();
buildForCursor();
buildForPlymouth();
buildForGrub();
//拷贝default.json
QFile::copy(m_debPath+"/globalTheme/default.json",m_debPath+"/globalTheme/"+FileProcess::g_themeENName+".json");
//修改conf
QString m_themeConf = m_debPath+"/globalTheme/theme.conf";
QString m_themeName = "Name\[zh_CN\]=寻光";
QString m_themeNewName = "Name\[zh_CN\]="+FileProcess::g_themeENName;
QFile file(m_themeConf);
if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) {
qDebug() << "Failed to open file.";
}
QTextStream in(&file);
QString fileContent = in.readAll();
// 查找目标字段并替换
int index1 = fileContent.indexOf(m_themeName);\
if (index1 != -1) {
fileContent.replace(index1, m_themeName.length(), m_themeNewName);
file.resize(0);
QTextStream out(&file);
out << fileContent;
qDebug() << "Name field updated.";
} else {
qDebug() << "Name field not found.";
}
QString m_themeWallpaper = "wallPaperPath=/usr/share/backgrounds/ubuntukylin-default-settings.jpg";
QString m_themeNewWallpaper = "wallPaperPath=/usr/share/config/globaltheme/"+FileProcess::g_themeENName+"/1-openkylin.png";
QDir directory(QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_themeENName + "/src/globalTheme");
QStringList fileList = directory.entryList(QDir::Files);
if (fileList.contains("1-openkylin.jpg")) {
m_themeNewWallpaper = "wallPaperPath=/usr/share/config/globaltheme/"+FileProcess::g_themeENName+"/1-openkylin.jpg";
}
int index2 = fileContent.indexOf(m_themeWallpaper);
if (index2 != -1) {
fileContent.replace(index2, m_themeWallpaper.length(), m_themeNewWallpaper);
file.resize(0);
QTextStream out(&file);
out << fileContent;
qDebug() << "Name field updated.";
} else {
qDebug() << "Name field not found.";
}
QString m_themeWidgetTheme = "widgetStyleName=default";
QString m_themeNewidgetTheme = "widgetStyleName="+FileProcess::g_createThemeType;
int index3 = fileContent.indexOf(m_themeWidgetTheme);
if (index3 != -1) {
fileContent.replace(index3, m_themeWidgetTheme.length(), m_themeNewidgetTheme);
file.resize(0);
QTextStream out(&file);
out << fileContent;
qDebug() << "Name field updated.";
} else {
qDebug() << "Name field not found.";
}
file.close();
}
//图标打包
void buildCheckWidget::buildForIcon(){
//创建打包目录
QString m_buildIconThemePath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/iconTheme/"
+ FileProcess::g_themeENName;
QString m_buildIconThemePath = m_debPath+"/iconTheme/"+FileProcess::g_themeENName;
QDir m_buildIconThemeDir = m_buildIconThemePath;
m_buildIconThemeDir.mkdir(m_buildIconThemeDir.absolutePath());
@ -206,8 +274,7 @@ void buildCheckWidget::buildForIcon(){
//光标打包
void buildCheckWidget::buildForCursor(){
//创建打包目录
QString m_buildcursorThemePath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src/cursorTheme/"
+ FileProcess::g_themeENName + "-cursor";
QString m_buildcursorThemePath = m_debPath+"/cursorTheme/"+ FileProcess::g_themeENName + "-cursor";
QDir m_buildCursorThemeDir = m_buildcursorThemePath;
m_buildCursorThemeDir.mkdir(m_buildCursorThemeDir.absolutePath());
@ -588,29 +655,71 @@ void buildCheckWidget::buildForCursor(){
//开机动画打包
void buildCheckWidget::buildForPlymouth(){
QString m_buildPlymouthPath = QDir::homePath()+ "/.cache/theme-build/" + FileProcess::g_date + "/src/plymouthTheme/";
QFile m_plymouthPic(m_buildPlymouthPath+"1.png");
QDir m_buildPlymouthThemeDir = m_buildPlymouthPath;
m_buildPlymouthThemeDir.mkdir(m_buildPlymouthThemeDir.absolutePath());
//拷贝文件
QFile::copy(":/resource/plymouth/logo.script", m_buildPlymouthPath + FileProcess::g_themeENName+"-logo.script");
QFile::copy(":/resource/plymouth/uk.png",m_buildPlymouthPath+"/uk.png");
QFile::copy(":/resource/plymouth/password_field.png",m_buildPlymouthPath+"/password_field.png");
QFile::copy(":/resource/plymouth/progress_dot_off.png",m_buildPlymouthPath+"/progress_dot_off.png");
if(m_plymouthPic.exists()){
for (int var = 2; var <= 72; ++var) {
QString sourceFilePath = m_plymouthPic.fileName();
QString destinationFilePath =m_buildPlymouthPath + QString::number(var) + ".png";
QFile::copy(sourceFilePath, destinationFilePath);
//写入plymouth文件
QFile m_themeplymouth(m_buildPlymouthPath + FileProcess::g_themeENName+"-logo.plymouth");
QTextStream m_themeplymouthStream(&m_themeplymouth);
if (m_themeplymouth.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
qDebug()<< m_themeplymouth;
m_themeplymouthStream << QStringLiteral("[Plymouth Theme]");
m_themeplymouthStream << endl << QStringLiteral("Name=My Theme");
m_themeplymouthStream << endl << QStringLiteral("Description=This theme is a template to build on");
m_themeplymouthStream << endl << QStringLiteral("ModuleName=script");
m_themeplymouthStream << endl;
m_themeplymouthStream << endl << QStringLiteral("[script]");
m_themeplymouthStream << endl << QStringLiteral("ImageDir=/usr/share/plymouth/themes/")+FileProcess::g_themeENName+QStringLiteral("-logo");
m_themeplymouthStream << endl << QStringLiteral("ScriptFile=/usr/share/plymouth/themes/")+FileProcess::g_themeENName
+QStringLiteral("-logo/")+FileProcess::g_themeENName+QStringLiteral("-logo.script");
m_themeplymouthStream.flush();
m_themeplymouth.close();
}
//写入postinst文件
QFile(m_debPath+"/debian/postinst").setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner);
QFile m_postinst(m_debPath+"/debian/postinst");
QTextStream m_plymouthpostinstStream(&m_postinst);
if (m_postinst.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
qDebug()<< m_postinst;
m_plymouthpostinstStream << endl << QStringLiteral("update-alternatives --remove-all default.plymouth");
m_plymouthpostinstStream << endl << QStringLiteral("update-alternatives"
" --install /usr/share/plymouth/themes/default.plymouth default.plymouth "
"/usr/share/plymouth/themes/")+FileProcess::g_themeENName+QStringLiteral("-logo/")
+FileProcess::g_themeENName+QStringLiteral("-logo.plymouth 150");
m_plymouthpostinstStream.flush();
m_postinst.close();
} else {
qDebug()<< "can't open!!!!!!!!!";
}
}
//grub打包
void buildCheckWidget::buildForGrub(){
QString m_buildGrubPath = QDir::homePath()+ "/.cache/theme-build/" + FileProcess::g_date + "/src/plymouthTheme/";
QFile m_grubPic(m_buildGrubPath+"background.png");
QString m_buildGrubPath = QDir::homePath()+ "/.cache/theme-build/" + FileProcess::g_date + "/src/grubTheme/";
//拷贝grub背景
QFile::copy(m_buildGrubPath+"background.png",m_buildGrubPath+"background-"+FileProcess::g_themeENName+".png");
if(!m_grubPic.exists()){
} else {
//写入postinst文件
QFile(m_debPath+"/debian/postinst").setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner);
QFile m_postinst(m_debPath+"/debian/postinst");
QTextStream m_grubpostinstStream(&m_postinst);
if (m_postinst.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) {
qDebug()<< m_postinst;
m_grubpostinstStream << endl << QStringLiteral("file_path='/usr/share/grub/themes/UKUI/theme.txt'");
m_grubpostinstStream << endl << QStringLiteral("line_number=$(grep -n 'desktop-image:' $file_path | cut -d ':' -f 1)");
m_grubpostinstStream << endl << QStringLiteral("if [ -n '$line_number' ]; then");
m_grubpostinstStream << endl << QStringLiteral(" sed -i '/^desktop-image:/s|\".*\"|\"'background-")+FileProcess::g_themeENName+(".png'\"|' \"$file_path\"");
m_grubpostinstStream << endl << QStringLiteral("fi");
m_grubpostinstStream.flush();
m_postinst.close();
}
}
//编译检查

View File

@ -37,7 +37,10 @@ private:
QString m_debRules;
QString m_debCopyRight;
QString m_debCopyPostinst;
QString m_debCopyPostrm;
QString m_debPath = QDir::homePath() + "/.cache/theme-build/" + FileProcess::g_date + "/src";
int buildCheckState = 0;
void buildCopy();
void buildForGlobal();

View File

@ -489,6 +489,8 @@ void ConfigFileManager::copyPictoCacheDir(const QString &destinationFilePath, QD
targetFileName = "background." + sourceFileExt;
}else if (type == "wallpaper"){
targetFileName = "1-openkylin." + sourceFileExt;
QFile::remove(cachedir.filePath("1-openkylin.png"));
QFile::remove(cachedir.filePath("1-openkylin.jpg"));
}
QString targetFilePath = cachedir.filePath(targetFileName);

View File

@ -365,13 +365,19 @@ void InfoCreateWidget::createMeson(const QString &m_date){
m_globalMesonStream << QStringLiteral("globaltheme_dir = join_paths(get_option('prefix'), 'share/config/globaltheme/')");
m_globalMesonStream << endl << QStringLiteral("platformconfig_dir = join_paths(get_option('prefix'), 'share/qt5-ukui-platformtheme/themeconfig/')");
m_globalMesonStream << endl;
m_globalMesonStream << endl << QStringLiteral("global_d = ['theme.conf','preview.png']");
QDir directory(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/globalTheme");
QStringList fileList = directory.entryList(QDir::Files);
if (fileList.contains("1-openkylin.png")) {
m_globalMesonStream << endl << QStringLiteral("global_d = ['theme.conf','preview.png','1-openkylin.png']");
} else {
m_globalMesonStream << endl << QStringLiteral("global_d = ['theme.conf','preview.png','1-openkylin.jpg']");
}
m_globalMesonStream << endl;
m_globalMesonStream << endl << QStringLiteral("foreach global: global_d");
m_globalMesonStream << endl << QStringLiteral(" install_data(global, install_dir: globaltheme_dir/'")+ FileProcess::g_themeENName +QStringLiteral("')");
m_globalMesonStream << endl << QStringLiteral("endforeach");
m_globalMesonStream << endl;
m_globalMesonStream << endl << QStringLiteral("install_data('default.json', install_dir: platformconfig_dir)");
m_globalMesonStream << endl << QStringLiteral("install_data('")+FileProcess::g_themeENName+(".json', install_dir: platformconfig_dir)");
}
}
@ -412,46 +418,33 @@ void InfoCreateWidget::createMeson(const QString &m_date){
}
}
if(FileProcess::g_createThemeType == "globalTheme" || FileProcess::g_createThemeType == "plymouthTheme"){
QFile m_plymouthMeson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/plymouthTheme/meson.build");
if (m_plymouthMeson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_plymouthMesonStream(&m_plymouthMeson);
m_plymouthMesonStream << QStringLiteral("icons_dir = join_paths(get_option('prefix'), 'share/icons')");
m_plymouthMesonStream << endl;
m_plymouthMesonStream << endl << QStringLiteral("data_d = ['cursor','timecursor']");
m_plymouthMesonStream << endl;
m_plymouthMesonStream << endl << QStringLiteral("foreach data: data_d");
m_plymouthMesonStream << endl << QStringLiteral(" install_subdir(");
m_plymouthMesonStream << endl << QStringLiteral(" data,");
m_plymouthMesonStream << endl << QStringLiteral(" install_dir: icons_dir/'")+ FileProcess::g_themeENName +QStringLiteral("-cursor/cursors',");
m_plymouthMesonStream << endl << QStringLiteral(" strip_directory: true");
m_plymouthMesonStream << endl << QStringLiteral(" )");
m_plymouthMesonStream << endl << QStringLiteral("endforeach");
}
}
if(FileProcess::g_createThemeType == "globalTheme" || FileProcess::g_createThemeType == "grubTheme"){
QFile m_grubMeson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/grubTheme/meson.build");
if (m_grubMeson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_grubMesonStream(&m_grubMeson);
m_grubMesonStream << QStringLiteral("grub_dir = join_paths(get_option('prefix'), 'share/grub/themes/UKUI')");
m_grubMesonStream << endl << QStringLiteral("install_data('background.png', install_dir: grub_dir)");
m_grubMesonStream << endl << QStringLiteral("install_data('background-")+FileProcess::g_themeENName+(".png', install_dir: grub_dir)");
}
}
if(FileProcess::g_createThemeType == "globalTheme" || FileProcess::g_createThemeType == "plymouthTheme"){
QFile m_grubMeson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/plymouthTheme/meson.build");
QFile m_plymouthMeson(QDir::homePath() + "/.cache/theme-build/" + m_date + "/src/plymouthTheme/meson.build");
if (m_grubMeson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_grubMesonStream(&m_grubMeson);
m_grubMesonStream << QStringLiteral("plymouth_dir = join_paths(get_option('prefix'), 'share/plymouth/themes/openkylin-logo')");
for (int var = 1; var <= 72; ++var) {
m_grubMesonStream << endl << QStringLiteral("install_data('")+QString::number(var)+QStringLiteral(".png',install_dir: plymouth_dir)");
if (m_plymouthMeson.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)){
QTextStream m_plymouthMesonStream(&m_plymouthMeson);
m_plymouthMesonStream << QStringLiteral("plymouth_dir = join_paths(get_option('prefix'), 'share/plymouth/themes/")
+FileProcess::g_themeENName+QStringLiteral("-logo')");
m_plymouthMesonStream << endl << QStringLiteral("install_data('uk.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('password_field.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('progress_dot_off.png',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('")+FileProcess::g_themeENName+("-logo.script',install_dir: plymouth_dir)");
m_plymouthMesonStream << endl << QStringLiteral("install_data('")+FileProcess::g_themeENName+("-logo.plymouth',install_dir: plymouth_dir)");
for (int var = 1; var <= 104; ++var) {
m_plymouthMesonStream << endl << QStringLiteral("install_data('")+QString::number(var)+QStringLiteral(".png',install_dir: plymouth_dir)");
}
}
}
this->close();