diff --git a/CHANGELOG.md b/CHANGELOG.md index 979a3de2e..10fd7f534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,9 @@ This is the changelog for this fork of OMI. It documents the changes in each of the tagged releases -## 1.0.2 - TBD +## 1.1.0 - TBD + ++ Added Archlinux as a known distribution ## 1.0.1 - 2020-08-20 diff --git a/README.md b/README.md index 37de6b959..000afd5c6 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ There are some other arguments you can supply to alter the behaviour of the buil The aim is to support the same distributions that PowerShell supports but so far the build tool only supports a limited number of distributions. The distributions that are currently setup in the `build.py` script are: ++ [archlinux.json](distribution_meta/archlinux.json) + [centos7.json](distribution_meta/centos7.json) + [centos8.json](distribution_meta/centos8.json) + [debian8.json](distribution_meta/debian8.json) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b43e9aad7..1bc9e1c26 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,6 +34,8 @@ stages: distribution: ubuntu16.04 Ubuntu18.04: distribution: ubuntu18.04 + Archlinux: + distribution: archlinux steps: - script: ./build.py $(distribution) --docker diff --git a/distribution_meta/archlinux.json b/distribution_meta/archlinux.json new file mode 100644 index 000000000..ed1a43128 --- /dev/null +++ b/distribution_meta/archlinux.json @@ -0,0 +1,24 @@ +{ + "container_image": "archlinux:latest", + "package_manager": "pacman", + "microsoft_repo": "", + "build_deps": [ + "gcc", + "inetutils", + "krb5", + "lsb-release", + "make", + "openssl", + "pkgconf", + "which" + ], + "test_deps": [ + "aur:gss-ntlmssp", + "aur:powershell-bin", + "docbook-xsl", + "doxygen", + "krb5", + "libwbclient", + "which" + ] +} diff --git a/utils.py b/utils.py index c4ec967fa..5d5c26216 100644 --- a/utils.py +++ b/utils.py @@ -47,9 +47,10 @@ def build_package_command(package_manager, packages): # type: (str, List[str]) """ Generates a command to install packages for a specific package manager. """ package_boilerplate = { 'apt': 'apt-get -q update\nDEBIAN_FRONTEND=noninteractive apt-get -q install -y', + 'dnf': 'dnf install -y -q', 'brew': 'brew install', + 'pacman': 'pacman -Sy --noconfirm --overwrite \'*\'', 'yum': 'yum install -y -q', - 'dnf': 'dnf install -y -q', } if package_manager not in package_boilerplate: @@ -67,10 +68,64 @@ def build_package_command(package_manager, packages): # type: (str, List[str]) else: brew_packages.append(package) - package_command = build_multiline_command(package_boilerplate[package_manager], packages) + package_command = build_multiline_command(package_boilerplate[package_manager], brew_packages) if cask_packages: package_command += '\n\n' + build_multiline_command('brew cask install', cask_packages) + elif package_manager == 'pacman': + pacman_packages = set() + aur_packages = set() + + for package in packages: + if package.startswith('aur:'): + # Installing an AUR package requires some extra binaries + pacman_packages.update({'base-devel', 'git', 'sudo'}) + aur_packages.add(package[4:]) + + else: + pacman_packages.add(package) + + package_command = build_multiline_command(package_boilerplate[package_manager], pacman_packages) + + # gss-ntlmssp in AUR doesn't seem to work, just build it ourselves for now + if 'gss-ntlmssp' in aur_packages: + aur_packages.remove('gss-ntlmssp') + package_command += '\n' + ''' +git clone https://github.com/gssapi/gss-ntlmssp.git /tmp/gss-ntlmssp +pushd /tmp/gss-ntlmssp +autoreconf -f -i +./configure +make && make install +popd +rm -rf /tmp/gss-ntlmssp + +mkdir -p /etc/gss/mech.d +echo "gssntlmssp_v1 1.3.6.1.4.1.311.2.2.10 /usr/local/lib/gssntlmssp/gssntlmssp.so" > /etc/gss/mech.d/ntlm.conf''' + + if aur_packages: + # We cannot run makpkg as root so we need to create another user + package_command += '\n' + ''' +AUR_USER=aur_user + +echo "Creating aur user for running makepg" +useradd -m "${AUR_USER}" +echo "${AUR_USER}:" | chpasswd -e +echo "${AUR_USER} ALL = NOPASSWD: ALL" >> /etc/sudoers + +AUR_PACKAGES=('%s') +for PACKAGE in "${AUR_PACKAGES[@]}"; do + echo "Installing ${PACKAGE} from AUR" + + PACKAGE_DIR="/tmp/${PACKAGE}" + git clone "https://aur.archlinux.org/${PACKAGE}.git" "${PACKAGE_DIR}" + chmod 777 "${PACKAGE_DIR}" + + pushd "${PACKAGE_DIR}" + su "${AUR_USER}" -c 'makepkg --install --noconfirm --syncdeps' + popd + rm -rf "${PACKAGE_DIR}" +done''' % "' '".join(aur_packages) + else: package_command = build_multiline_command(package_boilerplate[package_manager], packages) @@ -90,6 +145,9 @@ def build_package_repo_command(package_manager, repository): # type: (str, str) elif package_manager == 'brew': return 'echo "Not applicable on macOS"' + elif package_manager == 'pacman': + return 'echo "Not applicable on Archlinux"' + elif package_manager in ['yum', 'dnf']: return 'curl -s %s | tee /etc/yum.repos.d/microsoft.repo' % repository