A relative of mine asked me to restore a couple of files from backup CDs created by the windows native backup utility.
It turned out more difficult than I initially expected.
First, unlike other tools, the windows backup utility zips the files using the backslash as a directory separator and none of the Linux decompression tools can handle that.
Second, the files were encoded with one of the Windows native encodings, and none of the Linux decompression tools handle that (apparently unzip on Ubuntu is patched to add support for filename encodings, but Debian, as usual, is lacking).
What a mess ...
1. unzip with bsdtar as unzip would scramble the non-ascii filenames
$ bsdtar xf ../Backup\ files\ 7.zip
2. convert filenames to utf-8
$ convmv -r -f cp852 -t utf-8 --notest .
3. recreate the directory structure
$ cat y.py
#! /usr/bin/env python
import os
import errno
# already created directories, walk works topdown, so a child dir
# never creates a directory if there is a parent dir with a file.
made_dirs = set()
for root, dir_names, file_names in os.walk('.'):
for file_name in file_names:
if '\\' not in file_name:
continue
alt_file_name = file_name.replace('\\', '/')
if alt_file_name.startswith('/'):
alt_file_name = alt_file_name[1:] # cut of starting dir separator
alt_dir_name, alt_base_name = alt_file_name.rsplit('/', 1)
print('alt_dir', alt_dir_name)
full_dir_name = os.path.join(root, alt_dir_name)
if full_dir_name not in made_dirs:
try:
os.makedirs(full_dir_name)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(full_dir_name):
# the pass already exists and is a folder, let's just ignore it
pass
else:
raise
made_dirs.add(full_dir_name)
os.rename(os.path.join(root, file_name),
os.path.join(root, alt_file_name))
$ python y.py
Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts
Wednesday, November 1, 2017
Thursday, November 26, 2015
Arduino development in Solaris Studio
The unbeatable advantage of the Arduino IDE is that it just works, together with the large library of examples. However it really sucks as a source code editor.
Fortunately there's an Arduino plugin for Netbeans (and therefore for Solaris Studio, which is just thinly veiled Netbeans bundled with the Oracle compilers).
The trouble is the Netbeans plugin URL download button gets you the Windows version, but do not despair. The author apparently plays with Linux too, and there's a tmp/linux folder in the repository, containing a functional Linux version of the plugin.
I only had to alter the default Makefile slightly to adjust for Debian's packaging of the Arduino software and my version of the chip:
Fortunately there's an Arduino plugin for Netbeans (and therefore for Solaris Studio, which is just thinly veiled Netbeans bundled with the Oracle compilers).
The trouble is the Netbeans plugin URL download button gets you the Windows version, but do not despair. The author apparently plays with Linux too, and there's a tmp/linux folder in the repository, containing a functional Linux version of the plugin.
I only had to alter the default Makefile slightly to adjust for Debian's packaging of the Arduino software and my version of the chip:
8,9c8,9
8,9c8,9
< COM_PORT = /dev/ttyACM0
< BAUD_RATE = 115200
---
> COM_PORT = /dev/ttyUSB0
> BAUD_RATE = 19200
11,12c11,12
< ARDUINO_BASE_DIR = /home/jaques/opt/arduino-1.6.5-r5
< ARDUINO_CORE_DIR = ${ARDUINO_BASE_DIR}/hardware/arduino/avr/cores/arduino
---
> ARDUINO_BASE_DIR = /usr/share/arduino
> ARDUINO_CORE_DIR = ${ARDUINO_BASE_DIR}/hardware/arduino/cores/arduino
20c20
< ARDUINO_MODEL = atmega328p
---
> ARDUINO_MODEL = atmega168
22c22
< ARDUINO_PINS_DIR = ${ARDUINO_BASE_DIR}/hardware/arduino/avr/variants/standard
---
> ARDUINO_PINS_DIR = ${ARDUINO_BASE_DIR}/hardware/arduino/variants/standard
38c38
< AVR_DUDE = ${ARDUINO_BASE_DIR}/hardware/tools/avr/bin/avrdude -C ${ARDUINO_BASE_DIR}/hardware/tools/avr/etc/avrdude.conf
---
> AVR_DUDE = ${ARDUINO_BASE_DIR}/hardware/tools/avrdude -C ${ARDUINO_BASE_DIR}/hardware/tools/avrdude.conf
Monday, November 16, 2015
What can go wrong with Debian upgrade
When I moved from testing to stable I thought it'd be enough to just stop updating testing a while before the release, modify the apt sources and dist-upgrade.
And indeed all seemed to be working well.
Until now.
I wanted to install wine32, but there were all sorts of errors popping up.
I narrowed it down to libxml2 - it wasn't possible to install the 32-bit part:
# apt-get install libxml2:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
apache2-bin : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libabw-0.1-1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libaugeas0 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libe-book-0.1-1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libepub0 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libetonyek-0.1-1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libfontforge1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libgdraw4 : Depends: libxml2 (>= 2.6.27) but it is not going to be installed
libgeoclue0 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libgtk2.0-0 : Depends: shared-mime-info
Recommends: libgtk2.0-bin
libgupnp-dlna-2.0-3 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libmate-window-settings1 : Depends: libxml2 (>= 2.6.27) but it is not going to be installed
libopenconnect3 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libplist1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libstoken1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libxml-libxml-perl : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
marco : Depends: libmarco-private0 (= 1.8.2+dfsg1-6) but it is not going to be installed
Depends: zenity
mate-media : Depends: mate-media-pulse (>= 1.8.0+dfsg1-3) but it is not going to be installed or
mate-media-gstreamer (>= 1.8.0+dfsg1-3) but it is not going to be installed
mate-settings-daemon : Depends: mate-settings-daemon-pulse (>= 1.8.2-4) but it is not going to be installed or
mate-settings-daemon-gstreamer (>= 1.8.2-4) but it is not going to be installed
python-libxml2 : Depends: libxml2 (>= 2.9.1) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
It took me a while to realize that my libxml2 was actually of higher version than the one in Jessie! As soon as I downgraded it, the installation of wine32 went well...
# dpkg -l |grep libxml2
ii libxml2:amd64 2.9.2+dfsg1-1+b1
# apt-get install libxml2=2.9.1+dfsg1-5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be DOWNGRADED:
libxml2
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 800 kB of archives.
After this operation, 413 kB disk space will be freed.
Do you want to continue? [Y/n]
Get:1 http://ftp.cz.debian.org/debian/ jessie/main libxml2 amd64 2.9.1+dfsg1-5 [800 kB]
Fetched 800 kB in 0s (2,198 kB/s)
dpkg: warning: downgrading libxml2:amd64 from 2.9.2+dfsg1-1+b1 to 2.9.1+dfsg1-5
(Reading database ... 285067 files and directories currently installed.)
Preparing to unpack .../libxml2_2.9.1+dfsg1-5_amd64.deb ...
Unpacking libxml2:amd64 (2.9.1+dfsg1-5) over (2.9.2+dfsg1-1+b1) ...
Setting up libxml2:amd64 (2.9.1+dfsg1-5) ...
Processing triggers for libc-bin (2.19-18+deb8u1) ...
# apt-get install libxml2:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Recommended packages:
xml-core:i386
The following NEW packages will be installed:
libxml2:i386
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 833 kB of archives.
After this operation, 1,910 kB of additional disk space will be used.
Get:1 http://ftp.cz.debian.org/debian/ jessie/main libxml2 i386 2.9.1+dfsg1-5 [833 kB]
Fetched 833 kB in 4s (168 kB/s)
Selecting previously unselected package libxml2:i386.
(Reading database ... 285066 files and directories currently installed.)
Preparing to unpack .../libxml2_2.9.1+dfsg1-5_i386.deb ...
Unpacking libxml2:i386 (2.9.1+dfsg1-5) ...
Setting up libxml2:i386 (2.9.1+dfsg1-5) ...
Processing triggers for libc-bin (2.19-18+deb8u1) ...#
http://blog.hajma.cz/2015/04/fixating-testing-to-jessie.html
And indeed all seemed to be working well.
Until now.
I wanted to install wine32, but there were all sorts of errors popping up.
I narrowed it down to libxml2 - it wasn't possible to install the 32-bit part:
# apt-get install libxml2:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
apache2-bin : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libabw-0.1-1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libaugeas0 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libe-book-0.1-1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libepub0 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libetonyek-0.1-1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libfontforge1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libgdraw4 : Depends: libxml2 (>= 2.6.27) but it is not going to be installed
libgeoclue0 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libgtk2.0-0 : Depends: shared-mime-info
Recommends: libgtk2.0-bin
libgupnp-dlna-2.0-3 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libmate-window-settings1 : Depends: libxml2 (>= 2.6.27) but it is not going to be installed
libopenconnect3 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libplist1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libstoken1 : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
libxml-libxml-perl : Depends: libxml2 (>= 2.7.4) but it is not going to be installed
marco : Depends: libmarco-private0 (= 1.8.2+dfsg1-6) but it is not going to be installed
Depends: zenity
mate-media : Depends: mate-media-pulse (>= 1.8.0+dfsg1-3) but it is not going to be installed or
mate-media-gstreamer (>= 1.8.0+dfsg1-3) but it is not going to be installed
mate-settings-daemon : Depends: mate-settings-daemon-pulse (>= 1.8.2-4) but it is not going to be installed or
mate-settings-daemon-gstreamer (>= 1.8.2-4) but it is not going to be installed
python-libxml2 : Depends: libxml2 (>= 2.9.1) but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
It took me a while to realize that my libxml2 was actually of higher version than the one in Jessie! As soon as I downgraded it, the installation of wine32 went well...
# dpkg -l |grep libxml2
ii libxml2:amd64 2.9.2+dfsg1-1+b1
# apt-get install libxml2=2.9.1+dfsg1-5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be DOWNGRADED:
libxml2
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 800 kB of archives.
After this operation, 413 kB disk space will be freed.
Do you want to continue? [Y/n]
Get:1 http://ftp.cz.debian.org/debian/ jessie/main libxml2 amd64 2.9.1+dfsg1-5 [800 kB]
Fetched 800 kB in 0s (2,198 kB/s)
dpkg: warning: downgrading libxml2:amd64 from 2.9.2+dfsg1-1+b1 to 2.9.1+dfsg1-5
(Reading database ... 285067 files and directories currently installed.)
Preparing to unpack .../libxml2_2.9.1+dfsg1-5_amd64.deb ...
Unpacking libxml2:amd64 (2.9.1+dfsg1-5) over (2.9.2+dfsg1-1+b1) ...
Setting up libxml2:amd64 (2.9.1+dfsg1-5) ...
Processing triggers for libc-bin (2.19-18+deb8u1) ...
# apt-get install libxml2:i386
Reading package lists... Done
Building dependency tree
Reading state information... Done
Recommended packages:
xml-core:i386
The following NEW packages will be installed:
libxml2:i386
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 833 kB of archives.
After this operation, 1,910 kB of additional disk space will be used.
Get:1 http://ftp.cz.debian.org/debian/ jessie/main libxml2 i386 2.9.1+dfsg1-5 [833 kB]
Fetched 833 kB in 4s (168 kB/s)
Selecting previously unselected package libxml2:i386.
(Reading database ... 285066 files and directories currently installed.)
Preparing to unpack .../libxml2_2.9.1+dfsg1-5_i386.deb ...
Unpacking libxml2:i386 (2.9.1+dfsg1-5) ...
Setting up libxml2:i386 (2.9.1+dfsg1-5) ...
Processing triggers for libc-bin (2.19-18+deb8u1) ...#
http://blog.hajma.cz/2015/04/fixating-testing-to-jessie.html
Friday, May 1, 2015
Heroes of Might and Magic II
The latest Humble Bundle comes with HOMM2 Gold in the pay-what-you-want group. While it's for Windows only, the installer works in Wine flawlessly.
When it's started I noticed the game actually runs in DosBox, which sounds somewhat silly - to run a game inside a DOS emulator which runs in a Windows emulator :-)
The natural instinct lead me to try to remove the unnecessary levels.
I used lnk-parser to find out what the HOMM2 Desktop link was actually doing:
but when I run
Here's the necessary change to the config file:
When it's started I noticed the game actually runs in DosBox, which sounds somewhat silly - to run a game inside a DOS emulator which runs in a Windows emulator :-)
The natural instinct lead me to try to remove the unnecessary levels.
I used lnk-parser to find out what the HOMM2 Desktop link was actually doing:
$ lnk-parse-1.0/lnk-parse-1.0.pl /home/hajma/.wine/dosdevices/c\:/users/Public/Desktop/Heroes\ of\ Might\ and\ Magic\ 2\ Gold.lnk Link File: /home/hajma/.wine/dosdevices/c:/users/Public/Desktop/Heroes of Might and Magic 2 Gold.lnk Link Flags: HAS SHELLIDLIST | POINTS TO FILE/DIR | NO DESCRIPTION | NO RELATIVE PATH STRING | HAS WORKING DIRECTORY | HAS CMD LINE ARGS | HAS CUSTOM ICON | File Attributes: Create Time: Mon Jan 01 1601 00:57:44 Last Accessed time: Mon Jan 01 1601 00:57:44 Last Modified Time: Mon Jan 01 1601 00:57:44 Target Length: 0 Icon Index: 0 ShowWnd: 1 SW_NORMAL HotKey: 0 Target is on local volume Volume Type: Fixed (Hard Disk) Volume Serial: 00000000 Vol Label: Base Path: C:\Program Files\Ubisoft\Heroes of Might and Magic 2 Gold\dosbox.exe (App Path:) Remaining Path: Working Dir: C:\Program Files\Ubisoft\Heroes of Might and Magic 2 Gold\ Command Line: -conf dosboxhomm2.conf -noconsole Icon filename: C:\Program Files\Ubisoft\Heroes of Might and Magic 2 Gold\Icon.ico
but when I run
dosbox -conf ./dosboxhomm2.conf -noconsolethe game doe not run in full version, complaining about missing CD in the drive.
Here's the necessary change to the config file:
$ diff -u dosboxhomm2.conf.orig dosboxhomm2.conf --- dosboxhomm2.conf.orig 2015-05-01 00:38:24.937021111 +0200 +++ dosboxhomm2.conf 2015-05-01 01:05:30.530285702 +0200 @@ -193,8 +193,8 @@ @ECHO OFF mount C "." -imgmount d ".\homm2.inst" -t iso -fs iso c: +imgmount d "./homm2.inst" -t iso -fs iso cls heroes2.exe -exit \ No newline at end of file +exit
Monday, April 27, 2015
Fixating testing to Jessie
So, Jessie is released, and I'd like to keep it on my laptop for some time.
It turns out it's reather trivial to do, just make sure all entries in one's sources.list point to jessie instead of testing:
and run the usual
It turns out it's reather trivial to do, just make sure all entries in one's sources.list point to jessie instead of testing:
--- /etc/apt/sources.list.bak 2015-04-27 22:23:17.664326851 +0200 +++ /etc/apt/sources.list 2015-04-27 22:27:33.559723639 +0200 @@ -1,10 +1,5 @@ -deb http://ftp.cz.debian.org/debian/ testing main non-free -deb-src http://ftp.cz.debian.org/debian/ testing main non-free - -deb http://security.debian.org/ testing/updates main non-free -deb-src http://security.debian.org/ testing/updates main non-free - -# testing-updates, previously known as 'volatile' -deb http://ftp.cz.debian.org/debian/ testing-updates main non-free -deb-src http://ftp.cz.debian.org/debian/ testing-updates main non-free +deb http://ftp.cz.debian.org/debian/ jessie main non-free +deb-src http://ftp.cz.debian.org/debian/ jessie main non-free +deb http://security.debian.org/ jessie/updates main non-free +deb-src http://security.debian.org/ jessie/updates main non-free
and run the usual
apt-get update
apt-get dist-upgrade
Monday, December 29, 2014
Yes, Debian stinks
# apt-get dist-upgrade
...
dpkg: dependency problems prevent processing triggers for hal:
hal depends on libdbus-glib-1-2 (>= 0.78); however:
Package libdbus-glib-1-2:amd64 is not configured yet.
hal depends on pciutils; however:
Package pciutils is not configured yet.
hal depends on dbus (>= 0.61); however:
Package dbus is not configured yet.
dpkg: error processing package hal (--configure):
dependency problems - leaving triggers unprocessed
dpkg: dependency problems prevent processing triggers for hal:
hal depends on libdbus-glib-1-2 (>= 0.78); however:
Package libdbus-glib-1-2:amd64 is not configured yet.
hal depends on pciutils; however:
Package pciutils is not configured yet.
hal depends on dbus (>= 0.61); however:
Package dbus is not configured yet.
...
dpkg: error processing package hal (--configure):
dependency problems - leaving triggers unprocessed
dpkg: too many errors, stopping
Processing triggers for libc-bin (2.19-13) ...
Errors were encountered while processing:
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
Jesus, do you guys really have no QA???
...
dpkg: dependency problems prevent processing triggers for hal:
hal depends on libdbus-glib-1-2 (>= 0.78); however:
Package libdbus-glib-1-2:amd64 is not configured yet.
hal depends on pciutils; however:
Package pciutils is not configured yet.
hal depends on dbus (>= 0.61); however:
Package dbus is not configured yet.
dpkg: error processing package hal (--configure):
dependency problems - leaving triggers unprocessed
dpkg: dependency problems prevent processing triggers for hal:
hal depends on libdbus-glib-1-2 (>= 0.78); however:
Package libdbus-glib-1-2:amd64 is not configured yet.
hal depends on pciutils; however:
Package pciutils is not configured yet.
hal depends on dbus (>= 0.61); however:
Package dbus is not configured yet.
...
dpkg: error processing package hal (--configure):
dependency problems - leaving triggers unprocessed
dpkg: too many errors, stopping
Processing triggers for libc-bin (2.19-13) ...
Errors were encountered while processing:
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
hal
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
Jesus, do you guys really have no QA???
Wednesday, April 9, 2014
tail -f /dev/ttyUSB0 in Debian
After a recent Debian 7.4 (I hate the codenames!) update I was no longer able to read data from the Arduino's USB serial.
I found out that
cat /dev/ttyUSB0
worked, while
tail -f /dev/ttyUSB0
did nothing. Strangely enough, running the command in strace revealed that tail was reading the data correctly, it just failed to display them ...
I'm not sure whom to blame - coreutils or Debian. Anyway, here's the solution/workaround I found at debianforum.de:
$ stty -F /dev/ttyUSB0 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
$ stty -F /dev/ttyUSB0 9600 raw hupcl min 0
$ tail ---disable-inotify -f /dev/ttyUSB0
I found out that
cat /dev/ttyUSB0
worked, while
tail -f /dev/ttyUSB0
did nothing. Strangely enough, running the command in strace revealed that tail was reading the data correctly, it just failed to display them ...
I'm not sure whom to blame - coreutils or Debian. Anyway, here's the solution/workaround I found at debianforum.de:
$ stty -F /dev/ttyUSB0 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
$ stty -F /dev/ttyUSB0 9600 raw hupcl min 0
$ tail ---disable-inotify -f /dev/ttyUSB0
Subscribe to:
Posts (Atom)