@@ -11,15 +11,17 @@ import (
1111
1212 "github.com/linuxdeepin/go-lib/dbusutil"
1313 "github.com/linuxdeepin/go-lib/log"
14+ dutils "github.com/linuxdeepin/go-lib/utils"
1415)
1516
1617//go:generate dbusutil-gen em -type Helper
1718
1819const (
19- dbusServiceName = "org.deepin.dde.LocaleHelper1"
20- dbusPath = "/org/deepin/dde/LocaleHelper1"
21- dbusInterface = dbusServiceName
22- localeGenBin = "/usr/sbin/locale-gen"
20+ dbusServiceName = "org.deepin.dde.LocaleHelper1"
21+ dbusPath = "/org/deepin/dde/LocaleHelper1"
22+ dbusInterface = dbusServiceName
23+ localeGenBin = "/usr/sbin/locale-gen"
24+ deepinImmutableCtlBin = "/usr/sbin/deepin-immutable-ctl"
2325)
2426
2527type Helper struct {
@@ -90,10 +92,32 @@ func (h *Helper) canQuit() bool {
9092}
9193
9294func (h * Helper ) doGenLocale () error {
93- return exec .Command (localeGenBin ).Run ()
95+ if ! dutils .IsFileExist (deepinImmutableCtlBin ) {
96+ logger .Warning ("deepin-immutable-ctl not found, use locale-gen directly" )
97+ return exec .Command (localeGenBin ).Run ()
98+ } else {
99+ // TODO 在磐石适配 locale-gen 前使用 deepin-immutable-ctl 执行 locale-gen,否则有权限问题
100+ output , err := exec .Command (deepinImmutableCtlBin , "admin" , "exec" , localeGenBin ).CombinedOutput ()
101+ if err != nil {
102+ logger .Warning ("deepin-immutable-ctl exec locale-gen failed, err:" , err , "output:" , string (output ))
103+ return err
104+ }
105+ return nil
106+ }
94107}
95108
96109// locales version <= 2.13
97110func (h * Helper ) doGenLocaleWithParam (locale string ) error {
98- return exec .Command (localeGenBin , locale ).Run ()
111+ if ! dutils .IsFileExist (deepinImmutableCtlBin ) {
112+ logger .Warning ("deepin-immutable-ctl not found, use locale-gen directly" )
113+ return exec .Command (localeGenBin , locale ).Run ()
114+ } else {
115+ // TODO 在磐石适配 locale-gen 前使用 deepin-immutable-ctl 执行 locale-gen,否则有权限问题
116+ output , err := exec .Command (deepinImmutableCtlBin , "admin" , "exec" , "--" , localeGenBin , locale ).CombinedOutput ()
117+ if err != nil {
118+ logger .Warning ("deepin-immutable-ctl exec locale-gen failed, err:" , err , "output:" , string (output ))
119+ return err
120+ }
121+ return nil
122+ }
99123}
0 commit comments