-
Notifications
You must be signed in to change notification settings - Fork 197
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
Packaging #148
base: linux-diagnostics-with-packaging
Are you sure you want to change the base?
Packaging #148
Changes from 3 commits
721b98c
65146fa
b0ed4e0
dc17685
2073b91
a9d6e3a
734b908
f2d97aa
85514da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/python | ||
#!/usr/bin/python3 | ||
from bcc import BPF | ||
from bcc.utils import printb | ||
from time import sleep | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/python | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
#!/usr/bin/python3 | ||
from bcc import BPF | ||
from bcc.utils import printb | ||
from time import sleep | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/bash | ||
|
||
PACKAGE_TREE="$(dirname $(dirname $(readlink -f $0)))" | ||
run() { | ||
if [[ $1 == "nfs" ]] || [[ $1 == "cifs" ]]; | ||
then | ||
if [[ $1 == "nfs" ]] | ||
then script_path="${PACKAGE_TREE}/lib/NfsDiagnostics/nfsclientlogs.sh" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: I'm a little divided about pushing nfsclientlogs (and the smb equivalent) into |
||
else script_path="${PACKAGE_TREE}/lib/SMBDiagnostics/smbclientlogs.sh" | ||
fi | ||
$script_path "$@" | ||
|
||
else | ||
echo "Usage: diag-main.sh <cifs | nfs> <start | stop> [Version] [CaptureNetwork] [OnAnomaly]" >&2 | ||
fi | ||
} | ||
|
||
run "$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Package: $PKG_NAME | ||
Version: $VERSION | ||
Maintainer: Microsoft | ||
Architecture: all | ||
Description: Diagnostics scripts for CIFS and NFS. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
chown root:root $SYS_DIR/bin/diag-main.sh | ||
chmod 454 $SYS_DIR/bin/diag-main.sh |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rm -rf $SYS_DIR |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export PKG_NAME=azure-files-diag | ||
export RELEASE=1 | ||
export VERSION=1 | ||
export SYS_DIR=/opt/xstore | ||
export SRC_DIR=.. | ||
# export PKG_BUILD=$(PKG_NAME)$(sles)-$(RELEASE)-1.x86_64 | ||
# export PKG_DIR=BUILDROOT/$(PKG_BUILD) | ||
export PKG_DIR=$(PKG_NAME) | ||
export DEB_PKG_DIR=$(PKG_DIR)/DEBIAN | ||
export OPT_DIR=$(PKG_DIR)$(SYS_DIR) | ||
|
||
build: init debian rpm clean | ||
echo "Building deb and rpm packages" | ||
|
||
init: | ||
mkdir -p $(OPT_DIR)/bin | ||
mkdir -p $(OPT_DIR)/lib | ||
cp -r ../NfsDiagnostics $(OPT_DIR)/lib | ||
cp -r ../SMBDiagnostics $(OPT_DIR)/lib | ||
cp -r ../diag-main.sh $(OPT_DIR)/bin | ||
|
||
debian: init | ||
cp -r ./DEBIAN ./$(PKG_DIR) | ||
for file in ./$(PKG_DIR)/DEBIAN/*; do \ | ||
sed -i "s/\$$PKG_NAME/${PKG_NAME}/g" $$file; \ | ||
sed -i "s:\$$SYS_DIR:${SYS_DIR}:g" $$file; \ | ||
sed -i "s/\$$VERSION/${VERSION}/g" $$file; \ | ||
done | ||
dpkg-deb --build ./$(PKG_DIR) | ||
|
||
rpm: init | ||
mkdir -p ~/rpmbuild/SOURCES | ||
cp -r $(PKG_DIR)/opt ~/rpmbuild/SOURCES | ||
cp ./RPM/spec.spec . | ||
sed -i "s:\$$SYS_DIR:${SYS_DIR}:g" spec.spec | ||
sed -i "s:\$$PKG_NAME:${PKG_NAME}:g" spec.spec | ||
sed -i "s:\$$VERSION:${VERSION}:g" spec.spec | ||
sed -i "s:\$$RELEASE:${RELEASE}:g" spec.spec | ||
rpmbuild -bb spec.spec | ||
mv ~/rpmbuild/RPMS/x86_64/*.rpm . | ||
rm -r ~/rpmbuild | ||
|
||
clean: | ||
rm -rf ./$(PKG_DIR) spec.spec |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Run `make` to generate both .deb and .rpm packages and clean the build directories or individually run the following: | ||
|
||
- Run `make debian` to generate .deb package | ||
- Run `make rpm` to generate .rpm package | ||
- Run `make clean` once the packages are created. | ||
|
||
Edit `DEBIAN/control` and `RPM/spec.spec` files to change package description or maintainer information. \ | ||
Edit `Makefile` to make changes to PKG_NAME, RELEASE or VERSION, etc. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Name: $PKG_NAME | ||
Version: $VERSION | ||
Release: $RELEASE | ||
Summary: Diagnostics scripts for NFS and CIFS | ||
License: GPL | ||
URL: https://example.com | ||
|
||
%description | ||
Diagnostics scripts for NFS and CIFS | ||
|
||
%prep | ||
|
||
%install | ||
# Install script and related files | ||
# install -m 454 ~/opt/xstore/bin/diag-main.sh %{buildroot}/opt/xstore/bin/diag-main.sh | ||
cp -r ~/rpmbuild/SOURCES/opt %{buildroot} | ||
echo %{buildroot} | ||
|
||
%post | ||
chmod 454 $SYS_DIR/bin/diag-main.sh | ||
|
||
%files | ||
# List all the files that are part of the package | ||
# /opt/xstore/bin/diag-main.sh | ||
$SYS_DIR/bin/diag-main.sh | ||
$SYS_DIR/lib/NfsDiagnostics/README | ||
$SYS_DIR/lib/NfsDiagnostics/nfsclientlogs.sh | ||
$SYS_DIR/lib/NfsDiagnostics/trace-nfsbpf | ||
$SYS_DIR/lib/SMBDiagnostics/README | ||
$SYS_DIR/lib/SMBDiagnostics/smbclientlogs.sh | ||
$SYS_DIR/lib/SMBDiagnostics/trace-cifsbpf | ||
%changelog | ||
|
||
%postun | ||
rm -r $SYS_DIR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, Python3 is not available by default on at least some of the distros that we support (RHEL 7?). It might be a better idea to invoke Python as
/usr/bin/env python
. IIRC the scripts work the same across Python 2 & 3.