Archive

Posts Tagged ‘Debian’

Removing Debian packages which are upgradable and autoremovable

September 10, 2017 Leave a comment

Keeping autoremovable packages is not very useful yet I tend to that because I always say my self “may be you’ll need it a day when you’ll have no network to reinstall it”. But upgrading autoremovable packages is even more useless. Here is how I remove them before running apt-get dist-upgrade.

sudo apt-get remove --purge $(comm -12 \
<(apt-get --dry-run dist-upgrade | grep -Po '^Inst \K[^ ]+' | sort) \
<(apt-get --dry-run autoremove | grep -Po '^Remv \K[^ ]+' | sort))
Advertisements
Tags: ,

Cross building Xalan and Xerces for Mingw on Debian (2014 update)

May 19, 2014 Leave a comment

This is an update of this post.

dllwrap

Both xerces and xalan make files call dllwrap which cannot be found in a cross build environment. The real name of this command is <prefix>-dllwrap (ex: x86_64-w64-mingw32-dllwrap). I tried to create a dllwrap symlink, but I was not able to make dllwrap working at all. I fell back to the ld –out-implib flag which is what CMake use when creating dll with mingw. To do so without modifying xerces and xalan make files I created this wrapper:

#! /usr/bin/env python
import sys
import subprocess
for i in xrange(len(sys.argv)):
  if sys.argv[i] == '-o':
    output_index=i+1
    break
sys.argv.append("-Wl,--out-implib,%s.a" % sys.argv[output_index])
sys.argv[0]="x86_64-w64-mingw32-c++"
sys.argv.insert(1, "-shared")
sys.argv.remove('--export-all-symbols')
sys.argv.remove('--driver-name')
sys.argv.remove('c++')
print " ".join(sys.argv)
subprocess.call(sys.argv)

Then I just need to name this file dllwrap and ensure it’s in the PATH.

Xerces

The build instructions says to use set LDFLAGS=-no-undefined but even if this option is for libtool it’s also pass to g++ which will stop because it doesn’t know this option. A workaround is to run configure with -no-undefined then to manually change the Makefile after:

apt-get install g++-mingw-w64-x86-64
git clone https://github.com/apache/xerces-c.git
cd xerces-c
git checkout Xerces-C_3_1_1
./reconf
./configure --host x86_64-w64-mingw32 --prefix=/tmp/xerces-c-3.1.1
find . -name Makefile -exec sed -i 's/^LDFLAGS =/LDFLAGS = -no-undefined/g' {} \;
make && make install

Xalan

As mingw now provide the localtime_r function I needed to apply the following patch:

index c43e9df..47aa9b2 100644
--- a/src/xalanc/Include/GCCDefinitions.hpp
+++ b/src/xalanc/Include/GCCDefinitions.hpp
@@ -48,7 +48,6 @@
 #endif
 
 #if defined(__MINGW32__)
-#define XALAN_NO_REENTRANT_TIME_FUNCTIONS
 #define XALAN_WINDOWS_DIR_FUNCTIONS
 #define WINDOWS_THREAD_FUNCTIONS
 #else

Then the build is straightforward:

apt-get install g++-mingw-w64-x86-64
git clone https://github.com/apache/xalan-c.git
cd xalan-c
git checkout Xalan-C_1_11_0
export XALANCROOT=$PWD
export PATH=$PWD:$PATH
export XERCESCROOT=/tmp/xerces-c-3.1.1
./runConfigure -p cygwin -C--host -Cx86_64-w64-mingw32 -x x86_64-w64-mingw32-g++ -c x86_64-w64-mingw32-gcc -C--prefix=/tmp/xalanc-3.11
make

make install fail in bin/ because it doesn’t know how to handle the .exe extension but that’s enough for my usage.

XKB data changed the numpad decimal separator symbol

May 17, 2014 1 comment

Debian Sid has just received this change from XKeyboardConfig.

Here is how to to switch back to a period symbol:

  • Add

    kpdl:dot

    to XKBOPTIONS in /etc/default/keyboard.

    Note that dpkg-reconfigure keyboard-configuration cannot do it for you but thanks to this bug fix it will also not erase your changes.

  • run

    sudo udevadm trigger --subsystem-match=input --action=change

    then restart Xorg

See man xkeyboard-config and this Debian X Strike Force page for more.

EDIT: this bug is fixed in the upstream repository: https://bugs.freedesktop.org/show_bug.cgi?id=74274

Tags: ,

A Debian restaurant ?

May 26, 2013 Leave a comment

Poppies Hotel

No it’s not the last DebConf but the Poppies Hotel, a lovely place in Scotland.
Tags:

Cross building Xalan and Xerces for Mingw on Linux

August 19, 2011 1 comment

Here is how to cross-build Xerces-c 2.8 and Xalan-c 3.11-dev on Debian Wheezy, for Mingw 32bit.

Xerces

I first built Xerces this way:

apt-get install mingw-w64
apt-get source libxerces-c2-dev
cd xerces-c2-2.8.0+deb1/src/xercesc
export XERCESCROOT=$PWD/../..
./runConfigure -p mingw-msys -C--host -Ci686-w64-mingw32
make

Unfortunnatly it doesn’t create any import library (libXXXX.dll.a). Mingw support linking without import library but it’s dead slow (5 minutes by executables with Xerces and Xalan). Creating an import library is easy but require to pass 2 arguments to the linker, the name of the dll and the name of the import libary. The xerces-c build machinery pass only one argument so we would need to modify each Makefile to support import library creation. A dirty workaround is to create a linker wrapper which automatically add the import library name to the link command line:

#! /usr/bin/env python
import sys
import subprocess
for i in xrange(len(sys.argv)):
  if sys.argv[i] == '-o':
    output_index=i+1
    break

sys.argv.append("-Wl,--out-implib,%s.a" % sys.argv[output_index])
sys.argv[0]="i686-w64-mingw32-c++"
sys.argv.insert(1, "-shared")
print " ".join(sys.argv)
subprocess.call(sys.argv)

Save this file to src/xercesc/dllwrap then change Makefile.incl this as following:

--- src/xercesc/Makefile.incl	2007-08-30 14:10:20.000000000 +0200
+++ src/xercesc/Makefile.incl	2011-08-26 09:40:20.332772932 +0200
@@ -463,7 +463,7 @@
   PLATFORM_COMPILE_OPTIONS = -D${PLATFORM} -fexceptions -D__GNUWIN32__ -DWIN32 -D_WINDOWS -DNDEBUG -DPLATFORM_WIN32
 
   ifeq (${LIBTYPE},shared)
-    MAKE_SHARED = dllwrap --export-all-symbols --driver-name ${CXX} ${LDFLAGS}
+    MAKE_SHARED = $(dir $(lastword $(MAKEFILE_LIST)))/dllwrap ${LDFLAGS}
     MAKE_SHARED_C = ${CC} -D${PLATFORM} ${LDFLAGS}
   else
     PLATFORM_COMPILE_OPTIONS += -DXML_LIBRARY # switch off import/export

Re-run runConfigure and make, and the import library will be created.

Xalan

The current version of Xalan (1.10) doesn’t support Mingw so we need to use the development version.

git clone https://github.com/apache/xalan-c.git

During the build Xalan create and execute the MsgCreator command. As we are on Linux we need first to create this command for our guest OS. An other way would be to use wine (I did not tried).

git clone xalan-c xalan-c-linux
cd xalan-c-linux
export XALANCROOT=$PWD
export XERCESCROOT=/a/path/to/xerces-c2-2.8.0+deb1
./runConfigure -p linux
make

Now let’s copy the executable to the mingw build dir.

cp bin/MsgCreator /a/path/to/xalan-c/bin

Prepare the environment:

cd /tmp/xalan-c
export XALANCROOT=$PWD
export XERCESCROOT=/tmp/xerces-c2-2.8.0+deb1

Use the same workaround than in Xerces:

--- a/Makefile.incl.in
+++ b/Makefile.incl.in
@@ -136,9 +136,9 @@ ifeq ($(PLATFORM), MINGW)
   LDFLAGS += -Wl,--allow-multiple-definition
   LINK = $(CXX) -D${PLATFORM} ${LDFLAGS}

-  MAKE_SHARED = dllwrap --export-all-symbols --driver-name c++ ${LDFLAGS}
+  MAKE_SHARED = $(dir $(lastword $(MAKEFILE_LIST)))/dllwrap ${LDFLAGS}

-  MAKE_SHARED_LOC = dllwrap --export-all-symbols --driver-name c++ ${LDFLAGS}
+  MAKE_SHARED_LOC = $(dir $(lastword $(MAKEFILE_LIST)))/dllwrap ${LDFLAGS}

   LOC_OTHER_LINK_PARAMETERS = $(XERCES_LIB)

Xalan port to mingw is not yet finished (see the bug bug report). One thing which is missing is the support for dllexport/dllimport directives. Without this directive we would get huge library very slow to link. The following patch add support for dllexport/dllimport (It also break portability so it’s not suitable for upstream integration).

diff --git a/runConfigure b/runConfigure
index 5e40257..cdbc255 100755
--- a/runConfigure
+++ b/runConfigure
@@ -654,7 +654,7 @@ fi
 # Set the extra C and C++ compiler flags
 #

-CXXFLAGS="$compileroptions $debugflag $transcodingDefines $threadingDefines $bitstobuildDefines "
+CXXFLAGS="$compileroptions $debugflag $transcodingDefines $threadingDefines $bitstobuildDefines -DXALAN_BUILD_DLL"
 export CXXFLAGS

 CFLAGS="$compileroptions $debugflag $transcodingDefines $threadingDefines $bitstobuildDefines "
diff --git a/src/xalanc/Include/GCCDefinitions.hpp b/src/xalanc/Include/GCCDefinitions.hpp
index c43e9df..a1bf300 100644
--- a/src/xalanc/Include/GCCDefinitions.hpp
+++ b/src/xalanc/Include/GCCDefinitions.hpp
@@ -26,8 +26,8 @@
 //  These defines provide the platform specific keywords that they need
 //  to do this.
 // ---------------------------------------------------------------------------
-#define XALAN_PLATFORM_EXPORT
-#define XALAN_PLATFORM_IMPORT
+#define XALAN_PLATFORM_EXPORT __declspec(dllexport)
+#define XALAN_PLATFORM_IMPORT __declspec(dllimport)
 #define XALAN_PLATFORM_EXPORT_FUNCTION(T) T XALAN_PLATFORM_EXPORT
 #define XALAN_PLATFORM_IMPORT_FUNCTION(T) T XALAN_PLATFORM_IMPORT

diff --git a/src/xalanc/XPathCAPI/XPathCAPI.h b/src/xalanc/XPathCAPI/XPathCAPI.h
index b754c00..95bb097 100644
--- a/src/xalanc/XPathCAPI/XPathCAPI.h
+++ b/src/xalanc/XPathCAPI/XPathCAPI.h
@@ -20,7 +20,7 @@



-#if defined(_MSC_VER)
+#if defined(_MSC_VER || __MINGW32__)

 #if defined(XALAN_BUILD_DLL)

Next steps are almost the same than with Xerces. For one reason we need to add -c and -x flags which were not needed for Xerces.

./runConfigure -p mingw-msys -c i686-w64-mingw32-gcc -x i686-w64-mingw32-g++ -C--host -Ci686-w64-mingw32
make

Debian Wheezy on Eee PC 1001PX

May 28, 2011 Leave a comment

Installing Debian on a 1001PX Eee PC is almost straightforward. Here are solutions for the few issues I met.

The first problem came with the ath9k driver for the AR9285 wireless adapter. The hardware encryption seem buggy so I disabled it:

echo options ath9k nohwcrypt=1 > /etc/modprobe.d/ath9.conf

Next I get the Query no Synaptics: 6003C8 error message in the Xorg log. /usr/share/X11/xorg.conf.d configure the touchpad with both /dev/input/mouse* and /dev/input/event*. Adding the following content to /etc/X11/xorg.conf.d/10-touchpad.conf solved the problem:

Section "InputClass"
	Identifier "disable mouse touchpad"
	MatchDevicePath "/dev/input/mouse*"
	MatchIsTouchpad "on"
	Option "Ignore" "true"
EndSection

Section "InputClass"
	Identifier "touchpad catchall"
	MatchIsTouchpad "on"
	MatchDevicePath "/dev/input/event*"
	Driver "synaptics"
EndSection

Finally, as xdpyinfo|dimensions reported a screen much larger than 10.1″ I forced the dimension in /etc/X11/10-monitor.conf:

Section "Monitor"
    Identifier ""
    DisplaySize 223 125
EndSection
Tags: , , ,

Encrypting a laptop with dm-crypt without reinstalling from scratch

August 7, 2009 Leave a comment

First you need to backup the partition you want to encrypt. If like me you are using samba sharing not supporting large files you will probably want to compress and split you backup. Tar does’nt support multi-volume compressed archive, but you can create them using the split command:

tar --one-file-system -cvfz - / | split -b 700M - /mnt/backup/backup

Then boot your laptop with a live CD or USB stick. It needs to include at least cryptsetup, chroot and all tools required to get you backup back. I use a custom debian live USB key created with live-helper:

sudo apt-get install live-helper

lh_config -b usb-hdd -p standard \
--mirror-binary http://ftp.fr.debian.org/debian \
--mirror-binary-security http://ftp.fr.debian.org/security \
--mirror-bootstrap http://ftp.fr.debian.org/debian \
--mirror-chroot http://ftp.fr.debian.org/debian \
--mirror-chroot-security http://ftp.fr.debian.org/security \
--hostname "rescue" --packages "ntfsprogs cryptseup bzip2 smbclient lftp
openssh-server elinks vim-nox pciutils lshw ntfs-3g rsync debootstrap" \
--bootappend-live "locale=fr"

sudo lh_build

sudo dd if=binary.img of=/dev/sdf

Once booted, you have to prepare your partitions. The requirements are:

  • A partition for /boot (will be unencrypted
  • A partition for / (wil be encrypted)

You may also want to have an encrypted swap. I personally do not use any swap partition. Here is my configuration before partitioning modifications (yes, I have a Windows dual boot):

# fdisk -l /dev/sda

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xeede9d79

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          13      104391   de  Dell Utility
/dev/sda2   *          14        7327    58749705    7  HPFS/NTFS
/dev/sda3            7328       14593    58364145   83  Linux

I just removed the partition 3 and create 2 new ones using fdisk. Here is my new partition table:

# fdisk -l /dev/sda

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xeede9d79

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          13      104391   de  Dell Utility
/dev/sda2   *          14        7327    58749705    7  HPFS/NTFS
/dev/sda3            7328       14583    58283820   83  Linux
/dev/sda4           14584       14593       80325   83  Linux

Now let’s create the encrypted file system:

cryptsetup create sda3 /dev/sda3

It will ask for a password. You will have to enter this password at each boot. The encrypted partition should now appear as /dev/mapper/sda3. Format it and mount it:

mkfs.ext3 /dev/mapper/sda3
mkdir /mnt/sda3
mount /dev/mapper/sda3 /mnt/sd3

You can now restore your backup. If you used tar and split as said before, the untar command will look like this:

cd /mnt/sda3
cat /mnt/backup/backup* | tar -zxvf -

Later to configure initrd we will need to know the ciper, hash and key size used to encrypt the partition:

# cryptsetup status sda3

/dev/mapper/sda3 is active:
  cipher:  aes-cbc-plain
  keysize: 256 bits
  device:  /dev/sda3
  offset:  0 sectors
  size:    116567640 sectors
  mode:    read/write

Now let’s configure the restored system to make it able to boot on an encrypted file system. First chroot it:

mount --bind /proc /mnt/sda3/proc
mount --bind /sys /mnt/sda3/sys
mount --bind /dev /mnt/sda3/dev
chroot /mnt/sda3

You have to write a /etc/crypttab file so initramfs-tools know what to include in the initrd image.

#<target name>	<source device>		<key file>	<options>
sda3 /dev/sda3 none cipher=aes-cbc-plain,hash=ripemd160,size=256

initramfs-tools need some parts of the cryptsetup package to create the initrd:

apt-get install cryptsetup

During the installation of this package the initrd images will be recreated to take the new /etc/crypttab file into account. If cryptsetup was already installed you would have to update the initrd images manually:

update-initramfs

Final step… As your /boot directory as been moved, grub need to be reinstalled:

grub-install /dev/sda
update-grub