[SOLVED] xzm2lzm?

Post here if you are a new Porteus member and you're looking for some help.
User avatar
Syntux
White ninja
White ninja
Posts: 24
Joined: 24 May 2011, 06:01
Location: Germany

[SOLVED] xzm2lzm?

Post#1 by Syntux » 03 Jun 2011, 15:38

Don't know whether this is the right place to ask? How can I possibly convert xzm modules back to lzm? Is there something like xzm2lzm?
Last edited by Syntux on 04 Jun 2011, 16:35, edited 1 time in total.

User avatar
Ahau
King of Docs
King of Docs
Posts: 1331
Joined: 28 Dec 2010, 15:18
Distribution: LXDE & Xfce 32/64-bit
Location: USA

Re: xzm2lzm?

Post#2 by Ahau » 03 Jun 2011, 16:10

I assume you're looking to get modules built for V1.0 to run in V0.9?

I'd first say that you may run into some incompatibilities by using newer versions of software in the older version. With that disclaimer out of the way, here's my answer:

1) there is no xzm2lzm utility, and you cannot convert an xzm from within Version 0.9 -- the kernel and LZMA utilities can't handle the LZMA2 compression of an xzm module. To accomplish this from within porteus, you could install V1.0 RC2, download the xzm module, use xzm2dir (or the right click menu to extract xzm if you prefer GUI), then zip or tar that directory, and save the archived file to your storage media. Then, boot into V 09, extract the target archive to a directory, and use dir2lzm to convert it into an lzm module.

If you're using the 32-bit version of V1.0 -- it might have dir2lzm (I forget whether it does or not). If that's the case you might be able to do xzm2dir then dir2lzm from within V1.0, without needing to archive and switch porteus versions.

2) If you're doing this from another distro, you'd need to have squashfs4 and LZMA2 supported, and you could extract modules as suggested by brokenman here: http://porteus.org/forum/viewtopic.php? ... t=10#p3977
To unpack on slackware (providing you have squashfs support)

unsquashfs -f -dest /path/to/unpack /path/to/module.xzm
mksquashfs directory module.xzm

You can download the squashfs tools and stick them in your $PATH.

I hope that helps...my final suggestion would be to upgrade to V1.0 if possible :)
Please take a look at our online documentation, here. Suggestions are welcome!

User avatar
Syntux
White ninja
White ninja
Posts: 24
Joined: 24 May 2011, 06:01
Location: Germany

Re: xzm2lzm?

Post#3 by Syntux » 04 Jun 2011, 08:23

Thanks Ahau,

actually I use multiple versions: slax remix 08, 09 and porteus 1.0 rc2 (32 and 64-Bit) together with a combination of my own and 3rd party modules and I was looking for an easy way how to convert them back and forth.
Right now I use the manual way over tar.gz which you proposed, but I wonder if there was no easier medthod? I also used to create and extract modules on other distros like SuSE, RedHat and Slackware, but I wonder if this is still working, when I use the new squashfs4 and lzma2 tools form porteus 1.0? There is no dir2lzm on porteus 1.0 rc2 32-Bit unfortunately!

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: xzm2lzm?

Post#4 by fanthom » 04 Jun 2011, 11:34

@Syntux
current version of squashfs-tools for 1.0 are compiled with support for: gzip, lzo, lzma and xz. you can modify existing lzm2xzm script and convert it to xzm2lzm easily:

Code: Select all

#!/bin/sh
# script by fanthom

# Switch to root
if [ "$DISPLAY" ]; then
   if [ `whoami` != "root" ]; then
      xterm -T "Please enter root's password below" -e su -c "/opt/porteus-scripts/xzm2lzm $1"
      exit
   fi
else
   if [ `whoami` != "root" ]; then
      echo "Please enter root's password below"
      su -c "/opt/porteus-scripts/xzm2lzm $1"
      exit
   fi
fi

# Variables
c='\e[36m'
r='\e[31m'
e=`tput sgr0`

# Let's start
if [ "$1" = "" ]; then
echo && echo -e "${r}need a xzm module or folder containing xzm's as an argument
examples:

$0 /mnt/sda2/porteus_modules
$0 /root/module.xzm"$e
exit
fi

if [ -d "$1" ]; then cd $1; fi

for x in `ls $1 | grep .xzm`; do
    path=`readlink -f $x`
    name=`echo $path | rev | cut -d/ -f1 | rev | cut -d. -f1`                                                                              
    newnm=`echo $path | sed 's/.xzm/.lzm/g'`                                                                             
    unsquashfs -d /tmp/$name$$ $path                                                                                                   
    mksquashfs /tmp/$name$$ $newnm -comp lzma -b 256K
    rm -r /tmp/$name$$
    echo $newnm >> /tmp/list
done

echo && echo -e "${c}this is the list of converted modules..."$e
echo && cat /tmp/list
rm /tmp/list
the main change is to replace 'dir2xzm /tmp/$name$$ $newnm' with 'mksquashfs /tmp/$name$$ $newnm -comp lzma -b 256K'
pls save it as 'xzm2lzm' in /opt/porteus-scripts and let me know in case of troubles (i didn't test it).

Cheers
Please add [Solved] to your thread title if the solution was found.

User avatar
Syntux
White ninja
White ninja
Posts: 24
Joined: 24 May 2011, 06:01
Location: Germany

Re: xzm2lzm?

Post#5 by Syntux » 04 Jun 2011, 14:44

Hi fanthom,

this is the hint I needed to hear ;) ... here is xzm2lzm. By the way I used sed instead of cut to create $name, since it also works for modules with more "." (dots) in the name.
Maybe you could use this also in script lzm2xzm. It doesn't fail if you have multiple dots, but it is formally more correct I guess.

Code: Select all

#!/bin/sh                                                                       
# script by fanthom                                                             
                                                                                
# Switch to root                                                                
if [ "$DISPLAY" ]; then                                                         
   if [ `whoami` != "root" ]; then                                              
      xterm -e su -c "xzm2lzm $1"                                               
      exit                                                                      
   fi                                                                           
else                                                                            
   if [ `whoami` != "root" ]; then                                              
      echo "Please enter root's password below"                                 
      su -c "xzm2lzm $1"                                                        
      exit                                                                      
   fi                                                                           
fi                                                                              
                                                                                
# Variables                                                                     
c='\e[36m'                                                                      
r='\e[31m'                                                                      
e=`tput sgr0`                                                                   
                                                                                
# Let's start                                                                   
if [ "$1" = "" ]; then                                                          
echo && echo -e "${r}need a xzm module or folder containing xzm's as an argument
examples:                                                                       
                                                                                
$0 /mnt/sda2/porteus_modules                                                    
$0 /root/module.xzm"$e                                                          
exit                                                                            
fi                                                                              
                                                                                
if [ -d "$1" ]; then cd $1; fi                                                  
                                                                                
for x in `ls $1 | grep .xzm`; do                                                
    path=`readlink -f $x`                                                       
    name=`echo $path | rev | cut -d/ -f1 | rev | sed 's/.xzm//g'`               
    newnm=`echo $path | sed 's/.xzm/.sq4.lzm/g'`                                
    unsquashfs -d /tmp/$name$$ $path                                            
    mksquashfs /tmp/$name$$ $newnm -comp lzma -b 256k                           
    rm -r /tmp/$name$$                                                          
    echo $newnm >> /tmp/list                                                    
done                                                                            
                                                                                
echo && echo -e "${c}this is the list of converted modules..."$e                
echo && cat /tmp/list                                                           
rm /tmp/list 
Thanks a lot,
Syntux

Verfasst after 45 minutes 36 seconds:
@fanthom

I think there is one library of liblzma.so too much in /lib64 of porteus 64 1.0 rc2. Only liblzma.so.5.0.2 is needed I guess?

Code: Select all

lrwxrwxrwx 1 root root     16 Jun  4 13:19 liblzma.so.0 -> liblzma.so.0.0.0
-rwxr-xr-x 1 root root 134088 May  7 16:53 liblzma.so.0.0.0
lrwxrwxrwx 1 root root     16 Jun  4 13:19 liblzma.so.5 -> liblzma.so.5.0.2
-rwxr-xr-x 1 root root 138984 May  7 16:53 liblzma.so.5.0.2

User avatar
fanthom
Moderator Team
Moderator Team
Posts: 5666
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland
Contact:

Re: [SOLVED] xzm2lzm?

Post#6 by fanthom » 05 Jun 2011, 06:51

@Syntux
1) thanks for the hint but i'm staying with reordered syntax and 'cut' command:
name=`echo $path | rev | cut -d/ -f1 | cut -d. -f2- | rev`
'sed' deletes .xzm globally so is more dangerous than 'cut'.

2) this lib (and few other) comes from aaa_elflibs package. this package is still a little slackware mystery for me, i'm guessing that it's purpose is to make sure that userland gonna work despite of packages deleted/upgraded by the user in real slackware installation.
i would leave it in place.
Please add [Solved] to your thread title if the solution was found.

User avatar
Syntux
White ninja
White ninja
Posts: 24
Joined: 24 May 2011, 06:01
Location: Germany

Re: [SOLVED] xzm2lzm?

Post#7 by Syntux » 05 Jun 2011, 13:00

@fanthom
1) This syntax is much better now, since the module name can now have mutiple "." (dots) and I agree that sed is probably more dangerous
2) Okay, I thought the library was left over from an older version of the tools? Did also not understand why the version is 0.0.0.0?

By the way I created the files porteus_tools_32-1.0-0.tar.gz and porteus_tools_64-1.0-0.tar.gz that carries all the tools like xzm2dir, lzm2xzm, xzm2dir, etc. with the liblzma-libraries and can now simply unpack this to any other distro in order to create and reuse xzm/lzm modules. Quite convenient for me :) ...

https://rapidshare.com/files/1706743516 ... 0-1.tar.gz
https://rapidshare.com/files/1062617882 ... 0-1.tar.gz

Post Reply