creating ipa file using command line with code signing - hudson

I am trying to create an ipa file using xcode command line including signing.
i tried searching for it, i got the commands to create ipa with out code signing.
i need the commands mainly to integrate with hudson CI.
Please suggest.
-Prahasa

This is the script which I use to integrate with Hudson and my iPhone Apps.
#!/bin/sh
CONFIGURATION="AdHoc" # or Release or Debug
# location of files included in dist (.mobileprovision, iTunesArtwork, README)
DISTDIR="_distfiles"
. build.config
MARKETING_VERSION=`agvtool what-marketing-version -terse1`
build_xcode ()
{
xcodebuild -configuration "$CONFIGURATION" -sdk $SDK
}
# CONFIGURATION for xcode build can be overridden from commandline
NEWCONFIG="$1"
if ! test "$NEWCONFIG"x = x; then
echo "=== using configuration from command line $NEWCONFIG"
CONFIGURATION="$NEWCONFIG"
fi
# XCODE check build available for specified configuration
CHECKCONFIGURATION=`xcodebuild -list | egrep "$CONFIGURATION($|\ )"`
if test "$CHECKCONFIGURATION"x = x; then
echo "ERROR: xcodebuild could not find valid build configuration $CONFIGURATION"
echo
xcodebuild -list
echo
exit
fi
VERSION="$MARKETING_VERSION ($BUILD_NUMBER)"
#######
echo "=== Building distribution package for $RELEASE - $VERSION"
echo "=== setting build number to $BUILD_NUMBER"
agvtool new-version -all "${BUILD_NUMBER}"
# XCODE make sure buildpath exists for configuration, build if missing
BUILDPATH="build/$CONFIGURATION-iphoneos"
build_xcode
if [ $? != 0 ]; then
echo "ERROR: xcodebuild not successful"
exit 1
fi
if test ! -d "$BUILDPATH"; then
echo "ERROR: xcodebuild could not build configuration $CONGIRUATION ($BUILDPATH)"
exit
fi
echo "=== Successfully built configuration $CONFIGURATION ($BUILDPATH)"
# HACK : accomodate configurations with spaces, chdir to determine app name
cd "$BUILDPATH"
# derive name of .app dir (application)
APPDIR=`ls -d *.app`
cd ../..
APPPATH="$BUILDPATH/$APPDIR"
DSYMPATH="$BUILDPATH/$APPDIR.dSYM"
if test "$APPDIR"x = x; then
APPPATH="$BUILDPATH/.app"
fi
# XCODE make sure app dir exists in buildpath, build if missing
if test ! -d "$APPPATH"; then
echo "missing $APPPATH build in $BUILDPATH, trying to build"
build_xcode
# HACK : accomodate configurations with spaces, chdir to determine app name
cd "$BUILDPATH"
# derive name of .app dir (application)
APPDIR=`ls -d *.app`
cd ../..
# check again for APPDIR/APPPATH
APPPATH="$BUILDPATH/$APPDIR"
if test "$APPDIR"x = x; then
APPPATH="$BUILDPATH/.app"
fi
if test ! -d "$APPPATH"; then
echo "ERROR: xcodebuild could not build $APPPATH configuration $CONGIRUATION ($BUILDPATH)"
exit
fi
echo "=== Successfully built $APPDIR configuration $CONFIGURATION ($BUILDPATH)"
fi
# Create directory for release package
echo " - Creating release dir"
RELEASEDIR="$RELEASEBASE/$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
mkdir -p "$RELEASEDIR"
echo "RELEASEDIR = $RELEASEDIR"
echo "BUILDPATH = $BUILDPATH"
echo "APPPATH = $APPPATH"
echo "DSYMPATH = $APPPATH"
# Copy other files
cp $DISTDIR/* "$RELEASEDIR"
# .IPA file: iphone app archive file, installable by itunes
IPA=`echo $APPDIR | sed "s/\.app/\.ipa/"`
echo " - Creating $IPA payload"
mkdir -p "$RELEASEDIR/Payload/"
echo " - Copying $APPPATH to $RELEASEDIR/Payload/"
# Copy built .app to payload/ itunes-specific install dir
cp -Rp "$APPPATH" "$RELEASEDIR/Payload/"
# Build .IPA file
# this is just a zipfile with a payload/ dir with the .app, and artwork
cd "$RELEASEDIR"
# include 512x512 png of artwork, if foudn
if test -f "iTunesArtwork"; then
zip -y -r "$IPA" iTunesArtwork Payload/
rm -rf Payload iTunesArtwork
else
zip -y -r "$IPA" Payload/
rm -rf Payload
fi
cd ..
pwd
# Create .zip packaged Distribution
ZIPFILE="$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER.zip"
DSYMZIPFILE="$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER-dSYM.zip"
echo " - zipfile is $ZIPFILE"
echo " - Compressing release $ZIPFILE"
zip -y -r "$ZIPFILE" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
cp -pR "../$DSYMPATH" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER"
echo " - creating zip of dSYM file"
zip -y -r "$DSYMZIPFILE" "$RELEASE-$CONFIGURATION-$MARKETING_VERSION-$BUILD_NUMBER/$APPDIR.dSYM"
cd ..
echo "=== Build complete for $RELEASEBASE/$ZIPFILE"
Then, my hudson configuration looks like this:
./build.sh AdHoc
./build.sh Release
Finally, my files to archive looks like this:
_release/MobilePracticePro-*-${BUILD_NUMBER}*.zip
Hope this is helpful to you! Using Hudson is really great. Also, realize your signing key needs to be installed on the same box as hudson runs and running as same user. At least that is how it is for me.

I have been facing the same issue and resolved by using the steps give in the details of the link Xcode "Build and Archive" from command line

Related

To Add Junit tests in SonarQube

I am not able to view Junit tests in Sonarqube coverage report. We are running the pipeline in bitbucket and project is based on SAP hybris.
bit-bucket-pipeline.yml
mage: atlassian/default-image:3
clone:
lfs: true
pipelines:
custom:
qg-sonarqube-main:
- step:
name: 'sq init'
image: atlassian/default-image:3
script:
- |
echo "start notification"
echo "install java"
apt update
apt install -y --no-install-recommends openjdk-11-jdk rsync tree
java --version
echo "sonarqube scan of current branch; build dir $BITBUCKET_CLONE_DIR"
# assembly first
echo "download scanner-cli"
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli- 4.7.0.2747.zip -O $BITBUCKET_CLONE_DIR/sonarcli.zip
unzip -q $BITBUCKET_CLONE_DIR/sonarcli.zip -d $BITBUCKET_CLONE_DIR
ln -s $BITBUCKET_CLONE_DIR/sonar-scanner-4.7.0.2747/bin/sonar-scanner /bin/sonar-scanner
/bin/sonar-scanner -v
echo "hybris ootb assembly"
unzip -q ootb/CXCOM200500P_27-70004955.ZIP -d $BITBUCKET_CLONE_DIR
echo "unzip and copy modules"
unzip -q ootb/modules.zip -d $BITBUCKET_CLONE_DIR/hybris/bin/
echo "move sonar project configuration"
mv sonar-project.properties hybris/sonar-project.properties
echo "node version"
node -v
echo "move the customcode"
mv bin/custom hybris/bin/
echo "build the box"
cd hybris/bin/platform
. ./setantenv.sh
echo | ant clean
cd $BITBUCKET_CLONE_DIR
rsync -vau config/ hybris/config/
echo "check config dir"
cd hybris/bin/platform
ant customize
echo "copy valid props and localextensions taken from valid assembly"
ant build all
echo "scan"
cd $BITBUCKET_CLONE_DIR/hybris/
TODAY=$(date +'%d%m%Y')
echo "code version $BITBUCKET_BUILD_NUMBER.$TODAY"
/bin/sonar-scanner -Dsonar.login="$SONAR_LOGIN" -Dsonar.projectKey=alcon-"$BITBUCKET_BRANCH" -Dsonar.projectName=alcon-"$BITBUCKET_BRANCH" -Dsonar.projectVersion="$BITBUCKET_BUILD_NUMBER.$TODAY"
echo "waiting for CE"
# get ceTaskUrl var
source .scannerwork/report-task.txt
# up to 30 min
for _ in {0..60}; do
status=$(curl -s -H "Accept: application/json" -u "$SONAR_LOGIN:" $ceTaskUrl | jq -r .task.status)
case $status in
SUCCESS)
echo "notification about success"
echo "Task finished"
echo "Project dashboard: $dashboardUrl"
exit 0
;;
PENDING | IN_PROGRESS)
echo "Task still in progress"
sleep 30
;;
FAILED)
echo "notification about fail"
echo Got FAILED task status, exit
exit 1
;;
*)
echo "Unsupported task status: $status"
sleep 30
;;
esac
done
echo "Project dashboard: $dashboardUrl"
====================
Sonar-project.properties:
sonar.sources=bin/custom/
sonar.sourceEncoding=UTF-8
sonar.pdf.skip=true
sonar.language=java
sonar.java.source=1.8
sonar.java.binaries=bin/custom/
sonar.host.url=https://b2bint.sonarqube.alconcloud.com

BASH: Bakup MySQL database and send via FTP to remote server

I trying to create BASH script for my API server where I do daily backup with cron. Here is my script:
#!/bin/bash
################################################################
##
## MySQL Database Backup Script
## Written By: Ivijan-Stefan Stipic
## URL: https://infinitumform.com
## Last Update: Jul 08, 2019
##
################################################################
export PATH=/bin:/usr/bin:/usr/local/bin
#################################################################
# Today date
TODAY=`date +"%d%b%Y"`
# Database
DATABASE_NAME='some_database_name'
MYSQL_HOST='localhost'
MYSQL_PORT='3306'
MYSQL_USER='some_username'
MYSQL_PASSWORD='pa55W0r6'
# FTP
FTP_HOST='https://someremote.host'
FTP_USER='ftp-username'
FTP_PASSWORD='ftp-p#55w0r6'
FTP_PATH='/backup'
# Backup location
DB_BACKUP_PATH='/root/backups'
# Filename setup
FILE_NAME=${DATABASE_NAME} ## We can change this to some other name
FILE_NAME_PREFIX='' ## prefix in the file
FILE_NAME_SUFFIX='' ## suffix in the file
## Number of days to keep local backup copy
BACKUP_RETAIN_DAYS=15
# Full file path
FILE=${DB_BACKUP_PATH}/${TODAY}/${FILE_NAME_PREFIX}${FILE_NAME}${FILE_NAME_SUFFIX}-${TODAY}.sql.gz
#################################################################
if [ ! -z ${DATABASE_NAME} ]; then
mkdir -p ${DB_BACKUP_PATH}/${TODAY}
echo "Backup started for database - ${DATABASE_NAME}"
mysqldump --host=${MYSQL_HOST} --port=${MYSQL_PORT} --databases ${DATABASE_NAME} --add-drop-database --triggers --routines --events --password=${MYSQL_PASSWORD} --user=${MYSQL_USER} --single-transaction | gzip > ${FILE}
if [ $? -eq 0 ]; then
echo "Database backup successfully completed"
else
echo "Error found during backup"
fi
else
echo "ERROR: Datbase not defined"
fi
##### Remove backups older than {BACKUP_RETAIN_DAYS} days #####
DBDELDATE=`date +"%d%b%Y" --date="${BACKUP_RETAIN_DAYS} days ago"`
if [ ! -z ${DB_BACKUP_PATH} ]; then
cd ${DB_BACKUP_PATH}
if [ ! -z ${DBDELDATE} ] && [ -d ${DBDELDATE} ]; then
rm -rf ${DBDELDATE}
echo "Old backups cleaned up"
fi
fi
#### Send backup via FTP ####
if [ ! -z ${FTP_USER} ]; then
echo "Sending bakup files to ${FTP_HOST} via FTP"
curl -T "${FILE}" -u ${FTP_USER}:${FTP_PASSWORD} ${FTP_HOST}${FTP_PATH}
if [ $? -eq 0 ]; then
echo "Files successfuly sent via FTP to remote bakup server"
else
echo "FTP error. Files was not sent properly."
fi
fi
### End of script ####
In my office I have server where I keep backups and want to automate this script to send via FTP files from API server to my office server after backup is done.
I try to use cURL to send files but this fail.
...
#### Send backup via FTP ####
if [ ! -z ${FTP_USER} ]; then
echo "Sending bakup files to ${FTP_HOST} via FTP"
curl -T "${FILE}" -u ${FTP_USER}:${FTP_PASSWORD} ${FTP_HOST}${FTP_PATH}
if [ $? -eq 0 ]; then
echo "Files successfuly sent via FTP to remote bakup server"
else
echo "FTP error. Files was not sent properly."
fi
fi
...
Is there some good and safe way to do this?
You can use ncftpput.
See my simple script about it, here: https://github.com/NabiKAZ/MySQL-Backup

How to add `--registry-mirror` when starting docker from "Docker quickstart terminal"?

From the docker distribution document: https://github.com/docker/distribution
It says to configure the docker to use the mirror, we should:
Configuring the Docker daemon
You will need to pass the --registry-mirror option to your Docker daemon on startup:
docker --registry-mirror=https://<my-docker-mirror-host> daemon
I'm newbie to docker, and I start docker from mac normal by the provided "Docker Quickstart Termial" app, which actaully invokes a start.sh shell:
#!/bin/bash
VM=default
DOCKER_MACHINE=/usr/local/bin/docker-machine
VBOXMANAGE=/Applications/VirtualBox.app/Contents/MacOS/VBoxManage
BLUE='\033[0;34m'
GREEN='\033[0;32m'
NC='\033[0m'
unset DYLD_LIBRARY_PATH
unset LD_LIBRARY_PATH
clear
if [ ! -f $DOCKER_MACHINE ] || [ ! -f $VBOXMANAGE ]; then
echo "Either VirtualBox or Docker Machine are not installed. Please re-run the Toolbox Installer and try again."
exit 1
fi
$VBOXMANAGE showvminfo $VM &> /dev/null
VM_EXISTS_CODE=$?
if [ $VM_EXISTS_CODE -eq 1 ]; then
echo "Creating Machine $VM..."
$DOCKER_MACHINE rm -f $VM &> /dev/null
rm -rf ~/.docker/machine/machines/$VM
$DOCKER_MACHINE create -d virtualbox --virtualbox-memory 2048 --virtualbox-disk-size 204800 $VM
else
echo "Machine $VM already exists in VirtualBox."
fi
VM_STATUS=$($DOCKER_MACHINE status $VM)
if [ "$VM_STATUS" != "Running" ]; then
echo "Starting machine $VM..."
$DOCKER_MACHINE start $VM
yes | $DOCKER_MACHINE regenerate-certs $VM
fi
echo "Setting environment variables for machine $VM..."
clear
cat << EOF
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
EOF
echo -e "${BLUE}docker${NC} is configured to use the ${GREEN}$VM${NC} machine with IP ${GREEN}$($DOCKER_MACHINE ip $VM)${NC}"
echo "For help getting started, check out the docs at https://docs.docker.com"
echo
eval $($DOCKER_MACHINE env $VM --shell=bash)
USER_SHELL=$(dscl /Search -read /Users/$USER UserShell | awk '{print $2}' | head -n 1)
if [[ $USER_SHELL == *"/bash"* ]] || [[ $USER_SHELL == *"/zsh"* ]] || [[ $USER_SHELL == *"/sh"* ]]; then
$USER_SHELL --login
else
$USER_SHELL
fi
Is it the correct file that I can put my '--registry-mirror' config to it? What should I do?
If you do a docker-machine create --help:
docker-machine create --help
Usage: docker-machine create [OPTIONS] [arg...]
Create a machine.
Run 'docker-machine create --driver name' to include the create flags for that driver in the help text.
Options:
...
--engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option] Specify insecure registries to allow with the created en
gine
--engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option] Specify registry mirrors to use
So you can modify your script to add one more parameter:
--engine-registry-mirror=...
However, since your 'default' docker-machine probably already exists (do a docker-machine ls), you might need to remove it first (docker-machine rm default: make sure you can easily recreate your images from your local Dockerfiles, and/or that you don't have data container that would need to be saved first)
Open C:\Users\<YourName>\.docker\daemon.json, edit the "registry-mirrors" entry in that file.
{"registry-mirrors":["https://registry.docker-cn.com"],"insecure-registries":[], "debug":true, "experimental": true}

Issues installing IDAS on CentOS 7 VM through provided RPMs

I've been trying to install IDAS GE in a CentOS 7 VM on my machine through the UL2.0 RPMs(download link!) available in its catalogue page.
I followed the instructions on github, but I get stuck in starting the IoT as per section 3 of the Deployment section of the instructions. If I execute the init_iotagent.sh, where I inserted the local IP of the VM, I get the error:
log4cplus:ERROR No appenders could be found for logger (main).
log4cplus:ERROR Please initialize the log4cplus system properly.
HTTPFilter DESTRUCTOR 0
HTTPFilter DESTRUCTOR 0
Also, in the instructions for Starting IoTAgent as a Service, it's said that:
After installing iot-agent-base RPM an init.d script can be found in
this folder /usr/local/iot/init.d .
But this file is not there, leading me to believe that the IoTAgent wasn't installed properly from the RPMs provided.
Also, I can't find log files regarding IoTAgent, only the MongoDB has its log file at /usr/local/iot/mongodb-linux-x86_64-2.6.9/log/mongoc.log.
If anyone could help, it would be apreciated. Also, if more info is needed, please let me know.
Thank you
I recommend you to get the GitHub repository and build the RPMs from the source and then install it in your CentOS. Like is explained in the documentation:
NOTE: I changed the BUILD_TYPE to Release, so I created the Release dir.
GIT_VERSION and GIT_COMMIT are not the latest ones.
git clone https://github.com/telefonicaid/fiware-IoTAgent-Cplusplus.git
cd fiware....
mkdir -p build/Release
cd build/Release
cmake -DGIT_VERSION=20527 -DGIT_COMMIT=217023407f25ed258043cfc00a46b6c05fb0b52c -DMQTT=ON -DCMAKE_BUILD_TYPE=Release ../../
make install
make package
The packages will be in pack/Linux/RPM/
rpm -i iot-agent-base-xxxxxxx (xxxxxxx will be the numbers of the build)
rpm -i iot-agent-ul-xxxxxx (xxxxxxx will be the numbers of the build)
Once installed with RPMs the init.d file is in: /usr/local/iot/init.d/iotagent
This is the content of the file:
#!/bin/bash
# Copyright 2015 Telefonica Investigación y Desarrollo, S.A.U
#
# This file is part of fiware-IoTagent-Cplusplus (FI-WARE project).
#
# iotagent Start/Stop iotagent
#
# chkconfig: 2345 99 60
# description: iotagent
. /etc/rc.d/init.d/functions
PARAM=$1
INSTANCE=$2
USERNAME=iotagent
EXECUTABLE=/usr/local/iot/bin/iotagent
CONFIG_PATH=/usr/local/iot/config
iotagent_start()
{
local result=0
local instance=${1}
if [[ ! -x ${EXECUTABLE} ]]; then
printf "%s\n" "Fail - missing ${EXECUTABLE} executable"
exit 1
fi
if [[ -z ${instance} ]]; then
list_instances="${CONFIG_PATH}/iotagent_*.conf"
else
list_instances="${CONFIG_PATH}/iotagent_${instance}.conf"
fi
for instance_config in ${list_instances}
do
local NAME
NAME=${instance_config%.conf}
NAME=${NAME#*iotagent_}
source ${instance_config}
local IOTAGENT_PID_FILE="/var/run/iot/iotagent_${NAME}.pid"
printf "Starting iotagent ${NAME}..."
status -p ${IOTAGENT_PID_FILE} ${EXECUTABLE} &> /dev/null
if [[ ${?} -eq 0 ]]; then
printf "%s\n" " Already running, skipping $(success)"
continue
fi
# Load the environment
set -a
source ${instance_config}
# Mandatory parameters
IOTAGENT_OPTS=" ${IS_MANAGER} \
-n ${IOTAGENT_SERVER_NAME} \
-v ${IOTAGENT_LOG_LEVEL} \
-i ${IOTAGENT_SERVER_ADDRESS} \
-p ${IOTAGENT_SERVER_PORT} \
-d ${IOTAGENT_LIBRARY_DIR} \
-c ${IOTAGENT_CONFIG_FILE}"
su ${USERNAME} -c "LD_LIBRARY_PATH=\"${IOTAGENT_LIBRARY_DIR}\" \
${EXECUTABLE} ${IOTAGENT_OPTS} & echo \$! > ${IOTAGENT_PID_FILE}" &> /dev/null
sleep 2 # wait some time to leave iotagent start
local PID=$(cat ${IOTAGENT_PID_FILE})
local var_pid=$(ps -ef | grep ${PID} | grep -v grep)
if [[ -z "${var_pid}" ]]; then
printf "%s" "pidfile not found"
printf "%s\n" "$(failure)"
exit 1
else
printf "%s\n" "$(success)"
fi
done
return ${result}
}
iotagent_stop()
{
local result=0
local iotagent_instance=${1}
if [[ -z ${iotagent_instance} ]]; then
list_run_instances="/var/run/iot/iotagent_*.pid"
else
list_run_instances="/var/run/iot/iotagent_${iotagent_instance}.pid"
fi
if [[ $(ls -l ${list_run_instances} 2> /dev/null | wc -l) -eq 0 ]]; then
printf "%s\n" "There aren't any instance of IoTAgent ${iotagent_instance} running $(success)"
return 0
fi
for run_instance in ${list_run_instances}
do
local NAME
NAME=${run_instance%.pid}
NAME=${NAME#*iotagent_}
printf "%s" "Stopping IoTAgent ${NAME}..."
local RUN_PID=$(cat ${run_instance})
kill ${RUN_PID} &> /dev/null
local KILLED_PID=$(ps -ef | grep ${RUN_PID} | grep -v grep | awk '{print $2}')
if [[ -z ${KILLED_PID} ]]; then
printf "%s\n" "$(success)"
else
printf "%s\n" "$(failure)"
result=$((${result}+1))
fi
rm -f ${run_instance} &> /dev/null
done
return ${result}
}
iotagent_status()
{
local result=0
local iotagent_instance=${1}
if [[ -z ${iotagent_instance} ]]; then
list_run_instances="/var/run/iot/iotagent_*.pid"
else
list_run_instances="/var/run/iot/iotagent_${iotagent_instance}.pid"
fi
if [[ $(ls -l ${list_run_instances} 2> /dev/null | wc -l) -eq 0 ]]; then
printf "%s\n" "There aren't any instance of IoTAgent ${iotagent_instance} running."
return 1
fi
for run_instance in ${list_run_instances}
do
local NAME
NAME=${run_instance%.pid}
NAME=${NAME#*iotagent_}
printf "%s\n" "IoTAgent ${NAME} status..."
status -p ${run_instance} ${NODE_EXEC}
result=$((${result}+${?}))
done
return ${result}
}
case ${PARAM} in
'start')
iotagent_start ${INSTANCE}
;;
'stop')
iotagent_stop ${INSTANCE}
;;
'restart')
iotagent_stop ${INSTANCE}
iotagent_start ${INSTANCE}
;;
'status')
iotagent_status ${INSTANCE}
;;
esac
And the logs file are in /tmp/ :
IoTAgent-IoTPlatform.log
IoTAgent.log
IoTAgent-Manager.log
Hope this helps you.

Busybox rpm scriplets

I am packaging with rpm for embedded device with busybox instead normal GNU system.
When I install with busybox, it install module, but do not even try to run scriplets.
On regular system, It runs them and fails(ofc, another version of kernel).
Question: Where am I wrong, and how to work around it?
Here is my spec-file:
# The kernel version you are building for
%define kernel 3.4.0-rc6-01292-g9b8149d
# The name of the module you are supplying
%define modname ktgrabber
# The path to the module, after it is installed
%define modpath /lib/modules/%{kernel}/kernel/net/ipv4
# Which revision are we on
%define pkgrelease 1.SL
# Is this a new module, or are we replacing an existing module
# 1 - new module
# 0 - replacing an existing module
%define newmodule 1
# Optional - what Architecture we are building for
#%define thisarch ia32e
Name: kernel-module-%{modname}-%{kernel}
Summary: Kernel Module %{modname} for the %{kernel} kernel
Version: 0.99
Release: 1
Epoch: 0
License: GPLv2+
Packager: Troy Dawson <dawson#fnal.gov>
Group: System Environment/Kernel
BuildRoot: %{_tmppath}/%{name}-%{version}-root
#Requires: /boot/vmlinux-%{kernel}, modutils
Provides: kernel-module-%{modname} = %{epoch}:%{version}
Source0: %{modname}.ko.%{kernel}
%description
This package provides a %{modname} kernel module for
kernel %{kernel}.
%install
mkdir -p $RPM_BUILD_ROOT/%{modpath}
%if %{newmodule}
install -m 644 %{SOURCE0} $RPM_BUILD_ROOT/%{modpath}/%{modname}.ko
%else
install -m 644 %{SOURCE0} $RPM_BUILD_ROOT/%{modpath}/%{modname}.%{version}.%{pkgrelease}.o
%endif
%pre
touch /root/bar
mkdir /alice
%post
touch /bar
/bin/echo %{modname} >> /etc/modules
depmod
mkdir /foo
depmod -ae %{kernel} >/dev/null 2>&1
modprobe %{modname}
%postun
sed -i 's/^%{modname}$//g' /etc/modules
%if %{newmodule}
depmod -ae %{kernel} >/dev/null 2>&1 || :
%else
if [ "" = "0" ] ; then
if ! [ -f %{modpath}/%{modname}.original.o ] ; then
mv %{modpath}/%{modname}.o %{modpath}/%{modname}.original.o
fi
cp -f %{modpath}/%{modname}.%{version}.%{pkgrelease}.o %{modpath}/%{modname}.o
depmod -ae %{kernel} >/dev/null 2>&1 || :
fi
%endif
%files
%if %{newmodule}
%{modpath}/%{modname}.ko
%else
%{modpath}/%{modname}.%{version}.%{pkgrelease}.ko
%endif
Check out this link : http://lists.busybox.net/pipermail/busybox/2006-November/059507.html scriptlets aren't run by busybox's rpm command.
Looking at the source at http://git.busybox.net/busybox/tree/archival/rpm.c#n149 that appears to be true.