diff --git a/README.md b/README.md index 177f290..9a1bcab 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 git@github.com: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..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. diff --git a/linux-cmd-intallation.sh b/linux-cmd-intallation.sh new file mode 100644 index 0000000..259ed87 --- /dev/null +++ b/linux-cmd-intallation.sh @@ -0,0 +1,61 @@ +#!/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 + +# install required packages +echo 'Installing package dependencies...' +sudo dnf install python3 ruby subversion rpm-build + +echo 'Installing ruby gem dependencies...' +sudo gem install asciidoctor concurrent-ruby haml tilt +# do we still need pygit2? +pip3 install pygit2 + +echo 'Creating resources directories...' +for dir in "PantheonCMD/haml" "PantheonCMD/locales"; do if [ ! -d "$dir" ]; then mkdir $dir; fi; done + +echo 'Getting HAML templates...' +svn checkout https://github.com/redhataccess/pantheon/trunk/pantheon-bundle/src/main/resources/apps/pantheon/templates/haml/html5 PantheonCMD/haml + +echo 'Getting locales...' +svn checkout https://github.com/asciidoctor/asciidoctor/trunk/data/locale PantheonCMD/locales +rm -rf PantheonCMD/{haml,locales}/.svn + +echo 'Updating styling references...' +sed -i 's/^-\ pantheonCssPath.*/-\ pantheonCssPath\ \=\ \"resources\/rhdocs.min.css\"/' PantheonCMD/haml/document.html.haml +sed -i 's/href\=\"https\:\/\/static\.redhat\.com\/libs\/redhat\/redhat-font\/2\/webfonts\/red-hat-font\.css/href\=\"resources\/red-hat-font.css/' PantheonCMD/haml/document.html.haml + +echo 'Copying the source files to the local binaries directory...' +sudo cp -r PantheonCMD /usr/local/bin + +# do we need to account for different shells? +# exit code is 0 so setting +e +echo 'Adding an alias to the current shell...' +if [[ $SHELL = '/bin/bash' ]]; then + set +e && alias pcmd='/usr/bin/python3 /usr/local/bin/PantheonCMD/pcmd.py $@' && source ~/.bashrc +elif [[ $SHELL = '/bin/tcsh' ]]; then + set +e && alias pcmd '/usr/bin/python3 /usr/local/bin/PantheonCMD/pcmd.py $@' && source ~/.tcshrc +elif [[ $SHELL = '/bin/csh' ]]; then + set +e && alias pcmd '/usr/bin/python3 /usr/local/bin/PantheonCMD/pcmd.py $@' && source ~/.cshrc +fi + +rm -rf PantheonCMD/{haml,locales} + +trap : 0 + +echo >&2 ' +*** DONE *** +' diff --git a/osx-cmd-intallation.sh b/osx-cmd-intallation.sh index f500b01..c029f25 100644 --- a/osx-cmd-intallation.sh +++ b/osx-cmd-intallation.sh @@ -63,7 +63,7 @@ cp -r PantheonCMD /usr/local/bin echo 'Adding an alias to ~/.zshrc file...' -alias pcmd="/usr/local/bin/python3 /usr/local/bin/PantheonCMD/pcmd.py $@" +alias pcmd="/usr/bin/python3 /usr/local/bin/PantheonCMD/pcmd.py $@" echo 'Sourcing your ~/.zshrc file...'