opkg: fix several package installation bugs
[lede.git] / package / system / opkg / Makefile
1 #
2 # Copyright (C) 2006-2015 OpenWrt.org
3 # Copyright (C) 2016 LEDE Project
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7
8 include $(TOPDIR)/rules.mk
9 include $(INCLUDE_DIR)/kernel.mk
10 include $(INCLUDE_DIR)/version.mk
11 include $(INCLUDE_DIR)/feeds.mk
12
13 PKG_NAME:=opkg
14 PKG_RELEASE:=1
15 PKG_FLAGS:=essential
16
17 PKG_SOURCE_PROTO:=git
18 PKG_SOURCE_URL:=https://git.lede-project.org/project/opkg-lede.git
19 PKG_SOURCE_DATE:=2017-03-01
20 PKG_SOURCE_VERSION:=19070b6c1a9718bf7ceaa61c48f328cabf1d5ca7
21 PKG_MIRROR_HASH:=7fa506c752db01fff47522141e8349603485368ae955315fc41754aec9ecee13
22
23 PKG_LICENSE:=GPL-2.0
24 PKG_LICENSE_FILES:=COPYING
25
26 PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
27
28 PKG_FLAGS := nonshared
29 PKG_CONFIG_DEPENDS := CONFIG_SIGNED_PACKAGES
30
31 PKG_BUILD_PARALLEL:=1
32 HOST_BUILD_PARALLEL:=1
33 PKG_INSTALL:=1
34
35 HOST_BUILD_DEPENDS:=libubox/host
36
37 include $(INCLUDE_DIR)/package.mk
38 include $(INCLUDE_DIR)/host-build.mk
39 include $(INCLUDE_DIR)/cmake.mk
40
41 define Package/opkg
42   SECTION:=base
43   CATEGORY:=Base system
44   TITLE:=opkg package manager
45   DEPENDS:=+uclient-fetch +libpthread +libubox
46   URL:=https://git.lede-project.org/?p=project/opkg-lede.git
47   MENU:=1
48 endef
49
50 define Package/opkg/description
51   Lightweight package management system
52   opkg is the opkg Package Management System, for handling
53   installation and removal of packages on a system. It can
54   recursively follow dependencies and download all packages
55   necessary to install a particular package.
56
57   opkg knows how to install both .ipk and .deb packages.
58 endef
59
60 define Package/opkg/conffiles
61 /etc/opkg.conf
62 /etc/opkg/keys/
63 /etc/opkg/customfeeds.conf
64 endef
65
66 TARGET_CFLAGS += -ffunction-sections -fdata-sections
67 EXTRA_CFLAGS += $(TARGET_CPPFLAGS)
68
69 CMAKE_OPTIONS += \
70         -DBUILD_TESTS=OFF \
71         -DHOST_CPU=$(PKGARCH) \
72         -DVERSION="$(PKG_SOURCE_VERSION) ($(PKG_SOURCE_DATE))"
73
74 CMAKE_HOST_OPTIONS += \
75         -DSTATIC_UBOX=ON \
76         -DBUILD_TESTS=OFF \
77         -DHOST_CPU=$(PKGARCH) \
78         -DLOCK_FILE=/tmp/opkg.lock \
79         -DVERSION="$(PKG_SOURCE_VERSION) ($(PKG_SOURCE_DATE))"
80
81 define Package/opkg/install
82         $(INSTALL_DIR) $(1)/usr/lib/opkg
83         $(INSTALL_DIR) $(1)/bin
84         $(INSTALL_DIR) $(1)/etc/opkg
85         $(INSTALL_DIR) $(1)/etc/uci-defaults
86         $(INSTALL_DATA) ./files/customfeeds.conf $(1)/etc/opkg/customfeeds.conf
87         $(INSTALL_DATA) ./files/opkg$(2).conf $(1)/etc/opkg.conf
88         $(call FeedSourcesAppend,$(1)/etc/opkg/distfeeds.conf)
89         $(VERSION_SED) $(1)/etc/opkg/distfeeds.conf
90         $(INSTALL_BIN) ./files/20_migrate-feeds $(1)/etc/uci-defaults/
91         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/opkg-cl $(1)/bin/opkg
92   ifneq ($(CONFIG_SIGNED_PACKAGES),)
93         echo "option check_signature 1" >> $(1)/etc/opkg.conf
94   endif
95         $(INSTALL_DIR) $(1)/usr/sbin
96         $(INSTALL_BIN) ./files/opkg-key $(1)/usr/sbin/
97 endef
98
99 define Host/Install
100         $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/opkg-cl $(STAGING_DIR_HOST)/bin/opkg
101 endef
102
103 $(eval $(call BuildPackage,opkg))
104 $(eval $(call HostBuild))