Skip to content

Commit

Permalink
Added archlinux distro (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
jborean93 authored Sep 1, 2020
1 parent 37d7f2a commit 93fd19d
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ stages:
distribution: ubuntu16.04
Ubuntu18.04:
distribution: ubuntu18.04
Archlinux:
distribution: archlinux

steps:
- script: ./build.py $(distribution) --docker
Expand Down
24 changes: 24 additions & 0 deletions distribution_meta/archlinux.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
62 changes: 60 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand All @@ -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

Expand Down

0 comments on commit 93fd19d

Please sign in to comment.