Compiling proftpd - chown error

Hei guys!
I needed proftpd package on LEDE which does not seem to be supported anymore (even in openwrt).
So I decided to took the feed from the last supported openwrt, port it to LEDE and compile it on my own.
Everything went smooth (I already have the binary - which is sufficient for me) but there's still some error in my Makefile:

include $(TOPDIR)/rules.mk

PKG_NAME:=proftpd
PKG_VERSION:=1.3.5d
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=ftp://ftp.proftpd.org/distrib/source
PKG_MD5SUM:=bcd2846edf0dad4c4d49a7c8c176d83a

PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/proftpd
  SUBMENU:=File Transfer
  SECTION:=net
  CATEGORY:=Network
  TITLE:=ProFTPD FTP server
  URL:=http://www.proftpd.org/
  MAINTAINER:=Cezary Jackiewicz <cezary@eko.one.pl>
  DEPENDS:=+libopenssl +libcrypto +libz
endef

CONFIGURE_ARGS += \
    --disable-cap \
    --enable-devel \
    --disable-auth-pam \
    --enable-openssl \
    --with-modules=mod_sftp

CONFIGURE_VARS += \
    ac_cv_header_curses_h=no \
    ac_cv_header_ncurses_h=no

define Package/proftpd/install
    $(INSTALL_DIR) $(1)/etc
    $(if $(CONFIG_IPV6),,$(SED) 's/^UseIPv6/#UseIPv6/' $(PKG_INSTALL_DIR)/etc/proftpd.conf)
    $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/proftpd.conf $(1)/etc/
    $(INSTALL_DIR) $(1)/etc/init.d
    $(INSTALL_BIN) ./files/proftpd.init $(1)/etc/init.d/proftpd
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ftp{count,top,who} $(1)/usr/bin/
    $(INSTALL_DIR) $(1)/usr/sbin
    $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/{ftpshut,proftpd} $(1)/usr/sbin/
    $(CP) $(PKG_INSTALL_DIR)/usr/sbin/in.proftpd $(1)/usr/sbin/
endef

$(eval $(call BuildPackage,proftpd,+libopenssl))

after executing

[/mnt/data/lede]$ make -j1 V=s package/proftpd/compile

rusults in

...
make[5]: Leaving directory '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/contrib/mod_sftp'
make[4]: Leaving directory '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/modules'
test -z """" -a -z """" || (cd modules/ && make shared)
test -z """" || (cd locale/ && make locale)
test -f ./module-libs.txt || touch ./module-libs.txt
/bin/bash ./libtool --mode=link --tag=CC mips-openwrt-linux-musl-gcc -L./lib -L/mnt/data/lede/staging_dir/target-mips_24kc_musl/usr/lib -L/mnt/data/lede/staging_dir/target-mips_24kc_musl/lib -L/mnt/data/lede/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl/usr/lib -L/mnt/data/lede/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl/lib -znow -zrelro    -o proftpd src/main.o src/timers.o src/sets.o src/pool.o src/privs.o src/str.o src/table.o src/regexp.o src/dirtree.o src/expr.o src/support.o src/netaddr.o src/inet.o src/child.o src/parser.o src/log.o src/lastlog.o src/xferlog.o src/bindings.o src/netacl.o src/class.o src/scoreboard.o src/help.o src/feat.o src/netio.o src/cmd.o src/response.o src/data.o src/modules.o src/stash.o src/display.o src/auth.o src/fsio.o src/mkhome.o src/ctrls.o src/event.o src/var.o src/throttle.o src/session.o src/trace.o src/encode.o src/proctitle.o src/filter.o src/pidfile.o src/env.o src/version.o src/rlimit.o src/wtmp.o src/memcache.o modules/mod_core.o modules/mod_xfer.o modules/mod_rlimit.o modules/mod_auth_unix.o modules/mod_auth_file.o modules/mod_auth.o modules/mod_ls.o modules/mod_log.o modules/mod_site.o modules/mod_delay.o modules/mod_facts.o modules/mod_ident.o   modules/module_glue.o contrib/mod_sftp/mod_sftp.a -lsupp    -lssl -lcrypto -lssl -lcrypto -lcrypto -lz  `uniq ./module-libs.txt | tr '\n' ' '`
libtool: link: mips-openwrt-linux-musl-gcc -znow -zrelro -o proftpd src/main.o src/timers.o src/sets.o src/pool.o src/privs.o src/str.o src/table.o src/regexp.o src/dirtree.o src/expr.o src/support.o src/netaddr.o src/inet.o src/child.o src/parser.o src/log.o src/lastlog.o src/xferlog.o src/bindings.o src/netacl.o src/class.o src/scoreboard.o src/help.o src/feat.o src/netio.o src/cmd.o src/response.o src/data.o src/modules.o src/stash.o src/display.o src/auth.o src/fsio.o src/mkhome.o src/ctrls.o src/event.o src/var.o src/throttle.o src/session.o src/trace.o src/encode.o src/proctitle.o src/filter.o src/pidfile.o src/env.o src/version.o src/rlimit.o src/wtmp.o src/memcache.o modules/mod_core.o modules/mod_xfer.o modules/mod_rlimit.o modules/mod_auth_unix.o modules/mod_auth_file.o modules/mod_auth.o modules/mod_ls.o modules/mod_log.o modules/mod_site.o modules/mod_delay.o modules/mod_facts.o modules/mod_ident.o modules/module_glue.o  -L/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/lib -L/mnt/data/lede/staging_dir/target-mips_24kc_musl/usr/lib -L/mnt/data/lede/staging_dir/target-mips_24kc_musl/lib -L/mnt/data/lede/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl/usr/lib -L/mnt/data/lede/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl/lib contrib/mod_sftp/mod_sftp.a -lsupp -lssl -lcrypto -lz
/mnt/data/lede/staging_dir/toolchain-mips_24kc_gcc-5.4.0_musl/lib/gcc/mips-openwrt-linux-musl/5.4.0/../../../../mips-openwrt-linux-musl/bin/ld: copy reloc against protected `__stack_chk_guard' is dangerous
cd utils/ && make utils
make[4]: Entering directory '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/utils'
make[4]: Nothing to be done for 'utils'.
make[4]: Leaving directory '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/utils'
chown: changing ownership of '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/ipkg-install/usr/include': Operation not permitted
chown: changing ownership of '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/ipkg-install/var': Operation not permitted
chown: changing ownership of '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/ipkg-install/etc': Operation not permitted
chown: changing ownership of '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/ipkg-install/usr/sbin': Operation not permitted
/usr/bin/install -c  -o root -g root -m 0755 proftpd /mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/ipkg-install/usr/sbin/proftpd
/usr/bin/install: cannot change ownership of '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/ipkg-install/usr/sbin/proftpd': Operation not permitted
Makefile:113: recipe for target 'install-proftpd' failed
make[3]: *** [install-proftpd] Error 1
make[3]: Leaving directory '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d'
Makefile:69: recipe for target '/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/.built' failed
make[2]: *** [/mnt/data/lede/build_dir/target-mips_24kc_musl/proftpd-1.3.5d/.built] Error 2
make[2]: Leaving directory '/mnt/data/lede/feeds/packages/net/proftpd'
package/Makefile:109: recipe for target 'package/feeds/packages/proftpd/compile' failed
make[1]: *** [package/feeds/packages/proftpd/compile] Error 2
make[1]: Leaving directory '/mnt/data/lede'
/mnt/data/lede/include/toplevel.mk:199: recipe for target 'package/proftpd/compile' failed
make: *** [package/proftpd/compile] Error 2

What am I doing wrong?

Thanks!

Only "root" user can change ownership of a file to "root"... looks like you should execute that "make" command as "root".

Do you build LEDE as root? I do not.

No, that is not something I would recommend as a general rule... but it seems to be what that package is expecting. Or you could try to guess how to configure it to not do the CHOWN thing, and do that later.

Does that device (that you have mounted at /mnt/data) support settings ownership? Is is ext2/ext3/ext4 etc.? (or FAT or so?)

EDIT:
didn't read the point from eduperez about setting owner to root.
my bad :frowning:

But strange Makefile. Openwrt & LEDE have always been built as non-root.

This is half guess, but it looks to me that you have not taken the lines that set the user & group for the app (that have been in the last Openwrt Makefile of this package, in the "oldpackages" repo):

http://git.openwrt.org/?p=packages.git;a=blob;f=net/proftpd/Makefile;h=dff7233941ae68e3daa1f777fc1ac3bc81817e53;hb=HEAD

MAKE_FLAGS += \
         INSTALL_USER=$(shell id -u) \
         INSTALL_GROUP=$(shell id -g)

Ps. And did you take the patches that are there?
http://git.openwrt.org/?p=packages.git;a=tree;f=net/proftpd;hb=HEAD

Correct answer! Thanks! Working! :slight_smile: