Skip to content

Commit 430db52

Browse files
Add support for generic deb/rpm distros (#92)
1 parent 67cc662 commit 430db52

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

packages/scripts/install.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,38 @@ _discover_distro_repo() {
106106
_check_version_id
107107
DISTRO_REPO="openSUSE_Leap_${VERSION_ID}"
108108
;;
109-
*)
109+
"")
110110
_error "Unable to identify distribution. You may specify one with environment variable DISTRO_REPO"
111111
_error "Please, report to https://forum.crystal-lang.org/c/help-support/11"
112112
exit 1
113113
;;
114+
*)
115+
# If there's no dedicated repository for the distro, try to figure out
116+
# if the distro is apt or rpm based and use a default repository.
117+
_discover_distro_type
118+
119+
case "$DISTRO_TYPE" in
120+
deb)
121+
DISTRO_REPO="Debian_Unstable"
122+
;;
123+
rpm)
124+
DISTRO_REPO="RHEL_7"
125+
;;
126+
*)
127+
_error "Unable to identify distribution type ($ID). You may specify a repository with the environment variable DISTRO_REPO"
128+
_error "Please, report to https://forum.crystal-lang.org/c/help-support/11"
129+
exit 1
130+
;;
131+
esac
114132
esac
115133
}
116134

135+
_discover_distro_type() {
136+
DISTRO_TYPE=""
137+
[[ $(command -v apt-get) ]] && DISTRO_TYPE="deb" && return
138+
[[ $(command -v yum) ]] && DISTRO_TYPE="rpm" && return
139+
}
140+
117141
if [[ $EUID -ne 0 ]]; then
118142
_error "This script must be run as root"
119143
exit 1
@@ -149,6 +173,7 @@ fi
149173

150174
_install_apt() {
151175
if [[ -z $(command -v wget &> /dev/null) ]] || [[ -z $(command -v gpg &> /dev/null) ]]; then
176+
[[ -f /etc/apt/sources.list.d/crystal.list ]] && rm -f /etc/apt/sources.list.d/crystal.list
152177
apt-get update
153178
apt-get install -y wget gpg
154179
fi

packages/test/elementary_os.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bats
2+
3+
@test "Elementary OS stable" {
4+
./test-install-on-docker.sh elementary/docker:stable
5+
}
6+
7+
@test "Elementary OS unstable" {
8+
./test-install-on-docker.sh elementary/docker:unstable
9+
}

packages/test/mint.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bats
2+
3+
@test "Linux Mint 20" {
4+
./test-install-on-docker.sh linuxmintd/mint20-amd64
5+
}
6+
7+
@test "Linux Mint 19" {
8+
./test-install-on-docker.sh linuxmintd/mint19-amd64
9+
}

0 commit comments

Comments
 (0)