Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for opensuse #3298

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions host-bin/enter-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -676,11 +676,18 @@ if [ "$NOLOGIN" != 1 ] && grep -q '^root:' "$passwd" 2>/dev/null; then
fi

# Launch systemd-logind if available and not already running
# Whitelisted for saucy and trusty
# Whitelisted for saucy, trusty and tumbleweed
systemd_dir="`fixabslinks '/run/systemd'`"
if [ -x "$CHROOT/lib/systemd/systemd-logind" ] && \
systemd_logind="/lib/systemd/systemd-logind"
# openSUSE has a different systemd folder
if [ "$CHROOTRELEASE" = 'tumbleweed' ]; then
systemd_logind="/usr/lib/systemd/systemd-logind"
fi

if [ -x "$CHROOT$systemd_logind" ] && \
[ ! -d "$systemd_dir" ] && \
[ "$CHROOTRELEASE" = 'saucy' -o "$CHROOTRELEASE" = 'trusty' ]; then
[ "$CHROOTRELEASE" = 'saucy' -o "$CHROOTRELEASE" = 'trusty' \
-o "$CHROOTRELEASE" = 'tumbleweed' ]; then
# Every piece of systemd code ever assumes that this directory exists
mkdir -p "$systemd_dir"

Expand All @@ -691,7 +698,7 @@ if [ "$NOLOGIN" != 1 ] && grep -q '^root:' "$passwd" 2>/dev/null; then
"$CHROOT/sys/fs/cgroup/systemd"
fi
# systemd-logind doesn't fork
chrootcmd "/lib/systemd/systemd-logind >/dev/null 2>&1 </dev/null &"
chrootcmd "${systemd_logind} >/dev/null 2>&1 </dev/null &"
fi

chrootcmd "/usr/local/bin/croutonfindnacld >/dev/null 2>&1 </dev/null &"
Expand Down
46 changes: 46 additions & 0 deletions installer/opensuse/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh -e
# Copyright (c) 2016 The crouton Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This is a distro-specific bootstrap script, sourced from main.sh, and as such
# has access to all of the variables set by main.sh, namely $tmp (the temporary
# directory), $INSTALLERDIR/$DISTRO, $RELEASE, $BOOTSTRAP_RELEASE (if different
# from $RELEASE), $ARCH, and $MIRROR.

# Tumbleweed
url_tumbleweed_armv7hl="http://download.opensuse.org/ports/armv7hl/tumbleweed/images/openSUSE-Tumbleweed-ARM-JeOS.armv7hl-rootfs.armv7l-Current.tbz"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did you decide on these URLs? The sizes are dramatically different (the X11 ones are 800 megs!). There're also distribution/openSUSE-current/appliances/ and distribution/openSUSE-stable/appliances/ directories with similar images.

There are unversioned entries in the leap subdirectory. Are those always updated? Are we going to have to keep updating the tarball in this file if we specify a version?

And what happens on i386/x86_64?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JeOS images are minimal images (Just Enough Operating System). For armv7hl no plain JeOS image exists. I'm investigating this. Maybe we can just delete the armv7hl support for Leap42.2 and add it in a later patch.

Leap images don't get updated, they get released and that's it. The unversioned images are links to the versioned ones. I'll update the links, as the version is of no use.

We should try to add a automatic resolution of architecutre + os-version -> download link, but I would prefer to leave this for a latter patch, e.g. when adding Leap-42.3 support. TBH I'm not too confident that this will work out, as the folder structure of the download server might change for newer releases.

i386/x86_64 images don't exists at this point in time, only the installer ISO is created.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so as we can't support i386 right now, I will delete the architecutre from installer/opensuse/defaults as well.

Copy link
Author

@mbgg mbgg Aug 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, armv7hl JeOS image got created now, I will fix the URL.

url_tumbleweed_aarch64="http://download.opensuse.org/ports/aarch64/tumbleweed/images/openSUSE-Tumbleweed-ARM-JeOS.aarch64-rootfs.aarch64-Current.tbz"

# Leap
url_leap_42_2_armv7hl="http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/appliances/openSUSE-Leap42.2-ARM-JeOS.armv7-rootfs.armv7l.tbz"
url_leap_42_2_aarch64="http://download.opensuse.org/ports/aarch64/distribution/leap/42.2/appliances/openSUSE-Leap42.2-ARM-JeOS.aarch64-rootfs.aarch64.tbz"
url_leap_42_3_aarch64="http://download.opensuse.org/ports/aarch64/distribution/leap/42.3/appliances/openSUSE-Leap42.3-ARM-JeOS.aarch64-rootfs.aarch64.tbz"

BOOTSTRAP_ARCH="$ARCH"
BOOTSTRAP_RELEASE="$RELEASE"

# Rename factory to tumbleweed
if [ "$RELEASE" = "factory" ]; then
BOOTSTRAP_RELEASE=tumbleweed
elif [ "${RELEASE#leap}" != "$RELEASE" ]; then
BOOTSTRAP_RELEASE=$(echo "$RELEASE" | tr - _ | tr . _)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quoting (and line below)

echo $BOOTSTRAP_RELEASE
fi

# fix up the good old toolchain/kernel naming conflict
if [ "$ARCH" = "arm64" ]; then
BOOTSTRAP_ARCH=aarch64
fi

eval "URL=\"\${url_${BOOTSTRAP_RELEASE}_${BOOTSTRAP_ARCH}-}\""

if [ -z "$URL" ]; then
echo "Unknown Distribution / Architecture: $BOOTSTRAP_RELEASE $BOOTSTRAP_ARCH" >&2
exit 1
fi

mkdir -p "$tmp/$subdir"
curl -# -L --connect-timeout 60 --retry 2 "$URL" | tar -jx -C "$tmp/$subdir"

rm -rf "$tmp/$subdir/dev/"*
18 changes: 18 additions & 0 deletions installer/opensuse/defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh -e
# Copyright (c) 2016 The crouton Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This file is sourced from main.sh to update distro-specific defaults.
# It must set at least ARCH and MIRROR if not already specified.

if [ -z "$ARCH" ]; then
ARCH="$(uname -m)"
fi

case "$ARCH" in
arm64 | aarch64) ARCH="arm64";;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be above the arm* line, otherwise arm64 won't be matched properly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

arm*) ARCH="armv7hl";;
*) error 2 "Invalid architecture '$ARCH'.";;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait what happened to the x86 architectures

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dropped it for now, as there does no JeOS image exist, but just a installer image. That's something for the future. Creating an x86 image in the open build service and use it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely need x86 support before we can merge; this would confuse most of our users

esac

50 changes: 50 additions & 0 deletions installer/opensuse/getrelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh -e
# Copyright (c) 2017 The crouton authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

USAGE="${0##*/} -a|-r /path/to/chroot

Detects the release (-r) or arch (-a) of the chroot and prints it on stdout.
Fails with an error code of 1 if the chroot does not belong to this distro."

if [ "$#" != 2 ] || [ "$1" != '-a' -a "$1" != '-r' ]; then
echo "$USAGE" 1>&2
exit 2
fi

sources="${2%/}/etc/os-release"
if [ ! -s "$sources" ]; then
exit 1
fi

# Create release name from /etc/os-release file
# sed specialist can make that more elegant...
rel="$(grep CPE_NAME "$sources" | cut -d ":" -f 4)"
if [ "$rel" = "opensuse" -o "$rel" = "tumbleweed" ]; then
rel=tumbleweed
elif [ "$rel" = "leap" ]; then
ver="$(grep CPE_NAME "$sources" | cut -d ":" -f 5)"
rel="$rel-${ver%\"}"
else
exit 1
fi

# Print the architecture if requested
# Why use sed if you know cut...
sources="${2%/}/etc/products.d/openSUSE.prod"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fail if this doesn't exist?

if [ ! -s "$sources" ]; then
exit 1
fi

if [ "$1" = '-a' ]; then
arch="$(grep "<arch>" "$sources" | cut -d '>' -f 2 | cut -d '<' -f 1)"
if [ "$arch" = "aarch64" ]; then
arch="arm64"
fi
echo "$arch"
else
echo "$rel"
fi

exit 0
130 changes: 130 additions & 0 deletions installer/opensuse/prepare
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/sh -e
# Copyright (c) 2016 The crouton Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This is a distro-specific continuation of the prepare.sh script.

PKGEXT='rpm'
DISTROAKA='opensuse'


# install_dist: see install() in prepare.sh for details.
install_dist() {
local pkgs='' params='' asdeps=''
while [ "$#" != 0 ]; do
if [ "$1" = "--minimal" ]; then
params='--no-recommends'
elif [ "$1" = "--asdeps" ]; then
shift
continue
else
break
fi
shift
done
while [ "$#" != 0 ]; do
if [ "$1" = '--' ]; then
shift
break
fi
pkgs="$pkgs $1"
shift
done
zypper -q install -y $params $pkgs $(list_uninstalled_dist - "$@") || return $?
}


# install_pkg_dist: see install_pkg() in prepare.sh for details.
install_pkg_dist() {
local params=''
if [ "$1" = '--minimal' ]; then
params='--no-recommends'
shift
fi
if [ "$#" != 0 ]; then
zypper -q install -y $params "$@" || return $?
fi
}


# install_dummy_dist: see install_dummy() in prepare.sh for details.
install_dummy_dist() {
if [ "$#" = 0 ]; then
return
fi
local pkgname="crouton-$1" pkgprovides="$1" requires=""
shift
while [ "$#" != 0 ]; do
if [ "$1" = '--' ]; then
shift
break
fi
pkgprovides="$pkgprovides, $1"
shift
done
local pkgdepends="$1"
if [ "$#" != 0 ]; then
shift
while [ "$#" != 0 ]; do
pkgdepends="$pkgdepends, $1"
shift
done
fi

if [ -n "$pkgdepends" ]; then
requires="Requires: ${pkgdepends}"
fi

local tmp="$(mktemp -d crouton.XXXXXX --tmpdir=/tmp)"
addtrap "rm -rf '$tmp'"
cat > "$tmp/dummy.spec" <<EOF
Name: $pkgname
Version: 1.0.0
Release: 1.0.0
Group: dummy
Vendor: dummy
License: %{vendor}
Provides: $pkgprovides
$requires
Summary: Provides a dummy ${pkgname#*-} for crouton
BuildRoot: %{_tmppath}/%{name}-%{version}-build

%description
%{summary}

%files
EOF
rpmbuild --define='_rpmdir "$tmp"' -bb "$tmp/dummy.spec" > "$tmp/build.log"
if [ $? != 0 ]; then
echo "ERROR: Could not build dummy rpm!"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-fatal?

exit 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces, not tabs

fi
pkg="$(awk '/^wrote:/ { print $2 }' < "$tmp/build.log")"
rm "$tmp/build.log"
zypper -q install -y --force-resolution "$pkg"
}


# remove_dist: see remove() in prepare.sh for details.
remove_dist() {
zypper -q remove --clean-deps -y "$@"
}


# list_uninstalled_dist: see list_uninstalled() in prepare.sh for details.
list_uninstalled_dist() {
local suffix="$1" pkg
shift
for pkg in "$@"; do
if ! zypper se -i "$pkg" 2>/dev/null | grep -q '^i'; then
echo -n "$pkg$suffix "
fi
done
}

# enable network ping for all users
chmod u+s /usr/bin/ping

# add rpmbuild for dummy packages
install rpmbuild
3 changes: 3 additions & 0 deletions installer/opensuse/releases
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tumbleweed
leap-42.2
leap-42.3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we don't want just a "leap" release that grabs the latest version, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, these are independent releases.

2 changes: 1 addition & 1 deletion installer/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ compile() {
fi
shift 2
echo "Installing dependencies for $out..." 1>&2
local pkgs="gcc libc6-dev $*"
local pkgs="gcc opensuse=glibc-devel,libc6-dev $*"
install --minimal --asdeps $pkgs </dev/null
echo "Compiling $out..." 1>&2
local tmp="`mktemp crouton.XXXXXX --tmpdir=/tmp`"
Expand Down
11 changes: 9 additions & 2 deletions targets/audio
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ build_cras() {
install --minimal alsa-utils \
libasound2$pkgsuffix libspeexdsp1$pkgsuffix

install --minimal --asdeps gcc $pkgdepextra libc6-dev$pkgsuffix \
pkg-config libspeexdsp-dev$pkgsuffix
install --minimal --asdeps gcc $pkgdepextra opensuse=glibc-devel,libc6-dev$pkgsuffix \
pkg-config opensuse=speexdsp-devel,libspeexdsp-dev$pkgsuffix

# precise does not allow libasound2-dev and libasound2-dev:i386 to be
# installed simultaneously
Expand All @@ -99,6 +99,13 @@ build_cras() {
ln -sfT libasound.so.2 "$libasoundso"
fi
ALSALIBDIR="/usr/lib$archextrapath/alsa-lib"
elif [ "$DISTROAKA" = "opensuse" ]; then
install --minimal --asdeps alsa-devel
if [ "$ARCH" = "arm64" -o "$ARCH" = "x86_64"]; then
ALSALIBDIR="/usr/lib64/alsa-lib"
else
ALSALIBDIR="/usr/lib/alsa-lib"
fi
else
install --minimal --asdeps libasound2-dev$pkgsuffix
ALSALIBDIR="`PKG_CONFIG_PATH="$pkgconfigpath" \
Expand Down
4 changes: 2 additions & 2 deletions targets/chromium
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if [ "${TARGETNOINSTALL:-c}" = 'c' ] &&
[ "$DISTRO" = 'debian' -o "$DISTRO" = 'kali' ] &&
[ "$DISTRO" = 'debian' -o "$DISTRO" = 'kali' -o "$DISTROAKA" = 'opensuse' ] &&
[ "${ARCH#arm}" != "$ARCH" ]; then
error 99 "chromium target is not supported on Debian/ARM."
error 99 "chromium target is not supported on $DISTRO on ARM."
fi
REQUIRES='x11'
DESCRIPTION="Chromium browser. Uses the distro's version, which may be old."
Expand Down
2 changes: 1 addition & 1 deletion targets/cli-extra
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CHROOTBIN='croutonpowerd'
. "${TARGETSDIR:="$PWD"}/common"

### Append to prepare.sh:
install dbus openssh-client kbd
install opensuse=dbus-1,dbus opensuse=openssh,openssh-client kbd

TIPS="$TIPS
You can start a shell in a new VT via the startcli host command: sudo startcli
Expand Down
2 changes: 1 addition & 1 deletion targets/core
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fi
fixkeyboardmode

# Install critical packages
install --minimal sudo wget ca-certificates apt-transport-https
install --minimal sudo wget ca-certificates opensuse=,apt-transport-https

# Generate and set default locale
if [ ! -f '/etc/default/locale' ] && hash locale-gen 2>/dev/null; then
Expand Down
2 changes: 1 addition & 1 deletion targets/extension
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
. "${TARGETSDIR:="$PWD"}/common"

### Append to prepare.sh:
install x11-utils xsel
install opensuse=xprop,x11-utils xsel

compile websocket ''

Expand Down
6 changes: 3 additions & 3 deletions targets/gnome
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ fi

### Append to prepare.sh:
install --minimal evolution-data-server gnome-control-center \
gnome-screensaver gnome-session $legacy_session_package \
gnome-shell gnome-themes-standard gvfs-backends nautilus \
unzip gtk2-engines-pixbuf pulseaudio
opensuse=,gnome-screensaver gnome-session $legacy_session_package \
gnome-shell opensuse=gnome-themes,gnome-themes-standard gvfs-backends \
nautilus unzip opensuse=gtk2-engines,gtk2-engines-pixbuf pulseaudio

TIPS="$TIPS
You can start GNOME via the startgnome host command: sudo startgnome
Expand Down
Loading