I'm working on salt-stack for setting up multiple machines, I wanted to ask how can we deploy rpms(placed at a custom location in master) on to the minions? I already have an idea of how can we install packages using top.sls file and name of the package that needs to be installed on minions but what I'm looking for is to deploy my custom rpms on to the minions from master.
There are two ways to approach this:
Option 1:
Define the list of RPMs in a pillar file:
package_names:
- custom-rpm1: custom-rpm1-2.6.1-2.el7.x86_64.rpm
- custom-rpm2: custom-rpm2-release-el7-3.noarch.rpm
- custom-rpm3: custom-rpm3-latest.noarch.rpm
Then in an SLS file:
install-rpm:
pkg.installed:
- sources: {{ pillar['package_names'] }}
Option 2:
Copy the directory containing the RPMs (salt://rpms in below example is relative to file_roots) to target machine and use rpm command to install (with wildcard):
copy-rpms-dir:
file.recurse:
- name: /tmp/rpms
- source: salt://rpms
install-rpms:
cmd.run:
- name: rpm -ivh /tmp/rpms/*.rpm
- success_retcodes:
- 2
Installing with rpm command requires extra check for return codes as it returns non-zero (2) when RPM is already installed.
I'm trying to configure a template project for my STM32 blue pill board with CMake and cmake-tools for Visual Studio Code. It builds just fine, but the Intellisense feature of cmake-tools seems not to work with an external library (libopencm3 in this case).
This is most likely a configuration error on my side. Following my CMakeLists.txt. The toolchain is defined in a seperate .cmake file.
set(PRJ_NAME STM32_Template_Project)
cmake_minimum_required(VERSION 3.6)
project(${PRJ_NAME} C ASM)
set(COMMON_FLAGS "-mcpu=${MCU_ARCH} -mthumb -mthumb-interwork -mfloat-abi=${MCU_FLOAT_ABI} -ffunction-sections -fdata-sections -g -fno-common -fmessage-length=0 -DSTM32F1")
if (MCU_FLOAT_ABI STREQUAL hard)
set(COMMON_FLAGS "${COMMON_FLAGS} -mfpu=${MCU_FPU}")
endif ()
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++11")
set(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=gnu99")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections -T ${CMAKE_SOURCE_DIR}/${MCU_LINKER_SCRIPT}")
set(DEFINITIONS "${DEFINITIONS} -D${MCU_LINE}")
set(LIBOPENCM3_DIR "../libopencm3")
#headers
include_directories(sys)
include_directories(Inc)
include_directories(${LIBOPENCM3_DIR}/include)
# libopencm3
# Make sure that git submodule is initialized and updated
if (NOT EXISTS ${LIBOPENCM3_DIR}/Makefile)
message(FATAL_ERROR "libopencm3 submodule not found. Initialize with 'git submodule update --init' in the source directory")
endif()
add_custom_target(libopencm3 make TARGETS=stm32/f1 WORKING_DIRECTORY ${LIBOPENCM3_DIR})
link_directories(${LIBOPENCM3_DIR}/lib)
#files
file(GLOB_RECURSE USER_SOURCES Src/*.c)
set(CMSIS_STARTUP startup_${MCU_LINE}.s)
set(SOURCE_FILES ${USER_SOURCES} ${CMSIS_STARTUP} ${MCU_LINKER_SCRIPT})
# target
add_executable(${PROJECT_NAME}.elf ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME}.elf opencm3_stm32f1)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.map")
set(HEX_FILE ${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_SOURCE_DIR}/build/${PROJECT_NAME}.bin)
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
COMMENT "Building ${HEX_FILE} \nBuilding ${BIN_FILE}")
I am not very experienced with CMake and cmake-tools.
My repository is set up similar to the following:
repo_base
- artwork
- app
- designsystem
- api
Since each of the other folders in the repo (e.g. app, api, designsystem) depend on artwork, I have symlinks in place when running locally. This is working fine, as the path for images in the designsystem subdirectory is something like ../../artwork. When you check out the repository, the entire tree is checked out, so the symlinks are pointing to the correct directory.
However, when I deploy with capistrano, I use :repo_tree to only deploy a portion of the overall monorepo. For example, the deploy.rb script for the designsystem folder looks like:
# config valid for current version and patch releases of Capistrano
lock "~> 3.11.0"
set :application, "designsystem"
set :repo_url, "git#gitlab.com:myuser/mymonorepo"
set :deploy_to, "/var/www/someplace.net/designsystem.someplace.net"
set :deploy_via, "remote_cache_with_project_root"
set :repo_tree, 'designsystem'
set :log_level, :error
before 'deploy:set_current_revision', 'deploy:buildMonolith'
The problem, of course, is that this only ends up deploying the designsystem subdirectory. Thus, the symlinks aren't valid, and are actually skipped in the building (buildMonolith step).
I'm wondering how I might go about having capistrano check out another subdirectory, artwork, and placing it somewhere in the repository source tree.
I was able to solve this by adding a capistrano task called assets.rb:
require 'pathname'
##
# Import assets from a top level monorepo directory into the current working
# directory.
#
# When you use :repo_tree to deploy a specific directory of a monorepo, but your
# asset repository is in a different directory, you need to check out this
# top-level directory and add it to the deployment path. For example, if your
# monorepo directory structure looks something like:
#
# - /app
# - src/
# - assets -> symlink to ../../assets
# - /assets
# - /api
#
# And you want to deploy /app, the symlink to the upper directory won't exist if
# capistrano is configured to use :repo_tree "app". In order to overcome this,
# this task checks out a specified piece of the larger monorepo (in this case,
# the assets directory), and places it in the deployment directory at a
# specified location.
#
# Configuration:
# In your deploy/<stage>.rb file, you will need to specify two variables:
# - :asset_path - The location within the deployment directory where the
# assets should be placed. Relative to the deployment working
# directory.
# - :asset_source - The location of the top-level asset folder in the
# monorepo. Relative to the top level of the monorepo (i.e.
# the directory that would be used as a deployment if
# :repo_tree was not specified).
#
# In the above example, you would specify:
#
# set :asset_path, "src/assets"
# set :asset_source, "assets"
#
namespace :deploy do
desc "Import assets from a top-level monorepo directory"
task :import_assets do
on roles(:all) do |host|
within repo_path do
final_asset_location = "#{release_path}/#{fetch(:asset_path)}"
asset_stat_result = capture "stat", "-t", "#{final_asset_location}"
asset_stat_result = asset_stat_result.split(" ")
if asset_stat_result[0] == "#{final_asset_location}"
info "Removing existing asset directory #{final_asset_location}..."
execute "rm", "-rf", "#{final_asset_location}"
end
source_dir = Pathname.new(final_asset_location).parent.to_s
info "Importing assets to #{source_dir}/#{fetch(:asset_source)}"
execute "GIT_WORK_TREE=#{source_dir}", :git, "checkout", "#{fetch(:branch)}", "--", "#{fetch(:asset_source)}"
info "Moving asset directory #{source_dir}/#{fetch(:asset_source)} to #{final_asset_location}..."
execute :mv, "#{source_dir}/#{fetch(:asset_source)}", "#{final_asset_location}"
end
end
end
end
It would be nice if I could somehow link into the git scm plugin, rather than calling git from the command line directly.
I am trying to install my external package, which is built fine by the cross-compile toolchain but fails on the install step with the error
Install the project...
-- Install configuration: "Release"
-- Installing: /home/username/Projects/ProjectName/ProjectName_software/ProjectName_OS/build_ProjectName_os_raspberrypi3/target/home/username/Projects/ProjectName/ProjectName_software/ProjectName_
OS/build_ProjectName_os_raspberrypi3/build/APPNAME/APPNAME
APPNAME: installs files in /home/userName/Projects/ProjectName/ProjectName_software/ProjectName_OS/build_ProjectName_os_raspberrypi3/target//home/username/Projects/ProjectName/ProjectName
_software/ProjectName_OS/build_ProjectName_os_raspberrypi3
package/pkg-generic.mk:315: recipe for target '/home/alex/Projects/BlackBox/bbefx_software/BBEFX_OS/build_bbefx_os_raspberrypi3/build/BBEFX_CORE/.stamp_
target_installed' failed
I am guessing that the path prefixed by --Installing is the one generated by the package makefile and the one prefixed by APPNAME is the one that buildroot is expecting APPNAME to install to. Hence why the .stamp_target_install fails
The obvious issue is that the path buildroot expects is
/target//home/username/
This isn't the path that I would like to install to (usr/bin would be preferable). However I can't see how to specify a path within the package make file, which is as follows:
APPNAME_SITE = $(TOPDIR)/../../APPNAME
APPNAME_SITE_METHOD = local
APPNAME_INSTALL_TARGET = YES
$(eval $(cmake-package))
With the CMakeLists.txt being:
#
# CMake options
#
# CMake version
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
option(BUILD_DOC "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
# project name
project(APPNAME)
IF(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "No build type selected, default to Release")
SET(CMAKE_BUILD_TYPE "Release")
ENDIF()
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
IF(CMAKE_BUILD_TYPE AND
NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE)$")
MESSAGE(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
ENDIF()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DDEBUG)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++14")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -std=c++14")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++14")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -w -std=c++14")
endif()
# enable c++
enable_language(C CXX)
# project version
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)
# Find all sources and headers in the source folder
file(GLOB_RECURSE APPNAME_SOURCES "source/*.cpp")
file(GLOB_RECURSE APPNAME_HEADERS "source/*.hpp" "source/*.h")
# Add header directories, remove dupes
set (APPNAME_INCLUDE_DIRS "")
foreach (_headerFile ${APPNAME_HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list (APPEND APPNAME_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES APPNAME_INCLUDE_DIRS)
# Add sources and headers to exec
add_executable (APPNAME ${APPNAME_SOURCES})
target_include_directories(APPNAME PRIVATE ${APPNAME_INCLUDE_DIRS})
# Add Libs to link
find_package(libconfigpp REQUIRED)
find_package(Boost COMPONENTS system log REQUIRED)
include_directories(${LIBCONFIGPP_INCLUDE_DIR} $Boost_INCLUDE_DIRS)
target_link_libraries(APPNAME ${Boost_LIBRARIES} ${LIBCONFIGPP_LIBRARIES})
add_definitions(-DBOOST_LOG_DYN_LINK)
# Add platform specific Libs and preproc macros
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_definitions(-DSYSTEM_LINUX)
add_definitions(-D__UNIX_JACK__ )
find_package(libjack REQUIRED)
target_link_libraries(APPNAME ${JACK_LIBRARIES})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(APPNAME Threads::Threads)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
add_definitions(-DSYSTEM_DARWIN)
add_definitions(-D__MACOSX_CORE__)
find_library(COREMIDI_LIBRARY CoreMIDI)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
find_library(COREAUDIO_LIBRARY CoreAudio)
target_link_libraries(APPNAME ${COREFOUNDATION_LIBRARY} ${COREMIDI_LIBRARY} ${COREAUDIO_LIBRARY})
endif()
set(CONFIGFILE source/APPNAME_CONFIG.cfg)
#file(COPY ${CONFIGFILE} DESTINATION ${CMAKE_BINARY_DIR})
install (TARGETS APPNAME DESTINATION ${CMAKE_BINARY_DIR})
#
# Build Documentation
#
find_package(Doxygen)
if(BUILD_DOC)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
endif()
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/source/doc/Doxyfile.in)
set(DOXYFILE ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${DOXYFILE_IN} ${DOXYFILE} #ONLY)
add_custom_target(DOC
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
add_custom_command(TARGET DOC
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/source/doc/Documentation.html ${CMAKE_SOURCE_DIR}/doc
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
endif()
This line:
install (TARGETS APPNAME DESTINATION ${CMAKE_BINARY_DIR})
is wrong. According to the CMake documentation, CMAKE_BINARY_DIR is the The path to the top level of the build tree., which is why your binary gets installed in the wrong place.
Please replace this line with:
install (TARGETS APPNAME DESTINATION bin)
I am trying to verify signature of apk uploaded on my site.
I am trying to execute
String command= "cmd /c jarsigner -verify -verbose -certs " +Filelocation;
Process proc = Runtime.getRuntime().exec(command);
BufferedReader reader=new BufferedReader(new InputStreamReader(proc.getInputStream()));
BufferedReader reader1=new BufferedReader(new InputStreamReader(proc.getErrorStream()));
String line=reader.readLine();
String line1=reader1.readLine();
line output is null and line1 output is"Jarsigner is not recognized internal external command".
I have checked java_home,java.home,java.class.path.
java_home is holding jdk path
java.home is holding jre path
java.class.path holds jboss server>deploy folder.
I am running this part of code on JBOSS Server.
Make sure Java JDK is set on the PATH. In my case put "D:\Java\jdk1.6.0_34\bin" into System Variable PATH.
Make sure the release key and the apk are in the same directory.
1 Make sure below Environment Variables are set:
Variable name: JAVA_HOME
Varaible value: C:\Program Files\Java\jre7 (example only; update path based on your Java library location)
Variable name: Path
Varaible value: %JAVA_HOME%\bin;
2 Make sure that jarsigner.exe file exists in your JAVA library ie.
C:\Program Files\Java\jre7\bin\jarsigner.exe