opkg: Fix -Wformat-overflow warning A null pointer is being passed to printf. This can lead to problems. Fixes warning: error: '%s' directive argument is null [-Werror=format-overflow=] 41 | opkg_message(l, "%s: "fmt, __FUNCTION__, ##args); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ note: in expansion of macro 'opkg_msg' 45 | opkg_msg(l, fmt": %s.\n", ##args, strerror(errno)) | ^~~~~~~~ note: in expansion of macro 'opkg_perror' 247 | opkg_perror(ERROR, "Failed to create temporary directory '%s'", Signed-off-by: Rosen Penev <rosenp@gmail.com>
libopkg: only perform size check when information is available Fixes: cb66403 ("libopkg: check for file size mismatches") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: check for file size mismatches Reject package files whose file size deviates from the size specified in the package index in order to complicate producing hash collisions. Ref: https://groups.google.com/d/msg/opkg-devel/o4kiGQMvkiw/hu0TVv59DgAJ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Revert "libopkg: check installed reverse dependencies upon install/upgrade" This reverts commit 89fe77cb119a24f728088320d66d51250a1f02ab. After spending further thoughts on this I think this makes no sense at all and such situations should be avoided on the repo level instead by don't providing incompatible packages having an identical name. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: check installed reverse dependencies upon install/upgrade Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: don't print unresolved dependencies twice Sometimes opkg ends up reporting unresolved dependencies multiple times while also missing a newline between consecutive error lines, making the error message output looking garbled and confusing. Add some logic to skip repeated unresolved dependencies and ensure that message lines are properly terminated by newlines. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
check_data_file_clashes_change: remove duplicated offline root in paths The function check_data_file_clashes_change update the ownership of files that belong to a package being replaced. It calls pkg_get_installed_files then adds an offline root if opkg_conf->offline_root to each path. However, pkg_get_installed_files already returns paths with the offline root (if present). This fixes issue 156. Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
set_flags_from_control: remove function During installs, install_data_files calls set_flags_from_control to capture the case where fields, such as "Essential", are present in the package control file but are missing on the Packages file. This operation is expensive (re-parses the control file) and is catering to a case that should not be supported on the first place. Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com> [Jo-Philipp Wich: remove function prototype as well] Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: remove OpenSSL support Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: remove GPG support Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: drop custom md5 implementation, unconditionally enable sha256 support Drop custom md5 implementation and switch to the one provided by libubox, also remove support for enabling/disabling checksum support and always build it unconditionally. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: remove config.h references Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: fix hex encoding/decoding, add checksum getter/setter Fix broken hex encoding/decoding due to the use of signed chars and introduce new convenience getters and setters to simplify the checksum usage. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: store checksums in binary form, use integer index for architecture Instead of storing a copy of the architecture string and architecture priority value in each pkg_t instance, declare a 3 bit wide field which allows referencing the architecture in the global config array by index. The 3 bit field allows referencing up to 8 different architectures which is more than enough for the systems we target with opkg. Another nice side effect is that we can coalesce this field with other flag values in pkg_t, saving 4 bytes for an int member. Also convert the hexadecimal checksums to binary format before storing them in pkg_t's blob buffer to save 50% of the space per checksum. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
pkg: convert most other struct members into dynamic blob buffer fields Signed-off-by: Jo-Philipp Wich <jo@mein.io>
pkg: store size, installed size and installed time info in blob buffer Signed-off-by: Jo-Philipp Wich <jo@mein.io>
pkg: use a blob buffer in pkg_t to store variable fields Adds infrastructure to use a blob buffer in pkg_t to store and retrieve optional dynamic fields. This reduces the size of the pkg_t structure itself and lays the ground work for further optimization. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
treewrite: use Lindent to reformat to kernel coding style Use the kernels "Lindent" script to reformat files using kernel coding style. This should make subsequent refactoring much easier. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg: run prerm scripts for the old version also on upgrade To make sure we properly restart services on upgrade we need to call the prerm script of the old package, in case the init script changes (or vanishes). Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> Acked-by: Jo-Philipp Wich <jo@mein.io>
libopkg: fix --force-checksum to cover sha256sum cases as well Signed-off-by: Jo-Philipp Wich <jo@mein.io>