Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #
- # Sony CONFIDENTIAL
- #
- # Copyright 2006 Sony Corporation.
- #
- # DO NOT COPY AND/OR REDISTRIBUTE WITHOUT PERMISSION.
- #
- # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- # SUCH DAMAGE.
- #
- # do nothing if DisSW says "ignore SYSCON"
- `grep -q 0 /proc/ps3tool_gpio/SC_MODEX`;
- if ($? != 0) {
- exit 0;
- }
- if ($#ARGV < 1) {
- print "usage: $0 updatefile version\n";
- exit 1;
- }
- $updatefile = shift @ARGV;
- $new_version = shift @ARGV;
- $current_version = `/usr/local/sony/bin/scver`;
- $result = $?/256;
- if ($result == 0) {
- # erase last "\n"
- $current_version =~ s/\n$//;
- $result = &is_maskrom($current_version);
- if ($result != 0) {
- exit 0;
- }
- $result = &parse_version($current_version,
- \$current_major,\$current_middle,\$current_minor,\$current_release);
- if ($result != 0) {
- $result += 100;
- exit $result;
- }
- $result = &parse_version($new_version,
- \$new_major,\$new_middle,\$new_minor,\$new_release);
- if ($result != 0) {
- $result += 200;
- exit $result;
- }
- if ($current_major > $new_major) {
- #exit 0;
- }
- elsif ($current_major == $new_major) {
- if ($current_middle > $new_middle) {
- #exit 0;
- }
- elsif ($current_middle == $new_middle) {
- if ($current_minor > $new_minor) {
- #exit 0;
- }
- elsif ($current_minor == $new_minor) {
- if ($current_release > $new_release) {
- #exit 0;
- }
- elsif ($current_release == $new_release) {
- if ($current_version eq $new_version) {
- #exit 0;
- }
- }
- }
- }
- }
- print "Updating syscon: $current_version => $new_version...";
- }
- else {
- print "Updating syscon to $new_version...";
- }
- `/usr/local/sony/bin/scfirmup $updatefile`;
- $result = $?/256;
- if ($result == 0) {
- print " done.\n";
- }
- else {
- print " failed. ($result)\n";
- }
- exit $result;
- sub cut_directory
- {
- my($pathname) = $_[0];
- my($index);
- $index = rindex($pathname, '/');
- if ($index < 0) {
- return $pathname;
- }
- else {
- return substr($pathname, $index + 1, length($pathname) - $index - 1);
- }
- }
- sub is_maskrom
- {
- my($version) = $_[0];
- if ($version =~ /^.*_d.*$/) {
- return 1;
- }
- return 0;
- }
- sub parse_version
- {
- my($version) = $_[0];
- my($major) = $_[1];
- my($middle) = $_[2];
- my($minor) = $_[3];
- my($release) = $_[4];
- my($index);
- # erase directory parts
- # $version = &cut_directory($version);
- # convert all non-digit characters => '_'
- $version =~ tr/0-9/_/c;
- # erase top underscores
- $version =~ s/^[_]*//;
- # extract top number as a major version
- $index = index($version, '_');
- if ($index < 0) {
- return 1;
- }
- $$major = substr($version, 0, $index);
- # erase top number, underscores
- $version =~ s/^[0-9]*[_]*//;
- # extract top number as a middle version
- $index = index($version, '_');
- if ($index < 0) {
- return 2;
- }
- $$middle = substr($version, 0, $index);
- # erase top number, underscores
- $version =~ s/^[0-9]*[_]*//;
- # extract top number as a minor version
- $index = index($version, '_');
- if ($index < 0) {
- return 3;
- }
- $$minor = substr($version, 0, $index);
- # erase top number, underscores
- $version =~ s/^[0-9]*[_]*//;
- # extract top number as a release version
- $index = index($version, '_');
- if ($index < 0) {
- $$release = $version;
- }
- else {
- $$release = substr($version, 0, $index);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement