can't translate my program via debian package but with autotools can - linux

i use autotools as build system also i use gettext in my code for Translations.
I have few .po files (de.po, es.po and th.po ) and with autotools no problem to get them working. After:
./configure,
make
sudo make install
the program and the Translations .mo files get installed.
To testing that i open a terminal and change the locale e.g :
$ export LANG=de_DE.UTF-8
$ ./myprogram
and the translations works!.
I do with the same source code a debian deb package.
During the deb installation in a .posinst script i deploy the translations mo files to the locale destination (docklight is the program name):
#!/bin/bash
set -e
# check for locale dir (LIVE SYSTEMS don't have it)
if [ -d "/usr/local/share/locale" ]; then
podir="/usr/lib/docklight/docklight.data/po"
if [ -d ${podir} ]; then
cd ${podir}
PO_LINGUAS=$( if test -r LINGUAS; then grep -v "^\#" LINGUAS; fi)
linguas=$PO_LINGUAS
for lang in $linguas; do
dir=/usr/local/share/locale/$lang/LC_MESSAGES;
# check for locale dir (LIVE SYSTEMS don't have it)
if [ ! -d $dir ]; then
continue;
fi
# check for po file
if [ ! -f "$lang.po" ]; then
continue;
fi
file=`echo $lang | sed 's,.*/,,'`.gmo \
&& rm -f $file && /usr/local/bin/msgfmt -o $file "$lang.po"
/bin/bash install-sh -d $dir; \
if test -r $lang.gmo; then \
/usr/bin/install -c -m 644 $lang.gmo $dir/docklight.mo; \
echo "installing $lang.gmo as $dir/docklight.mo"; \
else \
/usr/bin/install -c -m 644 ./$lang.gmo $dir/docklight.mo; \
echo "installing ./$lang.gmo as" \
"$dir/docklight.mo"; \
fi
done
fi
fi
the generated Translations .mo files are correct and get installed on the locale folder for the language:
dir=/usr/local/share/locale/$lang/LC_MESSAGES;
exact the same like the build process with autotools.
After testing the languages:
$ export LANG=de_DE.UTF-8
$ ./myprogram
my program does not have any translation.
I don't know where the problem is. The deb installation works correct!
is something more that i need to care for the creation of a debian deb package?
As far as I understood, when you get myprogramm.mo files in place you should get the program translated.
Any ideas about that?
Thanks in advance for any help.

if find the solution:
I just need to set the PROGRAMNAME_LOCALEDIR path where the mo file are.
The gettext initialization can find the mo files and then everything gets translate. Works!
bindtextdomain(GETTEXT_PACKAGE, PROGRAMNAME_LOCALEDIR);
%s\n",domain,GETTEXT_PACKAGE,PROGRAMNAME_LOCALEDIR);
bind_textdomain_codeset - set encoding of message transā€lations
btdcodeset = bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
Thank you all.

Related

Why does musl ldconfig ignore standard directories?

I was trying to make a docker container based on Alpine linux. During installation of some software I noticed that shared libraries were not installed properly. After some investigation I found the musl ldconfig to be ignoring standard library directories.
The ldconfig script contains the following:
case "$FILE" in
/lib/*|/usr/lib/*|/usr/local/lib/*) ;;
*) [ -h "$LINK" -o ! -e "$LINK" ] && ln -sf "$TARGET" "$LINK"
esac
What is the reason for this?

Non-root users Installing packages from a rpm file

I'm a non-root user running centos Linux.....the problem is i have the desired rpm file i don't how to install them into my home directory being a non-root user.Any help would be appreciated.thanks in advance
This nice little script ( unPack_rpm.sh ) will unpack rpm packages to a folder with the package name ...
#!/bin/bash
# Purpose: Unpack RPM archives (author: #unSpawn)
# Args: /path/to/archive
# Deps: Bash, GNU utils, RPM
rpmDetails() { for Q in changelog provides requires scripts triggers triggerscripts; do
rpm -q -p --${Q} "${f}" 2>&1 | grep -v NOKEY > "${Q}.log"; done; }
rpmUnpack() { f=$(readlink -f "${f}"); file "${f}"|grep -q "RPM.v" && \
{ d=$(basename "${f}" .rpm); d="./${d:=ERROR_$$}"; mkdir -p "${d}" && \
{ cd "${d}" && rpm2cpio "${f}" | cpio -idmv && rpmDetails "${f}"; }; }; }
for f in $#; do rpmUnpack "${f}"; done
exit 0
I think this is somewhat a duplicate question, the same as the one here. In this thread, it is suggested to extract the rpm (using conversion to cpio) and then use the source files locally.
A link to an in-depth explenation for this is also supplied, you can see it here.

How to update a bash script with the old version of this script?

I have a linux bash script, which has a parameter to update the script self. My problem is, that the script can't update itself, while it's used. Well.. Does someone have a solution?
Currently I try to update the script as following:
# Download latest version
wget -q https://github.com/TS3Tools/TS3UpdateScript/archive/master.zip
# Unzip latest version
unzip master.zip TS3UpdateScript-master/* -x TS3UpdateScript-master/configs/ && mv -f TS3UpdateScript-master/* . && rmdir TS3UpdateScript-master/
But I receive the following error by the script:
replace TS3UpdateScript-master/LICENSE_GNU_GPL.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
ateScript-master/configs
caution: excluded filename not matched: TS3UpdateScript-master/configs/
# many arguments
I hope, someone can help me. Thanks in advance!
It seems that your error comes from file name wildcard without quotes. Bash does globbing first and replaces * with lots of filenames and then runs unzip with this parameters. Try master.zip 'TS3UpdateScript-master/*' -x 'TS3UpdateScript-master/configs/' .
Then there will be a problem with running a new version of script instead of old one running. I think it should be done like that:
#!/bin/bash
version=4
if [ "$UPDATED" != "$0" ]; then
cp self_update.new.sh self_update.sh
exec env UPDATED="$0" "$0" "$#"
fi
echo "This script's version is $version"
Thanks for your help and ideas! I've "outsourced" the code to another script, which contains following code:
#!/usr/bin/env bash
sleep 5s
# Download latest version
wget -q https://github.com/TS3Tools/TS3UpdateScript/archive/master.zip
# Unzip latest version
if [[ $(unzip master.zip TS3UpdateScript-master/* -x TS3UpdateScript-master/configs/*) ]]; then
if [ $(cp -Rf TS3UpdateScript-master/* . && rm -rf TS3UpdateScript-master/) ]; then
rm -rf master.zip
exit 1;
fi
else
rm -rf master.zip
exit 0;
fi

how to run .sh file on windows using cygwin?

I am beginner of cygwin terminal. I am trying to run *.sh file on windows 8 using command ./file_name.sh, but it gives error given below....
Using prebuilt externals
ERROR: Cannot find 'make' program. Please install Cygwin make package
or define the GNUMAKE variable to point to it.
I have installed cygwin in F drive, I google this error and set the variable path in computer properties > advance system properties > variable environment > path >edit and variable path is ;F:\cygwin\bin
But does not work. How can i solve this problem??
Here is my script
`# set params`
NDK_ROOT=/cygdrive/f/Android/android-ndk-r9b
COCOS2DX_ROOT=/cygdrive/f/Android/cocos2d-2.0-rc2-x-2.0.1
GAME_ROOT=$COCOS2DX_ROOT/molatx
GAME_ANDROID_ROOT=$GAME_ROOT/proj.android
RESOURCE_ROOT=$GAME_ROOT/Resources
buildexternalsfromsource=
usage(){
cat << EOF
usage: $0 [options]
Build C/C++ native code using Android NDK
OPTIONS:
-s Build externals from source
-h this help
EOF
}
while getopts "s" OPTION; do
case "$OPTION" in
s)
buildexternalsfromsource=1
;;
h)
usage
exit 0
;;
esac
done
`# make sure assets is exist`
if [ -d $GAME_ANDROID_ROOT/assets ]; then
rm -rf $GAME_ANDROID_ROOT/assets
fi
mkdir $GAME_ANDROID_ROOT/assets
`# copy resources`
for file in $RESOURCE_ROOT/*
do
if [ -d "$file" ]; then
cp -rf "$file" $GAME_ANDROID_ROOT/assets
fi
if [ -f "$file" ]; then
cp "$file" $GAME_ANDROID_ROOT/assets
fi
done
`# copy icons (if they exist)`
file=$GAME_ANDROID_ROOT/assets/Icon-72.png
if [ -f "$file" ]; then
cp $file $GAME_ANDROID_ROOT/res/drawable-hdpi/icon.png
fi
file=$GAME_ANDROID_ROOT/assets/Icon-48.png
if [ -f "$file" ]; then
cp $file $GAME_ANDROID_ROOT/res/drawable-mdpi/icon.png
fi
file=$GAME_ANDROID_ROOT/assets/Icon-32.png
if [ -f "$file" ]; then
cp $file $GAME_ANDROID_ROOT/res/drawable-ldpi/icon.png
fi
if [[ $buildexternalsfromsource ]]; then
echo "Building external dependencies from source"
$NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \
NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source
else
echo "Using prebuilt externals"
$NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \
NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt
fi
You have to install make package using cygwin "setup.exe" wizard.
Check what programming language is your script compiling because the compiler of that language will be also dependencies of your script.
Probably you will need to install some libraries too.
Your Windows system path is different to your Cygwin path. If you install the required packages using cygwin setup they will already be available in your $PATH.
Run cygwin setup an install: make , automake , gcc , gcc-c++

GNU Make removes downloaded zip files for no apparent reason

I have this makefile tha sthould download and build openssh (along with other things):
ROOT_DIR=$(PWD)
DATA_DIR=$(ROOT_DIR)/data
SOURCES_DIR=$(ROOT_DIR)/sources
RESOURCES_DIR=$(ROOT_DIR)/resources
DRAFTS_DIR=$(ROOT_DIR)/drafts
$(SOURCES_DIR):
mkdir $(SOURCES_DIR)
$(RESOURCES_DIR):
mkdir $(RESOURCES_DIR)
$(DRAFTS_DIR):
mkdir $(DRAFTS_DIR)
openssh-tar-url="ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/OpenSSH/portable/openssh-6.2p2.tar.gz"
TAR_PROJECTS += openssh
openssh:
echo "Building $#"
openssh-clean: openssh-archive-clean
.SECONDEXPANSION :
$(TAR_PROJECTS) : $(SOURCES_DIR) $(SOURCES_DIR)/$$#-archive
$(DRAFTS_DIR)/%.tar.gz: $(DRAFTS_DIR)
echo "Pulling $*."
wget $($*-tar-url) -O $(DRAFTS_DIR)/$*.tar.gz
.SECONDEXPANSION :
$(SOURCES_DIR)/%-archive : | $(DRAFTS_DIR)/$$*.tar.gz
mkdir $#
cd $# && tar xvzf $(DRAFTS_DIR)/$*.tar.gz
%-archive-clean:
rm -rf $(SOURCES_DIR)/$*-archive $(DRAFTS_DIR)/$*.tar.gz
When i run make openssh it runs correctly but at the end it removes the archive it downloaded. This is very strange to me:
$ make openssh --just-print
echo "Pulling openssh."
wget "ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/OpenSSH/portable/openssh-6.2p2.tar.gz" -O /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz
mkdir /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/sources/openssh-archive
cd /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/sources/openssh-archive && tar xvzf /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz
echo "Building openssh"
rm /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz
Pretty sure you can list targets (and intermediates) as .PRECIOUS to avoid them being deleted for you. I'm afraid you'll need to RTFM for more details - I'm in visual studio rather than make these days, so my make skills are a bit rusty...

Resources