📄 lrk-build
字号:
#!/bin/bash## Linux Rom Kitchen Build script## Copyright (C) 2007-2008 Pau Oliva Fora - <pof@eslack.org>## This program 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# opinion) any later version. See <http://www.gnu.org/licenses/gpl.html>#TOOLS="/usr/share/LinuxRomKitchen/"CURRENTDIR=`pwd`if ! [ -f $HOME/.lrk/NBSPLITOPTS ]; then echo "-kaiser" > $HOME/.lrk/NBSPLITOPTSfiNBSPLITOPTS=`cat ~/.lrk/NBSPLITOPTS`if [ -z $1 ]; then echo "USAGE: lrk-build <os-new.nb>" exit 1fiif [ -e $1 ]; then echo "ERROR: $1 already exists, please delete it first" exit 1fi## SYS, ROM & Packages folders must existif ! [ -d SYS ]; then echo "ERROR: SYS folder doesn't exist, run lrk-extract first" exit 1fiif ! [ -d ROM ]; then echo "ERROR: ROM folder doesn't exist, run lrk-extract first" exit 1fiif ! [ -d Packages_Install ]; then echo "Warning: Packages folder doesn't exist, creating an empty one" echo "No custom packages will be added to this rom." mkdir Packages_Installfiecho "$CURRENTDIR" |grep " " 1>/dev/nullif [ $? != 1 ]; then echo "ERROR: Sorry, the current work directory can't contain spaces: $CURRENTDIR" exit 1fiecho "Preparing..."rm -rf ~/.lrk/Temp/ 2>/dev/nullmkdir -p ~/.lrk/Temp/cd ~/.lrk/Temp#convert initflashfiles.dat to original formatINFF=`find ${CURRENTDIR}/SYS/OEM* -iname "initflashfiles.dat"`chmod 644 $INFFif [ $? != 0 ]; then echo "ERROR: Initflashfiles not found" exit 1fiLEN=`cat $HOME/.lrk/initflashfiles.txt |wc -l`if [ $LEN -gt 1 ]; then iconv -f iso-8859-15 -t utf16 $HOME/.lrk/initflashfiles.txt > $INFF FLAG=`hexdump $INFF |head -n 1 |cut -f 2 -d " "` size=`du -b $INFF |cut -f 1` if [ "$FLAG" = "feff" ]; then dd if=$INFF of=$INFF.tmp bs=1 skip=2 count=$(($size - 2)) mv $INFF.tmp $INFF fifichmod 444 $INFFmkdir Packagescd Packagesfind "$CURRENTDIR/SYS/" -name "*.rgu" -exec cp {} . \; 2>/dev/nullfind "$CURRENTDIR/ROM/" -name "*.rgu" -exec cp {} . \; 2>/dev/nullfind "$CURRENTDIR/Packages_Install/" -name "*.rgu" -exec cp {} . \; 2>/dev/nullfind "$CURRENTDIR/SYS/" -name "*.dsm" -exec cp {} . \; 2>/dev/nullfind "$CURRENTDIR/ROM/" -name "*.dsm" -exec cp {} . \; 2>/dev/nullfind "$CURRENTDIR/Packages_Install/" -name "*.dsm" -exec cp {} . \; 2>/dev/null# rgucomp.exe needs cereg400.dll to mount the hivesecho "Generating boot.hv..."export _FLATRELEASEDIR=.wine $TOOLS/rgucomp.exe -bmv boot.hv ..mv boot.rgu ..if [ $? != 0 ]; then echo "ERROR: rgucomp failed. Make sure have installed .net CF 2.0 in wine" echo "Hint:" echo " wget http://kegel.com/wine/winetricks" echo " sh winetricks corefonts dotnet20 vcrun2005" echo exit 1fiecho "Creating packages.cab.pkg..."lcab -n * ../packages.cab.pkgcd ..mv packages.cab.pkg Packages/if [ $? != 0 ]; then echo "ERROR: Problem creating packages.cab.pkg" exit 1fi# here we need to regenerate the packages.sofecho "Generating packages.sof"sofbuild Packages/wine $TOOLS/rgucomp.exeecho "Updating registry files..."# update the registry fileswine $TOOLS/rgucomp.exe -nologo -o default.hv > ~/.lrk/reg/default.txtwine $TOOLS/rgucomp.exe -nologo -o boot.hv > ~/.lrk/reg/boot.txtwine $TOOLS/rgucomp.exe -nologo -o user.hv > ~/.lrk/reg/user.txtdos2unix ~/.lrk/reg/*dos2unix ~/.lrk/reg/*### we need to end up only with 1 "dump" folder in Tempecho "Generating dump folder..."mkdir dumpcd dumpcp -R $CURRENTDIR/ROM/XIP/* .for f in `/bin/ls "$CURRENTDIR/SYS/"` ; do cp -R $CURRENTDIR/SYS/${f}/* . #fix for Metadata/.hst if [ $f = "Metadata" ]; then cp $CURRENTDIR/SYS/${f}/.hst . fidone# specialmkdir .VMmkdir .ROMcp -R $CURRENTDIR/SYS/.VM/* .VM/cp -R $CURRENTDIR/SYS/.ROM/* .ROM/# same for custom packages, but folder names usually contain spaces...echo "Adding custom packages to dump folder..."LEN=`cat ~/.lrk/pkginst.txt |wc -l`if [ $LEN != 0 ]; then for f in `seq 1 $LEN`; do FOLDER=`cat ~/.lrk/pkginst.txt |head -n $f |tail -n 1` cp -R "$CURRENTDIR/Packages_Install/$FOLDER/"* . donefirm -rf default.hv packages.sof user.hvif [ $? != 0 ]; then echo "ERROR: Some problem occurred when creating the dump folder" exit 1fi# return to Tempcd ..cp boot.hv boot.rgu default.hv packages.sof user.hv dump/if [ $? != 0 ]; then echo "ERROR: Some problem occurred when creating the dump folder" exit 1fichmod 444 dump/default.hv dump/packages.sof dump/user.hv### createROMcd ..cd Tempcp "$CURRENTDIR/ROM/OS.nb" .if [ $? != 0 ]; then echo "ERROR: OS.nb not found in ROM" exit 1fiif [ $NBSPLITOPTS != "-athena" ]; then nbsplit $NBSPLITOPTS ./OS.nb |tee log.dump if [ $? != 0 ]; then echo "ERROR: NBSplit failed, check that nbplit options are correct in kitchen preferences" exit 1 fielse cp ./OS.nb ./OS.nb.payloadfiImgfsFromNb OS.nb.payload imgfs.bin >> log.dumpwine $TOOLS/ImgfsFromDump.exe imgfs.bin imgfs-new.bin >> log.dumpwine $TOOLS/ImgfsToNb.exe imgfs-new.bin os.nb.payload os-new.nb.payload >> log.dumpif [ $NBSPLITOPTS != "-athena" ]; then wine $TOOLS/NBMerge.exe $NBSPLITOPTS os-new.nb >> log.dumpelse cp ./os-new.nb.payload os-new.nbfiecho "Cleaning up..."mv os-new.nb "$CURRENTDIR/$1"if [ $? != 0 ]; then echo "ERROR: Can't create $1" exit 1ficd "$CURRENTDIR"rm -rf ~/.lrk/Temp/ 2>/dev/nullecho "$1 created successfully :)"echo "Done!"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -