Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
cryptsetup (2:2.7.5-1deepin2.3) unstable; urgency=medium

* add Chinese localization to cryptroot

-- Liang Bo <liangbo@uniontech.com> Thu, 26 Apr 2025 16:40:22 +0800

cryptsetup (2:2.7.5-1deepin2.2) unstable; urgency=medium

* skip ERROR on usr-overlay device when updating initramfs
Expand Down
2 changes: 2 additions & 0 deletions debian/functions
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ crypttab_validate_option() {
submit-from-crypt-cpus) OPTION="submit_from_crypt_cpus";;
no-read-workqueue) OPTION="no_read_workqueue";;
no-write-workqueue) OPTION="no_write_workqueue";;
tpm2-device) OPTION="tpm2_device";;
esac

case "$o" in
Expand Down Expand Up @@ -247,6 +248,7 @@ crypttab_validate_option() {
submit-from-crypt-cpus) ;;
no-read-workqueue) ;;
no-write-workqueue) ;;
tpm2-device) ;;
x-initrd.attach)
unset -v OPTION ;; # ignored, cf. #1072058
*)
Expand Down
4 changes: 4 additions & 0 deletions debian/initramfs/hooks/cryptroot
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ copy_exec /sbin/dmsetup

[ "$ASKPASS" = n ] || copy_exec /lib/cryptsetup/askpass

copy_exec /bin/gettext
mkdir -p $DESTDIR/usr/share/locale/zh_CN/LC_MESSAGES/
cp /usr/share/locale/zh_CN/LC_MESSAGES/cryptroot.mo $DESTDIR/usr/share/locale/zh_CN/LC_MESSAGES/

# We need sed. Either via busybox or as standalone binary.
if [ "$BUSYBOX" = n ] || [ -z "$BUSYBOXDIR" ]; then
copy_exec /bin/sed
Expand Down
42 changes: 42 additions & 0 deletions debian/initramfs/po/cryptroot.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-03 14:13+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

#: ../scripts/local-top/cryptroot:186
msgid "Failed to unlock automatically, please check TPM or input recovery key."
msgstr ""

#: ../scripts/local-top/cryptroot:188
msgid "Wrong password! You have %s input chances more."
msgstr ""

#: ../scripts/local-top/cryptroot:191
msgid "Wrong recovery key! You have %s input chances more"
msgstr ""

#: ../scripts/local-top/cryptroot:194
msgid "Wrong password! You have %s input chances more"
msgstr ""

#: ../scripts/local-top/cryptroot:225
msgid "Unlocking successfully!"
msgstr ""

#: ../scripts/local-top/cryptroot:230
msgid "Please reboot!"
msgstr ""
43 changes: 43 additions & 0 deletions debian/initramfs/po/zh_CN.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Chinese translations for PACKAGE package
# PACKAGE 软件包的简体中文翻译.
# Copyright (C) 2024 THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# <liangbo@uniontech.com>, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-03 14:13+0800\n"
"PO-Revision-Date: 2024-01-03 14:19+0800\n"
"Last-Translator: liangbo@uniontech.com\n"
"Language-Team: Chinese (simplified)\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.1\n"

#: ../scripts/local-top/cryptroot:186
msgid "Failed to unlock automatically, please check TPM or input recovery key."
msgstr "自动解密失败,请检查TPM硬件或输入恢复密钥解密."

#: ../scripts/local-top/cryptroot:188
msgid "Wrong password! You have %s input chances more."
msgstr "密码错误,您还可以输入%s次."

#: ../scripts/local-top/cryptroot:191
msgid "Wrong recovery key! You have %s input chances more"
msgstr "恢复密钥错误,您还可以输入%s次"

#: ../scripts/local-top/cryptroot:194
msgid "Wrong password! You have %s input chances more"
msgstr "密码错误,您还可以输入%s次"

#: ../scripts/local-top/cryptroot:225
msgid "Unlocking successfully!"
msgstr "解锁成功!"

#: ../scripts/local-top/cryptroot:230
msgid "Please reboot!"
msgstr "多次输入错误,请重启系统后再尝试"
47 changes: 42 additions & 5 deletions debian/initramfs/scripts/local-top/cryptroot
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ esac
[ -f /lib/cryptsetup/functions ] || return 0
. /lib/cryptsetup/functions

if [ -f /etc/default/locale ]; then
. /etc/default/locale
fi
if [ -z $LANG ]; then
if [ -n "$locales" ]; then
LANG=$locales
LANGUAGE=${locales%.*}
fi
fi
export LANG
export LANGUAGE

alias get_loc_str='gettext "cryptroot"'

# wait_for_source()
# Wait for encrypted $CRYPTTAB_SOURCE . Set $CRYPTTAB_SOURCE
Expand Down Expand Up @@ -148,7 +161,7 @@ setup_mapping() {
fi
fi

local count=0 maxtries="${CRYPTTAB_OPTION_tries:-3}" fstype vg rv
local count=0 maxtries="${CRYPTTAB_OPTION_tries:-10}" recovery_tries=5 fstype vg rv
while [ $maxtries -le 0 ] || [ $count -lt $maxtries ]; do
if [ -z "${CRYPTTAB_OPTION_keyscript+x}" ] && [ "$CRYPTTAB_KEY" != "none" ]; then
# unlock via keyfile
Expand All @@ -161,8 +174,29 @@ setup_mapping() {
count=$(( $count + 1 ))

if [ $rv -ne 0 ]; then
cryptsetup_message "ERROR: $CRYPTTAB_NAME: cryptsetup failed, bad password or options?"
sleep 1
left_count=$(( $maxtries - $count))
if [ -f "/tmp/crypt_mode" ]; then
if [ $left_count -ge $recovery_tries ]; then
left_count=$(($left_count - $recovery_tries))
crypt_mode=$(cat /tmp/crypt_mode)
if [ "$crypt_mode" = "tpm" ]; then
count=5
# make askpass accept recovery key
echo "$CRYPTTAB_NAME 6" > /tmp/crypt-tries.cache
pattern=$(get_loc_str "Failed to unlock automatically, please check TPM or input recovery key.")
else
pattern=$(get_loc_str "Wrong password! You have %s input chances more.")
fi
else
pattern=$(get_loc_str "Wrong recovery key! You have %s input chances more")
fi
else
pattern=$(get_loc_str "Wrong password! You have %s input chances more")
fi
wrong_pass_tip=$(printf $pattern $left_count)
plymouth message --text="$wrong_pass_tip"
sleep 2
plymouth message --text=""
continue
elif ! dev="$(dm_blkdevname "$CRYPTTAB_NAME")"; then
cryptsetup_message "ERROR: $CRYPTTAB_NAME: unknown error setting up device mapping"
Expand All @@ -180,12 +214,15 @@ setup_mapping() {
fi
fi

cryptsetup_message "$CRYPTTAB_NAME: set up successfully"
plymouth message --text="$(get_loc_str "Unlocking successfully!")"
wait_for_udev 10
return 0
done

cryptsetup_message "ERROR: $CRYPTTAB_NAME: maximum number of tries exceeded"
plymouth message --text="$(get_loc_str "Please reboot!")"
while true; do
sleep 100
done
exit 1
}

Expand Down
3 changes: 3 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ endif

# generate gettext po files (for luksformat)
$(MAKE) -C debian/scripts/po all luksformat.pot
$(MAKE) -C debian/initramfs/po all cryptroot.pot

execute_before_dh_auto_test:
# tests/fake_token_path.so is built without global $(CFLAGS)
Expand All @@ -59,6 +60,7 @@ execute_before_dh_auto_test:
execute_after_dh_auto_install:
# install gettext po files (for luksformat)
$(MAKE) -C debian/scripts/po DESTDIR=$(CURDIR)/debian/cryptsetup-bin install
$(MAKE) -C debian/initramfs/po DESTDIR=$(CURDIR)/debian/cryptsetup-initramfs install

execute_after_dh_install:
# install apport files when building on Ubuntu
Expand All @@ -74,6 +76,7 @@ override_dh_installinit:

execute_after_dh_auto_clean:
$(MAKE) -C debian/scripts/po update clean
$(MAKE) -C debian/initramfs/po update clean
if [ -f $(CURDIR)/debian/cryptsetup-initramfs.preinst.in ]; then \
mv -fT $(CURDIR)/debian/cryptsetup-initramfs.preinst.in $(CURDIR)/debian/cryptsetup-initramfs.preinst; \
fi
Expand Down
Loading