diff options
| author | Sergio <sergiotarxz@posteo.net> | 2026-09-20 22:14:23 +0200 |
|---|---|---|
| committer | Sergio <sergiotarxz@posteo.net> | 2026-09-20 22:14:23 +0200 |
| commit | db0840dad435dfe38cffc14c87138e24aeac036b (patch) | |
| tree | 84295ce27738c5f7873401dbd797a5bb599e4ac2 | |
| parent | 74560c4d7e121888bdf7970a3cde09c1bb23c4e1 (diff) | |
Supporting custom preference of the update channel..v1.0.0-rc11
| -rw-r--r-- | lib/AlgaOS/Updater/GUI.pm | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/AlgaOS/Updater/GUI.pm b/lib/AlgaOS/Updater/GUI.pm index aa943e5..d65d239 100644 --- a/lib/AlgaOS/Updater/GUI.pm +++ b/lib/AlgaOS/Updater/GUI.pm @@ -36,6 +36,7 @@ has _have_update => ( is => 'rw' ); has _is_updating => ( is => 'rw' ); has _machine_id => ( is => 'lazy' ); has _tmp_dir => ( is => 'lazy' ); +has _channel_preference => ( is => 'lazy' ); sub _build__machine_id { open my $fh, '<', '/etc/machine-id'; @@ -45,6 +46,20 @@ sub _build__machine_id { return $return; } +sub _build__channel_preference($self) { + open my $fh, '<', '/etc/algaos-channel'; + local $/ = undef; + my $return = <$fh>; + $return =~ s/\s+//g; + if ( !grep { $return eq $_ } (qw/latest next stable/) ) { + $self->notify( +'El actualizador de AlgaOS encontró un valor inesperado en /etc/algaos-channel y sufrió un error, los valores validos son latest y next.' + ); + die "No channel $return."; + } + return $return; +} + sub _build__tmp_dir { my $tmp_dir = '/tmp/algaos-updater/'; system qw{sudo rm -rf}, $tmp_dir; @@ -53,11 +68,15 @@ sub _build__tmp_dir { } sub sync_repo($self) { + my $webrsync_options = + defined $self->_channel_preference + ? "?preference=" . $self->_channel_preference + : ""; my $file = $self->_tmp_dir . "/webrsync.tar.bz2"; system qw{sudo rm -rf /var/db/repos/algaos/}; system qw{sudo mkdir -pv /var/db/repos/algaos/}; system qw{sudo curl -L -o}, $file, - "https://algaos.com/dist/" . $self->_machine_id . "/webrsync.tar.bz2"; + "https://algaos.com/dist/" . $self->_machine_id . "/webrsync.tar.bz2$webrsync_options"; system qw{sudo tar -C /var/db/repos/algaos/ -xvpf}, $file; } @@ -145,11 +164,15 @@ sub is_there_updates($self) { qw{sudo tee /etc/portage/binrepos.conf/algaos.conf} or die "open: $!"; + my $binpkg_options = + defined $self->_channel_preference + ? "?preference=" . $self->_channel_preference + : ""; say $bin_fh <<"EOF"; [algaos] -location = https://algaos.com/dist/@{[$self->_machine_id]}/binpkg -sync-uri = https://algaos.com/dist/@{[$self->_machine_id]}/binpkg +location = https://algaos.com/dist/@{[$self->_machine_id]}/binpkg$binpkg_options +sync-uri = https://algaos.com/dist/@{[$self->_machine_id]}/binpkg$binpkg_options priority = 1 verify-signature = false EOF |
