|
| 1 | +package Slim::Utils::OS::pCP; |
| 2 | + |
| 3 | +# OS file for pCP https://www.picoreplayer.org |
| 4 | +# |
| 5 | +# Revision 1.1 |
| 6 | +# 2017-04-16 Removed /proc from a music path |
| 7 | +# |
| 8 | +# Revision 1.2 |
| 9 | +# 2017-08-14 Added Manual Plugin directory at Cache/Plugins |
| 10 | +# |
| 11 | +# Revision 2.0 |
| 12 | +# 2025-03-23 Packages now being built by Lyrion.org. Use default Cache/updates folder |
| 13 | + |
| 14 | +use strict; |
| 15 | +use warnings; |
| 16 | + |
| 17 | +use base qw(Slim::Utils::OS::Linux); |
| 18 | +use File::Spec::Functions qw(catdir); |
| 19 | + |
| 20 | +use constant MAX_LOGSIZE => 1024*1024*1; # maximum log size: 1 MB |
| 21 | +use constant UPDATE_DIR => '/tmp/slimupdate'; |
| 22 | + |
| 23 | +sub initDetails { |
| 24 | + my $class = shift; |
| 25 | + |
| 26 | + $class->{osDetails} = $class->SUPER::initDetails(); |
| 27 | + $class->{osDetails}->{osName} = 'piCore'; |
| 28 | + return $class->{osDetails}; |
| 29 | +} |
| 30 | + |
| 31 | +sub getSystemLanguage { 'EN' } |
| 32 | + |
| 33 | +sub localeDetails { |
| 34 | + my $lc_ctype = 'utf8'; |
| 35 | + my $lc_time = 'C'; |
| 36 | + |
| 37 | + return ($lc_ctype, $lc_time); |
| 38 | +} |
| 39 | + |
| 40 | +=head2 dirsFor( $dir ) |
| 41 | +
|
| 42 | +Return OS Specific directories. |
| 43 | +
|
| 44 | +Argument $dir is a string to indicate which of the server directories we |
| 45 | +need information for. |
| 46 | +
|
| 47 | +pCP Uses a update directory in /tmp and a custom manual plugin folder |
| 48 | +
|
| 49 | +=cut |
| 50 | + |
| 51 | +sub dirsFor { |
| 52 | + my ($class, $dir) = @_; |
| 53 | + |
| 54 | + my @dirs; |
| 55 | + |
| 56 | + if ($dir eq 'updates') { |
| 57 | + |
| 58 | + mkdir UPDATE_DIR unless -d UPDATE_DIR; |
| 59 | + @dirs = (UPDATE_DIR); |
| 60 | + } |
| 61 | + else { |
| 62 | + @dirs = $class->SUPER::dirsFor($dir); |
| 63 | + |
| 64 | + if ($dir eq "Plugins") { |
| 65 | + push @dirs, catdir( Slim::Utils::Prefs::preferences('server')->get('cachedir'), 'Plugins' ); |
| 66 | + unshift @INC, catdir( Slim::Utils::Prefs::preferences('server')->get('cachedir') ); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + return wantarray() ? @dirs : $dirs[0]; |
| 71 | +} |
| 72 | + |
| 73 | +sub canAutoUpdate { 1 } |
| 74 | +sub installerExtension { 'tcz' } |
| 75 | +sub installerOS { 'pcp' } |
| 76 | + |
| 77 | +sub getUpdateParams { |
| 78 | + my ($class, $url) = @_; |
| 79 | + |
| 80 | + if ($url) { |
| 81 | + require File::Slurp; |
| 82 | + |
| 83 | + my $updateFile = UPDATE_DIR . '/update_url'; |
| 84 | + File::Slurp::write_file($updateFile, $url); |
| 85 | + } |
| 86 | + |
| 87 | + return { |
| 88 | + cb => \&Slim::Utils::OS::Linux::signalUpdateReady |
| 89 | + }; |
| 90 | +} |
| 91 | + |
| 92 | +sub logRotate { |
| 93 | + # only keep small log files (1MB) because they are in RAM |
| 94 | + Slim::Utils::OS->logRotate($_[1], MAX_LOGSIZE); |
| 95 | +} |
| 96 | + |
| 97 | +sub ignoredItems { |
| 98 | + return ( |
| 99 | + 'bin' => '/', |
| 100 | + 'dev' => '/', |
| 101 | + 'etc' => '/', |
| 102 | + 'opt' => '/', |
| 103 | + 'init' => '/', |
| 104 | + 'root' => '/', |
| 105 | + 'sbin' => '/', |
| 106 | + 'tmp' => '/', |
| 107 | + 'var' => '/', |
| 108 | + 'lib' => '/', |
| 109 | + 'run' => '/', |
| 110 | + 'sys' => '/', |
| 111 | + 'usr' => '/', |
| 112 | + 'proc' => '/', |
| 113 | + 'lost+found'=> 1, |
| 114 | + ); |
| 115 | +} |
| 116 | + |
| 117 | +1; |
| 118 | + |
0 commit comments