ad-build-test / BuildSystem

Testing buildsystem repo
0 stars 0 forks source link

Build and Deploy RPM logic for IOCs #6

Open pnispero opened 3 weeks ago

pnispero commented 3 weeks ago

Build and deploy rpm logic for an IOC

note - If rpm's is the direction were heading, we will build and deploy rpms for the other types of apps as well including HLA, Tools/script, matlab, pydm, etc.

Building RPM

  1. Determine the build results of an IOC
  2. Put build results in build_results/ directory
  3. Build the rpm package for the app

    3.1) cd build_results

        # 3.2) tar czf component-branch.tar.gz *
        # 3.3) mkdir rpm && cd rpm/
        # 3.4) mkdir BUILD RPMS SOURCES SPECS
        # 3.5) mv ../component-branch.tar.gz SOURCES
        # 4.) Create component-branch.spec
        # 5) To solve the problem of different filepaths to install to, here are the options:
            ## a) create multiple rpms, each with a slightly different .spec to install in certain dir
            ## b) Have rpm's install in standard directory like /opt/rpm_installs
                ### But that directory is pointed to from standard deployment locations with symlinks
            ## c) install rpm in standard directory, but have a post-installation script
                ### that will copy the installation to the desired deployment destination
        # todo: need to figure out the envPaths problem, just reuse cram logic?
            # a) possible options besides slicing that piece of cram
            # a) union of envPaths, with if (facility) then (var)
            # b) define one crucial environment var, which is the facility which would be added in st.cmd
  4. If local build, then leave .rpm in $TOP/build_results/rpm directory
  5. if remote build, then send package to artifact storage

    Deploying RPM

  6. Create ansible playbook
  7. important to add prefix, or use existing environment variables for the facility to determine the installation path
pnispero commented 1 week ago

This issue is in progress at Branch feat-6. This issue is put on hold as getting root accounts is taking some time among other things. Moving on with issue #7

pnispero commented 5 days ago

Notes - rpm spec I used to build the RPM

test-ioc.spec

Name:           test-ioc
Version:        1.0.0
Release:        1%{?dist}
Summary:        test-ioc built for buildsystem testing
BuildArch:      x86_64

License:        GPL
Source0:        %{name}-%{version}.tar.gz

# Requires:       
# TODO: Need to figure out if we want to specify dependencies here like all of them?
# Or just copy over the dependencies from the manifest CONFIG.yaml

%description
A demo RPM build

# Define the _prefix macro with a default value
%define _prefix /sdf/scratch/ad/build/lcls/epics/iocTop

%prep
%setup -q

# %build
# No build steps for this - can assume the tarball is already built

%install
# Install refers to installing the tarball on BUILDROOT/ of the rpm package
# Create the test-ioc directory in the buildroot

mkdir -p %{buildroot}%{_prefix}/%{name}-%{version}/bin
mkdir -p %{buildroot}%{_prefix}/%{name}-%{version}/db
mkdir -p %{buildroot}%{_prefix}/%{name}-%{version}/dbd
mkdir -p %{buildroot}%{_prefix}/%{name}-%{version}/iocBoot

# List the contents of the source directories for debugging
echo "Listing source directory contents:"
ls -R %{_sourcedir}/%{name}-%{version}.tar.gz

# Copy contents from the unpacked tarball into the test-ioc directory
cp -a bin/* %{buildroot}%{_prefix}/%{name}-%{version}/bin/
cp -a db/* %{buildroot}%{_prefix}/%{name}-%{version}/db/
cp -a dbd/* %{buildroot}%{_prefix}/%{name}-%{version}/dbd/
cp -a iocBoot/* %{buildroot}%{_prefix}/%{name}-%{version}/iocBoot/

%clean
# No clean steps for this - since there is no building step

%files
# Files refer to copying the files to desired directories on target system
# This one has to be dynamic with %_prefix
# The install location is dynamic and determined at installation using '_prefix'
# ex: rpm -i test-ioc.rpm --prefix /sdf/scratch/ad/build/lcls/epics/iocTop

%{_prefix}/%{name}-%{version}/bin/*
%{_prefix}/%{name}-%{version}/db/*
%{_prefix}/%{name}-%{version}/dbd/*
%{_prefix}/%{name}-%{version}/iocBoot/*

%changelog
* Fri Aug 23 2024 Patrick Nisperos <pnispero@slac.stanford.edu> - 1.0.0
- First version being packaged