/usr/bin/ubuntustudio-installer is in ubuntustudio-installer 0.01.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #!/usr/bin/perl -w
# A script for taking package names on the command line, checking if they
# are available, and displaying a list from which the user can select which
# package(s) to install.
#
# this installer is intended to be used from an xdg desktop file so that
# the packages on the command line can match the menu where the
# desktop file is displayed.
# lets set some variables here so they are easy to find:
# Start of our command to run package selection window
$zen = 'zenity --title="Ubuntu Studio - software installer" --width=650 --height=400 --list --text="Select the metas to install" --separator=" " --print-column=2 --checklist --column="select" --column="package" --column="description" ';
# how many arguments?
$numpkgs = @ARGV;
# count var for packages actually found
$pksfnd = 0;
# print usage if no arguements
if ($numpkgs == 0) {
print STDERR "USAGE:\n ubuntustudio-installer <packagename> [<packagename>] ... \n";
exit 1;
}
# get a string with list of packages
for ($count = 0; $count < $numpkgs; $count++) {
# check if exists while getting description
$cachecmd = "apt-cache search -n $ARGV[$count] |";
open(FHCACHE, $cachecmd);
while (<FHCACHE>) {
@ln = split;
$p = shift @ln;
if ($p eq $ARGV[$count]) {
#get rid of -
shift @ln;
++$pksfnd;
#make description back into string
$d = join(" ",@ln);
#add a line onto zenity command line
$zen = "$zen false $p \"$d\"";
}
}
close (FHCACHE);
}
# if none of the listed packages exist get out
if ($pksfnd == 0) {
print STDERR "None of the packages appear to be the repos you are connected to\n";
exec( "zenity --warning --text=\"packages not in repositories.\"");
}
# show the selection dialog and collect users selected packages
$SIG{PIPE} = "IGNORE";
open(FHSEL, "$zen|") || die "can't fork: $!";
$selpkgs = <FHSEL>;
close(FHSEL) || die "Transaction Canceled (status=$?)";
#run the install as system with progress bar in terminal and exit
if ($selpkgs) {
# initialize current percent to 0
$pctcur = 0;
# run apt-get install -y open stdout as file handle
$aptcmd = "pkexec apt-get install -y $selpkgs |";
open(FHAPTG, $aptcmd) || die "Unable to run apt-get";
# run zenity --progress pipe we print to it's stdin
# zenity progree starts at 0%, initial text = "Installing"
$zenprogcmd = " |zenity --progress --width=650 --no-cancel --title=\"UbuntuStudio Installer\" --text=\"Installing\" --percentage=0";
open(FHZENPROG, $zenprogcmd) || die "Failed to start zenity.";
# turn off buffering for FHZENPROG
select (FHZENPROG);
$| = 1;
select (STDOUT);
# run loop for each line from aptget
while (<FHAPTG>) {
@ln = split;
@ln = (@ln, ".");
# start if else stuff
# look for no. upgraded, no. newly installed
if ($ln[1] eq "upgraded,") {
$pkttl = $ln[0] + $ln[2];
# step value is how many percent to add for each step
if ($pkttl == 0) {
$stepval = 0;
}else{
$stepval = 100 / ( $pkttl * 3 + 1);
}
print FHZENPROG "# $pkttl Packages to install. \n";
sleep (1);
# For each get:
}elsif ($ln[0] =~ /^Get/) {
$pctcur = $pctcur + $stepval;
print FHZENPROG "$pctcur\n";
print FHZENPROG "# Downloading $ln[3] \n";
# For each Unpacking line:
}elsif ($ln[0] =~ /^Unpackin/) {
$pctcur = $pctcur + $stepval;
print FHZENPROG "$pctcur\n";
if ($ln[1] eq "replacement") {
print FHZENPROG "# $ln[0] $ln[1] $ln[2] \n";
}else{
print FHZENPROG "# $ln[0] $ln[1] \n";
}
# For each Setting up line:
}elsif ($ln[0] =~ /^Setting/) {
$pctcur = $pctcur + $stepval;
print FHZENPROG "$pctcur\n";
print FHZENPROG "# @ln \n";
}
}
# apt-get has finished when we get here so close it's file handle
close (FHAPTG);
print FHZENPROG "# Installation complete. \n";
print FHZENPROG "100\n";
# close file handle so that OK is the only live button.
close (FHZENPROG);
}else{
exec( "zenity --warning --text=\"no package chosen\"");
}
|