OpenWrt Forum Archive

Topic: PKG_BUILD_DIR and PKG_INSTALL_DIR

The content of this topic has been archived on 7 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

in include/package.mk, both PKG_BUILD_DIR and PKG_INSTALL_DIR are defined. If not defined before, PKG_INSTALL_DIR becomes $(PKG_BUILD_DIR)/ipkg-install.

I'm trying to port some packages and have a couple of questions regarding these directories:
- My packages don't have a PKG_INSTALL_DIR after they are built. Is that ok or a problem with my makefiles?
- In the installation section of other makefiles I looked at (i.e. Build/InstallDev and Package/<name>/install), sometimes PKG_BUILD_DIR is used in the source path, sometime PKG_INSTALL_DIR is used. When should which be used?

Thanks in advance,
Malte

mforkel wrote:

My packages don't have a PKG_INSTALL_DIR after they are built. Is that ok or a problem with my makefiles?

Afaik, adding

PKG_INSTALL=1 or PKG_INSTALL:=1

to the package Makefile, if the source Makefile has an install target, should create the directory.

mforkel wrote:

In the installation section of other makefiles I looked at (i.e. Build/InstallDev and Package/<name>/install), sometimes PKG_BUILD_DIR is used in the source path, sometime PKG_INSTALL_DIR is used. When should which be used?

PKG_INSTALL_DIR looks to be prefered.

Thanks. But I could't find any references to PKG_INSTALL in the build system or the package makefiles.

Some of the packages that create a PKG_INSTALL_DIR (i.e. an ipkg-install subdirectory), refer to PKG_INSTALL_DIR in their makefile's compile section (Build/Compile). One example is the alsa package.

Other packages that end up with a PKG_INSTALL_DIR only refer to it in the build section (Build/InstallDev or Package/<name>/install). libbogg would be one example here.

Still confused,
Malte

Hi.

PKG_INSTALL_DIR is the directory that is about to be packed into an *.ipk archive, it can be viewed as "root filesystem hierarchy of the target device". The PKG_BUILD_DIR is where the source code was compiled/prepared/assembled.

Usually an install section copies the final binaries (or config files or headers) from the PKG_BUILD_DIR into the PKG_INSTALL_DIR (which is passed as $(1) in install sections) to the appropriate places (like $(1)/usr/bin/...).

~ JoW

Thanks. That makes sense to me.

But I'm still a bit confused. The build dir of my package does not have an ipkg-install subdirectory. Nevertheless, a proper .ipk file is built in bin/packages/<target>.

The package's makefile does not contain a Build/Compile section. And when I simply change the reference to PKG_BUILD_DIR in

define Package/squeezeslave/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/squeezeslave-alsa $(1)/usr/bin/
endef

to a reference to PKG_INSTALL_DIR

define Package/squeezeslave/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/squeezeslave-alsa $(1)/usr/bin/
endef

this expands to

install -d -m0755 /home/malte/Entwicklung/openwrt/kamikaze/build_dir/target-mipsel_uClibc-0.9.30.1/squeezeslave-0.8-25/ipkg-adm5120_mipsel/squeezeslave/usr/bin
install -m0755 /home/malte/Entwicklung/openwrt/kamikaze/build_dir/target-mipsel_uClibc-0.9.30.1/squeezeslave-0.8-25/ipkg-install/bin/squeezeslave-alsa /home/malte/Entwicklung/openwrt/kamikaze/build_dir/target-mipsel_uClibc-0.9.30.1/squeezeslave-0.8-25/ipkg-adm5120_mipsel/squeezeslave/usr/bin/

and the non-existent ipkg-install subdir causes an error:

install: cannot stat `/home/malte/Entwicklung/openwrt/kamikaze/build_dir/target-mipsel_uClibc-0.9.30.1/squeezeslave-0.8-25/ipkg-install/bin/squeezeslave-alsa': No such file or directory

This looks to me like PKG_BUILD_DIR is passed in as $(1), and not PKG_INSTALL_DIR. But then, PKG_INSTALL_DIR is used in simliar fashion in many makefiles as the source root dir for installation. As is PKB_BUILD_DIR in many other makefiles...

One could even think that

define Package/squeezeslave/install
    $(INSTALL_DIR) $(PKG_INSTALL_DIR)/usr/bin
    $(INSTALL_BIN) $(1)/bin/squeezeslave-alsa $(PKG_INSTALL_DIR)/usr/bin/
endef

would make more sense, but the incantation of

$(INSTALL_DIR) $(1)/usr/bin

is ubiquitous.

I'm afraid I still haven't understood when to use PKG_BUILD_DIR and PKG_INSTALL_DIR and what the prerequisites are for using PKG_INSTALL_DIR :-( But I'm sure I'll understand as soon as I have sent off this note :-)

Malte

As I said in my last note: As soon as you have asked a question, you'll stand a good change of coming up with an answer by yourself...

How about this (partial) explanation: PKG_INSTALL_DIR can only be used in the install section, if prior used explicitly in the compile section (this assumption not checked against existing makefiles).

But I still don't know how the build system determines from where to take the files when creating the final .ipk package in bin/packages, especially if PKG_INSTALL_DIR is not used.

Malte

The discussion might have continued from here.