aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmk-pot58
-rwxr-xr-xremove-old-kernels19
2 files changed, 38 insertions, 39 deletions
diff --git a/mk-pot b/mk-pot
index 7ce93f3..df6a4d5 100755
--- a/mk-pot
+++ b/mk-pot
@@ -1,53 +1,59 @@
#!/usr/bin/bash
# Create remove-old-kernels.pot from remove-old-kernels script
-linesin=0; linesout=0
-
-grep -o '(i18n ".*)' remove-old-kernels|sed "s/(i18n/msgid /"|sed "s/.$//" > pot-temp
-
-rm -f pot-temp1
+# Get raw i18n strings (max two per script line)
while read line; do
- ((linesin++))
- echo "$line" >> pot-temp1
- ((linesout++))
-done < pot-temp
-echo "lines in from script $linesin"
-echo "lines out after fixing plurals $linesout"
+if echo "$line"|grep -q '(i18n'; then
+ idstr1="$(echo "$line"|grep i18n|sed 's/\$(i18n/@/g'|cut -d@ -f2|cut -d\" -f2| sed 's/").*//')"
+ idstr2="$(echo "$line"|grep i18n|sed 's/\$(i18n/@/g'|cut -d@ -f3|cut -d\" -f2| sed 's/").*//')"
+ if [[ ${#idstr1} > 0 ]]; then
+ echo "$idstr1" >> pot-temp
+ if [[ ${#idstr2} > 0 ]]; then
+ echo "$idstr2" >> pot-temp
+ fi
+ fi
+else
+ continue
+fi
+done < remove-old-kernels
-#Check for dupes
-rm -f pot-temp2
+# Check for dupes
rawarray=(); x=0 ; y=0
-# Loop through pot-temp1
-while read line; do
+# Loop through pot-temp
+while IFS= read -r line; do
# Reset isdupe
- isdupe=0; rawstr=""
-# get raw string
- rawstr="$(echo $line|cut -d\" -f2)"
+ isdupe=0
+
#loop through array to check if msgid already exists
for ((y=1;y<$((x+1));y++)); do
- if [[ "$rawstr" == "${rawarray[$y]}" ]]; then
+ if [[ "$line" == "${rawarray[$y]}" ]]; then
isdupe=1
break
fi
done
+
# Dupe found so loop and ignore this $line
[[ $isdupe = 1 ]] && continue
-# Dupe not found so add raw string to array
-# increment line index
+
+# Dupe not found so add string to array
+# Increment line index
((x++))
- rawarray[$x]="$rawstr"
+ rawarray[$x]="$line"
+
# Output line to pot-temp2
- echo "$line" >> pot-temp2
+ echo "msgid \""$line"\"" >> pot-temp2
+
# Insert blank msgstr line and blank line
echo -e 'msgstr ""\n' >> pot-temp2
-done < pot-temp1
+done < pot-temp
-echo "Lines out after dupe removal: $x"
+echo "msgid's out: $x"
# Save to po dir
cat pot_header.txt > po/remove-old-kernels.pot
cat pot-temp2 >> po/remove-old-kernels.pot
-# Delete all tmp files
+
+# Delete tmp files
rm -f pot-temp*
# Add date and time for last pot file change
diff --git a/remove-old-kernels b/remove-old-kernels
index ab64f01..e937695 100755
--- a/remove-old-kernels
+++ b/remove-old-kernels
@@ -91,8 +91,7 @@ if cat ${maincfg}|grep -q "ALTCFG=" && [[ $ALTCFG -gt 0 ]]; then
currcfg="${cfgpath}${prog}_${ALTCFG}.cfg"
source $currcfg
else
- echo -e "${RemvCol}$(i18n "Your alternative configuration file does not exist:")${Normal}\
-/etc/remove-old-kernels_$ALTCFG.cfg\n$(i18n "Either replace it or set ALTCFG=0 in") /etc/remove-old-kernels.cfg"
+ echo -e "${RemvCol}$(i18n "Your alternative configuration file does not exist:")${Normal}/etc/remove-old-kernels_$ALTCFG.cfg\n$(i18n "Either replace it or set ALTCFG=0 in") /etc/remove-old-kernels.cfg"
exit 1
fi
fi
@@ -122,8 +121,7 @@ dnfNBK=0; dnfmsg=false
# Function to check we are root or exit
chkroot() {
if (((UID))); then
- echo -e "${RemvCol}$(i18n "Must be root to edit configuration")\
-${Normal}\n$(i18n "Tap spacebar")"
+ echo -e "${RemvCol}$(i18n "Must be root to edit configuration")${Normal}\n$(i18n "Tap spacebar")"
read -n1; echo -en "${ClearLine}"
exit 0
fi
@@ -294,8 +292,7 @@ NK=$(ls /boot/vmlinuz*.mga* | wc -l)
#================================ Show status ==============================
-echo -e "${HdBgCol} System: $(cat /etc/mageia-release) | $(i18n "Kernels in") /boot/:${NK} | \
-AUTO:$autostat | $(i18n "KEEP"):$NBK ${qamssg}${cfgmssg}${Normal} "
+echo -e "${HdBgCol} System: $(cat /etc/mageia-release) | $(i18n "Kernels in") /boot/:${NK} | AUTO:$autostat | $(i18n "KEEP"):$NBK ${qamssg}${cfgmssg}${Normal} "
#================================= Analyse rpms =============================
# Get master list from rpm -qa --last
@@ -459,8 +456,7 @@ if [[ ${nbt} -ne 0 ]] ; then
else
kernstr="$(i18n "kernel"):"
fi
- read -p "$(i18n "Remove") ${nbt} $kernstr ? \
- $(i18n "y/N/i (i=confirm for each)") " -n 1 response
+ read -p "$(i18n "Remove") ${nbt} $kernstr ? $(i18n "y/N/i (i=confirm for each)") " -n 1 response
if [[ -z ${response} ]] ; then response="n" ; fi
case ${response} in
[Yy])
@@ -486,8 +482,7 @@ if [[ ${nbt} -ne 0 ]] ; then
for installedKernelPackage in $(tac ${TMPKTR}) ; do
if [[ ${MODE} = "I" ]] ; then # --- interactive mode ---
- read -p "$(i18n "Remove") ${installedKernelPackage} ? \
-$(i18n "y/N/q (q=quit)") " -n 1 response
+ read -p "$(i18n "Remove") ${installedKernelPackage} ? $(i18n "y/N/q (q=quit)") " -n 1 response
echo -e " \n"
if [[ -z ${response} ]]; then
response="N"
@@ -524,9 +519,7 @@ $(i18n "y/N/q (q=quit)") " -n 1 response
done
NK=$(ls /boot/vmlinuz*.mga[0-9] | wc -l)
OCCDISK2=$(df -B 1M -l --output=used / | tail -n1 | awk '{ print $1 }')
- echo -e "${HdBgCol} $(i18n "Gain"):\
-$((OCCDISK1 - OCCDISK2)) MB - \
-$(i18n "Kernels in") /boot/: ${NK} ${Normal}"
+ echo -e "${HdBgCol} $(i18n "Gain"):$((OCCDISK1 - OCCDISK2)) MB - $(i18n "Kernels in") /boot/: ${NK} ${Normal}"
fi
[[ $MODE == "I" ]] && { echo "$(i18n "Tap spacebar to exit")"; read -n1; echo -en "${ClearLine}"; }