summaryrefslogtreecommitdiffstats
path: root/.local/bin/install-port
diff options
context:
space:
mode:
authorjoe <rbo@gmx.us>2025-10-02 11:14:43 +0200
committerjoe <rbo@gmx.us>2025-10-02 11:14:43 +0200
commita190993b0579dfaacd5fe75a49fcb3214e2cb1bf (patch)
tree128708ae1ca9f6e5ab433e73542d7b52125357df /.local/bin/install-port
parentup (diff)
downloaddotfiles-bsd-a190993b0579dfaacd5fe75a49fcb3214e2cb1bf.tar.gz
dotfiles-bsd-a190993b0579dfaacd5fe75a49fcb3214e2cb1bf.tar.bz2
dotfiles-bsd-a190993b0579dfaacd5fe75a49fcb3214e2cb1bf.tar.xz
dotfiles-bsd-a190993b0579dfaacd5fe75a49fcb3214e2cb1bf.tar.zst
dotfiles-bsd-a190993b0579dfaacd5fe75a49fcb3214e2cb1bf.zip
up
Diffstat (limited to '.local/bin/install-port')
-rwxr-xr-x.local/bin/install-port169
1 files changed, 0 insertions, 169 deletions
diff --git a/.local/bin/install-port b/.local/bin/install-port
deleted file mode 100755
index 83ec07c..0000000
--- a/.local/bin/install-port
+++ /dev/null
@@ -1,169 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-use Term::ANSIColor;
-
-sub upgrdports {
- my $upgrd_nbr_cmd = "/usr/sbin/pkg version -l '<' | /usr/bin/wc -l | /usr/bin/awk '{print \$1}'";
- if (system(
- '/usr/local/bin/doas',
- '/usr/sbin/pkg',
- 'update'
- ) != 0) {
- exit;
- }
- if (system(
- '/usr/local/bin/doas',
- '/usr/sbin/portsnap',
- 'fetch',
- 'update'
- ) != 0) {
- exit;
- }
- print colored("\nPorts to be updated: ", 'bold');
- my $upgrd_nbr = `$upgrd_nbr_cmd`;
- chomp $upgrd_nbr;
- print colored($upgrd_nbr, 'bold green') . "\n";
- open(PS, "/usr/sbin/pkg version -l '<' |");
- while (<PS>) {
- print
- }
- close(PS);
- if ($upgrd_nbr == 0) {
- print colored("No ports to be updated.\n", 'bold green');
- exit;
- }
- print colored("\nUpgrade these ports? ", 'bold yellow')
- . colored('[', 'bold green')
- . colored('y', 'bold red')
- . colored('/N', 'bold green')
- . colored("]\n", 'bold green')
- . colored("~> ", 'yellow');
- my $answer = <STDIN>;
- chomp $answer;
- if ($answer ne "y" && $answer ne "Y") {
- print "Exiting...\n";
- exit;
- }
- system('/usr/local/bin/dash',
- '-c',
- '/usr/local/bin/notify-send "Initiating upgrade" "Ports upgrade has started\nTotal: ' . $upgrd_nbr . ' to be updated" >/dev/null 2>&1');
- if (system('/usr/local/bin/dash',
- '-c',
- '/usr/local/bin/doas /usr/local/sbin/portmaster -dya --no-confirm') == 0) {
- my $failed_nbr = `$upgrd_nbr_cmd`;
- chomp $failed_nbr;
- my $diff_nbr = $upgrd_nbr - $failed_nbr;
- system('/usr/local/bin/dash',
- '-c',
- '/usr/local/bin/notify-send "Upgrade complete!" "Ports upgrade installed successfully\nTotal: ' . $diff_nbr . ' installed" >/dev/null 2>&1');
- }
- else {
- my $failed_nbr = `$upgrd_nbr_cmd`;
- substr($failed_nbr, -1) = "";
- my $diff_nbr = $upgrd_nbr - $failed_nbr;
- system('/usr/local/bin/dash',
- '-c',
- '/usr/local/bin/notify-send -u critical -t 10000 "Upgrade failed!" "Some ports failed to compile\nTotal: ' . $diff_nbr . ' installed - ' . $failed_nbr . ' failed" >/dev/null 2>&1');
- }
- exit;
-}
-
-sub configport {
- my $port = $_[0];
- my $port_basename = $_[1];
- if (system(
- '/usr/local/bin/doas',
- '/usr/bin/make',
- 'config-recursive') == 0) {
- if (system(
- '/usr/local/bin/doas',
- '/usr/bin/make',
- 'config-recursive') == 0) {
- if (system(
- '/usr/local/bin/doas',
- '/usr/bin/make',
- 'config-recursive') == 0) {
- }
- system(
- '/usr/local/bin/notify-send',
- 'Configuration success!',
- 'Ports config - ' . $port . ' - configured successfully',
- );
- }
- }
- else {
- system(
- '/usr/local/bin/notify-send',
- '-u',
- 'critical',
- '-t',
- '10000',
- 'Configuration failure!',
- 'Ports config - ' . $port . ' - failed to configure'
- );
- }
-}
-
-sub installport {
- my $port = $_[0];
- my $port_basename = $_[1];
- if (system(
- '/usr/local/bin/doas',
- '/usr/bin/make',
- 'install',
- 'clean'
- ) == 0) {
- system(
- '/usr/local/bin/notify-send',
- 'Compilation success!',
- 'Ports - ' . $port . ' - installed successfully'
- );
- }
- else {
- system(
- '/usr/local/bin/notify-send',
- '-u',
- 'critical',
- '-t',
- '10000',
- 'Compilation failure!',
- 'Ports - ' . $port . ' - failed to install'
- );
- }
-}
-
-sub main {
- my $argc = $#ARGV + 1;
- if ($argc == 0) {
- print colored("Failed!\n", 'bold red')
- . "No port or argument specified\n";
- exit 1;
- }
- my $port = $ARGV[0];
- if ($ARGV[0] eq "upgrade") {
- upgrdports();
- }
- elsif (-d "/usr/ports/" . $port) {
- my $port_basename = `echo $ARGV[0] | awk -F '/' '{print \$2}'`;
- print colored("Port ", 'bold')
- . colored($port, 'bold green')
- . colored(" found\n", 'bold');
- chdir "/usr/ports/" . $port;
- configport($port, $port_basename);
- installport($port, $port_basename);
- }
- else {
- print colored("Failed!\n", 'bold red')
- . "Port "
- . colored($port, 'bold yellow')
- . " doesn't exist in "
- . colored("/usr/ports/\n", 'bold');
- }
- exit;
-}
-
-main();
-
-__END__