How to compile p7zip to lede / openwrt?

I'm trying to compile p7zip to openwrt but it doesn't work, here's the Makefile:

#
# Copyright (C) 2009-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=p7zip
PKG_VERSION:=16.02
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION)_src_all.tar.bz2
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)
PKG_SOURCE_URL:=http://downloads.sourceforge.net/p7zip/p7zip_16.02_src_all.tar.bz2
#PKG_MD5SUM:=

include $(INCLUDE_DIR)/package.mk

#define Build/Configure
#	$(CP) $(PKG_BUILD_DIR)/makefile.linux_cross_arm $(PKG_BUILD_DIR)/makefile.machine
#endef

define Package/p7zip
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=p7zip archiver
  URL:=http://http://www.7-zip.org
endef

define Package/p7zip/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/zip $(1)/usr/bin/
endef

$(eval $(call BuildPackage,p7zip))

When I compile that, I get the following error:
https://s4.postimg.org/ijylf3bbx/Screenshot_-170717-_03_04_04.png

How can I compile this package ?

Are you sure that the $(INSTALL_BIN) $(PKG_BUILD_DIR)/zip file exists ?
It looks like it's either not there, or not generated.

I've tried commenting that part to be like this, it compiled but the package size is only 700 bytes and doesn't work when I install it

define Package/p7zip/install
	$(INSTALL_DIR) $(1)/usr/bin
	#$(INSTALL_BIN) $(PKG_BUILD_DIR)/zip $(1)/usr/bin/
endef

Well, you shouldn't comment out that part.
Otherwise nothing gets installed.

Go into the lede/build_dir/target-/p7zip- folder and find where the p7zip executable is situated, and modify the source path to that.

Here's the install.sh from the p7zip source code:

#! /bin/sh

installShared()
{
  prg=$1
  if [ -x bin/${prg} ]
  then
    echo "- installing ${DEST_DIR}${DEST_BIN}/${prg}"
    cp bin/${prg} "${DEST_DIR}${DEST_SHARE}/${prg}"
    chmod 755 "${DEST_DIR}${DEST_SHARE}/${prg}"
    strip     "${DEST_DIR}${DEST_SHARE}/${prg}"
    echo "#! /bin/sh" > "${DEST_DIR}${DEST_BIN}/${prg}"
    echo "\"${DEST_SHARE}/${prg}\" \"\$@\"" >> "${DEST_DIR}${DEST_BIN}/${prg}"
    chmod 755 "${DEST_DIR}${DEST_BIN}/${prg}"
  fi
}

# global install
DEST_HOME=/usr/local
# for testing 
# DEST_HOME=${HOME}/INSTALL/usr/local
DEST_BIN=${DEST_HOME}/bin
DEST_SHARE=${DEST_HOME}/lib/p7zip
DEST_MAN=${DEST_HOME}/man
DEST_SHARE_DOC=${DEST_HOME}/share/doc/p7zip
DEST_DIR=
[ "$1" ] && DEST_BIN="$1"
[ "$2" ] && DEST_SHARE="$2"
[ "$3" ] && DEST_MAN="$3"
[ "$4" ] && DEST_SHARE_DOC="$4"
[ "$5" ] && DEST_DIR="$5"

umask 0022

use_share="n"

if [ -x bin/7zCon.sfx ]
then
  use_share="o"
fi

if [ -x bin/7z ]
then
  use_share="o"
fi

if [ -x bin/7zG ]
then
  use_share="o"
fi

if [ -x bin/7zFM ]
then
  use_share="o"
fi

# cleaning previous install
rm -f  "${DEST_DIR}${DEST_BIN}/7z"
rm -f  "${DEST_DIR}${DEST_BIN}/7za"
rm -f  "${DEST_DIR}${DEST_BIN}/7zr"
rm -f  "${DEST_DIR}${DEST_BIN}/7zG"
rm -f  "${DEST_DIR}${DEST_BIN}/p7zipForFilemanager"
rm -f  "${DEST_DIR}${DEST_BIN}/7zFM"
rm -f  "${DEST_DIR}${DEST_SHARE}/7z"
rm -f  "${DEST_DIR}${DEST_SHARE}/7za"
rm -f  "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
rm -f  "${DEST_DIR}${DEST_SHARE}/7zr"
rm -f  "${DEST_DIR}${DEST_SHARE}/7zG"
rm -f  "${DEST_DIR}${DEST_SHARE}/7zFM"
rm -f  "${DEST_DIR}${DEST_SHARE}/7z.so"
chmod -R 777 "${DEST_DIR}${DEST_SHARE}/Codecs" 2> /dev/null
chmod -R 777 "${DEST_DIR}${DEST_SHARE}/Formats" 2> /dev/null
rm -fr "${DEST_DIR}${DEST_SHARE}/Codecs"
rm -fr "${DEST_DIR}${DEST_SHARE}/Formats"
rm -fr "${DEST_DIR}${DEST_SHARE}/Lang"
rm -f  "${DEST_DIR}${DEST_MAN}/man1/7z.1"
rm -f  "${DEST_DIR}${DEST_MAN}/man1/7za.1"
rm -f  "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
chmod -R 777 "${DEST_DIR}${DEST_SHARE_DOC}" 2> /dev/null
rm -fr  "${DEST_DIR}${DEST_SHARE_DOC}"

if [ "${use_share}" = "o" ]
then
  mkdir -p "${DEST_DIR}${DEST_BIN}"
  mkdir -p "${DEST_DIR}${DEST_SHARE}"
  installShared 7za
  installShared 7zr
  installShared 7z
  installShared 7zG
  installShared 7zFM

  if [ -x bin/7zCon.sfx ]
  then
    echo "- installing ${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
    cp bin/7zCon.sfx "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
    chmod 755 "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
    strip     "${DEST_DIR}${DEST_SHARE}/7zCon.sfx"
  fi

  if [ -x bin/7z.so ]
  then
    echo "- installing ${DEST_DIR}${DEST_SHARE}/7z.so"
    cp bin/7z.so "${DEST_DIR}${DEST_SHARE}/7z.so"
    chmod 755 "${DEST_DIR}${DEST_SHARE}/7z.so"
  fi

  if [ -d bin/Codecs ]
  then
    echo "- installing ${DEST_DIR}${DEST_SHARE}/Codecs"
    cp -r bin/Codecs "${DEST_DIR}${DEST_SHARE}/"
    chmod 755 "${DEST_DIR}${DEST_SHARE}"/*/*
  fi

else
  if [ -x bin/7za ]
  then
    echo "- installing ${DEST_DIR}${DEST_BIN}/7za"
    mkdir -p "${DEST_DIR}${DEST_BIN}"
    cp bin/7za "${DEST_DIR}${DEST_BIN}/7za"
    chmod 755  "${DEST_DIR}${DEST_BIN}/7za"
    strip      "${DEST_DIR}${DEST_BIN}/7za"
  fi

  if [ -x bin/7zr ]
  then
    echo "- installing ${DEST_DIR}${DEST_BIN}/7zr"
    mkdir -p "${DEST_DIR}${DEST_BIN}"
    cp bin/7zr "${DEST_DIR}${DEST_BIN}/7zr"
    chmod 755  "${DEST_DIR}${DEST_BIN}/7zr"
    strip      "${DEST_DIR}${DEST_BIN}/7zr"
  fi
fi

mkdir -p "${DEST_DIR}${DEST_MAN}/man1"
if [ -d DOC ]
then
   echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7z.1"
   sed -e s?"{DEST_SHARE_DOC}"?"${DEST_SHARE_DOC}/DOC"?g man1/7z.1 > "${DEST_DIR}${DEST_MAN}/man1/7z.1"
   chmod 644 "${DEST_DIR}${DEST_MAN}/man1/7z.1"

   echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7za.1"
   sed -e s?"{DEST_SHARE_DOC}"?"${DEST_SHARE_DOC}/DOC"?g man1/7za.1 > "${DEST_DIR}${DEST_MAN}/man1/7za.1"
   chmod 644 "${DEST_DIR}${DEST_MAN}/man1/7za.1"

   echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7zr.1"
   sed -e s?"{DEST_SHARE_DOC}"?"${DEST_SHARE_DOC}/DOC"?g man1/7zr.1 > "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
   chmod 644 "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
else
   echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7z.1"
   grep -v "{DEST_SHARE_DOC}" man1/7z.1 > "${DEST_DIR}${DEST_MAN}/man1/7z.1"
   chmod 644 "${DEST_DIR}${DEST_MAN}/man1/7z.1"

   echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7za.1"
   grep -v "{DEST_SHARE_DOC}" man1/7za.1 > "${DEST_DIR}${DEST_MAN}/man1/7za.1"
   chmod 644 "${DEST_DIR}${DEST_MAN}/man1/7za.1"

   echo "- installing ${DEST_DIR}${DEST_MAN}/man1/7zr.1"
   grep -v "{DEST_SHARE_DOC}" man1/7zr.1 > "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
   chmod 644 "${DEST_DIR}${DEST_MAN}/man1/7zr.1"
fi

if [ -f README ]
then
  echo "- installing ${DEST_DIR}${DEST_SHARE_DOC}/README"
  mkdir -p  "${DEST_DIR}${DEST_SHARE_DOC}"
  cp README "${DEST_DIR}${DEST_SHARE_DOC}/README"
  chmod 644 "${DEST_DIR}${DEST_SHARE_DOC}/README"
fi

if [ -f ChangeLog ]
then
  echo "- installing ${DEST_DIR}${DEST_SHARE_DOC}/ChangeLog"
  mkdir -p     "${DEST_DIR}${DEST_SHARE_DOC}"
  cp ChangeLog "${DEST_DIR}${DEST_SHARE_DOC}/ChangeLog"
  chmod 644    "${DEST_DIR}${DEST_SHARE_DOC}/ChangeLog"
fi

if [ -d DOC ]
then
  echo "- installing HTML help in ${DEST_DIR}${DEST_SHARE_DOC}/DOC"
  mkdir -p "${DEST_DIR}${DEST_SHARE_DOC}"
  cp -r DOC "${DEST_DIR}${DEST_SHARE_DOC}/DOC"
  find "${DEST_DIR}${DEST_SHARE_DOC}/DOC" -type d -exec chmod 755 {} \;
  find "${DEST_DIR}${DEST_SHARE_DOC}/DOC" -type f -exec chmod 644 {} \;
fi

use_lang="n"

if [ -x bin/7zG ]
then
  use_lang="o"
  cp GUI/p7zipForFilemanager "${DEST_DIR}${DEST_BIN}/"
  chmod 755 "${DEST_DIR}${DEST_BIN}/"
fi

if [ -x bin/7zFM ]
then
  use_lang="o"
fi

if [ "${use_lang}" = "o" ]
then
  echo "- installing Lang in ${DEST_DIR}${DEST_SHARE}"
  cp -r GUI/Lang "${DEST_DIR}${DEST_SHARE}/"
  find "${DEST_DIR}${DEST_SHARE}/Lang" -type d -exec chmod 755 {} \;
  find "${DEST_DIR}${DEST_SHARE}/Lang" -type f -exec chmod 644 {} \;
fi

So I modified my Makefile to:

define Package/p7zip/install
	$(INSTALL_DIR) $(1)/usr/local/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR) $(1)/usr/local/bin
endef

But it still returns the error like above

Hey,

So, this Makefile [ below ] compiles, but I did not test it on a target yet.
I had to get in front of a computer to test it.

A few bits that were missing from your initial Makefile (that were not so obvious to me initially)

  • you need to add either PKG_HASH or PKG_MD5SUM
  • PKG_SOURCE_URL did not seem correct ; i.e. the tarball is not part of the URL ; I added the short-hand version of the SF link
  • +libstdcpp needs to be a dependency

And the part that was obvious to me from the start was $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/7za $(1)/usr/bin/
Well, to be more accurate, it was clear that your initial path was not correct (i.e. $(INSTALL_BIN) $(PKG_BUILD_DIR)/zip $(1)/usr/bin/) because the build error in your image says No such file or directory

Personally, when I write OpenWrt/LEDE makefiles [for packages], I don't look much at the package's install rules or Makefile ; it usually ends up confusing me, more than helping.
I just look for the binary that the build produces.
In this case I looked for what the build produced in <lede>/build_dir/target-mips_24kc_musl/p7zip_16.02/
That's also to say, I'm not completely sure that this works ; but likely it might.

#
# Copyright (C) 2009-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=p7zip
PKG_VERSION:=16.02
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION)_src_all.tar.bz2
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
PKG_HASH:=5eb20ac0e2944f6cb9c2d51dd6c4518941c185347d4089ea89087ffdd6e2341f

include $(INCLUDE_DIR)/package.mk

define Package/p7zip
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=p7zip archiver
  URL:=http://http://www.7-zip.org
  DEPENDS:=+libstdcpp
endef

define Package/p7zip/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/7za $(1)/usr/bin/
endef

$(eval $(call BuildPackage,p7zip))

p7zip in general is going to be really slow on low-power SoCs. bsdtar is in the package tree already and handles 7z files.
https://github.com/libarchive/libarchive/wiki/LibarchiveFormats
https://github.com/openwrt/packages/blob/master/libs/libarchive/Makefile

I'm new to writing Makefile and I'm not a programmer either, how did you know it was missing dependency libstdcpp which file did you take a look at? I'm running OpenWrt CC and in my case it was also missing libpthread. After adding that one it compiled just fine and it also works just fine. Thank you for helping me out. Here's the Makefile I used to compile p7zip to openwrt CC:

#
# Copyright (C) 2009-2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=p7zip
PKG_VERSION:=16.02
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION)_src_all.tar.bz2
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
PKG_HASH:=5eb20ac0e2944f6cb9c2d51dd6c4518941c185347d4089ea89087ffdd6e2341f

include $(INCLUDE_DIR)/package.mk

define Package/p7zip
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=p7zip archiver
  URL:=http://http://www.7-zip.org
  DEPENDS:=+libstdcpp +libpthread
endef

define Package/p7zip/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/7za $(1)/usr/bin/
endef

$(eval $(call BuildPackage,p7zip))

I installed libarchive with:

opkg install libarchive

but I can't find where bsdtar is located, how do I extract 7z files with it ?

I'm new to writing Makefile and I'm not a programmer either, how did you know it was missing dependency libstdcpp which file did you take a look at?

No worries ; you have time to learn.
I tested on LEDE, so I got the err from the build that libstdc++ is missing.
Not sure how much OpenWrt CC differs from LEDE trunk [where I test usually]

Regarding bsdtar, I don't know.
I wonder if installing opkg install bsdtar works ?
From the Makefile, it should be installed in /usr/bin

But, it looks like for OpenWrt CC, bsdtar is not packaged/built:

So, you could backport the change, or try a newer version of LEDE/OpenWrt.
Using the master trunk [of packages] with OpenWrt CC can be tricky ; and is usually unsupported.

You need bsdtar (which isn't built for OpenWRT) and you should really switch to LEDE in general (release or master/head/trunk). Pretty much nothing gets tested against uclibc nowdays so your milage may wary.

As far as bsdtar goes.... bsdtar xf archive.7z :slight_smile:

No I can't do opkg install bsdtar it's not in the openwrt repo yet. I'll just use p7zip right now

Is LEDE 17.01.2 pretty stable right now? I can't switch to lede yet since there are packages that aren't in the lede repository, I'll probably try to submit new packages and see if they accept them, then I'll switch to lede. I'm running OpenWrt on orange pi zero right now and the installation process is a bit of a pain in the neck since this board isn't officially supported by openwrt yet.

Umm.
I'd say that LEDE 17.01.2 is pretty stable.
I mean, just as stable OpenWrt is.

But, you could create your own packages [git] repository, put all the packages that you need there, and reference what you need from the official feeds.
And then, move stuff from your repo to the official feed as it gets accepted.

It's even more stable in general I'd say. What packages are you missing?

  1. sshpass
  2. badvpn-tun2socks
  3. httping
  4. corkscrew

I'm not a programmer and I'm not familiar with submitting patches, if you want to add those packages to the official repo, I can give you all the Makefile of those packages.

You have to read the patch submission guidelines on github, I have no interest nor will I use the listed software so I'm out.

I tried submitting those packages myself, can you please take a look and see if they're correctly submitted?
https://github.com/lede-project/source/pull/1224

A post was split to a new topic: Compiling/Installing Corkscrew on 22.03 (ipq806x/generic)