MC burner
- From: Laszlo Monda <mondalaci freemail hu>
- To: mc-devel gnome org
- Subject: MC burner
- Date: Fri, 31 Jan 2003 03:28:01 +0100
Hi,
I've written a CD burner menu extension for MC. It consists of the menu file (of course) and a bash script sourced from the menu. I know it's quite simple and not well integrated into MC, but it works well and it's (more or less) feature full.
You can burn single session/multi session CDs in dummy mode or on-the-fly. Additionally you can blank CDs (that wasn't really hard to implement ;)
This stuff supposes that you have a correct cdrecord config (correctly set up cdrecord.conf with default scsi device and speed (/etc/default/cdrecord.conf in debian))
I know you rejected a cd burner patch from someone else some time ago. The reason was that we should wait for some API change to implement the extension as a plugin. I think it's really time to provide a way to burn CDs from MC. This solution doesn't require any modification in the MC code and may be good until that API change.
I have written dozens of CDs well with this tiny piece of code but there's one known bug: when I want to burn another session sometimes the content of the disk is the same as before the burn.
I've both attached the files and included them for easier discussion. I am interested in your opinion.
The last entry of the menu doesn't belong to cd burning but it was extremly useful for me.
I'm subscribed so you don't need to CC: me.
---------------------------- menu -----------------------------------
shell_patterns=0
a tagged files->image->burn [dummy][multi]
. mc-burner
read_mod
create_path_list %u
create_image
read -p "please insert the CD-R into your recorder and press ENTER to burn!"
$cdrecord $dummy $multi $iso && rm $iso || echo "You may use the image file \`$iso' for further burning"
b tagged files->burn (on-the-fly) [dummy][multi]
. mc-burner
read_mod
create_path_list %u
read -p "please insert the CD-R into your recorder and press ENTER to burn!"
$mkisofs | $cdrecord $dummy $multi -
rm $pathlist
c image (selected)->burn [dummy][multi]
. mc-burner
read_mod
$cdrecord $dummy $multi "%s"
d blank CD
. mc-burner
$cdrecord blank=all
r make a release
read -p 'release number: ' release
mv %s %s-$release
tar -cvvf %s-$release.tar --exclude=CVS %s-$release
mv %s-$release %s
bzip2 -9 %s-$release.tar
-------------------------- mc-burner --------------------------------
#!/bin/sh
CD_74_SECT=337350
CD_80_SECT=359849
tmp=${MC_BURNER_TMP-/tmp}
mkisofs_base=${MC_BURNER_MKISOFS-"mkisofs -R -J -dir-mode 555"}
cdrecord=${MC_BURNER_CDRECORD-"cdrecord -data -v -eject $dummy $multi"}
tmpfileprefix=$tmp/mc-burner.`date +%Y-%m-%d_%H.%M.%S`
pathlist=$tmpfileprefix.pathlist
iso=$tmpfileprefix.iso
mkisofs="$mkisofs_base -graft-points -path-list $pathlist"
trap "rm -f $pathlist $iso" SIGINT
function read_mod()
{
read -p "type \`d' for dummy, \`m' for multi burn or \`df' for both: " mod
if [ "$mod" == "d" ]; then
dummy="-dummy"
elif [ "$mod" == "m" ]; then
multi="-multi"
elif [ "$mod" == "dm" -o "$mod" == "md" ]; then
dummy="-dummy"
multi="-multi"
fi
}
function is_fit()
{
if (($1<=$2)); then
echo -n FIT
else
echo -n NOT FIT
fi
}
function create_path_list()
{
echo -n Creating path list...
exec 6>&1 1>$pathlist
while [ "$1" ]; do
s=`echo $1 | sed -e 's/=/\\\\=/g'`
if [ -d "$1" ]
then echo $s/=$s
else echo $s
fi
shift
done
exec 1>&6 6>&-
echo OK
}
function create_image()
{
if [ ! -d "$tmp" -a ! -w "$tmp" ]; then
echo Temporary directory \`$tmp\' does not exist or not writable or not a real directory! >&2
echo You may set MC_BURNER_TMP to a correct directory! >&2
exit 1
fi
msinfo=`cdrecord -msinfo`
if [ $msinfo ]; then
size=`echo $msinfo|awk -F , '{print $2}'`
((CD_74_SECT-=size))
((CD_80_SECT-=size))
msinfo="-M 0,0,0 -C $msinfo"
fi
echo computing occupied space:
image_size=`$mkisofs -print-size 2>/dev/null`
df_out=`df $tmp --block-size=2048 | grep '^/dev/'`
free_space=`echo $df_out | awk '{print $4}'`
free_drive=`echo $df_out | awk '{print $1}'`
if [ $((image_size>CD_80_SECT)) = 1 ]; then
echo Your image is too large \($((image_size/500))MB\) thus it wouldn\'t even fit on a 700MB CD, aborting. >&2
rm $pathlist
exit 1
fi
echo " image of CD64: $((2*image_size))K of $((2*CD_74_SECT))K ($((100*image_size/CD_74_SECT)).$((1000*image_size/CD_74_SECT%10))%) `is_fit $image_size $CD_74_SECT`"
echo " image of CD70: $((2*image_size))K of $((2*CD_80_SECT))K ($((100*image_size/CD_80_SECT)).$((1000*image_size/CD_80_SECT%10))%) `is_fit $image_size $CD_80_SECT`"
echo " image of $free_drive: $((2*image_size))K of $((2*free_space))K ($((100*image_size/free_space)).$((1000*image_size/free_space%10))%) `is_fit $image_size $free_space`"
if [ $((free_space<image_size)) = 1 ]; then
echo "You may set MC_BURNER_TMP to an appropriate path."
rm $pathlist
exit 1
fi
echo creating image:
if $mkisofs $* $msinfo -o $iso 2>&1 | grep -v '^Using.*'; then
rm $pathlist
else
echo Image creation failed! >&2
echo "You can find the path file for further image creation: \`$pathlist'." >&2
exit 4
fi
}
-----------------------------------------------------------------------------
thanks,
Laci
shell_patterns=0
a tagged files->image->burn [dummy][multi]
. mc-burner
read_mod
create_path_list %u
create_image
read -p "please insert the CD-R into your recorder and press ENTER to burn!"
$cdrecord $dummy $multi $iso && rm $iso || echo "You may use the image file \`$iso' for further burning"
b tagged files->burn (on-the-fly) [dummy][multi]
. mc-burner
read_mod
create_path_list %u
read -p "please insert the CD-R into your recorder and press ENTER to burn!"
$mkisofs | $cdrecord $dummy $multi -
rm $pathlist
c image (selected)->burn [dummy][multi]
. mc-burner
read_mod
$cdrecord $dummy $multi "%s"
d blank CD
. mc-burner
$cdrecord blank=all
r make a release
read -p 'release number: ' release
mv %s %s-$release
tar -cvvf %s-$release.tar --exclude=CVS %s-$release
mv %s-$release %s
bzip2 -9 %s-$release.tar
#!/bin/sh
CD_74_SECT=337350
CD_80_SECT=359849
tmp=${MC_BURNER_TMP-/tmp}
mkisofs_base=${MC_BURNER_MKISOFS-"mkisofs -R -J -dir-mode 555"}
cdrecord=${MC_BURNER_CDRECORD-"cdrecord -data -v -eject $dummy $multi"}
tmpfileprefix=$tmp/mc-burner.`date +%Y-%m-%d_%H.%M.%S`
pathlist=$tmpfileprefix.pathlist
iso=$tmpfileprefix.iso
mkisofs="$mkisofs_base -graft-points -path-list $pathlist"
trap "rm -f $pathlist $iso" SIGINT
function read_mod()
{
read -p "type \`d' for dummy, \`m' for multi burn or \`df' for both: " mod
if [ "$mod" == "d" ]; then
dummy="-dummy"
elif [ "$mod" == "m" ]; then
multi="-multi"
elif [ "$mod" == "dm" -o "$mod" == "md" ]; then
dummy="-dummy"
multi="-multi"
fi
}
function is_fit()
{
if (($1<=$2)); then
echo -n FIT
else
echo -n NOT FIT
fi
}
function create_path_list()
{
echo -n Creating path list...
exec 6>&1 1>$pathlist
while [ "$1" ]; do
s=`echo $1 | sed -e 's/=/\\\\=/g'`
if [ -d "$1" ]
then echo $s/=$s
else echo $s
fi
shift
done
exec 1>&6 6>&-
echo OK
}
function create_image()
{
if [ ! -d "$tmp" -a ! -w "$tmp" ]; then
echo Temporary directory \`$tmp\' does not exist or not writable or not a real directory! >&2
echo You may set MC_BURNER_TMP to a correct directory! >&2
exit 1
fi
msinfo=`cdrecord -msinfo`
if [ $msinfo ]; then
size=`echo $msinfo|awk -F , '{print $2}'`
((CD_74_SECT-=size))
((CD_80_SECT-=size))
msinfo="-M 0,0,0 -C $msinfo"
fi
echo computing occupied space:
image_size=`$mkisofs -print-size 2>/dev/null`
df_out=`df $tmp --block-size=2048 | grep '^/dev/'`
free_space=`echo $df_out | awk '{print $4}'`
free_drive=`echo $df_out | awk '{print $1}'`
if [ $((image_size>CD_80_SECT)) = 1 ]; then
echo Your image is too large \($((image_size/500))MB\) thus it wouldn\'t even fit on a 700MB CD, aborting. >&2
rm $pathlist
exit 1
fi
echo " image of CD64: $((2*image_size))K of $((2*CD_74_SECT))K ($((100*image_size/CD_74_SECT)).$((1000*image_size/CD_74_SECT%10))%) `is_fit $image_size $CD_74_SECT`"
echo " image of CD70: $((2*image_size))K of $((2*CD_80_SECT))K ($((100*image_size/CD_80_SECT)).$((1000*image_size/CD_80_SECT%10))%) `is_fit $image_size $CD_80_SECT`"
echo " image of $free_drive: $((2*image_size))K of $((2*free_space))K ($((100*image_size/free_space)).$((1000*image_size/free_space%10))%) `is_fit $image_size $free_space`"
if [ $((free_space<image_size)) = 1 ]; then
echo "You may set MC_BURNER_TMP to an appropriate path."
rm $pathlist
exit 1
fi
echo creating image:
if $mkisofs $* $msinfo -o $iso 2>&1 | grep -v '^Using.*'; then
rm $pathlist
else
echo Image creation failed! >&2
echo "You can find the path file for further image creation: \`$pathlist'." >&2
exit 4
fi
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]