Add psmisc, closes #649
authorFlorian Fainelli <florian@openwrt.org>
Sun, 3 Sep 2006 22:23:59 +0000 (22:23 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Sun, 3 Sep 2006 22:23:59 +0000 (22:23 +0000)
SVN-Revision: 4745

openwrt/package/Config.in
openwrt/package/Makefile
openwrt/package/psmisc/Config.in [new file with mode: 0644]
openwrt/package/psmisc/Makefile [new file with mode: 0644]
openwrt/package/psmisc/ipkg/psmisc.control [new file with mode: 0644]
openwrt/package/psmisc/ipkg/psmisc.postinst [new file with mode: 0644]
openwrt/package/psmisc/ipkg/psmisc.postrm [new file with mode: 0644]
openwrt/package/psmisc/ipkg/psmisc.preinst [new file with mode: 0644]
openwrt/package/psmisc/ipkg/psmisc.prerm [new file with mode: 0644]

index bcc6f17648f1c7c79e8921f44550fb2d66557bcd..dc576182a4802cee8128b6fbe18eb8836de789df 100644 (file)
@@ -18,6 +18,7 @@ source "package/microperl/Config.in"
 source "package/monit/Config.in"
 source "package/osiris/Config.in"
 source "package/procps/Config.in"
+source "package/psmisc/Config.in"
 menu "sablevm - a Java Virtual Machine (JVM) implementation"
 source "package/sablevm/Config.in"
 source "package/sablevm-classpath/Config.in"
index 79a45cffd3f15103680adf8310b8d364a286ebcf..0b9c14e00a157f838df7617f37755048c7a68e3d 100644 (file)
@@ -92,6 +92,7 @@ package-$(BR2_PACKAGE_PPP) += ppp
 package-$(BR2_PACKAGE_PPTP) += pptp
 package-$(BR2_PACKAGE_PPTPD) += pptpd
 package-$(BR2_PACKAGE_PROCPS) += procps
+package-$(BR2_PACKAGE_PSMISC) += psmisc
 package-$(BR2_PACKAGE_QUAGGA) += quagga
 package-$(BR2_PACKAGE_RADVD) += radvd
 package-$(BR2_COMPILE_RADIUSCLIENT_NG) += radiusclient-ng
diff --git a/openwrt/package/psmisc/Config.in b/openwrt/package/psmisc/Config.in
new file mode 100644 (file)
index 0000000..50d13c0
--- /dev/null
@@ -0,0 +1,33 @@
+menu "Misc /proc utilities"
+
+config BR2_PACKAGE_PSMISC
+       prompt "Misc /proc utilities"
+       tristate
+       default m if CONFIG_DEVEL
+       help
+       PSmisc package is a set of additional small useful utilities that use
+       the proc filesystem: fuser, killall, pstree, and pidof
+       
+       http://psmisc.sourceforge.net/
+
+config BR2_PACKAGE_PSMISC_FUSER
+       prompt "fuser - identify processes using files or sockets"
+       bool
+       default y if CONFIG_DEVEL
+       depends BR2_PACKAGE_PSMISC
+
+config BR2_PACKAGE_PSMISC_KILLALL
+       prompt "killall - kill process by name, pidof - find PIDs by name"
+       bool
+       default y if CONFIG_DEVEL
+       depends BR2_PACKAGE_PSMISC
+
+config BR2_PACKAGE_PSMISC_PSTREE
+       prompt "pstree (requires libncurses) - display a tree of processes"
+       bool
+       default y if CONFIG_DEVEL
+       depends BR2_PACKAGE_PSMISC
+       select BR2_PACKAGE_LIBNCURSES
+       depends BR2_PACKAGE_PSMISC
+
+endmenu
diff --git a/openwrt/package/psmisc/Makefile b/openwrt/package/psmisc/Makefile
new file mode 100644 (file)
index 0000000..11a8dc4
--- /dev/null
@@ -0,0 +1,98 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=psmisc
+PKG_VERSION:=22.2
+PKG_RELEASE:=1
+PKG_MD5SUM:=77737c817a40ef2c160a7194b5b64337
+
+PKG_SOURCE_URL:=@SF/psmisc
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_CAT:=zcat
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+
+include $(TOPDIR)/package/rules.mk
+
+$(eval $(call PKG_template,PSMISC,$(PKG_NAME),$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
+
+$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
+       (cd $(PKG_BUILD_DIR); \
+               $(TARGET_CONFIGURE_OPTS) \
+               CFLAGS="$(TARGET_CFLAGS)" \
+               CPPFLAGS="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
+               LDFLAGS="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib" \
+               ./configure \
+                       --target=$(GNU_TARGET_NAME) \
+                       --host=$(GNU_TARGET_NAME) \
+                       --build=$(GNU_HOST_NAME) \
+                       --prefix=$(PKG_INSTALL_DIR) \
+                       --without-libiconv-prefix \
+                       --without-libintl-prefix \
+                       --disable-nls \
+                       --disable-ipv6 \
+                       --disable-largefile\
+       );
+
+       touch $@
+
+APPS:=
+
+ifneq ($(BR2_PACKAGE_PSMISC_FUSER),)
+APPS += /sbin/fuser
+endif
+ifneq ($(BR2_PACKAGE_PSMISC_KILLALL),)
+APPS += /usr/bin/killall /bin/pidof
+endif
+ifneq ($(BR2_PACKAGE_PSMISC_PSTREE),)
+APPS += /usr/bin/pstree
+endif
+
+$(PKG_BUILD_DIR)/.built:
+       rm -rf $(PKG_INSTALL_DIR)
+       mkdir -p $(PKG_INSTALL_DIR)/usr/bin
+       mkdir -p $(PKG_INSTALL_DIR)/sbin
+       mkdir -p $(PKG_INSTALL_DIR)/bin
+       #Note here that we pass cross-compiler as default compiler to use
+       $(MAKE) -C $(PKG_BUILD_DIR) \
+               CC=$(TARGET_CC) \
+               CPPFLAGS="-I$(STAGING_DIR)/usr/include" \
+               LD="$(TARGET_CC)" \
+               LDFLAGS="-L$(STAGING_DIR)/usr/lib" \
+               $(TARGET_CONFIGURE_OPTS) \
+               prefix="$(PKG_INSTALL_DIR)"
+
+       if [ -n "$(BR2_PACKAGE_PSMISC_KILLALL)" ];then $(CP) $(PKG_BUILD_DIR)/src/killall $(PKG_INSTALL_DIR)/usr/bin;fi
+       if [ -n "$(BR2_PACKAGE_PSMISC_FUSER)" ];then $(CP) $(PKG_BUILD_DIR)/src/fuser $(PKG_INSTALL_DIR)/sbin;fi
+       if [ -n "$(BR2_PACKAGE_PSMISC_PSTREE)" ];then $(CP) $(PKG_BUILD_DIR)/src/pstree $(PKG_INSTALL_DIR)/usr/bin;fi
+
+       touch $@
+
+$(IPKG_PSMISC):
+       install -d -m0755 $(IDIR_PSMISC)/usr/bin
+       install -d -m0755 $(IDIR_PSMISC)/sbin
+       install -d -m0755 $(IDIR_PSMISC)/bin
+       
+       if [ -n "$(BR2_PACKAGE_PSMISC_KILLALL)" ];then $(CP) $(PKG_INSTALL_DIR)/usr/bin/killall $(IDIR_PSMISC)/usr/bin;fi
+       if [ -n "$(BR2_PACKAGE_PSMISC_FUSER)" ];then $(CP) $(PKG_INSTALL_DIR)/sbin/fuser $(IDIR_PSMISC)/sbin;fi
+       if [ -n "$(BR2_PACKAGE_PSMISC_PSTREE)" ];then $(CP) $(PKG_INSTALL_DIR)/usr/bin/pstree $(IDIR_PSMISC)/usr/bin;fi
+       
+       $(RSTRIP) $(IDIR_PSMISC)
+       
+       # Insert BUILT variable into preinst script
+       grep -v -e ^BUILT -e /bin/sh $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst > $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst.tmp
+       rm $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst
+       echo -e "#!/bin/sh\nBUILT='$(APPS)'\n" > $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst
+       cat $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst.tmp >> $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst
+       rm $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/preinst.tmp
+
+       if [ -n "$(BR2_PACKAGE_PSMISC_PSTREE)" ] || \
+               [ -n "$(BR2_PACKAGE_PSMISC_PSTREE)" ]; then\
+       echo "Depends: libncurses" >> $(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/control; fi
+       echo "Description: Extra /proc utils: $(notdir $(APPS))" >>  \$(PKG_INSTALL_DIR)/../ipkg/$(PKG_NAME)/CONTROL/control
+
+       $(IPKG_BUILD) $(IDIR_PSMISC) $(PACKAGE_DIR)
+
+mostlyclean:
+       make -C $(PKG_BUILD_DIR) clean
+       rm $(PKG_BUILD_DIR)/.built
diff --git a/openwrt/package/psmisc/ipkg/psmisc.control b/openwrt/package/psmisc/ipkg/psmisc.control
new file mode 100644 (file)
index 0000000..0884767
--- /dev/null
@@ -0,0 +1,3 @@
+Package: psmisc
+Priority: optional
+Section: admin
diff --git a/openwrt/package/psmisc/ipkg/psmisc.postinst b/openwrt/package/psmisc/ipkg/psmisc.postinst
new file mode 100644 (file)
index 0000000..4e6f654
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -f /usr/bin/killall ]
+then
+    echo "Hard linking pidof to killall"
+    ln /usr/bin/killall /bin/pidof
+fi
+
+exit 0
diff --git a/openwrt/package/psmisc/ipkg/psmisc.postrm b/openwrt/package/psmisc/ipkg/psmisc.postrm
new file mode 100644 (file)
index 0000000..9dcab82
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+BINS="/sbin/fuser /usr/bin/killall /usr/bin/pstree /bin/pidof"
+echo "Recreating original BusyBox links: "
+
+for bin in $BINS
+do
+    if busybox 2>&1 | grep ${bin##/*/} >/dev/null
+    then
+         echo "$bin "
+         ln -sf /bin/busybox $bin
+    fi
+done
+
+exit 0
diff --git a/openwrt/package/psmisc/ipkg/psmisc.preinst b/openwrt/package/psmisc/ipkg/psmisc.preinst
new file mode 100644 (file)
index 0000000..1a5518d
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+echo "Removing symbolic links to BusyBox: "
+for bin in $BUILT
+do
+    if [ -h $bin ]
+    then
+        echo "$bin "
+        rm -f $bin
+    elif [ -e $bin ]
+    then
+        echo -e "$bin exists but is not a symbolic link.\nRe-creating BusyBox links and aborting..."
+        for bin in $BUILT
+        do
+            if busybox 2>&1 | grep ${bin##/*/} >/dev/null && [ ! -e $bin ]
+            then
+                ln -s /bin/busybox $bin
+            fi
+        done
+        exit 1
+    fi
+done
+
+exit 0
diff --git a/openwrt/package/psmisc/ipkg/psmisc.prerm b/openwrt/package/psmisc/ipkg/psmisc.prerm
new file mode 100644 (file)
index 0000000..c229d22
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ -f /sbin/pidof ]
+then
+    echo "Removing hard link from pidof to killall"
+    rm -f /sbin/pidof
+fi
+
+exit 0