-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
pkgname=ros-humble-usb-cam | ||
_pkgname=usb_cam | ||
pkgver=0.8.0 | ||
pkgrel=0 | ||
pkgdesc="$_pkgname package for ROS humble" | ||
url="http://wiki.ros.org/usb_cam" | ||
arch="all" | ||
license="BSD" | ||
|
||
depends="ffmpeg-dev ros-humble-builtin-interfaces ros-humble-camera-info-manager ros-humble-cv-bridge ros-humble-image-transport ros-humble-image-transport-plugins ros-humble-rclcpp ros-humble-rclcpp-components ros-humble-ros-workspace ros-humble-rosidl-default-runtime ros-humble-sensor-msgs ros-humble-std-msgs ros-humble-std-srvs v4l-utils ffmpeg-dev ros-humble-builtin-interfaces ros-humble-camera-info-manager ros-humble-cv-bridge ros-humble-image-transport ros-humble-image-transport-plugins ros-humble-rclcpp ros-humble-rclcpp-components ros-humble-sensor-msgs ros-humble-std-msgs ros-humble-std-srvs v4l-utils" | ||
makedepends="py3-setuptools py3-rosdep py3-rosinstall py3-rosinstall-generator py3-vcstool chrpath ffmpeg-dev ros-humble-ament-cmake-auto ros-humble-ament-cmake-gtest ros-humble-ament-lint-auto ros-humble-ament-lint-common ros-humble-builtin-interfaces ros-humble-camera-info-manager ros-humble-cv-bridge ros-humble-image-transport ros-humble-image-transport-plugins ros-humble-rclcpp ros-humble-rclcpp-components ros-humble-ros-environment ros-humble-rosidl-default-generators ros-humble-sensor-msgs ros-humble-std-msgs ros-humble-std-srvs v4l-utils" | ||
|
||
subpackages="$pkgname-dbg $pkgname-doc" | ||
|
||
source="" | ||
builddir="$startdir/abuild" | ||
srcdir="/tmp/dummy-src-dir" | ||
buildlog="$builddir/ros-abuild-build.log" | ||
checklog="$builddir/ros-abuild-check.log" | ||
statuslog="$builddir/ros-abuild-status.log" | ||
if [ x${GENERATE_BUILD_LOGS} != "xyes" ]; then | ||
buildlog="/dev/null" | ||
checklog="/dev/null" | ||
statuslog="/dev/null" | ||
fi | ||
|
||
export ROS_PYTHON_VERSION=3 | ||
export PYTHON_VERSION=$(python3 -c 'import sys; print("%i.%i" % (sys.version_info.major, sys.version_info.minor))') | ||
if [ ! -f /usr/ros/humble/setup.sh ]; then | ||
export PYTHONPATH=/usr/ros/humble/lib/python${PYTHON_VERSION}/site-packages:$PYTHONPATH | ||
export AMENT_PREFIX_PATH=/usr/ros/humble | ||
fi | ||
rosinstall="- git: | ||
local-name: usb_cam | ||
uri: https://github.com/ros2-gbp/usb_cam-release.git | ||
version: release/humble/usb_cam/0.8.0-1 | ||
" | ||
|
||
prepare() { | ||
set -o pipefail | ||
mkdir -p $builddir | ||
echo "preparing" > $statuslog | ||
cd "$builddir" | ||
rm -rf src || true | ||
mkdir -p src | ||
echo "$rosinstall" > pkg.rosinstall | ||
vcs import --shallow --input pkg.rosinstall src | ||
find $startdir -maxdepth 1 -name "*.patch" | while read patchfile; do | ||
echo "Applying $patchfile" | ||
(cd src/* && patch -p1 -i $patchfile) | ||
done | ||
} | ||
|
||
build() { | ||
set -o pipefail | ||
echo "building" > $statuslog | ||
cd "$builddir" | ||
if [ -f /usr/ros/humble/setup.sh ]; then | ||
source /usr/ros/humble/setup.sh | ||
fi | ||
mkdir build | ||
cd build | ||
cmake ../src/$_pkgname \ | ||
-DCMAKE_INSTALL_PREFIX=/usr/ros/humble \ | ||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | ||
-DCMAKE_INSTALL_LIBDIR=lib 2>&1 | tee $buildlog | ||
make 2>&1 | tee -a $buildlog | ||
} | ||
|
||
check() { | ||
if [ -f $startdir/NOCHECK ]; then | ||
echo "Check skipped" | tee $checklog | ||
return 0 | ||
fi | ||
set -o pipefail | ||
echo "checking" >> $statuslog | ||
cd "$builddir" | ||
if [ -f /usr/ros/humble/setup.sh ]; then | ||
source /usr/ros/humble/setup.sh | ||
fi | ||
export PYTHONPATH="$builddir"/tmp/pkg/usr/ros/humble/lib/python${PYTHON_VERSION}/site-packages:${PYTHONPATH} | ||
export AMENT_PREFIX_PATH="$builddir"/tmp/pkg/usr/ros/humble:${AMENT_PREFIX_PATH} | ||
export PATH="$builddir"/tmp/pkg/usr/ros/humble/bin:${PATH} | ||
export LD_LIBRARY_PATH="$builddir"/tmp/pkg/usr/ros/humble/lib:${LD_LIBRARY_PATH} | ||
mkdir -p "$builddir"/tmp/pkg | ||
cd build | ||
make install DESTDIR="$builddir"/tmp/pkg | ||
if [ $(make -q test > /dev/null 2> /dev/null; echo $?) -eq 1 ]; then | ||
make test 2>&1 | tee $checklog | ||
fi | ||
} | ||
|
||
dbg() { | ||
mkdir -p "$subpkgdir" | ||
default_dbg | ||
} | ||
|
||
package() { | ||
echo "packaging" >> $statuslog | ||
mkdir -p "$pkgdir" | ||
cd "$builddir" | ||
export DESTDIR="$pkgdir" | ||
|
||
if [ -f /usr/ros/humble/setup.sh ]; then | ||
source /usr/ros/humble/setup.sh | ||
fi | ||
cd build | ||
make install | ||
|
||
# Tweak invalid RPATH | ||
find $pkgdir -name "*.so" | while read so; do | ||
chrpath_out=$(chrpath ${so} || true) | ||
if echo ${chrpath_out} | grep -q "RPATH="; then | ||
rpath=$(echo -n "${chrpath_out}" | sed -e "s/^.*RPATH=//") | ||
if echo "${rpath}" | grep -q -e "\(home\|aports\)"; then | ||
echo "RPATH contains home/aports!: ${rpath}" | ||
rpathfix=$(echo -n "${rpath}" | tr ":" "\n" \ | ||
| grep -v -e home | grep -v -e aports \ | ||
| tr "\n" ":" | sed -e "s/:$//; s/::/:/;") | ||
echo "Fixing to ${rpathfix}" | ||
chrpath -r ${rpathfix} ${so} || (echo chrpath failed; false) | ||
fi | ||
fi | ||
done | ||
|
||
# Tweak hardcoded library versions | ||
find $pkgdir -name "*.cmake" | while read cm; do | ||
libs=$(sed -n '/^set(libraries/{s/^.*"\(.*\)")$/\1/;s/;/ /g;p}' $cm) | ||
for lib in $libs; do | ||
rep= | ||
# lib.so.0.1.2 -> lib.so.0.1 | ||
if echo $lib | grep -q -e '\.so\.[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$'; then | ||
rep=$(echo $lib | sed -e 's/\(\.so\.[0-9]\{1,\}\.[0-9]\{1,\}\)\.[0-9]\{1,\}$/\1/') | ||
fi | ||
# lib-0.1.so.2 -> lib-0.1.so | ||
if echo $lib | grep -q -e '-[0-9]\{1,\}\.[0-9]\{1,\}\.so\.[0-9]\{1,\}$'; then | ||
rep=$(echo $lib | sed -e 's/\(-[0-9]\{1,\}\.[0-9]\{1,\}\.so\)\.[0-9]\{1,\}$/\1/') | ||
fi | ||
|
||
if [ ! -z "$rep" ]; then | ||
if [ -f $rep ]; then | ||
echo "$cm: $lib -> $rep" | ||
sed -e "s|\([\";]\)$lib\([\";]\)|\1$rep\2|g" -i $cm | ||
else | ||
echo "$cm: $lib is specified, but $rep doesn't exist" | ||
fi | ||
fi | ||
done | ||
done | ||
|
||
# Install license files | ||
licensedir="$pkgdir"/usr/share/licenses/$pkgname/ | ||
cd $builddir/src/$_pkgname | ||
find . \ | ||
-iname "license*" -or \ | ||
-iname "copyright*" -or \ | ||
-iname "copying*" -or \ | ||
-iname "gnu-*gpl*" \ | ||
| while read file; do | ||
# Copy license files under the source | ||
if echo $file | grep -e '^\./\.'; then | ||
# Omit files under hidden directory | ||
continue | ||
fi | ||
if echo $file | grep -e '^\./build/'; then | ||
# Omit files under build directory | ||
continue | ||
fi | ||
echo "Copying license files from source tree: $file" | ||
install -Dm644 $file "$licensedir"/$file | ||
done | ||
if [ -f $startdir/LICENSE ]; then | ||
# If LICENSE file is in aports directory, copy it | ||
echo "Copying license file from aports" | ||
install -Dm644 $startdir/LICENSE "$licensedir"/LICENSE | ||
fi | ||
if [ -f $startdir/LICENSE_URLS ]; then | ||
# If LICENSE_URLS file is in aports directory, download it | ||
echo "Downloading license file from URLs" | ||
cat $startdir/LICENSE_URLS | while read url; do | ||
echo "- $url" | ||
mkdir -p "$licensedir" | ||
wget -O "$licensedir"/$(basename $url) $url | ||
done | ||
fi | ||
if [ -z "$(find "$licensedir" -type f)" ]; then | ||
# If no explicit license file found, extract from source files | ||
mkdir -p "$licensedir" | ||
echo "Copying license from source file headers" | ||
find . -name "*.h" -or -name "*.c" -or -name "*.cpp" -or -name "*.py" | while read file; do | ||
echo "Checking license header in $file" | ||
tmplicense=$(mktemp) | ||
# Extract heading comment | ||
sed -n '1{/^#!/d}; | ||
/\/\*/{/\*\//d; :l0; p; n; /\*\//!b l0; p; q}; | ||
/^\s*#/{:l1; /^#!/!p; n; /^\s*#/b l1; q}; | ||
/^\s*\/\//{:l2; p; n; /^\s*\/\//b l2; q};' $file > $tmplicense | ||
# Remove comment syntax | ||
sed 's/\/\*//; s/\*\///; s/^s*\/\/\s\{0,1\}//; | ||
s/^ \* \{0,1\}//; s/^\s*# \{0,1\}//; s/\s\+$//;' -i $tmplicense | ||
# Trim empty lines | ||
sed ':l0; /^$/d; n; /^$/!b l0; :l1; n; b l1;' -i $tmplicense | ||
sed '${/^$/d}' -i $tmplicense | ||
|
||
if ! grep -i -e "\(license\|copyright\|copyleft\)" $tmplicense > /dev/null; then | ||
# Looks not like a license statement | ||
echo "No license statement" | ||
rm -f $tmplicense | ||
continue | ||
fi | ||
|
||
echo "Checking duplication" | ||
licenses=$(mktemp) | ||
find "$licensedir" -type f > $licenses | ||
savethis=true | ||
while read existing; do | ||
if diff -bBiw $tmplicense $existing > /dev/null; then | ||
# Same license statement found | ||
savethis=false | ||
break | ||
fi | ||
done < $licenses | ||
|
||
if $savethis; then | ||
# Save license statement | ||
local num=0 | ||
while true; do | ||
newfile="$licensedir"/LICENSE.$num | ||
if [ ! -f "$newfile" ]; then | ||
echo "Saving license statement as $newfile" | ||
mv $tmplicense $newfile | ||
break | ||
fi | ||
num=$(expr $num + 1) | ||
done | ||
fi | ||
|
||
rm -f $licenses $tmplicense | ||
done | ||
fi | ||
# List license files | ||
echo "License files:" | ||
find "$licensedir" -type f | xargs -n1 echo "-" | ||
|
||
echo "finished" >> $statuslog | ||
} | ||
|
||
doc() { | ||
mkdir -p $subpkgdir | ||
|
||
default_doc | ||
} | ||
|
||
if [ -f ./apkbuild_hook.sh ]; then | ||
. ./apkbuild_hook.sh | ||
apkbuild_hook | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/include/usb_cam/formats/mjpeg.hpp b/include/usb_cam/formats/mjpeg.hpp | ||
index 2faff23..2b40bb2 100644 | ||
--- a/include/usb_cam/formats/mjpeg.hpp | ||
+++ b/include/usb_cam/formats/mjpeg.hpp | ||
@@ -233,7 +233,7 @@ private: | ||
std::cerr << m_averror_str << std::endl; | ||
} | ||
|
||
- AVCodec * m_avcodec; | ||
+ const AVCodec * m_avcodec; | ||
AVCodecContext * m_avcodec_context; | ||
AVCodecParserContext * m_avparser; | ||
AVFrame * m_avframe_device; |
14 changes: 14 additions & 0 deletions
14
ros/humble.v3.17/ros-humble-usb-cam/disable-uncrustify-test.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 791070e..5ea8532 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -105,6 +105,9 @@ endif() | ||
if(BUILD_TESTING) | ||
if($ENV{ROS_VERSION} EQUAL 2) | ||
find_package(ament_lint_auto REQUIRED) | ||
+ list(APPEND AMENT_LINT_AUTO_EXCLUDE | ||
+ ament_cmake_uncrustify | ||
+ ) | ||
ament_lint_auto_find_test_dependencies() | ||
|
||
find_package(ament_cmake_gtest) |