oracle: Support other architectures
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
parent
b2e34747d2
commit
89ac169fa4
@ -18,6 +18,7 @@ import (
|
|||||||
// OracleLinuxHTTP represents the Oracle Linux downloader.
|
// OracleLinuxHTTP represents the Oracle Linux downloader.
|
||||||
type OracleLinuxHTTP struct {
|
type OracleLinuxHTTP struct {
|
||||||
majorVersion string
|
majorVersion string
|
||||||
|
architecture string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewOracleLinuxHTTP creates a new OracleLinuxHTTP instance.
|
// NewOracleLinuxHTTP creates a new OracleLinuxHTTP instance.
|
||||||
@ -28,7 +29,8 @@ func NewOracleLinuxHTTP() *OracleLinuxHTTP {
|
|||||||
// Run downloads Oracle Linux.
|
// Run downloads Oracle Linux.
|
||||||
func (s *OracleLinuxHTTP) Run(definition shared.Definition, rootfsDir string) error {
|
func (s *OracleLinuxHTTP) Run(definition shared.Definition, rootfsDir string) error {
|
||||||
s.majorVersion = definition.Image.Release
|
s.majorVersion = definition.Image.Release
|
||||||
fname := "x86_64-boot.iso"
|
s.architecture = definition.Image.ArchitectureMapped
|
||||||
|
fname := fmt.Sprintf("%s-boot.iso", s.architecture)
|
||||||
baseURL := fmt.Sprintf("%s/OL%s", definition.Source.URL, definition.Image.Release)
|
baseURL := fmt.Sprintf("%s/OL%s", definition.Source.URL, definition.Image.Release)
|
||||||
|
|
||||||
latestUpdate, err := s.getLatestUpdate(baseURL)
|
latestUpdate, err := s.getLatestUpdate(baseURL)
|
||||||
@ -36,7 +38,7 @@ func (s *OracleLinuxHTTP) Run(definition shared.Definition, rootfsDir string) er
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = shared.DownloadHash(fmt.Sprintf("%s/%s/x86_64/%s", baseURL, latestUpdate, fname),
|
err = shared.DownloadHash(fmt.Sprintf("%s/%s/%s/%s", baseURL, latestUpdate, s.architecture, fname),
|
||||||
"", nil)
|
"", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Error downloading Oracle Linux image: %s", err)
|
return fmt.Errorf("Error downloading Oracle Linux image: %s", err)
|
||||||
@ -102,7 +104,7 @@ func (s *OracleLinuxHTTP) unpackISO(latestUpdate, filePath, rootfsDir string) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine rpm and yum packages
|
// Determine rpm and yum packages
|
||||||
baseURL := fmt.Sprintf("https://yum.oracle.com/repo/OracleLinux/OL%s/%s/base/x86_64", s.majorVersion, latestUpdate)
|
baseURL := fmt.Sprintf("https://yum.oracle.com/repo/OracleLinux/OL%s/%s/base/%s", s.majorVersion, latestUpdate, s.architecture)
|
||||||
|
|
||||||
doc, err := htmlquery.LoadURL(fmt.Sprintf("%s/index.html", baseURL))
|
doc, err := htmlquery.LoadURL(fmt.Sprintf("%s/index.html", baseURL))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -191,13 +193,14 @@ set -eux
|
|||||||
|
|
||||||
version="%s"
|
version="%s"
|
||||||
update="%s"
|
update="%s"
|
||||||
|
arch="%s"
|
||||||
|
|
||||||
# Create required files
|
# Create required files
|
||||||
touch /etc/mtab /etc/fstab
|
touch /etc/mtab /etc/fstab
|
||||||
|
|
||||||
# Fetch and install rpm and yum from the Oracle repo
|
# Fetch and install rpm and yum from the Oracle repo
|
||||||
_rpm=$(curl -s https://yum.oracle.com/repo/OracleLinux/OL${version}/${update}/base/x86_64/index.html | grep -Eo '>rpm-[[:digit:]][^ ]+\.rpm<' | tail -1 | sed 's|[<>]||g')
|
_rpm=$(curl -s https://yum.oracle.com/repo/OracleLinux/OL${version}/${update}/base/${arch}/index.html | grep -Eo '>rpm-[[:digit:]][^ ]+\.rpm<' | tail -1 | sed 's|[<>]||g')
|
||||||
_yum=$(curl -s https://yum.oracle.com/repo/OracleLinux/OL${version}/${update}/base/x86_64/index.html | grep -Eo '>yum-[[:digit:]][^ ]+\.rpm<' | tail -1 | sed 's|[<>]||g')
|
_yum=$(curl -s https://yum.oracle.com/repo/OracleLinux/OL${version}/${update}/base/${arch}/index.html | grep -Eo '>yum-[[:digit:]][^ ]+\.rpm<' | tail -1 | sed 's|[<>]||g')
|
||||||
|
|
||||||
rpm -ivh --nodeps "${_rpm}" "${_yum}"
|
rpm -ivh --nodeps "${_rpm}" "${_yum}"
|
||||||
rpm --import RPM-GPG-KEY-oracle
|
rpm --import RPM-GPG-KEY-oracle
|
||||||
@ -207,7 +210,7 @@ mkdir -p /etc/yum.repos.d
|
|||||||
cat <<- EOF > /etc/yum.repos.d/base.repo
|
cat <<- EOF > /etc/yum.repos.d/base.repo
|
||||||
[base]
|
[base]
|
||||||
name=Oracle Linux
|
name=Oracle Linux
|
||||||
baseurl=https://yum.oracle.com/repo/OracleLinux/OL${version}/${update}/base/x86_64
|
baseurl=https://yum.oracle.com/repo/OracleLinux/OL${version}/${update}/base/${arch}
|
||||||
enabled=1
|
enabled=1
|
||||||
gpgcheck=1
|
gpgcheck=1
|
||||||
gpgkey=file:///RPM-GPG-KEY-oracle
|
gpgkey=file:///RPM-GPG-KEY-oracle
|
||||||
@ -223,12 +226,12 @@ mkdir -p /rootfs/etc/yum.repos.d
|
|||||||
cat <<- EOF > /rootfs/etc/yum.repos.d/base.repo
|
cat <<- EOF > /rootfs/etc/yum.repos.d/base.repo
|
||||||
[base]
|
[base]
|
||||||
name=Oracle Linux
|
name=Oracle Linux
|
||||||
baseurl=https://yum.oracle.com/repo/OracleLinux/OL${version}/${update}/base/x86_64
|
baseurl=https://yum.oracle.com/repo/OracleLinux/OL${version}/${update}/base/${arch}
|
||||||
enabled=1
|
enabled=1
|
||||||
gpgcheck=1
|
gpgcheck=1
|
||||||
gpgkey=file:///RPM-GPG-KEY-oracle
|
gpgkey=file:///RPM-GPG-KEY-oracle
|
||||||
EOF
|
EOF
|
||||||
`, s.majorVersion, latestUpdate))
|
`, s.majorVersion, latestUpdate, s.architecture))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exitChroot()
|
exitChroot()
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user