# For sdb debugging
sdb_debugging=1
-sdb_rule='SUBSYSTEM=="switch", ATTR{name}=="usb_cable", ATTR{state}=="1", RUN+="/usr/bin/direct_set_debug.sh --sdb-set"\nSUBSYSTEM=="switch", ATTR{name}=="usb_cable", ATTR{state}=="0", RUN+="/usr/bin/direct_set_debug.sh --sdb-unset"'
# Back up data
backup () {
cwd=`pwd`
backup ${cwd}/${tmp_root} $2
-# For sdb debugging
-if [ ${sdb_debugging} -eq 1 ]
-then
- echo "Install sdb rule file"
- rule_file="99-sdb-switch.rules"
- echo ${sdb_rule} > ${rule_file}
- install -m 644 ${rule_file} ${tmp_root}/usr/lib/udev/rules.d
- rm ${rule_file}
-fi
-
sync
umount ${tmp_root}
ln -s ../cynara.socket %{buildroot}%{_unitdir}/system-update.target.wants
# SDB debugging
-mkdir -p %{buildroot}%{_libdir}/udev/rules.d
-ln -s /opt/data/recovery/99-sdb-switch.rules %{buildroot}%{_libdir}/udev/rules.d
install -m 644 units/udev-sdb-init.service %{buildroot}%{_unitdir}
ln -s ../udev-sdb-init.service %{buildroot}%{_unitdir}/system-update.target.wants
%clean
rm -rf %{buildroot}
+%posttrans
+if [ -e %{_libdir}/udev/rules.d/99-sdb-switch.rules ]; then
+ echo "Exist 99-sdb-switch.rules, Skip!"
+else
+ mkdir -p %{_libdir}/udev/rules.d
+ ln -s /opt/data/recovery/99-sdb-switch.rules %{_libdir}/udev/rules.d
+fi
+
%files
%manifest %{name}.manifest
%license LICENSE.Apache-2.0
%{_unitdir}/init-update.service
%{_unitdir}/system-update.target.wants
%{_unitdir}/udev-sdb-init.service
-%{_libdir}/udev/rules.d/*