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

Some fixes for building synApps on a fresh Ubuntu 22 successfully #6

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
90 changes: 90 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: build

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main pullrequest0]
pull_request:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
# convert this to a matrix if builds differ between platforms
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ['ubuntu-latest']
steps:

- name: Install required packages
run: |
sudo apt-get install -y git build-essential curl libusb-dev libusb-1.0-0-dev re2c x11proto-dev libx11-dev libxext-dev

# get & build EPICS first
- name: Restore cached EPICS
id: cache-epics
uses: actions/cache/restore@v4
with:
path: epics-base
key: ${{ runner.os }}-epics-base

- name: Check out epics
if: steps.cache-epics.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: epics-base/epics-base
ref: '7.0'
submodules: recursive
path: epics-base

- name: Build EPICS
if: steps.cache-epics.outputs.cache-hit != 'true'
run: |
cd epics-base
make distclean
make

- name: Cache EPICS
uses: actions/cache/save@v4
with:
path: epics-base
key: ${{ steps.cache-epics.outputs.cache-primary-key }}

- name: Check out assemble_synApps
uses: actions/checkout@v4
with:
path: assemble_synApps

- name: Build synApps
run: |
./assemble_synApps/assemble_synApps --base="$(pwd)/epics-base" --dir="$(pwd)/synapps" 2>&1 | tee assemble.log
cd synapps/support
make 2>&1 | tee ../../make.log

- name: Check Galil created files
run: |
cd synapps/support
echo Listing all files in Galil-* directory
find Galil-* -type f

- name: Store logs as artifacts
if: success() || failure() # always store the logs
uses: actions/upload-artifact@v4
with:
name: build_logs
path: |
assemble.log
make.log

- name: Store build results as artifacts
uses: actions/upload-artifact@v4
with:
name: synApps+epics
path: |
assemble_synApps
epics-base
synapps
45 changes: 38 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,45 @@ synApps assemble script
Used to pull a user-defined set of EPICS modules at given tags and package them into a
single synApps directory that will build with a single 'make' command.

## usage
## Usage

The script can be called by itself and will use a default set of modules and tags to
build the synApps release. There are also a set of command line options to customize
the setup as needed. Or otherwise, the script itself is rather easy to find and replace
default values.

### Command Line Interface
## Requirements (Linux)

Additional packages to install on Ubuntu 22.04:

apt install -y git build-essential curl libusb-dev libusb-1.0-0-dev re2c x11proto-dev libx11-dev libxext-dev

## Example Setup on Linux

1. Create a base folder for synApps/EPICS setup:

mkdir -p ~/epics

2. Get & build EPICS base

cd ~/epics
git clone --recursive -b 7.0 https://github.com/epics-base/epics-base.git base
cd base && make distclean && make -j8

3. Get synApps

cd ~/epics
git clone https://github.com/BAMresearch/EPICS-synApps-assemble.git assemble_synApps

4. Build synApps

cd ~/epics
# make sure the source tree belongs to the current user, avoids errors around this
sudo chown -R $(id -un).$(id -gn) .
# assemble synApps which builds everything finally
./assemble_synApps/assemble_synApps --base="$(realpath base)" --dir="$(realpath synapps)"

## Command Line Interface

The command line options that assemble_synApps recognizes are:

Expand All @@ -22,7 +53,7 @@ The command line options that assemble_synApps recognizes are:
* --check
* --help

#### config
### config

The config option is used to provide a separate file with a list of modules and their tags.
This file should be arranged with each definition on their own line and in the form of
Expand All @@ -34,19 +65,19 @@ module isn't defined in the config file provided, it will not use any default va
module just will not be downloaded.


#### dir
### dir

The dir option is used to define the name of the synApps directory to be created. All modules
will be downloaded into the folder structure synApps_dir_name/support.


#### base
### base

The base option is used to define the location of the installation of EPICS base on your system
that synApps will link against.


#### set
### set

The set option is used to make individual changes to the module definitions you will be using.
Each usage of the `--set` option should be followed by a string in the form of
Expand All @@ -57,7 +88,7 @@ already exist, or will overwrite an existing definition. This works regardless o
using the default module definitions or if you have a config file.


#### check
### check

The check option is a sanity check before you fully run the script. It will display the values of
all the module definitions that it will be downloading.
43 changes: 12 additions & 31 deletions assemble_synApps
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if ($releasefile eq "default")
$modules{'DXPSITORO'} = 'R1-3';
$modules{'DEVIOCSTATS'} = '3.1.16';
$modules{'ETHERIP'} = 'ether_ip-3-3';
$modules{'GALIL'} = 'V3-5';
$modules{'GALIL'} = 'R3-6-85';
$modules{'IP'} = 'R2-22';
$modules{'IPAC'} = '2.16';
$modules{'IP330'} = 'R2-10';
Expand Down Expand Up @@ -202,11 +202,6 @@ sub get_repo {

chdir "$FOLDER_NAME";
`git checkout -q $TAG`;
chdir "..";

say $REL "$RELEASE_NAME=\$(SUPPORT)/$FOLDER_NAME";

print "\n";
}
else
{
Expand All @@ -218,12 +213,11 @@ sub get_repo {
`git stash -q`;
`git clean -fdx`;
`git checkout -q $TAG`;
chdir "..";

say $REL "$RELEASE_NAME=\$(SUPPORT)/$FOLDER_NAME";

print "\n";
}
system("mkdir -p configure; echo 'EPICS_BASE=$EPICS_BASE' >> configure/RELEASE.local");
chdir "..";
say $REL "$RELEASE_NAME=\$(SUPPORT)/$FOLDER_NAME";
print "\n";
}


Expand Down Expand Up @@ -262,7 +256,7 @@ $module_info{DXP} = {group => "epics-modules", repo => "dxp"};
$module_info{DXPSITORO} = {group => "epics-modules", repo => "dxpSITORO"};
$module_info{DEVIOCSTATS} = {group => "epics-modules", repo => "iocStats"};
$module_info{ETHERIP} = {group => "epics-modules", repo => "ether_ip"};
$module_info{GALIL} = {group => "motorapp", repo => "Galil-3-0"};
$module_info{GALIL} = {group => "motorapp", repo => "Galil"};
$module_info{IP} = {group => "epics-modules", repo => "ip"};
$module_info{IPAC} = {group => "epics-modules", repo => "ipac"};
$module_info{IP330} = {group => "epics-modules", repo => "ip330"};
Expand Down Expand Up @@ -520,24 +514,10 @@ if (exists($modules{GALIL}))

$FILTER_TAG =~ s/V//g;

chdir "Galil-3-0-$modules{GALIL}";

copy_recur("${FILTER_TAG}/.", "./");
rmtree("${FILTER_TAG}");
chdir "Galil-$modules{GALIL}";

copy("./config/GALILRELEASE", "./configure/RELEASE.local");

add_line('-include $(TOP)/../RELEASE.local', "./configure/RELEASE");
add_line('-include $(TOP)/../RELEASE.$(EPICS_HOST_ARCH).local', "./configure/RELEASE");
add_line('-include $(TOP)/configure/RELEASE.local', "./configure/RELEASE");

do_substitution("\QLIBRARY_IOC += GalilSupport\E", "LIBRARY_IOC_Linux \+= GalilSupport\nLIBRARY_IOC_WIN32 += GalilSupport", "GalilSup/src/Makefile");
do_substitution("PROD_IOC = GalilTest", "PROD_IOC_Linux = GalilTest\nPROD_IOC_WIN32 = GalilTest", "GalilTestApp/src/Makefile");

if (exists($modules{SNCSEQ}))
{
do_substitution("asyn motor calc sscan autosave busy", "asyn motor calc sscan autosave busy seq pv", "GalilTestApp/src/Makefile");
}

chdir "..";
}
Expand Down Expand Up @@ -591,7 +571,7 @@ if (exists($modules{MEASCOMP}))

system("./configure --prefix=${PWD}");
system("make");
`make install || true`;
`sudo make install || true`;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is requiring root access here? The point of line 585 is that 'make install' will install everything into its own directory. I just ran the script on Ubuntu 22 and there were no root requirements.

Copy link
Author

Choose a reason for hiding this comment

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

When running this in a fresh system with a regular unprivileged user, it tries to install udev rules and modifying ld.so.cache.

Here, this first example is from the Github Action runner:

make[1]: Leaving directory '/home/runner/work/EPICS-synApps-assemble/EPICS-synApps-assemble/synapps/support/measComp-R4-2/libuldaq-1.2.1'
/usr/bin/install: cannot create regular file '/lib/udev/rules.d/50-uldaq.rules': Permission denied
make[2]: *** [Makefile:484: install-dist_rulesdataDATA] Error 1
make[1]: *** [Makefile:814: install-am] Error 2
make: *** [Makefile:511: install-recursive] Error 1

This happens after the permissions to udev are fixed:

make[2]: Leaving directory '/epics/synapps/support/measComp-R4-2/libuldaq-1.2.1/examples'
make[2]: Entering directory '/epics/synapps/support/measComp-R4-2/libuldaq-1.2.1'
make[2]: Leaving directory '/epics/synapps/support/measComp-R4-2/libuldaq-1.2.1'
make[1]: Leaving directory '/epics/synapps/support/measComp-R4-2/libuldaq-1.2.1'
Failed to send reload request: Permission denied
/sbin/ldconfig.real: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
make[3]: *** [Makefile:951: install-data-hook] Error 1
make[2]: *** [Makefile:866: install-data-am] Error 2
make[1]: *** [Makefile:814: install-am] Error 2
make: *** [Makefile:511: install-recursive] Error 1

To be sure, I removed sudo in my main branch and let it build as Github Action, the logs should be accessible for this job: https://github.com/BAMresearch/EPICS-synApps-assemble/actions/runs/8023437425/job/21919899065

Copy link
Author

Choose a reason for hiding this comment

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

Edit: The build logs and artifacts are listed at the bottom of the summary of a build job, here: https://github.com/BAMresearch/EPICS-synApps-assemble/actions/runs/8023437425


unlink("../configure/CONFIG_SITE.local");
add_line("USR_LDFLAGS+=-L${PWD}/lib", "../configure/CONFIG_SITE.local");
Expand Down Expand Up @@ -733,8 +713,9 @@ say $RELEASE "-include \$(SUPPORT)/RELEASE.local";
say $RELEASE "-include \$(SUPPORT)/RELEASE.\$(EPICS_HOST_ARCH).local";
say $RELEASE "-include \$(SUPPORT)/configure/RELEASE.local";
say $RELEASE "-include \$(SUPPORT)/configure/RELEASE.\$(EPICS_HOST_ARCH).local";


close($RELEASE);

`make release`;
# Make RELEASE files for support modules consistent
system("make release"); # system() forwards output and errors of the command
# Start the build
system("make");