How to replace MacPort's libiconv with Mac's default 64-bit version? - macports

MacPorts installed "libiconv #1.14_0+universal" as a dependency on my system. This happens to be a 32-bit flavor and it started causing issue when I tried to compile a voice recognition software called Simon Listens.
While googling I found out that that Mac actually ships with a 64-bit flavor of libiconv by default and I was able to locate the said files on my system:
$ find /usr/lib -name libiconv*
/usr/lib/libiconv.2.4.0.dylib
/usr/lib/libiconv.2.dylib
/usr/lib/libiconv.dylib
In order to use the system library, the quickest way I could think of was to uninstall MacPort's version of libiconv so that the system's library would end up getting selected as a fallback as it has to present (my guess) somewhere downstairs on the PATH already.
But that failed due to dependecies:
$ sudo port uninstall libiconv #1.14_0+universal
Unable to uninstall libiconv #1.14_0+universal, the following ports depend on it:
...
So now my question is how can I tell MacPort to replace its dependency graph to point to and use the library already on my system?

Another approach to avoid MacPorts libiconv issues would be to build simon against a fresh MacPorts system plus the necessary packages such as cyrus-sasl2, zlib, portaudio and kdesdk4 in a custom location, e. g. /opt/macports-simon.
The following code worked for me on my machine running Mac OS X 10.6.8:
# compile simon on Mac OS X 10.6.8 using MacPorts for the installation of zlib, portaudio and kdesdk4
# http://www.simon-listens.org
# http://sourceforge.net/projects/speech2text/
# get a root shell
sudo -H -i
# prevent idle sleep
pmset -a force sleep 0 displaysleep 0 disksleep 0
mv -i /opt/local /opt/local-off
mv -i /usr/local /usr/local-off
cd /tmp
mkdir buildsimon || exit 1
cd buildsimon || exit 1
# create custom /opt/macports-simon to install zlib, portaudio and kdesdk4
# cf. http://guide.macports.org/#installing.macports.source.multiple
MP_PREFIX='/opt/macports-simon'
unset PATH
export PATH='/bin:/sbin:/usr/bin:/usr/sbin'
curl -L -O https://distfiles.macports.org/MacPorts/MacPorts-2.0.4.tar.bz2
tar -xjf MacPorts-2.0.4.tar.bz2
cd MacPorts-2.0.4 || exit 1
./configure --prefix="${MP_PREFIX}" --with-applications-dir="${MP_PREFIX}/Applications"
make
make install
cd /tmp/buildsimon
unset PATH
export PATH="${MP_PREFIX}/bin:/bin:/sbin:/usr/bin:/usr/sbin"
# get the Portfiles and update the system
port -v selfupdate
# install cyrus-sasl2
port -f uninstall cyrus-sasl2
port clean --all cyrus-sasl2
port extract cyrus-sasl2
cd "$(port dir cyrus-sasl2)"/work/cyrus-sasl-2.1.23
printf '%s\n' H '/\(darwin\[15\]\)/s//\1./g' wq | sudo ed -s config/ltconfig
printf '%s\n' H '/\(darwin\[15\]\)/s//\1./g' wq | sudo ed -s saslauthd/config/ltconfig
cd /tmp/buildsimon
port -f -s install cyrus-sasl2
otool -L /opt/macports-simon/lib/libsasl2.dylib
port -f install zlib
port -f install portaudio
port -f install kdesdk4
port installed zlib portaudio kdesdk4 cyrus-sasl2
# enable dbus with launchd
# http://www.freedesktop.org/wiki/Software/dbus
# open -e dbus-1.5.8/README.launchd
launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
sudo -u _mysql mysql_install_db5
sudo port load mysql5-server
# todo: how to configure simon to use /opt/macports-simon directly?
ln -isv "${MP_PREFIX}" /usr/local
cd /tmp/buildsimon
# http://sourceforge.net/projects/speech2text/
curl -L -O http://netcologne.dl.sourceforge.net/project/speech2text/simon/0.3.0/simon-0.3.0.tar.bz2
tar -xjf simon-0.3.0.tar.bz2
cd simon-0.3.0 || exit 1
# Note that /usr/local got symlinked to "${MP_PREFIX}" above!
unset PATH
export PATH='/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin'
# the following commands are taken from simon-0.3.0/build.sh
mkdir build 2> /dev/null
cd build || exit 1
cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..
# append ${MP_PREFIX}/lib/libiconv.dylib to gcc command in link.txt file
printf '%s\n' H '/\/usr\/bin\/gcc/s|\(.*\)|\1 '"${MP_PREFIX}"'/lib/libiconv.dylib|' wq |
ed -s julius/julius/CMakeFiles/juliusexe.dir/link.txt
# replace gcc option ' -bundle ' with ' -dynamiclib '
egrep -Ilsr -Z -e ' -bundle ' . |
xargs -0 -n 1 /bin/sh -c 'printf "%s\n" H "g/ -bundle /s// -dynamiclib /g" wq | /bin/ed -s "${1}"' argv0
make
touch ./julius/gramtools/mkdfa/mkfa-1.44-flex/*
make
make install
# ldconfig # not needed on Mac OS X
kbuildsycoca4
echo -e "**** Build completed ****\n\nThe executable file \"simon\" is now ready and has been installed.\n\nIssue \"simon\" to start it."
unset PATH
export PATH="${MP_PREFIX}/bin:/bin:/sbin:/usr/bin:/usr/sbin"
otool -L "${MP_PREFIX}/bin/simon"
simon
mv -i /opt/local-off /opt/local
mv -i /usr/local-off /usr/local

Related

WildFly 10 rpmbuild

I am building a custom RPM for WildFly 10. I am stuck on deploying the systemd service. The spec file is able to deploy the code as well as create a user, however, no matter what avenue I try, I cannot get the RPM to create the service. I have tried install -m 644 but rpmbuild has tries finding the file, even if I specify full path:
e.g. install -m 644 %{buildroot}/opt/%{name}/docs/contrib/scripts/systemd/%{name}.service %{buildroot}/usr/lib/systemd/system/%{name}.service
I have also tried a series of systemd scriptlets as noted in https://fedoraproject.org/wiki/Packaging:Scriptlets, but that does nothing (the RPM will build with exit 0 status, but the service is never created). Any assistance would be appreciated.
$ cat SPECS/wildfly.spec
Name: wildfly
Version: 10.0.0.Final
Release: 1%{?dist}
Summary: WildFly (JBoss) Application Server
Group: System Environment/Daemons
License: LGPL 2.1
URL: http://wildfly.org
Source0: http://download.jboss.org/wildfly/%{version}/%{name}-%{version}.tar.gz
ExclusiveArch: x86_64 i686
ExclusiveOS: Linux
%{?systemd_requires}
Requires: systemd
Requires: shadow-utils
Requires: java >= 1.8.0
Requires: /etc/init.d/functions
Provides: %{name}
%description
WildFly Application Server packaged from the binary distribution.
%prep
%setup -q -n %{name}-%{version}
%install
mkdir -p %{buildroot}/opt/%{name}
mkdir -p %{buildroot}/var/log/%{name}
mkdir -p %{buildroot}/var/run/%{name}
cp -R . %{buildroot}/opt/%{name}
%pre
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || \
useradd -r -g %{name} -d /opt/%{name} -s /sbin/nologin %{name}
%post
alternatives --install /etc/alternatives/%{name} %{name} /opt/%{name} 100
%systemd_post %{name}.service
%postun
alternatives --remove %{name} /opt/%{name}
%systemd_postun %{name}.service
userdel %{name}
%files
%defattr(-,root,root,0755)
%dir /opt/%{name}
/opt/%{name}/appclient
/opt/%{name}/bin
/opt/%{name}/docs
/opt/%{name}/domain
/opt/%{name}/jboss-modules.jar
/opt/%{name}/modules
%attr(-,%{name},%{name}) /opt/%{name}/standalone
/opt/%{name}/welcome-content
%dir /var/log/%{name}
%dir /var/run/%{name}
%doc /opt/%{name}/copyright.txt
%doc /opt/%{name}/LICENSE.txt
%doc /opt/%{name}/README.txt

How to execute in other directory?

I have three directories:
/home/Desktop/1
/home/Desktop/2
/home/Desktop/3
In the directories 1 and 2 are executable C programs, which can be executed in the terminal like this ./tst1 or ./tst2.
In the directory 3 I have a bash script, which executes a C program tst3.c from the same directory.
I want to execute these C programs from directories 1 and 2 using my bash script in the directory 3 like this
#!/bin/bash
sudo ./tst3
sleep 1
sudo ./tst1 # from directory 1
sleep 2
sudo ./tst2 # from directory 2
Any ideas?
You have multiple options, including at least:
Set PATH to include the directories where your commands are found:
#!/bin/bash
export PATH="$PATH:/home/Desktop/1:/home/Desktop/2:/home/Desktop/3"
sudo tst3 # from directory 3
sleep 1
sudo tst1 # from directory 1
sleep 2
sudo tst2 # from directory 2
Use absolute paths to the commands:
#!/bin/bash
sudo /home/Desktop/3/tst3 # from directory 3
sleep 1
sudo /home/Desktop/1/tst1 # from directory 1
sleep 2
sudo /home/Desktop/2/tst2 # from directory 2
Use relative paths to the commands:
#!/bin/bash
sudo ../3/tst3 # from directory 3
sleep 1
sudo ../1/tst1 # from directory 1
sleep 2
sudo ../2/tst2 # from directory 2
These treat the directories symmetrically. Another alternative is to place the commands in a directory already on your PATH (like $HOME/bin, perhaps), and then run them without any path. This is what I'd normally do — ensure the commands to be run are in a directory on my PATH.
If you are simply trying to locate the scripts:
#!/bin/bash
base_dir="$( dirname "$( readlink -e "$0" )" )"/..
sudo "$base_dir/3/tst3"
sleep 1
sudo "$base_dir/1/tst1"
sleep 2
sudo "$base_dir/2/tst2"
or
#!/bin/bash
cd "$( dirname "$( readlink -e "$0" )" )"/..
sudo 3/tst3
sleep 1
sudo 1/tst1
sleep 2
sudo 2/tst2
If you want the CWD to be changed the directory of each executable before executing it:
#!/bin/bash
cd "$( dirname "$( readlink -e "$0" )" )"
sudo ./tst3
cd ../1
sleep 1
sudo ./tst1
cd ../2
sleep 2
sudo ./tst2
These scripts will work properly even if its launched from a directory other than the directory it's found in. They will even work if they are launched via a symlink!

Pkg-config file is on the pkg-config path but can not be found by configure script

I am trying to install libvirt from source. The version I am trying to install is 1.2.7. I want libssh2 enabled. Here is how I call the configure script:
./configure --prefix=/home/administrator/dev/workspaces/libvirt/built/libvirt-1.2.7/ --with-sasl --with-qemu --with-lxc --with-gnutls --with-remote --with-ssh2 --with-polkit
I got the following error:
configure: error: You must install the libssh2 >= 1.3 pkg-config module to compile libvirt
I downloaded the libssh2 lib version 1.4.3 and installed it using the default options:
$ ./configure
$ make
$ sudo make install
Here is some useful info:
$ sudo ldconfig
$ sudo updatedb
$ locate libssh2.so
/usr/local/lib/libssh2.so
/usr/local/lib/libssh2.so.1
/usr/local/lib/libssh2.so.1.0.1
$ locate libssh2.pc
/usr/local/lib/pkgconfig/libssh2.pc
$ pkg-config --variable pc_path pkg-config
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
Obviously the libssh2.pc file is on the pkg-config path. However, when I tried executing the configure script for libvirt, the same error occurred. Any ideas what I am doing wrong ? Thank you.
EDIT: Fragment of the config.log file:
34475 configure:59141: checking for SSH2
34476 configure:59148: $PKG_CONFIG --exists --print-errors "libssh2 >= 1.3"
34477 configure:59151: $? = 0
34478 configure:59165: $PKG_CONFIG --exists --print-errors "libssh2 >= 1.3"
34479 configure:59168: $? = 0
34480 configure:59182: result: no
34481 Package libssl was not found in the pkg-config search path.
34482 Perhaps you should add the directory containing `libssl.pc'
34483 to the PKG_CONFIG_PATH environment variable
34484 Package 'libssl', required by 'libssh2', not found
34485 configure:59225: error: You must install the libssh2 >= 1.3 pkg-config module to compile libvirt
...
34576 ac_cv_env_PKG_CONFIG_LIBDIR_set=
34577 ac_cv_env_PKG_CONFIG_LIBDIR_value=
34578 ac_cv_env_PKG_CONFIG_PATH_set=
34579 ac_cv_env_PKG_CONFIG_PATH_value=
34580 ac_cv_env_PKG_CONFIG_set=
34581 ac_cv_env_PKG_CONFIG_value=
...
34874 ac_cv_path_ac_pt_PKG_CONFIG=/usr/bin/pkg-config
36432 PKG_CONFIG='/usr/bin/pkg-config'
36433 PKG_CONFIG_LIBDIR=''
36434 PKG_CONFIG_PATH=''

extracting and creating ipk files

ipk packages are the intallation packages used by opkg.
I'm trying to extract the contents of one of them and also create my own ipk.
I've read that I should be able to untar them but that is not true.
I've tried:
tar -zxvf mypack.ipk
and I get:
zip: stdin: not in gzip format
I've also tried:
tar -xvf mypack.ipk
and I get:
tar: This does not look like a tar archive
I've found that most of the information on the internet regarding ipk's are inaccurate.
My ipk was generated by bitbake. I'm having a hard time with bitbake and want to avoid using it.
Any ideas on how to extract and how to create ipk files? A simple template with a single package would be useful to have.
I figured it out.
You can extract the main package with the ar x command, then extract the control.tar.gz with the tar -zxf command.
I have tested "ar x package-name.ipk" command but it didn't help
I found bellow command which worked perfectly
tar zxpvf package-name.ipk
This extracts three files:
debian-binary
data.tar.gz
control.tar.gz
use the same command to open data.tar.gz and control.tar.gz files
for more information refer to
https://cognito.me.uk/computers/manual-extractioninstallation-of-ipk-packages-on-gargoyleopenwrt/
You need to create a control file, and then do some archiving using tar and ar. In my case, I was distributing just python scripts, so there was no architecture dependency. You should check the control and Makefile into version control, and delete all the other intermediate files.
Here are the contents of control
Package: my-thing-python
Version: 1.0
Description: python scripts for MyCompany
Section: extras
Priority: optional
Maintainer: John
License: CLOSED
Architecture: all
OE: my-thing-python
Homepage: unknown
Depends: python python-distutils python-pyserial python-curses python-mmap python-ctypes
Source: N/A
Here is my Makefile which sits in the same directory as all my python scripts.
all: my-thing-python.ipk
my-thing-python.ipk:
rm -rf ipk
mkdir -p ipk/opt/my-thing-python
cp *.py ipk/opt/my-thing-python
tar czvf control.tar.gz control
cd ipk; tar czvf ../data.tar.gz .; cd ..
echo 2.0 > debian-binary
ar r my-thing-python.ipk control.tar.gz data.tar.gz debian-binary
clean: FORCE
rm -rf ipk
rm -f control.tar.gz
rm -f data.tar.gz
rm -f my-thing-python.ipk
FORCE:
Extracting with these commands:
Extract the file by running the command:
ar -xv <.ipk file>
Extract the control.tar.gz file by running the command:
tar -zxvf control.tar.gz
data.tar.gz : untar by running the command:
tar –zxvf data.tar.gz
If you want a list of files in an ipk, you can do something like:
#!/bin/sh
for f
do
tar -x -z -f $f ./data.tar.gz -O | tar tvzf -
done
-O is extract to standard output.
ipk files used to be AR (like DPKG), but are now tgz.
I feel that some dpkg utility ought to cope with ipkg files, but I haven't found the right one.

LXR for Ruby interpreter?

I'm trying to track down a bug caused by the intersection of MRI 1.8.7 and libxml-1.1.3, and I need to do some digging around in the codebase of the Ruby interpreter itself. The SVN browser is of limited utility; what I'd really like is to use LXR, which hyperlinks a C codebase for easy navigation, e.g. http://lxr.linux.no/perl+perl-5.10.1/utf8.c
I can certainly set up LXR on my machine, but does anyone know if there's a public LXR for Ruby out there? Google is not very helpful: http://www.google.com/search?ie=UTF-8&q=lxr+ruby
I still haven't found a public LXR for MRI, so I set up one on my machine. Here's how to do it on Ubuntu 10.10:
: josh#josh; cat /etc/issue
Ubuntu 10.10 \n \l
: josh#josh; sudo aptitude install apache2 lxr
: josh#josh; sudo vim /etc/apache2/sites-available/default
: josh#josh; tail -6 /etc/apache2/sites-available/default
Alias /lxr /usr/share/lxr
Options All
AllowOverride All
: josh#josh; sudo vim /usr/share/lxr/http/.htaccess
: josh#josh; sudo cat /usr/share/lxr/http/.htaccess
SetHandler cgi-script
: josh#josh; sudo mkdir -p /usr/share/lxr/source/1.8.7-p334
: josh#josh; cd /usr/share/lxr/source/1.8.7-p334
: josh#josh; sudo tar xvjf /tmp/ruby-1.8.7.tar.bz2
: josh#josh; sudo mv ruby-1.8.7 ruby
: josh#josh; sudo vim /usr/share/lxr/source/versions
: josh#josh; sudo cat /usr/share/lxr/source/versions
1.8.7-p334
: josh#josh; sudo ln -s /usr/share/lxr/source/1.8.7-p334 /usr/share/lxr/source/defversion
: josh#josh; sudo genxref ruby
Starting pass 1: Collect identifier definitions.
(Pass 1) vms/vmsruby_private.c (993), file 1 of 262…
[...]
(Pass 3) identifier 8200 of maximum 17136…
(Pass 3) identifier 8300 of maximum 17136…
Completed pass 3 (0s):Information on 8316 identifiers dumped to disk.
: josh#josh; sudo chmod -R o+r .
: josh#josh; sudo vim /usr/share/lxr/http/lxr.conf
: josh#josh; sudo cat /usr/share/lxr/http/lxr.conf
# Configuration file.
# [...]
# The source is here.
sourceroot: /usr/share/lxr/source/$v/ruby/
srcrootname: Ruby
# [...]
Its not LXR, but I did a lot of that recently and found Understand extremely helpful. It'll let you click on any symbol and go to a definition/declaration and do simple call graphing and other static analysis. I just wish it supported Ruby source too.
On another note, libxml is still hopelessly broken, if you can migrate to Nokogiri it'll save you a lot of grief. Their APIs are very similar.
Introducing another code cross reference site, for general use besides linux kernel
https://code-grep.com

Resources