Skip to content

Commit 5abf417

Browse files
author
panyi
committed
add debian floder
1 parent 2645462 commit 5abf417

11 files changed

+272
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ src/**/*.o
6262
platform/**/*.egg-info
6363
platform/**/*-none-any.whl
6464
platform/**/.pybuild
65-
platform/**/debian/*
65+
#platform/**/debian/*
6666
platform/**/build
6767
platform/**/*.ko
6868
platform/**/*.mod.c
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sonic-centec-platform-modules (1.3) unstable; urgency=low
2+
3+
* Add support for ragile ra-b6010-48gt4x
4+
5+
-- sonic_rd <[email protected]> Mon, 21 Sep 2020 13:34:33 +0800
6+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Source: sonic-centec-platform-modules
2+
Section: main
3+
Priority: extra
4+
Maintainer: shil <[email protected]>
5+
Build-Depends: debhelper (>= 8.0.0), bzip2
6+
Standards-Version: 3.9.3
7+
8+
Package: platform-modules-ra-b6010-48gt4x
9+
Architecture: arm64
10+
Description: kernel modules for platform devices such as fan, led, sfp
11+
12+
Package: platform-modules-ra-b6010-48gt4x-r
13+
Architecture: arm64
14+
Description: kernel modules for platform devices such as fan, led, sfp
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
# This script load/unload centec kernel modules
3+
4+
function install_python_api_package()
5+
{
6+
device="/usr/share/sonic/device"
7+
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
8+
9+
rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null)
10+
if [ $? -ne 0 ]; then
11+
echo -n "Install sonic_platform-1.0-py3-none-any.whl ..."
12+
rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl)
13+
fi
14+
}
15+
16+
function load_kernel_modules()
17+
{
18+
hwaddr=`fw_printenv ethaddr | awk -F = '{print $2}'`
19+
if [ "$hwaddr" != "" ]; then
20+
ifconfig eth0 hw ether $hwaddr
21+
fi
22+
depmod -a
23+
modprobe dal
24+
}
25+
26+
function remove_kernel_modules()
27+
{
28+
modprobe -r dal
29+
}
30+
31+
case "$1" in
32+
start)
33+
echo -n "Load Centec kernel modules... "
34+
35+
load_kernel_modules
36+
install_python_api_package
37+
38+
echo "done."
39+
;;
40+
41+
stop)
42+
echo -n "Unload Centec kernel modules... "
43+
44+
remove_kernel_modules
45+
46+
echo "done."
47+
;;
48+
49+
force-reload|restart)
50+
echo "Not supported"
51+
;;
52+
53+
*)
54+
echo "Usage: /etc/init.d/platform-modules-ra-b6010-48gt4x-r {start|stop}"
55+
exit 1
56+
;;
57+
esac
58+
59+
exit 0
60+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ra-b6010-48gt4x-r/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/arm64-ragile_ra-b6010-48gt4x-r-r0
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
systemctl enable ra-b6010-48gt4x-r_platform.service
2+
systemctl start ra-b6010-48gt4x-r_platform.service
3+
systemctl enable device_i2c.service
4+
systemctl start device_i2c.service
5+
systemctl enable privatenetwork.service
6+
systemctl start privatenetwork.service
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
# This script load/unload centec kernel modules
3+
4+
function install_python_api_package()
5+
{
6+
device="/usr/share/sonic/device"
7+
platform=$(/usr/local/bin/sonic-cfggen -H -v DEVICE_METADATA.localhost.platform)
8+
9+
rv=$(pip3 show sonic-platform > /dev/null 2>/dev/null)
10+
if [ $? -ne 0 ]; then
11+
echo -n "Install sonic_platform-1.0-py3-none-any.whl ..."
12+
rv=$(pip3 install $device/$platform/sonic_platform-1.0-py3-none-any.whl)
13+
fi
14+
}
15+
16+
function load_kernel_modules()
17+
{
18+
hwaddr=`fw_printenv ethaddr | awk -F = '{print $2}'`
19+
if [ "$hwaddr" != "" ]; then
20+
ifconfig eth0 hw ether $hwaddr
21+
fi
22+
depmod -a
23+
modprobe dal
24+
}
25+
26+
function remove_kernel_modules()
27+
{
28+
modprobe -r dal
29+
}
30+
31+
case "$1" in
32+
start)
33+
echo -n "Load Centec kernel modules... "
34+
35+
load_kernel_modules
36+
install_python_api_package
37+
38+
echo "done."
39+
;;
40+
41+
stop)
42+
echo -n "Unload Centec kernel modules... "
43+
44+
remove_kernel_modules
45+
46+
echo "done."
47+
;;
48+
49+
force-reload|restart)
50+
echo "Not supported"
51+
;;
52+
53+
*)
54+
echo "Usage: /etc/init.d/platform-modules-ra-b6010-48gt4x {start|stop}"
55+
exit 1
56+
;;
57+
esac
58+
59+
exit 0
60+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ra-b6010-48gt4x/modules/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/arm64-ragile_ra-b6010-48gt4x-r0
2+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
systemctl enable ra-b6010-48gt4x_platform.service
2+
systemctl start ra-b6010-48gt4x_platform.service
3+
systemctl enable device_i2c.service
4+
systemctl start device_i2c.service
5+
systemctl enable privatenetwork.service
6+
systemctl start privatenetwork.service
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/usr/bin/make -f
2+
# -*- makefile -*-
3+
# Sample debian/rules that uses debhelper.
4+
# This file was originally written by Joey Hess and Craig Small.
5+
# As a special exception, when this file is copied by dh-make into a
6+
# dh-make output file, you may use that output file without restriction.
7+
# This special exception was added by Craig Small in version 0.37 of dh-make.
8+
9+
include /usr/share/dpkg/pkg-info.mk
10+
11+
# Uncomment this to turn on verbose mode.
12+
#export DH_VERBOSE=1
13+
14+
export INSTALL_MOD_DIR:=extra
15+
16+
PYTHON = python3.9
17+
18+
PACKAGE_PRE_NAME := platform-modules
19+
KVERSION ?= $(shell uname -r)
20+
KERNEL_SRC := /lib/modules/$(KVERSION)
21+
MOD_SRC_DIR:= $(shell pwd)
22+
MODULE_DIRS:= ra-b6010-48gt4x
23+
MODULE_DIRS_R:= ra-b6010-48gt4x-r
24+
MODULE_DIR := common
25+
CUSTOMS_DIRS := common_custom/common_ragile
26+
SERVICE_DIR := service
27+
CLASSES_DIR := classes
28+
CONFIG_DIR := config
29+
KDAL_DIR := ../../centec/centec-dal/
30+
export KERNEL_SRC
31+
32+
33+
34+
clean:
35+
dh_testdir
36+
dh_testroot
37+
dh_clean
38+
39+
build:
40+
#make modules -C $(KERNEL_SRC)/build M=$(MODULE_SRC)
41+
(for mod in $(KDAL_DIR); do \
42+
make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/; \
43+
done)
44+
(for mod in $(MODULE_DIRS); do \
45+
make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
46+
cd $${mod}; $(PYTHON) setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
47+
cd -; \
48+
done)
49+
(for mod in $(MODULE_DIRS_R); do \
50+
make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
51+
cd $${mod}; $(PYTHON) setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}/modules; \
52+
cd -; \
53+
done)
54+
make -C $(MODULE_DIR);
55+
make -C $(CUSTOMS_DIRS);
56+
57+
binary: binary-arch binary-indep
58+
# Nothing to do
59+
60+
binary-arch:
61+
# Nothing to do
62+
63+
binary-indep:
64+
dh_testdir
65+
dh_installdirs
66+
67+
# Custom package commands
68+
(for mod in $(MODULE_DIRS); do \
69+
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
70+
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} lib/systemd/system; \
71+
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} etc; \
72+
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} boot; \
73+
cp -r $(MOD_SRC_DIR)/$(MODULE_DIR)/build/* debian/$(PACKAGE_PRE_NAME)-$${mod}/; \
74+
cp -r $(MOD_SRC_DIR)/$(CUSTOMS_DIRS)/build/* debian/$(PACKAGE_PRE_NAME)-$${mod}/; \
75+
cp $(MOD_SRC_DIR)/$${mod}/config/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \
76+
cp $(MOD_SRC_DIR)/$${mod}/modules/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
77+
cp $(MOD_SRC_DIR)/$(KDAL_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
78+
cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
79+
cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \
80+
cp $(MOD_SRC_DIR)/${CONFIG_DIR}/* debian/$(PACKAGE_PRE_NAME)-$${mod}/etc/; \
81+
cd -; \
82+
done)
83+
(for mod in $(MODULE_DIRS_R); do \
84+
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
85+
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} lib/systemd/system; \
86+
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} etc; \
87+
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} boot; \
88+
cp -r $(MOD_SRC_DIR)/$(MODULE_DIR)/build/* debian/$(PACKAGE_PRE_NAME)-$${mod}/; \
89+
cp -r $(MOD_SRC_DIR)/$(CUSTOMS_DIRS)/build/* debian/$(PACKAGE_PRE_NAME)-$${mod}/; \
90+
cp $(MOD_SRC_DIR)/$${mod}/config/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \
91+
cp $(MOD_SRC_DIR)/$${mod}/modules/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
92+
cp $(MOD_SRC_DIR)/$(KDAL_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
93+
cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
94+
cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \
95+
cp $(MOD_SRC_DIR)/${CONFIG_DIR}/* debian/$(PACKAGE_PRE_NAME)-$${mod}/etc/; \
96+
cd -; \
97+
done)
98+
# Resuming debhelper scripts
99+
dh_testroot
100+
dh_install
101+
dh_installchangelogs
102+
dh_installdocs
103+
dh_systemd_enable
104+
dh_installinit
105+
dh_systemd_start
106+
dh_link
107+
dh_fixperms
108+
dh_compress
109+
dh_strip
110+
dh_installdeb
111+
dh_gencontrol
112+
dh_md5sums
113+
dh_builddeb
114+
.PHONY: build binary binary-arch binary-indep clean

0 commit comments

Comments
 (0)