From: Mazet Laurent Date: Sat, 9 Dec 2023 08:14:00 +0000 (+0100) Subject: update script X-Git-Url: https://secure.softndesign.org/git/?p=iso2ps2.git;a=commitdiff_plain;h=a8671a5de60b0ae47fff308312d881c6e1598c7c update script --- diff --git a/iso2ps2 b/iso2ps2 index fd26b5f..8800034 100755 --- a/iso2ps2 +++ b/iso2ps2 @@ -1,10 +1,24 @@ #!/bin/bash +PROGNAME="$(basename $0)" +PWD=$(dirname $0) +[ "$PWD" ] || PWD=$(pwd) +PWD=$(cd $PWD; pwd) + # default values -PROGNAME=$(basename $0) +CACHE=$PWD/cache +CONFIGS=$PWD/CONFIGS KLICENSE="e4e54fd67c16c316f47829a30484d843" -PS2CLASSIC=ps2classic/ps2classic -PSNPACKAGE=psn_package_npdrm/psn_package_npdrm +PS2CLASSIC=$PWD/ps2classic/ps2classic +PSNPACKAGE=$PWD/psn_package_npdrm/psn_package_npdrm +# FAT SLIM SUPER ULTRA +MODEL="ULTRA" + +# formating functions +function title () { echo -e "\033[0;1m$*\033[0;0m"; } +function pass () { echo -e "\033[1;32m$*\033[0;0m"; } +function warn () { echo -e "\033[1;33m$*\033[0;0m"; } +function fail () { echo -e "\033[1;31m$*\033[0;0m"; exit 1; } # defaut values id=0 @@ -20,7 +34,6 @@ serial=$(isoinfo -f -i "$file" | \ grep "^/[A-Z][A-Z][A-Z][A-Z]_[0-9][0-9][0-9]\.[0-9][0-9];" | \ sed 's,[/.],,g;s,_,-,;s,;.*,,') [ "$serial" ] || { serial=$(printf "PS2U-1%04d" $id); let id++; } -CID=${serial/-} # store last value echo > .$PROGNAME @@ -31,7 +44,7 @@ function getname () { [ -f jlist2.html ] || wget https://psxdatacenter.com/psx2/jlist2.html [ -f plist2.html ] || wget https://psxdatacenter.com/psx2/plist2.html [ -f ulist2.html ] || wget https://psxdatacenter.com/psx2/ulist2.html - awk '/>'$1''$file'/, "") sub(/ /, " ") gsub(/^[ \t]*/, "") @@ -45,67 +58,122 @@ function getname () { title=$(awk -F\; '"'$serial'" == $1 {print $2}' PS2-GAMEID-TITLE-MASTER.csv) [ "$title" ] || title=$(basename "$file" | sed 's/ *(.*//') +# create CID +title "create CID" +cid=2P0001-${serial/-}_00-$(echo ${title}0000111122223333 | \ + tr '[a-z]' '[A-Z]' | \ + sed 's/[^A-Z0-9]//g;s/\(................\).*$/\1/') + # main process +title "description" echo "File: '$file'" echo "Serial: $serial" echo "Title: '$title'" +echo "CID: $cid" -# skeleton +# install skeleton +title "install skeleton" mkdir $serial tar -C $serial -xzf skeleton.tgz +[ -d $CACHE ] || mkdir $CACHE # images: # - ICON0.PNG 320x176 # - PIC0.PNG 1000x560 # - PIC1.PNG 1920x1080 -# cover -wget https://psxdatacenter.com/psx2/images2/covers/$serial.jpg -if [ -f $serial.jpg ]; then - convert $serial.jpg tmp.png - mogrify -resize 320x176 tmp.png - mogrify -background transparent -gravity center -extent 320x176 tmp.png - mv tmp.png $serial/ICON0.PNG - rm $serial.jpg +# get cover image +title "get cover image" +if [ -f $CACHE/$serial-ICON0.PNG ]; then + cp $CACHE/$serial-ICON0.PNG $serial/ICON0.PNG +else + wget https://psxdatacenter.com/psx2/images2/covers/$serial.jpg + if [ -f $serial.jpg ]; then + convert $serial.jpg tmp.png + mogrify -resize 320x176 tmp.png + mogrify -background transparent -gravity center -extent 320x176 tmp.png + mv tmp.png $serial/ICON0.PNG + rm $serial.jpg + cp $serial/ICON0.PNG $CACHE/$serial-ICON0.PNG + else + warn "can't find cover" + fi fi -# screenshot -touch .touch -find $HOME/.config/PCSX2/snaps/ -type f | xargs rm .touch -pcsx2 "$file" -capture=$(find $HOME/.config/PCSX2/snaps/ -type f | sort) -if [ "$capture" ]; then - cp "$capture" tmp.png - mogrify -scale 1000x560 tmp.png - mogrify -background transparent -gravity center -extent 1000x560 tmp.png - mv tmp.png $serial/PIC0.PNG +# get screenshot +title "get screenshot" +if [ $CACHE/$serial-PIC0.PNG ]; then + cp $CACHE/$serial-PIC0.PNG $serial/PIC0.PNG +else + touch .touch + find $HOME/.config/PCSX2/snaps/ -type f | xargs rm .touch + pcsx2 "$file" + capture=$(find $HOME/.config/PCSX2/snaps/ -type f | sort) + if [ "$capture" ]; then + cp "$capture" tmp.png + mogrify -scale 1000x560 tmp.png + mogrify -background transparent -gravity center -extent 1000x560 tmp.png + mv tmp.png $serial/PIC0.PNG + cp $serial/PIC0.PNG $CACHE/$serial-PIC0.PNG + else + warn "can't find screenshot" + fi fi +# create PARAM.SFO +title "create PARAM.SFO" # parameters # - file: PARAM.SFO -# 0x108: title -# 0x188: CID +# 0x120: title +# 0x1a0: ${serial/-} # - file: USRDIR/ISO.BIN.EDAT -# 0x017: CID -echo -n $title | xxd | xxd -r -s 0x108 - $serial/PARAM.SFO -echo -n $CID | xxd | xxd -r -s 0x188 - $serial/PARAM.SFO -echo -n $CID | xxd | xxd -r -s 0x17- $serial/USRDIR/ISO.BIN.EDAT +# 0x017: ${serial/-} +echo -n $title | xxd | xxd -r -s 0x120 - $serial/PARAM.SFO +echo -n ${serial/-} | xxd | xxd -r -s 0x1a0 - $serial/PARAM.SFO +echo -n ${serial/-} | xxd | xxd -r -s 0x17- $serial/USRDIR/ISO.BIN.EDAT # generate key +title "generate key" dd bs=1 count=$(expr ${#KLICENSE} / 2) if=/dev/zero of=$serial/ps2.key -echo "00000000 $KLICENSE" | xdd -r - > $serial/ps2.key - -# package config -echo > $serial/package.conf << EOF -Content-ID = $CID +echo "00000000 $KLICENSE" | xxd -r - $serial/ps2.key + +# find config file +title "find config file" +confname=$(echo $serial.CONFIG | sed 's/-/_/;s/_\(...\)/_\1./') +case "$MODEL" in + FAT) + config=$(cd $CONFIGS; find GX -name $confname | head -1) + ;; + SLIM|SUPER|ULTRA) + config=$(cd $CONFIGS; find CUSTOM SOFT NET -name $confname | head -1) + ;; +esac +[ -f "CONFIGS/$config" ] || fail "can't find config" +cp $CONFIGS/$config $serial/$confname + +# create package config +title "create package config" +cat > $serial/package.conf << EOF +Content-ID = $cid k_licensee = 0x$KLICENSE DRM_Type = Free -Content_Type = Game_Data +Content_Type = PS2_Classics_Game PackageVersion = 01.01 EOF +# prepare iso +title "prepare iso" +$PS2CLASSIC prepare "$file" + # convert iso -$PS2CLASSIC e cex $serial/ps2.key "$1" $serial/USRDIR/ISO.BIN.ENC ISO.BIN.ENC 2P0001-${CID}_00-0000111122223333 +title "convert iso" +$PS2CLASSIC e cex $serial/ps2.key "$file" $serial/USRDIR/ISO.BIN.ENC ISO.BIN.ENC $cid # create package -$PSNPACKAGE $serial +title "create package" +( cd $serial; $PSNPACKAGE $confname package.conf . ) +mv $serial/$cid.pkg . + +# cleaning +title "cleaning" +rm -rf $serial diff --git a/psn_package_npdrm/psn_package_npdrm b/psn_package_npdrm/psn_package_npdrm index 42a0e3f..74b5c8b 100755 --- a/psn_package_npdrm/psn_package_npdrm +++ b/psn_package_npdrm/psn_package_npdrm @@ -2,4 +2,4 @@ PWD=$(dirname $0) [ "$PWD" ] || PWD=. -wine $PWD/$0.exe +wine $PWD/$(basename $0).exe $@ diff --git a/skeleton.tgz b/skeleton.tgz index ee71b16..d958120 100644 Binary files a/skeleton.tgz and b/skeleton.tgz differ