Skip to content

Commit bf510fa

Browse files
committed
new: dev: add scapy spec and patch with matching workflow, update readme
Signed-off-by: Stephen L Arnold <sarnold@vctlabs.com>
1 parent e3f968c commit bf510fa

File tree

4 files changed

+289
-0
lines changed

4 files changed

+289
-0
lines changed

.github/workflows/scapy.yml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: scapy RPMs
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
10+
jobs:
11+
get_version:
12+
name: Get version info
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
defaults:
17+
run:
18+
shell: bash
19+
outputs:
20+
version: ${{ steps.spec_ver.outputs.version }}
21+
22+
steps:
23+
- uses: actions/checkout@v6
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Get package version
28+
id: spec_ver
29+
run: |
30+
version=$(make version)
31+
echo "version=${version}" >> $GITHUB_OUTPUT
32+
echo Version from spec: $version
33+
env:
34+
NAME: python-scapy
35+
36+
build_rpms:
37+
name: scapy-rpms
38+
timeout-minutes: 30
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
name: [rocky9]
43+
include:
44+
- name: rocky9
45+
spec: python-scapy
46+
image: quay.io/rockylinux/rockylinux:9
47+
48+
runs-on: ubuntu-latest
49+
needs: [get_version]
50+
container:
51+
image: ${{ matrix.image }}
52+
permissions:
53+
contents: read
54+
defaults:
55+
run:
56+
shell: bash
57+
env:
58+
PYTHONIOENCODING: utf-8
59+
60+
steps:
61+
- uses: actions/checkout@v6
62+
with:
63+
fetch-depth: 0
64+
65+
# Work-around for https://github.com/actions/runner-images/issues/6775
66+
- name: Change Owner of Container Working Directory
67+
if: matrix.image
68+
run: chown root.root .
69+
70+
- name: Check version
71+
env:
72+
VERSION: ${{ needs.get_version.outputs.version }}
73+
run: |
74+
echo Dev version from get_version step: $VERSION
75+
76+
- name: Install deps for rpm builds (centos/rocky)
77+
run: |
78+
bash scripts/install_deps_el9.sh
79+
80+
- name: Build rpm pkgs
81+
run: |
82+
NAME="${{ matrix.spec }}" make packages
83+
env:
84+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.get_version.outputs.version }}
85+
VERSION: ${{ needs.get_version.outputs.version }}
86+
87+
- name: Upload rpm files
88+
uses: actions/upload-artifact@v6
89+
with:
90+
name: packages
91+
path: |
92+
tmp/RPMS/*/*.rpm
93+
tmp/SRPMS/*.rpm
94+
95+
create-release:
96+
name: Create scapy Release
97+
runs-on: ubuntu-latest
98+
needs: [get_version, build_rpms]
99+
permissions:
100+
contents: write
101+
steps:
102+
- name: Checkout
103+
uses: actions/checkout@v6
104+
105+
- name: Download Artifacts
106+
uses: actions/download-artifact@v7
107+
with:
108+
name: packages
109+
path: packages
110+
111+
- name: List Artifacts
112+
run: find . -maxdepth 3 -name \*.rpm
113+
114+
- name: Fetch tags
115+
run: git fetch --tags --prune --quiet
116+
117+
- name: Tag Release
118+
id: tag_release
119+
if: ${{ github.event_name != 'pull_request' }}
120+
run: |
121+
set +e
122+
if git rev-list "scapy-${{ needs.get_version.outputs.version }}" >/dev/null 2>&1 ; then
123+
echo "Tag for scapy-${{ needs.get_version.outputs.version }} already exists. Skipping release creation."
124+
echo "NEW_RELEASE=false" >> $GITHUB_OUTPUT
125+
else
126+
git tag "scapy-${{ needs.get_version.outputs.version }}"
127+
git push origin "scapy-${{ needs.get_version.outputs.version }}"
128+
echo "NEW_RELEASE=true" >> $GITHUB_OUTPUT
129+
fi
130+
131+
- name: Create draft release
132+
id: create_release
133+
if: ${{ github.event_name != 'pull_request' && steps.tag_release.outputs.NEW_RELEASE == 'true' }}
134+
uses: softprops/action-gh-release@v2
135+
env:
136+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137+
with:
138+
tag_name: scapy-${{ needs.get_version.outputs.version }}
139+
name: RPM Release scapy-${{ needs.get_version.outputs.version }}
140+
body: Latest RPMs for scapy-${{ needs.get_version.outputs.version }}
141+
draft: false
142+
prerelease: false
143+
files: |
144+
packages/RPMS/*/*.rpm
145+
packages/SRPMS/*.rpm

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ or RPM repo host).
5454
pyprctl |pyprctl|
5555
pyserv |pyserv|
5656
rpmget |rpmget|
57+
scapy |scapy|
5758
stoppy |stoppy|
5859
timed-count |timed-count|
5960
tftpy |tftpy|
@@ -120,6 +121,10 @@ or RPM repo host).
120121
:target: https://sarnold.github.io/rpmget/
121122
:alt: rpmget RPM status
122123

124+
.. |scapy| image:: https://github.com/VCTLabs/el9-rpm-toolbox/actions/workflows/scapy.yml/badge.svg
125+
:target: https://github.com/secdev/scapy
126+
:alt: scapy RPM status
127+
123128
.. |stoppy| image:: https://github.com/VCTLabs/el9-rpm-toolbox/actions/workflows/stoppy.yml/badge.svg
124129
:target: https://github.com/morefigs/stoppy
125130
:alt: stoppy RPM status

specs/python-scapy.spec

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Name: scapy
2+
Version: 2.7.0
3+
Release: 1%{?dist}
4+
Summary: Interactive packet manipulation tool and network scanner
5+
6+
License: GPLv2
7+
URL: http://www.secdev.org/projects/scapy/
8+
Source0: https://github.com/secdev/scapy/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
9+
Patch0: scapy-2.7.0-rhel9.patch
10+
11+
%global common_desc %{expand:
12+
Scapy is a powerful interactive packet manipulation program built on top
13+
of the Python interpreter. It can be used to forge or decode packets of
14+
a wide number of protocols, send them over the wire, capture them, match
15+
requests and replies, and much more.}
16+
17+
18+
# By default build with python3 subpackage
19+
%bcond_without python3
20+
%bcond_with python2
21+
%bcond_with doc
22+
23+
BuildArch: noarch
24+
25+
BuildRequires: make
26+
BuildRequires: sed
27+
28+
BuildRequires: python%{python3_pkgversion}-devel
29+
BuildRequires: python%{python3_pkgversion}-setuptools
30+
31+
Recommends: tcpdump
32+
# Using database of manufactures /usr/share/wireshark/manuf
33+
Recommends: wireshark-cli
34+
35+
%description %{common_desc}
36+
37+
%package -n python%{python3_pkgversion}-%{name}
38+
Summary: Interactive packet manipulation tool and network scanner
39+
40+
%{?python_provide:%python_provide python%{python3_pkgversion}-%{name}}
41+
Provides: %{name} = %{version}-%{release}
42+
43+
Recommends: PyX
44+
Recommends: python%{python3_pkgversion}-matplotlib
45+
Recommends: ipython3
46+
47+
%description -n python%{python3_pkgversion}-%{name}
48+
%{common_desc}
49+
50+
51+
%prep
52+
%autosetup -p 1 -n %{name}-%{version}
53+
54+
# Remove shebang
55+
# https://github.com/secdev/scapy/pull/2332
56+
SHEBANGS=$(find ./scapy -name '*.py' -print | xargs grep -l -e '^#!.*env python')
57+
for FILE in $SHEBANGS ; do
58+
sed -i.orig -e 1d "${FILE}"
59+
touch -r "${FILE}.orig" "${FILE}"
60+
rm "${FILE}.orig"
61+
done
62+
63+
%build
64+
%py3_build
65+
66+
%install
67+
install -dp -m0755 %{buildroot}%{_mandir}/man1
68+
install -Dp -m0644 doc/scapy.1* %{buildroot}%{_mandir}/man1/
69+
70+
%py3_install
71+
rm -f %{buildroot}%{python3_sitelib}/*egg-info/requires.txt
72+
73+
# Rename the executables
74+
mv -f %{buildroot}%{_bindir}/scapy %{buildroot}%{_bindir}/scapy3
75+
76+
# Link the default to the python3 version of executables
77+
ln -s %{_bindir}/scapy3 %{buildroot}%{_bindir}/scapy
78+
79+
# check
80+
# TODO: Need to fix/remove slow/failed test
81+
# cd test/
82+
# ./run_tests_py2 || true
83+
# ./run_tests_py3 || true
84+
85+
86+
%files -n python%{python3_pkgversion}-%{name}
87+
%license LICENSE
88+
%doc %{_mandir}/man1/scapy.1*
89+
%{_bindir}/scapy
90+
%{_bindir}/scapy3
91+
%{python3_sitelib}/scapy/
92+
%{python3_sitelib}/scapy-*.egg-info
93+
%exclude %{python3_sitelib}/test
94+
95+
96+
%changelog
97+
* Tue Jan 06 2026 Stephen Arnold <nerdboy@gentoo.org> - 2.7.0
98+
- New/upgraded package

specs/scapy-2.7.0-rhel9.patch

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff -ruN scapy-2.7.0/pyproject.toml /home/mambroz/rpmbuild/BUILD/scapy-2.7.0/pyproject.toml
2+
--- scapy-2.7.0/pyproject.toml 2025-12-25 12:31:39.000000000 +0000
3+
+++ /home/mambroz/rpmbuild/BUILD/scapy-2.7.0/pyproject.toml 2026-01-05 12:38:06.679524673 +0000
4+
@@ -1,5 +1,5 @@
5+
[build-system]
6+
-requires = [ "setuptools>=62.0.0" ]
7+
+requires = [ "setuptools>=53.0.0" ]
8+
build-backend = "setuptools.build_meta"
9+
10+
[project]
11+
diff -ruN scapy-2.7.0/setup.cfg /home/mambroz/rpmbuild/BUILD/scapy-2.7.0/setup.cfg
12+
--- scapy-2.7.0/setup.cfg 1970-01-01 00:00:00.000000000 +0000
13+
+++ /home/mambroz/rpmbuild/BUILD/scapy-2.7.0/setup.cfg 2026-01-05 12:38:06.682524715 +0000
14+
@@ -0,0 +1,16 @@
15+
+[metadata]
16+
+name = scapy
17+
+version = attr: scapy.VERSION
18+
+
19+
+[options]
20+
+packages = find:
21+
+python_requires = >=3.6
22+
+
23+
+[options.entry_points]
24+
+console_scripts =
25+
+ scapy = scapy.main:interact
26+
+
27+
+[options.packages.find]
28+
+exclude =
29+
+ test
30+
+ test.*
31+
diff -ruN scapy-2.7.0/setup.py /home/mambroz/rpmbuild/BUILD/scapy-2.7.0/setup.py
32+
--- scapy-2.7.0/setup.py 2025-12-25 12:31:39.000000000 +0000
33+
+++ /home/mambroz/rpmbuild/BUILD/scapy-2.7.0/setup.py 2026-01-05 12:38:06.681524701 +0000
34+
@@ -82,6 +82,7 @@
35+
_build_version(self.build_lib)
36+
37+
setup(
38+
+ name="scapy",
39+
cmdclass={'sdist': SDist, 'build_py': BuildPy},
40+
data_files=[('share/man/man1', ["doc/scapy.1"])],
41+
long_description=get_long_description(),

0 commit comments

Comments
 (0)