mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Ticket #3027: use xorriso (if exists) for writing into ISO images
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
b3bc7a077e
commit
1ca5bd3e6e
@ -1,20 +1,99 @@
|
||||
#! /bin/sh
|
||||
|
||||
# ISO9660 VFS for MC by Michael Shigorin <mike@altlinux.org>,
|
||||
# modifications by Grigory Milev <week@altlinux.org>
|
||||
# and Kachalov Anton <mouse@linux.ru.net> April 2003
|
||||
# Midnight Commander - ISO9660 VFS for MC
|
||||
# based on lslR by Tomas Novak <tnovak@ipex.cz> April 2000
|
||||
# -- look there for additional parsing comments if needed
|
||||
#
|
||||
# Copyright (C) 2000, 2003
|
||||
# The Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by:
|
||||
# Michael Shigorin <mike@altlinux.org>,
|
||||
# Grigory Milev <week@altlinux.org>,
|
||||
# Kachalov Anton <mouse@linux.ru.net>, 2003
|
||||
# Victor Ananjevsky <ananasik@gmail.com>, 2013
|
||||
# slava zanko <slavazanko@gmail.com>, 2013
|
||||
#
|
||||
# This file is part of the Midnight Commander.
|
||||
#
|
||||
# The Midnight Commander is free software: you can redistribute it
|
||||
# and/or modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
#
|
||||
# The Midnight Commander is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#*** include section (source functions, for example) *******************
|
||||
|
||||
#*** file scope functions **********************************************
|
||||
|
||||
XORRISO=$(which xorriso 2>/dev/null)
|
||||
|
||||
xorriso_list() {
|
||||
if test -z "$XORRISO"; then
|
||||
return 1
|
||||
fi
|
||||
local dir attr ln usr gr sz dt1 dt2 dt3 nm len name
|
||||
dir="$2"
|
||||
$XORRISO -dev stdio:"$1" -cd "$dir" -lsl 2> /dev/null | @GREP@ "^[-d]" | \
|
||||
while read attr ln usr gr sz dt1 dt2 dt3 nm ; do
|
||||
len=$((${#nm} - 2))
|
||||
name=$(printf "$nm" | cut -c2-$len) # remove quotes
|
||||
if test $(printf "$nm" | cut -c1-2) != "d"; then
|
||||
printf "%s %s %s %s %s %s %s %s %s/%s\n" "$attr" "$ln" "$usr" "$gr" "$sz" "$dt1" "$dt2" "$dt3" "$dir" "$name"
|
||||
else
|
||||
xorriso_list "$1" "$dir/$name"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
xorriso_copyout() {
|
||||
if test -z "$XORRISO"; then
|
||||
return 1
|
||||
fi
|
||||
$XORRISO -dev stdio:"$1" -osirrox on -extract "$2" "$3" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
xorriso_copyin() {
|
||||
if test -z "$XORRISO"; then
|
||||
return 1
|
||||
fi
|
||||
$XORRISO -dev stdio:"$1" -cpr "$3" "$2" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
xorriso_mkdir() {
|
||||
if test -z "$XORRISO"; then
|
||||
return 1
|
||||
fi
|
||||
$XORRISO -dev stdio:"$1" -mkdir "$2" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
xorriso_rmdir() {
|
||||
if test -z "$XORRISO"; then
|
||||
return 1
|
||||
fi
|
||||
$XORRISO -dev stdio:"$1" -rmdir "$2" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
xorriso_rm() {
|
||||
if test -z "$XORRISO"; then
|
||||
return 1
|
||||
fi
|
||||
$XORRISO -dev stdio:"$1" -rm "$2" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# tested to comply with isoinfo 2.0's output
|
||||
|
||||
test_iso () {
|
||||
CHARSET=`locale charmap 2>/dev/null`
|
||||
CHARSET=$(locale charmap 2>/dev/null)
|
||||
if test -z "$CHARSET"; then
|
||||
CHARSET=`locale 2>/dev/null | @GREP@ LC_CTYPE | sed -n -e 's/.*\.\(.*\)"$/\1/p'`
|
||||
CHARSET=$(locale 2>/dev/null | @GREP@ LC_CTYPE | sed -n -e 's/.*\.\(.*\)"$/\1/p')
|
||||
fi
|
||||
if test -n "$CHARSET"; then
|
||||
CHARSET=`echo "$CHARSET" | tr '[A-Z]' '[a-z]' | sed -e 's/^iso-/iso/'`
|
||||
CHARSET=$(echo "$CHARSET" | tr '[A-Z]' '[a-z]' | sed -e 's/^iso-/iso/')
|
||||
isoinfo -j $CHARSET -i /dev/null 2>&1 | @GREP@ "Iconv not yet supported\|Unknown charset" >/dev/null && CHARSET=
|
||||
fi
|
||||
if test -n "$CHARSET"; then
|
||||
@ -24,19 +103,19 @@ test_iso () {
|
||||
fi
|
||||
ISOINFO="isoinfo -R"
|
||||
|
||||
ISOINFO_D_I="`isoinfo -d -i "$1" 2>/dev/null`"
|
||||
ISOINFO_D_I="$(isoinfo -d -i "$1" 2>/dev/null)"
|
||||
|
||||
echo "$ISOINFO_D_I" | @GREP@ "UCS level 1\|NO Joliet" > /dev/null || ISOINFO="$ISOINFO $JOLIET_OPT"
|
||||
|
||||
if [ `echo "$ISOINFO_D_I" | @GREP@ "Joliet with UCS level 3 found" | wc -l` = 1 \
|
||||
-a `echo "$ISOINFO_D_I" | @GREP@ "NO Rock Ridge" | wc -l` = 1 ] ; then
|
||||
if [ $(echo "$ISOINFO_D_I" | @GREP@ "Joliet with UCS level 3 found" | wc -l) = 1 \
|
||||
-a $(echo "$ISOINFO_D_I" | @GREP@ "NO Rock Ridge" | wc -l) = 1 ] ; then
|
||||
SEMICOLON="YES"
|
||||
fi
|
||||
}
|
||||
|
||||
mcisofs_list () {
|
||||
# left as a reminder to implement compressed image support =)
|
||||
case "$1" in
|
||||
# left as a reminder to implement compressed image support =)
|
||||
case "$1" in
|
||||
*.lzma) MYCAT="lzma -dc";;
|
||||
*.xz) MYCAT="xz -dc";;
|
||||
*.bz2) MYCAT="bzip2 -dc";;
|
||||
@ -44,9 +123,9 @@ case "$1" in
|
||||
*.z) MYCAT="gzip -dc";;
|
||||
*.Z) MYCAT="gzip -dc";;
|
||||
*) MYCAT="cat";;
|
||||
esac
|
||||
esac
|
||||
|
||||
$ISOINFO -l -i "$1" 2>/dev/null | @AWK@ -v SEMICOLON=$SEMICOLON '
|
||||
$ISOINFO -l -i "$1" 2>/dev/null | @AWK@ -v SEMICOLON=$SEMICOLON '
|
||||
BEGIN {
|
||||
dir="";
|
||||
# Pattern to match 8 first fields.
|
||||
@ -85,6 +164,8 @@ mcisofs_copyout () {
|
||||
fi
|
||||
}
|
||||
|
||||
#*** main code *********************************************************
|
||||
|
||||
LC_ALL=C
|
||||
|
||||
cmd="$1"
|
||||
@ -92,12 +173,42 @@ shift
|
||||
|
||||
case "$cmd" in
|
||||
list)
|
||||
xorriso_list "$@" || {
|
||||
test_iso "$@";
|
||||
mcisofs_list "$@";
|
||||
exit 0;;
|
||||
}
|
||||
exit 0
|
||||
;;
|
||||
rm)
|
||||
xorriso_rm "$@" || {
|
||||
exit 1
|
||||
}
|
||||
exit 0
|
||||
;;
|
||||
rmdir)
|
||||
xorriso_rmdir "$@" || {
|
||||
exit 1
|
||||
}
|
||||
exit 0
|
||||
;;
|
||||
mkdir)
|
||||
xorriso_mkdir "$@" || {
|
||||
exit 1
|
||||
}
|
||||
exit 0
|
||||
;;
|
||||
copyin)
|
||||
xorriso_copyin "$@" || {
|
||||
exit 1
|
||||
}
|
||||
exit 0
|
||||
;;
|
||||
copyout)
|
||||
xorriso_copyout "$@" || {
|
||||
test_iso "$@";
|
||||
mcisofs_copyout "$@";
|
||||
exit 0;;
|
||||
}
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user