PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

install-powershell.sh doesn't work on azure-linux

Open dpoole73 opened this issue 1 year ago • 11 comments

Prerequisites

Steps to reproduce

I deployed a virtual machine in azure specifying:

publisher: MicrosoftCBLMariner offer: azure-linx sku: azure-linux-gen2

when I ran the install script, it failed saying it was an unsupported os:

Sorry, your operating system is based on and is not supported by PowerShell or this installer at this time

Expected behavior

pwsh is installed

Actual behavior

pswh installation fails with error:

Sorry, your operating system is based on  and is not supported by PowerShell or this installer at this time

Error details

Sorry, your operating system is based on  and is not supported by PowerShell or this installer at this time

Environment data

N/A

Visuals

No response

dpoole73 avatar Jun 13 '24 00:06 dpoole73

https://gitee.com/chuanjiao10/kasini3000_agent_linux#microsoft-azurelinux-20-kernel515

kasini3000 avatar Jun 13 '24 12:06 kasini3000

Hey, Can you please run the code like this in the azure linux console and let me know the output?

OS=$(lowercase "$(uname)") echo ${OS}

bosesubham2011 avatar Jun 13 '24 13:06 bosesubham2011

My best guess is the above statement doesn't work in Azure linux. Maybe it misses lowercase command and it is failing at that level. I will put a PR, if you can confirm me the output of ${OS}

bosesubham2011 avatar Jun 13 '24 13:06 bosesubham2011

yes it seems the base image is missing lowercase:

adminUsername@vm [ ~ ]$ OS=$(lowercase "$(uname)")
-bash: lowercase: command not found
adminUsername@vm [ ~ ]$ echo ${OS}

FYI

uname returns Linux

cat /etc/os-release returns

NAME="Microsoft Azure Linux"
VERSION="3.0.20240524"
ID=azurelinux
VERSION_ID="3.0"
PRETTY_NAME="Microsoft Azure Linux 3.0"
ANSI_COLOR="1;34"
HOME_URL="https://aka.ms/azurelinux"
BUG_REPORT_URL="https://aka.ms/azurelinux"
SUPPORT_URL="https://aka.ms/azurelinux"

I just tried an experiment to see if it had been there whether it would have worked. I created a script called lowercase with the following contents:

#!/bin/bash
echo $1 | tr 'A-Z' 'a-z'

and put it in /bin

now the command returns

root@vm [ / ]# OS=$(lowercase "$(uname)")
root@vm [ / ]# echo $OS
linux

but... install_powershell.sh still doesn't work.

I modified it and added set -x here is the output:

+ install
+ local VERSION=1.2.0
+ local gitreposubpath=PowerShell/PowerShell/master
+ local gitreposcriptroot=https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools
+ local gitscriptname=install-powershell.psh
+ echo 'Get-PowerShell MASTER Installer Version 1.2.0'
Get-PowerShell MASTER Installer Version 1.2.0
+ echo 'Installs PowerShell and Optional The Development Environment'
Installs PowerShell and Optional The Development Environment
+ echo '  Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh'
  Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh
+ echo 'Arguments used: '
Arguments used: 
+ echo ''

+ trap '
    trap - INT # restore default INT handler
    echo "Interrupted"
    kill -s INT "$$"
    ' INT
+ local OS
+++ uname
++ lowercase Linux
++ echo Linux
++ tr '[:upper:]' '[:lower:]'
+ OS=linux
+ local KERNEL
++ uname -r
+ KERNEL=6.6.29.1-3.azl3
+ local MACH
++ uname -m
+ MACH=x86_64
+ local DIST
+ local DistroBasedOn
+ local PSUEDONAME
+ local REV
+ '[' linux == windowsnt ']'
+ '[' linux == darwin ']'
+++ readlink -f ./i.sh
++ dirname /var/lib/waagent/custom-script/download/0/i.sh
+ SCRIPTFOLDER=/var/lib/waagent/custom-script/download/0
++ uname
+ install
+ local VERSION=1.2.0
+ local gitreposubpath=PowerShell/PowerShell/master
+ local gitreposcriptroot=https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools
+ local gitscriptname=install-powershell.psh
+ echo 'Get-PowerShell MASTER Installer Version 1.2.0'
Get-PowerShell MASTER Installer Version 1.2.0
+ echo 'Installs PowerShell and Optional The Development Environment'
Installs PowerShell and Optional The Development Environment
+ echo '  Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh'
  Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh
+ echo 'Arguments used: '
Arguments used: 
+ echo ''

+ trap '
    trap - INT # restore default INT handler
    echo "Interrupted"
    kill -s INT "$$"
    ' INT
+ local OS
+++ uname
++ lowercase Linux
++ echo Linux
++ tr '[:upper:]' '[:lower:]'
+ OS=linux
+ local KERNEL
++ uname -r
+ KERNEL=6.6.29.1-3.azl3
+ local MACH
++ uname -m
+ MACH=x86_64
+ local DIST
+ local DistroBasedOn
+ local PSUEDONAME
+ local REV
+ '[' linux == windowsnt ']'
+ '[' linux == darwin ']'
+++ readlink -f ./i.sh
++ dirname /var/lib/waagent/custom-script/download/0/i.sh
+ SCRIPTFOLDER=/var/lib/waagent/custom-script/download/0
++ uname
+ OS=Linux
++ lsb_release --id
++ sed -E 's/^.*:[[:space:]]*//'
+ DISTRIBUTOR_ID=
+ '[' Linux == SunOS ']'
+ '[' Linux == AIX ']'
+ '[' Linux == Linux ']'
+ '[' -f /etc/redhat-release ']'
+ '[' -f /etc/system-release ']'
+ '[' -f /etc/mariner-release ']'
+ '[' -f /etc/mandrake-release ']'
+ '[' -f /etc/debian_version ']'
+ '[' '' = Gentoo ']'
+ '[' -f /etc/UnitedLinux-release ']'
++ source /etc/os-release
+++ NAME='Microsoft Azure Linux'
+++ VERSION=3.0.20240524
+++ ID=azurelinux
+++ VERSION_ID=3.0
+++ PRETTY_NAME='Microsoft Azure Linux 3.0'
+++ ANSI_COLOR='1;34'
+++ HOME_URL=https://aka.ms/azurelinux
+++ BUG_REPORT_URL=https://aka.ms/azurelinux
+++ SUPPORT_URL=https://aka.ms/azurelinux
++ echo Microsoft Azure Linux 3.0
+ osname='Microsoft Azure Linux 3.0'
+ [[ Microsoft Azure Linux 3.0 = *SUSE* ]]
++ lowercase Linux
++ echo Linux
++ tr '[:upper:]' '[:lower:]'
+ OS=linux
++ lowercase
++ echo ''
++ tr '[:upper:]' '[:lower:]'
+ DistroBasedOn=
+ echo 'Operating System Details:'
Operating System Details:
+ echo '  OS: linux'
  OS: linux
+ echo '  DIST: '
  DIST: 
+ echo '  DistroBasedOn: '
  DistroBasedOn: 
+ echo '  PSUEDONAME: '
  PSUEDONAME: 
+ echo '  REV: '
  REV: 
+ echo '  KERNEL: 6.6.29.1-3.azl3'
  KERNEL: 6.6.29.1-3.azl3
+ echo '  MACH: x86_64'
  MACH: x86_64
+ echo '  OSSTR: '
  OSSTR: 
+ case "$DistroBasedOn" in
+ echo 'Sorry, your operating system is based on  and is not supported by PowerShell or this installer at this time.'
Sorry, your operating system is based on  and is not supported by PowerShell or this installer at this time.
+ exit 1

it seems to behave the same way with or without lowercase command so that may not be the issue

dpoole73 avatar Jun 13 '24 16:06 dpoole73

i think the script will need to be updated to check for /etc/azurelinux-release

dpoole73 avatar Jun 13 '24 18:06 dpoole73

Let me see, thanks for your findings.

bosesubham2011 avatar Jun 14 '24 06:06 bosesubham2011

Yes, it is certain that there is no support for Microsoft Azure Linux.

bosesubham2011 avatar Jun 14 '24 13:06 bosesubham2011

I might be completely off, but this was a quick and easy solution to try and implement.

https://github.com/PowerShell/PowerShell/pull/23955

This is a PR that I have raised to fix the issue. Please let me know your thoughts on this.

bosesubham2011 avatar Jun 14 '24 13:06 bosesubham2011

I tested with your changes and it didn't work, here is the error:

Get-PowerShell MASTER Installer Version 1.2.0
Installs PowerShell and Optional The Development Environment
  Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.psh
Arguments used:

Operating System Details:
  OS: linux
  DIST:
  DistroBasedOn: mariner
  PSUEDONAME: Azure Linux 3.0
AZURELINUX_BUILD_NUMBER=3.0.20240524
  REV: Azure
AZURELINUX_BUILD_NUMBER=3.0.20240524
  KERNEL: 6.6.29.1-3.azl3
  MACH: x86_64
  OSSTR:
Configuring PowerShell Environment for: mariner  Azure
AZURELINUX_BUILD_NUMBER=3.0.20240524
Could not find "installpsh-mariner.sh" next to this script...
Pulling and executing it from "https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/installpsh-mariner.sh"
found and using curl

*** PowerShell Development Environment Installer 1.2.0 for mariner
***    Original script is at: https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/installpsh-mariner.sh

*** Arguments used:

*** This installer is only for mariner and you are running , please run "https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools\install-powershell.sh" to see if your distro is supported AND to auto-select the appropriate installer if it is.

dpoole73 avatar Jun 17 '24 20:06 dpoole73

I deployed a virtual machine in azure specifying:

publisher: MicrosoftCBLMariner offer: azure-linx sku: azure-linux-gen2

@dpoole73 Can you share the details steps to create an Azure VM with the azure-linux image? I cannot find the image when creating a VM in Auzre Portal. The https://github.com/microsoft/azurelinux says the azurelinux is an internal Linux distribution for Microsoft’s cloud infrastructure and services. If so, the image won't be public, right?

GitHub
Linux OS for Azure 1P services and edge appliances - microsoft/azurelinux

daxian-dbw avatar Jun 17 '24 20:06 daxian-dbw

oh I didn't realize it was an internal image. I am using an internal microsoft subscription so likely it shows up for me but not for you. I'm trying to install powershell on it so that I can validate the image for testing. I guess mariner got rebranded to azure-linux so I'm guessing this is just the latest image and will be available going forward?

dpoole73 avatar Jun 17 '24 21:06 dpoole73

📣 Hey @dpoole73, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback