chiark / gitweb /
package.sh: add fedora
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 14 Jan 2015 12:19:45 +0000 (13:19 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 14 Jan 2015 13:45:47 +0000 (14:45 +0100)
Fedora builds Cura by using ```mock```, thereby enabling it to build RPMs
for every distribution that ```mock``` has a configuration file for. In
pratice this means that Fedora can build RPMs for several versions of
Fedora, CentOS and RHEL.

Cura can be built under a regular user account, there is no need to have
root privileges. In fact, having root privileges is very much discouraged.

However, the user account under which the build is performed needs to be
a member of the 'mock' group.

Specify only 'fedora' to build RPMs for the current system.
  ./package.sh fedora

Additionally specify any number of mock configurations
(ls -1 /etc/mock/*.cfg) to build RPMs for those configurations.
  ./package.sh fedora fedora-21-x86_64.cfg fedora-21-i386.cfg ...

Since only the filename of the mock configurations is used, this
also works:
  ./package.sh fedora /etc/mock/fedora-21-x86_64.cfg ...

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
README.md
package.sh
scripts/linux/fedora/.gitignore [new file with mode: 0644]
scripts/linux/fedora/rpm.spec [new file with mode: 0644]
scripts/linux/fedora/usr/bin/cura [new file with mode: 0755]
scripts/linux/fedora/usr/share/.gitignore [new file with mode: 0644]
scripts/linux/fedora/usr/share/applications/cura.desktop [new file with mode: 0755]

index 98d53329e14d61223a711dd99bbac1da73dacb2c..e6cdbf46369de45858c98506ab38a46dae8f2481 100644 (file)
--- a/README.md
+++ b/README.md
@@ -26,6 +26,60 @@ The "package.sh" script generates a final release package. You should not need i
 \r
 Both MacOS and Linux require some extra instructions for development, as you need to prepare an environment. Look below at the proper section to see what is needed.\r
 \r
+Fedora\r
+--------\r
+\r
+Fedora builds Cura by using ```mock```, thereby enabling it to build RPMs for\r
+every distribution that ```mock``` has a configuration file for. In pratice\r
+this means that Fedora can build RPMs for several versions of Fedora, CentOS\r
+and RHEL.\r
+\r
+Cura can be built under a regular user account, there is no need to have root\r
+privileges. In fact, having root privileges is very much discouraged.\r
+\r
+However, the user account under which the build is performed needs to be a\r
+member of the 'mock' group. This is accomplished as follows:\r
+\r
+```bash\r
+sudo usermod -a -G mock "$(whoami)"\r
+```\r
+\r
+To install the software that is required to build Cura, run the following\r
+commands:\r
+\r
+```bash\r
+sudo yum install -y git rpmdevtools rpm-build mock arduino\r
+\r
+# Ensure that the Arduino tools can be found by the build\r
+sudo mkdir -p /usr/share/arduino/hardware/tools/avr\r
+sudo ln -sf /usr/bin /usr/share/arduino/hardware/tools/avr/bin\r
+\r
+```\r
+\r
+To build and install Cura, run the following commands:\r
+\r
+```bash\r
+# Get the Cura software, only required once\r
+git clone https://github.com/daid/Cura.git Cura\r
+\r
+# Build for the current system\r
+cd Cura\r
+./package.sh fedora\r
+\r
+# Install on the current system\r
+sudo yum localinstall -y scripts/linux/fedora/RPMS/Cura-*.rpm\r
+```\r
+\r
+Examples of building other configurations:\r
+\r
+```bash\r
+# Build for Fedora rawhide x86-64 and i386\r
+./package.sh fedora fedora-rawhide-x86_64.cfg fedora-rawhide-i386.cfg\r
+\r
+# Since only the basename of the mock configurations is used, this also works:\r
+./package.sh fedora /etc/mock/fedora-21-x86_64.cfg /etc/mock/fedora-rawhide-i386.cfg\r
+```\r
+\r
 Debian and Ubuntu Linux\r
 --------\r
 \r
index 018d895219704a001ddb666efc451394d602f33c..e6c5570d2577496bc58f291ee17a960c8205c0c8 100755 (executable)
@@ -95,6 +95,8 @@ if [ "$BUILD_TARGET" = "none" ]; then
        echo "$0 debian_armhf"
        echo "$0 darwin"
        echo "$0 freebsd"
+       echo "$0 fedora                         # current   system"
+       echo "$0 fedora \"mock_config_file\" ...  # different system(s)"
        exit 0
 fi
 
@@ -144,6 +146,7 @@ if [ ! -d "$ARDUINO_PATH" ]; then
   exit 1
 fi
 
+
 #Build the Ultimaker Original firmwares.
 gitClone git@github.com:Ultimaker/Marlin.git _UltimakerMarlin
 cd _UltimakerMarlin/Marlin
@@ -379,6 +382,133 @@ if [ "$BUILD_TARGET" = "debian_armhf" ]; then
        exit
 fi
 
+#############################
+# Fedora Generic
+#############################
+
+function sanitiseVersion() {
+  local _version="$1"
+  echo "${_version//-/.}"
+}
+
+function fedoraCreateSRPM() {
+  local _curaName="$1"
+  local _version="$(sanitiseVersion "$2")"
+  local _srcSpecFile="$3"
+  local _srcSpecFileRelease="$4"
+  local _dstSrpmDir="$5"
+
+  local _dstTarSources="$HOME/rpmbuild/SOURCES/$_curaName-$_version.tar.gz"
+  local _dstSpec="$HOME/rpmbuild/SPECS/$_curaName-$_version.spec"
+
+  local _namePower="Power"
+  local _nameCuraEngine="CuraEngine"
+
+  gitClone "https://github.com/GreatFruitOmsk/Power" "$_namePower"
+  gitClone "$CURA_ENGINE_REPO" "$_nameCuraEngine"
+
+  cd "$_namePower"
+  local _gitPower="$(git rev-list -1 HEAD)"
+  cd -
+
+  cd "$_nameCuraEngine"
+  local _gitCuraEngine="$(git rev-list -1 HEAD)"
+  cd -
+
+  local _gitCura="$(git rev-list -1 HEAD)"
+
+  rpmdev-setuptree
+
+  rm -fv "$_dstTarSources"
+  tar \
+    --exclude-vcs \
+    --transform "s#^#$_curaName-$_version/#" \
+    -zcvf "$_dstTarSources" \
+      "$_nameCuraEngine" \
+      "$_namePower" \
+      Cura \
+      resources \
+      plugins \
+      scripts/linux/cura.py \
+      scripts/linux/fedora/usr
+
+  sed \
+    -e "s#__curaName__#$_curaName#" \
+    -e "s#__version__#$_version#" \
+    -e "s#__gitCura__#$_gitCura#" \
+    -e "s#__gitCuraEngine__#$_gitCuraEngine#" \
+    -e "s#__gitPower__#$_gitPower#" \
+    -e "s#__basedir__#scripts/linux/fedora#" \
+    "$_srcSpecFile" \
+    > "$_dstSpec"
+
+  rpmbuild -bs "$_dstSpec"
+
+  mkdir -pv "$_dstSrpmDir"
+  cp -v \
+    "$HOME/rpmbuild/SRPMS/$_curaName-$_version-$_srcSpecFileRelease.src.rpm" \
+    "$_dstSrpmDir"
+}
+
+function buildFedora() {
+  local _nameForRpm="Cura"
+  local _versionForRpm="$(sanitiseVersion "$BUILD_NAME")"
+
+  #
+  # SRPM
+  #
+
+  local _srcSpecFile="scripts/linux/fedora/rpm.spec"
+  local _srcSpecFileRelease="$(rpmspec -P "$_srcSpecFile" | grep -E '^Release:'|awk '{print $NF}')"
+  local _dstSrpmDir="scripts/linux/fedora/SRPMS"
+
+  fedoraCreateSRPM \
+    "$_nameForRpm" \
+    "$_versionForRpm" \
+    "$_srcSpecFile" \
+    "$_srcSpecFileRelease" \
+    "$_dstSrpmDir"
+
+  #
+  # RPM
+  #
+
+  local _srpmFile="$_dstSrpmDir/$_nameForRpm-$_versionForRpm-$_srcSpecFileRelease.src.rpm"
+  local _dstRpmDir="scripts/linux/fedora/RPMS"
+
+  while [ $# -ne 0 ]; do
+    local _mockRelease="$(basename "${1%\.cfg}")"
+    local _mockReleaseArg=""
+    if [ -n "$_mockRelease" ]; then
+      _mockReleaseArg="-r $_mockRelease"
+    fi
+
+    mkdir -pv "$_dstRpmDir/$_mockRelease"
+    mock \
+      $_mockReleaseArg \
+      --resultdir="$_dstRpmDir/$_mockRelease" \
+      "$_srpmFile"
+
+    shift 1
+  done
+}
+
+#############################
+# Fedora RPMs
+#############################
+
+if [ "$BUILD_TARGET" = "fedora" ]; then
+  shift 1 # skip "fedora" arg
+
+  if [ $# -eq 0 ]; then
+    "$0" "$BUILD_TARGET" ""
+  else
+    buildFedora "${@}"
+  fi
+
+  exit
+fi
+
 #############################
 # Rest
 #############################
diff --git a/scripts/linux/fedora/.gitignore b/scripts/linux/fedora/.gitignore
new file mode 100644 (file)
index 0000000..ea03173
--- /dev/null
@@ -0,0 +1,2 @@
+/RPMS/
+/SRPMS/
diff --git a/scripts/linux/fedora/rpm.spec b/scripts/linux/fedora/rpm.spec
new file mode 100644 (file)
index 0000000..230aebf
--- /dev/null
@@ -0,0 +1,82 @@
+%global _curaName      __curaName__
+%global _baseDir       __basedir__
+%global _version       __version__
+%global _gitCura       __gitCura__
+%global _gitCuraEngine __gitCuraEngine__
+%global _gitPower      __gitPower__
+
+
+Name:             %{_curaName}
+Version:          %{_version}
+Release:          1%{?dist}
+Summary:          3D printing software aimed at RepRaps and the Ultimaker
+Group:            Applications/Engineering
+
+License:          GPLv2+
+URL:              https://github.com/daid/Cura.git
+Source0:          %{_curaName}-%{_version}.tar.gz
+
+BuildRequires:    libstdc++-static, glibc-static
+Requires:         wxPython, curl
+Requires:         python3-setuptools >= 0.6.34
+Requires:         python3-PyOpenGL >= 3.0.2, PyOpenGL >= 3.0.2
+Requires:         python3-pyserial >= 2.6, pyserial >= 2.6
+Requires:         python3-numpy >= 1.6.2, numpy >= 1.6.2
+Requires:         python3-power >= 1.2
+
+
+%description
+%{_curaName} is a full software solution for 3D printing, aimed at RepRaps and
+the Ultimaker.
+
+It's free software payed for and maintained by Ultimaker.
+
+
+%prep
+%setup -q -n %{name}-%{version}
+
+
+%build
+make -C CuraEngine VERSION=%{_version}
+
+dstDir="%{_baseDir}/usr/share/cura"
+
+rm    -frv "$dstDir"
+mkdir -pv  "$dstDir"
+
+cp -av -t  "$dstDir" \
+  Cura \
+  resources \
+  plugins \
+  CuraEngine/build/CuraEngine \
+  Power/power \
+  scripts/linux/cura.py
+
+echo "%{_version}" > "$dstDir/Cura/version"
+cat > "$dstDir/Cura/versions" << EOF
+# Git SHAs of software used to build %{_curaName}
+Cura       : %{_gitCura}
+CuraEngine : %{_gitCuraEngine}
+Power      : %{_gitPower}
+EOF
+
+
+%install
+mkdir -pv "%{buildroot}"
+cp -av -t "%{buildroot}" "%{_baseDir}/usr"
+
+
+%files
+%defattr(-,root,root)
+%{_bindir}/cura
+%attr(644, root, root) %{_datarootdir}/applications/cura.desktop
+%attr(755, root, root) %{_datarootdir}/cura/Cura/cura.py
+%attr(755, root, root) %{_datarootdir}/cura/Cura/util/pymclevel/mce.py
+%attr(755, root, root) %{_datarootdir}/cura/CuraEngine
+%attr(755, root, root) %{_datarootdir}/cura/cura.py
+%{_datarootdir}/cura
+
+
+%changelog
+* Wed Jan 14 2015 Ferry Huberts <ferry.huberts@pelagic.nl>
+- Initial packaging, currently at version 15.01.RC7
diff --git a/scripts/linux/fedora/usr/bin/cura b/scripts/linux/fedora/usr/bin/cura
new file mode 100755 (executable)
index 0000000..bd9ef0e
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+PYTHONPATH=$PYTHONPATH:/usr/share/cura/ /usr/bin/python /usr/share/cura/cura.py "$@"
diff --git a/scripts/linux/fedora/usr/share/.gitignore b/scripts/linux/fedora/usr/share/.gitignore
new file mode 100644 (file)
index 0000000..90e6af1
--- /dev/null
@@ -0,0 +1 @@
+/cura/
diff --git a/scripts/linux/fedora/usr/share/applications/cura.desktop b/scripts/linux/fedora/usr/share/applications/cura.desktop
new file mode 100755 (executable)
index 0000000..25dcc7f
--- /dev/null
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+Name=Cura
+Comment=Cura
+Icon=/usr/share/cura/resources/images/c.png
+Exec=/usr/bin/python /usr/share/cura/cura.py
+Path=/usr/share/cura/
+StartupNotify=true
+Terminal=false
+Categories=Graphics;3DGraphics;Engineering;Development;