Can't create a XZM file.

Post here if you are a new Porteus member and you're looking for some help.
glestwid
Samurai
Samurai
Posts: 182
Joined: 09 Jan 2018, 20:05
Distribution: Porteus-XFCE 5.0 i586

Can't create a XZM file.

Post#1 by glestwid » 29 Jul 2022, 18:19

Hi,

I'm trying to make a missed XZM file form existing DEB at Ubuntu/ To realize it I'm issuing the following command:

wget http://de.archive.ubuntu.com/ubuntu/poo ... 1_i386.deb

Then it's time to run deb2xzm:
root@porteus:/tmp# deb2xzm python3-tk_3.10.4-0ubuntu1_i386.deb
Checking required libraries ...
And I receive nothing. What am I doing wrong ?

beny
Full of knowledge
Full of knowledge
Posts: 2092
Joined: 02 Jan 2011, 11:33
Location: italy

Can't create a XZM file.

Post#2 by beny » 29 Jul 2022, 19:17

uest@porteus:~$ sudo '/opt/porteus-scripts/deb2xzm' -x /home/guest/Downloads/ansible-lint_4.3.7-1_all.deb
Password:
Checking required libraries ...

Verifying package ansible-lint_4.3.7-1_all.tgz.
Installing package ansible-lint_4.3.7-1_all.tgz:
PACKAGE DESCRIPTION:
Package ansible-lint_4.3.7-1_all.tgz installed.
Creating /tmp/deb2xzm2665/ansible-lint_4.3.7-1_all.xzm

Traceback (most recent call last):
File "/usr/share/porteus/gtkdialog.py", line 7, in <module>
import gi
ImportError: No module named gi
guest@porteus:~$
you can use also the su option with password toor

glestwid
Samurai
Samurai
Posts: 182
Joined: 09 Jan 2018, 20:05
Distribution: Porteus-XFCE 5.0 i586

Can't create a XZM file.

Post#3 by glestwid » 29 Jul 2022, 20:34

Here's my output for '/opt/porteus-scripts/deb2xzm:
root@porteus:~/Downloads# sudo '/opt/porteus-scripts/deb2xzm' -x /home/root/Downloads/python3-tk_3.10.5-2ubuntu2_i386.deb

root@porteus:~/Downloads#
And no XZM again. What's wrong with my Porteus/deb2xzm/whatever else?

beny
Full of knowledge
Full of knowledge
Posts: 2092
Joined: 02 Jan 2011, 11:33
Location: italy

Can't create a XZM file.

Post#4 by beny » 29 Jul 2022, 21:37

the file that you have to change is ok? you can see it with an archive manager like file roller and type the script into a console and run it without the deb file see what tell you.

glestwid
Samurai
Samurai
Posts: 182
Joined: 09 Jan 2018, 20:05
Distribution: Porteus-XFCE 5.0 i586

Can't create a XZM file.

Post#5 by glestwid » 29 Jul 2022, 22:33

beny wrote:
29 Jul 2022, 21:37
the file that you have to change is ok?
Yep, it's opened in file manager and 7Zip as well.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3932
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Can't create a XZM file.

Post#6 by ncmprhnsbl » 30 Jul 2022, 02:49

but why python3-tk_3.10.5-2ubuntu2_i386.deb? porteus 5.0 has python-3.9 ...so getpkg tk would seem a better bet.
more generally, .debs seem to be hit and miss with deb2xzm ... possibly due to poorly built .debs ..? (havn't a problem with any i've tested so far)
possibility: the internals of a deb have a "data" archive which deb2xzm checks for one four types: tar.bz2, tar.lzma, tar.xz, tar.gz .. perhaps another one(or more) have been introduced?
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

donald
Full of knowledge
Full of knowledge
Posts: 2067
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

Can't create a XZM file.

Post#7 by donald » 30 Jul 2022, 11:28

--> python3-tk_3.10.4-0ubuntu1_i386.deb -- zst compression is used inside this file
therefore deb2xzm can not handle it.
I made some modifications to deb2xzm and also to convert_deb - which is used by the xfce
context menu.
Try them if you like.
deb2xzm goes into /opt/porteus-scripts (rename the original one to deb2xzm.orig first before
you copy in the new one so you can revert back if it does not work correctly.)
convert_deb is in /opt/porteus-scripts/context-menu (also rename the original one beforehand)
Note: I used a x86_64-xfce porteus system. there may or may not differences in a 32bit system.

deb2xzm

Code: Select all

#!/bin/sh
# Convert .deb. packages to .xzm modules.

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

. /usr/share/porteus/porteus-functions
. /usr/share/porteus/gtkdialog-functions
PATH=$PATH:/usr/share/porteus/

get_colors
function chklibs(){
echo "Checking required libraries ..."
echo
if [[ ! `/sbin/ldconfig -p | grep libbfd` ]]; then
	bold "#############################"
	bold "#     Missing library       #"
	bold "#############################"
	echo
	echo "You are missing libbfd. Please"
	echo "activate 05_devel or run the"
	bold "command: getpkg binutils"
	echo "and installpkg the file."
	echo
	exit
fi
}

show_help() {
    echo
    echo "Convert Debian's DEB package into .xzm compressed module"
    echo "usage: $0 <option> <argument> "
    echo " options:  -x : use xz compression. "
    echo " options:  -z : use zstd compression. "
    echo " if no option is given xz is used. "
    echo "           -h       : show this usage. "
    echo
    echo "example: $0 /mnt/sda2/debian_packages/package.deb"
	echo
}

# Exit if nothing is provided as an argument
if [ "$1" = "" ]; then
    show_help
    exit 1
fi

chklibs

# Switch to root:
if [ `whoami` != root ]; then
    for x in "$@"; do
		LIST+=("$x")
    done

    CURRENTPATH="-current=$PWD"
    LIST+=("$CURRENTPATH")

    # Re-execute this script with super user privileges:
    if [ "$DISPLAY" ] && [ "$QUIETMODE" != "-q" ]; then
    	/opt/porteus-scripts/xorg/psu /opt/porteus-scripts/deb2xzm "${LIST[@]}"
	else
		echo "Please enter root's password below:"
		ROOTCOMMAND="/opt/porteus-scripts/deb2xzm"$(printf ' %q' "${LIST[@]}")
		su -c "$ROOTCOMMAND"
    fi
    exit
fi

# Get current path
for var in "$@"; do
	if [[ "$var" = "-current"* ]]; then
		cd ${var#*=}
		break
	fi
done

COMP="-x"
COMP_ZSTD="-z"

while getopts "xzh" opt; do
case "$opt" in
    x)
        shift "$(($OPTIND -1))"
        ;;
    z)
        COMP="$COMP_ZSTD"
        shift "$(($OPTIND -1))"
        ;;
    h)
        show_help
        exit 0
        ;;
esac
done

# Work only on deb packages:
for x in $*; do
    ext=`echo $x | rev | cut -d. -f1 | rev`
    if [ "$ext" = deb ]; then
        mod=`readlink -f $x`
        MOD=`echo $MOD $mod`
    fi
done

# Create module:
for y in $MOD; do
    mod=`readlink -f $y | sed s/.deb$/.xzm/`
    pkg=`echo $mod | awk -F/ '{print$NF}' | sed s/.xzm//g`
    dataname=`ar t $y | grep data`
    if [ "$DISPLAY" ]; then
	case $dataname in
	data.tar.bz2)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.gz && bzip2 -d data.tar.bz2 && gzip data.tar && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod
	if [ $? -eq 0 ]; then
	    gtkdialog.py -p "Success! Module created as $mod" -t 2000
	else
	    gtkdialog.py -p "Error , $mod creation failed." -d err
	fi
	;;
	data.tar.gz)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.gz && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod
	if [ $? -eq 0 ]; then
	    gtkdialog.py -p "Success!  Module created as $mod" -t 2000
	else
	    gtkdialog.py -p "Error , $mod creation failed." -d err
	fi
	;;
	data.tar.lzma)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.lzma && unxz data.tar.lzma && gzip data.tar && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod
	if [ $? -eq 0 ]; then
	    gtkdialog.py -p "Success! Module created as $mod" -t 2000
	else
	    gtkdialog.py -p "Error , $mod creation failed." -d err
	fi
	;;
	data.tar.xz)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.xz && unxz data.tar.xz && gzip data.tar && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod
	if [ $? -eq 0 ]; then
	    gtkdialog.py -p "Success! Module created as $mod" -t 2000
	else
	    gtkdialog.py -p "Error , $mod creation failed." -d err
	fi
	;;
    data.tar.zst)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.zst && zstd -d data.tar.zst && gzip data.tar && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod
	if [ $? -eq 0 ]; then
	    gtkdialog.py -p "Success! Module created as $mod" -t 2000
	else
	    gtkdialog.py -p "Error , $mod creation failed." -d err
	fi
	;;
	esac
    else
	case $dataname in
	data.tar.bz2)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.gz && bzip2 -d data.tar.bz2 && gzip data.tar && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod && echo && echo -e "${c}Module created as $mod"$e || echo -e ''${r}$mod' creation failed!'$e
	;;
	data.tar.gz)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.gz && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod && echo && echo -e "${c}Module created as $mod"$e || echo -e ''${r}$mod' creation failed!'$e
	;;
	data.tar.lzma)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.lzma && unxz data.tar.lzma && gzip data.tar && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod && echo && echo -e "${c}Module created as $mod"$e || echo -e ''${r}$mod' creation failed!'$e
	;;
	data.tar.xz)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.xz && unxz data.tar.xz && gzip data.tar && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod && echo && echo -e "${c}Module created as $mod"$e || echo -e ''${r}$mod' creation failed!'$e
	;;
    data.tar.zst)
	mkdir /tmp/deb2xzm$$ && cp $y /tmp/deb2xzm$$ && cd /tmp/deb2xzm$$ && /usr/bin/ar x * data.tar.zst && zstd -d data.tar.zst && gzip data.tar && mv data.tar.gz $pkg.tgz && txz2xzm $COMP /tmp/deb2xzm$$/$pkg.tgz && mv /tmp/deb2xzm$$/$pkg.xzm $mod && echo && echo -e "${c}Module created as $mod"$e || echo -e ''${r}$mod' creation failed!'$e
	;;
	esac
    fi
    rm -rf /tmp/deb2xzm$$
done
convert_deb

Code: Select all

#!/bin/bash
# Service menu script to convert deb packages to xzm modules
# Author: Brokenman <brokenman@porteus.org>

. /usr/lib/librokenman

selection=$*

COMP="-x"
COMP_ZSTD="-z"

while getopts "xz" opt; do
case "$opt" in

    x)
        shift "$(($OPTIND -1))"
        ;;

    z)
        COMP="$COMP_ZSTD"
        shift "$(($OPTIND -1))"
        ;;

esac
done

# Root check
if [ "`whoami`" != "root" ]; then
  /opt/porteus-scripts/xorg/psu $0 $COMP $selection &
  exit
fi

# Convert the packages
for package in $selection; do
  path=${package%/*}
  name=${package##*/}
  dir=${name%.*}
  #echo "$name" >> /tmp/.extracted
  #echo "$name" > /tmp/.message
  /usr/share/porteus/gtkprogress.py -w "DEB Conversion" -m "Converting ${name}..." -t "Processing..." &
  #prog=$(ps ax|grep gtkprogress.py |awk '{print$1}'|head -n1)
  prog=$!
  #sleep 2
  mkdir /tmp/deb2xzm$$
  cp ${path}/${name} /tmp/deb2xzm$$
  cd /tmp/deb2xzm$$
  dataname=`ar t * | grep data`
  
  case $dataname in
data.tar.gz)
  ar x * data.tar.gz
;;
data.tar.lzma)
  ar x * data.tar.lzma && unxz data.tar.lzma && gzip data.tar
;;
data.tar.xz)
  ar x * data.tar.xz && unxz data.tar.xz && gzip data.tar
;;
data.tar.zst)
  ar x * data.tar.zst && zstd -d data.tar.zst && gzip data.tar
  esac
  
  mv data.tar.gz ${dir}.tgz
  txz2xzm ${COMP} ${dir}.tgz
  mv ${dir}.xzm ${path}/
  rm -r /tmp/deb2xzm$$
  # kill progress
  kill ${prog}
done



# Give notification
/usr/share/porteus/gtkdialog.py -p "Conversion complete!" -t 2000 &

#rm /tmp/.message /tmp/.extracted 2>/dev/null
exit

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3932
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Can't create a XZM file.

Post#8 by ncmprhnsbl » 30 Jul 2022, 22:12

donald wrote:
30 Jul 2022, 11:28
I made some modifications to deb2xzm and also to convert_deb - which is used by the xfce
context menu.
looks good, thanks donald, added to the scripts TREE ..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

Post Reply