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

script for linux installation #63

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
53 changes: 9 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Pantheon CMD is a Python-based command-line tool that allows you to generate a rendered preview of modular documentation using the new HAML templates.

Installing Pantheon CMD using RPM allows you to perform actions using the predefined aliases such as:
Installing Pantheon CMD using RPM allows you to perform actions using the predefined aliases such as:
* `pcmd validate`
* `pcmd build`
* `pcmd preview`
Expand All @@ -24,58 +24,23 @@ A script used to package the script as an RPM-based package that can be installe
**PantheonCMD**
A directory containing the source files for the script, and the man page file.

## Updating the Script
All additions and updates to the script are welcome.

## Packaging the Script
## Packaging and Installing Pantheon CMD on RHEL and Fedora
After you update Pantheon CMD and test the changes, build an RPM-based package for the script to be installed on systems that use *yum* or *dnf*.

* Prerequisites:
* A user has registered their SSH keys with GitHub.

1. Install the `svn` and `rpmbuild` packages on your system:
```shell
# on RHEL
$ sudo yum install subversion
$ sudo yum install rpm-build

# on Fedora
$ sudo dnf install subversion
$ sudo dnf install rpm-build
```
2. Clone this repository.
1. Clone this repository.
```shell
$ git clone [email protected]:redhataccess/pantheon-cmd.git
```
3. Open *./build/pantheon-cmd.spec*.
4. Increment the value of the *Release* number.
As an example, `Release: 1%{?dist}` increments the version of the build to `1.0.1`, where `{?dist}` identifies of your Linux distribution.
5. Run the build script:
```shell
$ sh make.sh 1.0
```
As a result, the `build/pantheon-cmd-1.0-X.<your-distribution-and-version>.noarch.rpm` file is generated in the root of the repository. This file will be used in the following step.

## Installing Pantheon CMD

Install Pantheon CMD on a local system.

## Installing Pantheon CMD on RHEL and Fedora

Install the RPM and all Ruby gem dependencies.

1. Install the RPM:
```shell
$ sudo dnf localinstall build/pantheon-cmd-1.0-X.el8.noarch.rpm
```
Note that your `rpm` filename might differ based on your Linux distribution.
* Example:
* `el8` for RHEL 8
* `fc34` for Fedora 34

2. Install Ruby gem dependencies:
2. Navigate to the `pantheon-cmd` directory:
```shell
$ cd pantheon-cmd
```
3. Run the `linux-cmd-intallation.sh` packaging and installation script:
```shell
$ sudo gem install asciidoctor concurrent-ruby haml tilt
$ sh linux-cmd-intallation.sh
```

The script is installed on your local machine.
Expand Down
44 changes: 44 additions & 0 deletions linux-cmd-intallation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Error handling
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG
terminate()
{
echo >&2 '
*** terminated ***
'
echo "\"$last_command\" command failed with exit code $?."
exit 1
}

trap 'terminate' 0

set -e

# clone repo

# install required packages
sudo dnf install subversion
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make this a one-liner, perhaps?

E.g. sudo dnf install subversion rpm-build

sudo dnf install rpm-build


if [[ $(basename "$PWD") = "pantheon-cmd" ]]; then
release_number=$(grep -o -P '(?<=Release: ).*(?=%{)' build/pantheon-cmd.spec)
incremented_release_number=$((release_number+1))
else
echo "Navigate to the pantheon-cmd directory."
exit 2
fi

sh make.sh $incremented_release_number

# install dependencies
sudo gem install asciidoctor concurrent-ruby haml tilt

sudo dnf install build/pantheon-cmd-*.noarch.rpm

trap : 0

echo >&2 '
*** DONE ***
'